@@ -19,23 +19,23 @@ This is a lightweight library that works as a connector to [Binance Futures publ
1919pip install binance-futures-connector
2020```
2121
22- ## Documentation
23- - USDT-M Futures: https://github.com/Binance-docs/binance-futures-connector-python/wiki/USDT-M-Futures
24- - COIN-M Futures: https://github.com/Binance-docs/binance-futures-connector-python/wiki/COIN-M-Futures
2522
2623## RESTful APIs
2724
2825Usage examples:
2926``` python
30- from binance.futures import Futures
3127
32- client = Futures()
33- print (client.time())
28+ from binance.cm_futures import CMFutures
29+
30+ cm_futures_client = CMFutures()
31+
32+ # get server time
33+ print (cm_futures_client.time())
3434
35- client = Futures (key = ' <api_key>' , secret = ' <api_secret>' )
35+ cm_futures_client = CMFutures (key = ' <api_key>' , secret = ' <api_secret>' )
3636
3737# Get account information
38- print (client .account())
38+ print (cm_futures_client .account())
3939
4040# Post a new order
4141params = {
@@ -47,7 +47,7 @@ params = {
4747 ' price' : 59808
4848}
4949
50- response = client .new_order(** params)
50+ response = cm_futures_client .new_order(** params)
5151print (response)
5252```
5353Please find ` examples ` folder to check for more endpoints.
@@ -78,10 +78,10 @@ It defaults to `5000` (milliseconds) and can be any value lower than `60000`(mil
7878Anything beyond the limit will result in an error response from Binance server.
7979
8080``` python
81- from binance.futures import Futures as Client
81+ from binance.cm_futures import CMFutures
8282
83- client = Client (key, secret)
84- response = client .query_order(' BTCUSDT' , orderId = 11 , recvWindow = 10000 )
83+ cm_futures_client = CMFutures (key = ' <api_key> ' , secret = ' <api_secret> ' )
84+ response = cm_futures_client .query_order(' BTCUSDT' , orderId = 11 , recvWindow = 10000 )
8585```
8686
8787### Timeout
@@ -91,20 +91,20 @@ Please remember the value as it won't be shown in error message _no bytes have b
9191By default, ` timeout ` is None. Hence, requests do not time out.
9292
9393``` python
94- from binance.futures import Futures as Client
94+ from binance.cm_futures import CMFutures
9595
96- client= Client (timeout = 1 )
96+ client= CMFutures (timeout = 1 )
9797```
9898
9999### Proxy
100100proxy is supported
101101
102102``` python
103- from binance.futures import Futures as Client
103+ from binance.cm_futures import CMFutures
104104
105105proxies = { ' https' : ' http://1.2.3.4:8080' }
106106
107- client= Client (proxies = proxies)
107+ client= CMFutures (proxies = proxies)
108108```
109109
110110### Response Metadata
@@ -113,15 +113,15 @@ The Binance API server provides weight usages in the headers of each response.
113113You can display them by initializing the client with ` show_limit_usage=True ` :
114114
115115``` python
116- from binance.futures import Futures as Client
116+ from binance.cm_futures import CMFutures
117117
118- client = Client (show_limit_usage = True )
118+ client = CMFutures (show_limit_usage = True )
119119print (client.time())
120120```
121121returns:
122122
123123``` python
124- {' data ' : { ' serverTime ' : 1587990847650 }, ' limit_usage' : {' x-mbx-used-weight' : ' 31 ' , ' x-mbx-used-weight-1m ' : ' 31 ' }}
124+ {' limit_usage' : {' x-mbx-used-weight-1m ' : ' 1 ' } , ' data ' : { ' serverTime ' : 1653563092778 }}
125125```
126126You can also display full response metadata to help in debugging:
127127
@@ -158,12 +158,13 @@ There are 2 types of error returned from the library:
158158## Websocket
159159
160160``` python
161- from binance.websocket.futures.websocket_client import FuturesWebsocketClient as WebsocketClient
161+ import time
162+ from binance.websocket.cm_futures.websocket_client import CMFuturesWebsocketClient
162163
163164def message_handler (message ):
164165 print (message)
165166
166- ws_client = WebsocketClient ()
167+ ws_client = CMFuturesWebsocketClient ()
167168ws_client.start()
168169
169170ws_client.mini_ticker(
@@ -178,7 +179,11 @@ ws_client.instant_subscribe(
178179 callback = message_handler,
179180)
180181
182+ time.sleep(10 )
183+
184+ print (" closing ws connection" )
181185ws_client.stop()
186+
182187```
183188More websocket examples are available in the ` examples ` folder
184189
@@ -187,3 +192,5 @@ More websocket examples are available in the `examples` folder
187192Once connected, the websocket server sends a ping frame every 3 minutes and requires a response pong frame back within
188193a 10 minutes period. This package handles the pong responses automatically.
189194
195+ ## License
196+ MIT
0 commit comments