Skip to content

Instantly share code, notes, and snippets.

@FloChronoTech
Last active January 11, 2021 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FloChronoTech/5b63fac137d390aba80e29cb0459bbef to your computer and use it in GitHub Desktop.
Save FloChronoTech/5b63fac137d390aba80e29cb0459bbef to your computer and use it in GitHub Desktop.
TimeX API Guide #1
import base64
import requests
import random
api_key = 'your public API key here'
api_secret = 'your API secret here'
userpass = api_key + ':' + api_secret
encoded_u = base64.b64encode(userpass.encode()).decode()
headers = {"Authorization": "Basic %s" % encoded_u}
def get_24h_stat_as_str(symbol):
params = (('useCache', 'true'),
('market', symbol))
response = requests.get('https://plasma-relay-backend.timex.io/public/tickers24', headers=headers,
params=params).json()
return response
def set_buy_order(symbol: str, price: float, size: float, expire_in: float = 99999999):
params = (('clientOrderId', random.randint(1111111, 9999999)),
('price', str(price)),
('quantity', str(size)),
('side', 'BUY'),
('symbol', str(symbol)),
('expireIn', str(expire_in)))
response = requests.post('https://plasma-relay-backend.timex.io/trading/orders', headers=headers,
params=params).json()
print('buy order set, info: ' + str(response))
symbol = 'TIMEBTC'
price = 0.00005
size = 2 # in TIME
print(get_24h_stat_as_str(symbol))
#set_buy_order(symbol=symbol, size=size, price=price)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment