Closed ioogle closed 3 years ago
Actually there are examples that you can subscribe to multiple channels with multiple contracts using one connection
For example
from gate_ws import Configuration, Connection
from gate_ws.futures import FuturesUserTradesChannel, FuturesBalanceChannel
async def main():
conn = Connection(Configuration(api_key='YOUR_API_KEY',
api_secret='YOUR_API_SECRET',
default_callback=lambda c, r: print(r.result),
app='futures', settle='usdt')
balance_channel = FuturesBalanceChannel(conn)
balance_channel.subscribe(["BTC_USDT", "ETH_USDT"])
user_trade_channel = FuturesUserTradesChannel(conn)
user_trade_channel.subscribe(["YOUR_USER_ID", "BTC_USDT"])
user_trade_channel.subscribe(["YOUR_USER_ID", "ETH_USDT"])
# start the client
await conn.run()
Thanks. But considering that there are around 7-8 user-specific endpoints that are also contract specific. If I want to monitor all of the contracts, there might be hundreds of connections which may be unacceptable.
The example above uses only one connection to subscribe to multiple channels with multiple contracts. Even for contract specific channels, you can call subscribe
multiples times with different contracts. All contracts' updates will be returned in one connection.
That's really cool. Would you mind providing an example for Golang?
The example in quick start shows how to do so
Thank you again for your patient reply:)
Thanks for your hard work! But there are two critical problems that I found in your futures API:
1. Some connections are contract specific which is inconvenient
For example, for User Trades API, the connection is contract specific:
which means that
N
connections are needed if we want to receive notifications fromN
contracts.2. If all user-specific data can be integrated with one connection, it will be much better
As far as I know, Binance provides a single Websocket endpoint User Data Stream to receive all user updates, and that's really awesome.