Skip to content

Instantly share code, notes, and snippets.

@rmcxm
rmcxm / ccxt api samples
Last active June 12, 2020 01:47
ccxt api samples
import ccxt
exchange_id = 'bitmex'
exchange_class = getattr(ccxt, exchange_id)
exchange = exchange_class({'apiKey': 'jyZEyWNzfRLaT', 'secret': 'hMwffHAZDiEg0iewrV51k', 'timeout': 60000})
exchange.fetch_order_book('BTC/USD',limit=2))['bids'][0][0]
exchange.fetch_trades('BTC/USD',limit=1)
print(exchange.fetch_ticker('BTC/USD'))
@rmcxm
rmcxm / Bitmex Swagger API samples
Last active April 25, 2020 15:14
Bitmex Swagger API samples
client = bitmex.bitmex(test=True, api_key='r72bdD9PDSGTN', api_secret='osCkZ-LosU2-6Wq5FO5U5pGDsTdo_urrX')
current price:
import requests, json
response = requests.get("https://www.bitmex.com/api/v1/orderBook/L2?symbol=eth&depth=1").json()
response [{'symbol': 'ETHUSD', 'id': 29699996359, 'side': 'Sell', 'size': 342, 'price': 182.05},
{'symbol': 'ETHUSD', 'id': 29699996360, 'side': 'Buy', 'size': 160102, 'price': 182}]
client.OrderBook.OrderBook_getL2(symbol="XBTUSD",depth=2).result()