Open iwreckitralph opened 4 years ago
Hi Pankaj,
You should send trading requests after receiving {'ch': 'tradingStatus', 'data': {'available': True}}
Function handle_trading_status has a comment for that:
Kind regards, Yaroslav
нд, 20 вер. 2020 о 18:10 Pankaj Kumar notifications@github.com пише:
Hi Buddy, need some assistance reg. digitex client api.
I am trying to place new order but it says "authentication in progress" . I am not a good programmer . Glad if you can help..
Using below code to connect to exchange and place market order... As provided by you..
Output by this code.. Response of place order .... received: ping sending: pong received: {'id': 1, 'status': 'ok'} unhandled message: {'ch': 'liquidations', 'data': {'symbol': 'BTCUSD-PERP', 'positions': [{'ts': 1600607162791, 'qty': 2, 'px': 10815, 'type': 'LONG'}]}} received: {'id': 3, 'status': 'error', 'code': 3016, 'msg': 'authentication in progress'} received: {'id': 2, 'status': 'ok'} {'ch': 'tradingStatus', 'data': {'available': True}} trading: AVAILABLE requesting trader status sending: {"id": 4, "method": "getTraderStatus", "params": {"symbol": "BTCUSD-PERP"}} received: {'id': 4, 'status': 'ok'} {'ch': 'traderStatus', 'data': {'symbol': 'BTCUSD-PERP', 'traderBalance': 100000.2, 'orderMargin': 0, 'positionMargin': 0, 'upnl': 0, 'pnl': 0, 'markPx': 10840.9439, 'positionContracts': 0, 'positionVolume': 0, 'positionLiquidationVolume': 0, 'positionBankruptcyVolume': 0, 'contracts': [], 'activeOrders': [], 'leverage': 1, 'conditionalOrders': []}} trader balance: 100000.2 open contracts: {} active_orders: {} active conditional orders: {}
Code async def run(): global trader_token global auth_req_id
random.seed()
use wss://ws.mapi.digitexfutures.com for mainnet environment
uri = "wss://ws.tapi.digitexfutures.com" async with websockets.connect(uri, ssl=True) as ws: req = create_subscriptions_request(["BTCUSD-PERP@index", "BTCUSD-PERP@orderbook_5", "BTCUSD-PERP@ticker", "BTCUSD-PERP@trades", "BTCUSD-PERP@liquidations"]) await send_request(ws, req) await authenticate(ws, trader_token)
#Started to add logic :begin symbol ="BTCUSD-PERP" print("Length of open contracts... " , len(open_contracts)) if len(open_contracts) ==0: print("Here.................................") await place_market_order(ws, symbol=symbol, side="BUY", amount=10, tif="FOK") print("Response of place order .... " ) #Ended to add logic :end while True: msg = await ws.recv() if msg == "ping": print("received: ping") await send(ws, "pong") else: response = json.loads(msg) if "ch" in response: await handle_exchange_message(ws, response) else: print(f"received: {response}")
asyncio.get_event_loop().run_until_complete(run())
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DigitexOfficial/digitex_api_doc/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBQYVEMQTGKXC2SGQTXE23SGYLMRANCNFSM4RTV4ENQ .
Hi Buddy, need some assistance reg. digitex client api.
I am trying to place new order but it says "authentication in progress" . I am not a good programmer . Glad if you can help..
Using below code to connect to exchange and place market order... As provided by you..
Output by this code.. Response of place order .... received: ping sending: pong received: {'id': 1, 'status': 'ok'} unhandled message: {'ch': 'liquidations', 'data': {'symbol': 'BTCUSD-PERP', 'positions': [{'ts': 1600607162791, 'qty': 2, 'px': 10815, 'type': 'LONG'}]}} received: {'id': 3, 'status': 'error', 'code': 3016, 'msg': 'authentication in progress'} received: {'id': 2, 'status': 'ok'} {'ch': 'tradingStatus', 'data': {'available': True}} trading: AVAILABLE requesting trader status sending: {"id": 4, "method": "getTraderStatus", "params": {"symbol": "BTCUSD-PERP"}} received: {'id': 4, 'status': 'ok'} {'ch': 'traderStatus', 'data': {'symbol': 'BTCUSD-PERP', 'traderBalance': 100000.2, 'orderMargin': 0, 'positionMargin': 0, 'upnl': 0, 'pnl': 0, 'markPx': 10840.9439, 'positionContracts': 0, 'positionVolume': 0, 'positionLiquidationVolume': 0, 'positionBankruptcyVolume': 0, 'contracts': [], 'activeOrders': [], 'leverage': 1, 'conditionalOrders': []}} trader balance: 100000.2 open contracts: {} active_orders: {} active conditional orders: {}
Code async def run(): global trader_token global auth_req_id
asyncio.get_event_loop().run_until_complete(run())