This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |