Closed mmterkc closed 2 years ago
The API requires currency_pair to be present. The only way you can do is loop. But you can do it asynchronously with async_req set to true. But this way you are most likely to be blocked from request limits if you send them too fast.
How can i configure async_req true? than what is request limit? @revilwang Thanks
Every method provides an async_req
parameter. You can find it in the method's python doc.
The request limit can be found in the official API documents Frequency Limit Rules
section.
Hi mmterkc, don't do it via continuos request. Use the websockets method instead. Websockets is like listening to price coming in, you make you're "request" once and you're done.
Here's a piece of code you can use.
First connect to the websocket:
ws = create_connection("wss://api.gateio.ws/ws/v4/") ws.send(json.dumps({ "time": int(time.time()), "channel": "spot.trades", "event": "subscribe", # "unsubscribe" for unsubscription "payload": ["BTC_USDT"] })) resp = json.loads(ws.recv()) print(resp)
Then try this: while True: resp = json.loads(ws.recv())
Have a look a this and tell me if is it helpful
Yes, websocket is preferred. We have provided gatews package which you can install with
pip install gatews
and the source code is in gate.io/gatews repo
Hi again I tried with gate ws. But I got "Got a an error: 'NoneType' object is not subscriptable" error. I use ws = create_connection("wss://api.gateio.ws/ws/v4/") ws.send(json.dumps({ "time": int(time.time()), "channel": "spot.trades", "event": "subscribe", # "unsubscribe" for unsubscription "payload": ['LIT3S_USDT', 'LYXE_USDT', 'BCHA_USDT', 'ZEC3S_USDT',"BTC_USDT","ETH_USDT",'HARD_USDT','GRIN3S_USDT', 'SLC_USDT', 'CATGIRL_USDT','ROSN_USDT', 'DOGE3L_USDT','ELON_USDT','GHST_USDT' , 'CTK_USDT','RACA3S_USDT', 'OPEN_USDT','MCRN_USDT', 'THEOS_USDT', 'SYS_USDT', 'SPA_USDT', 'AAVE3S_USDT', 'NII_USDT', 'VGX_USDT','RSR_USDT', 'UNISTAKE_USDT', 'STRONG_USDT', 'DPY_USDT', 'RBC_USDT', 'KFC_USDT', 'METIS_USDT', 'BIRD_USDT', 'MEAN_USDT', 'STETH_USDT', 'ALPA_USDT', 'SWINGBY_USDT', 'WAVES3L_USDT', 'DUSK_USDT', 'WAVES_USDT'] })) resp = json.loads(ws.recv()) print(resp) How can I solve NoneType error I want to subscribe all coin USDT pairs .There are an estimated 1500 pairs
Hi, I want to get last trade data from all pairs at same time. api_instance.list_trades method need currency pairs but list.tickers method don't need. How can I get last trades data from all pairs? I tried with for loop but it tooks a lot of time. Thanks.