Open oliver-zehentleitner opened 1 year ago
Thank you very much for your code update!
When sending a new create_order with type "MARKET" , "timeInForce" and "price" need to be removed from posting to the endpoint, otherwise the order will not get submitted.
Thank you very much for your code update!
When sending a new create_order with type "MARKET" , "timeInForce" and "price" need to be removed from posting to the endpoint, otherwise the order will not get submitted.
Right, thank you! I will fix that!
Beste Grüße ;)
@oliver-zehentleitner
Could you give me the code example on how to use it? Like sending a new order, get account information, etc.
I wonder if using websocket API is better than rest API?
@Animouse31 in the post above yours there is a link to medium with an how to... doesnt it help you?
what do you think about the idea of being able to pass a callback function to each request that is executed as soon as the response is received from binance?
I updatd the implementation, its released with 1.46.0. I think the code structure/layout is ok now. If tests are fine I will start adding more request types.
For LIMIT_MAKER timeInForce should be removed
'api.py line 648 ' side can only be SELL, BUY
if side.upper() == "LIMIT": params['price'] = str(price) params['timeInForce'] = time_in_force
api.py line 1191
if symbol is None: params = {"symbol": symbol} if symbols is None: symbols = [symbol.upper() for symbol in symbols] params = {"symbols": symbols} if permissions is None: params = {"permissions": permissions}
seems like should be is not None
Beside, Great Job !!!
order = ws.api.create_order(order_type='MARKET', quantity=qty, side='SELL', symbol=symbol)
"code":-1106,"msg":"Parameter 'timeInForce' sent when not required."
Gives the timeInForce error described earlier.
Was excited to try this out today, but turns out this issue has not been addressed yet. Any progress on making this work, or perhaps a quick fix I can try myself? Cheers
Yes, There will be a new release in mid of July!
We are restructuring to be able to deliver updates quickly again in the future.
I am getting the following error using the requests:
connection.py", line 138, in __aenter__ self._conn = connect(uri, raise exceptions.InvalidURI(uri, "scheme isn't ws or wss") websockets.exceptions.InvalidURI: isn't a valid URI: scheme isn't ws or wss
My code is the basic ping test:
` def soc_message(data): print(f"receive data: \r\n {data}\r\n")
bwam = BinanceWebSocketApiManager( exchange='binance.com-futures', process_stream_data=soc_message, output_default='UnicornFy' )
bwam.create_stream( api=True, api_key=API, api_secret=SECRET, stream_label='trader_1', stream_buffer_name='trader_1' )
while True: bwam.api.ping() time.sleep(10) `
Have tried this with numerous virtual envs is there a solution to this problem? Thanks in advance Oliver for the fantastic work your doing!
I am getting the following error using the requests:
connection.py", line 138, in __aenter__ self._conn = connect(uri, raise exceptions.InvalidURI(uri, "scheme isn't ws or wss") websockets.exceptions.InvalidURI: isn't a valid URI: scheme isn't ws or wss
My code is the basic ping test:
` def soc_message(data): print(f"receive data: \r\n {data}\r\n")
bwam = BinanceWebSocketApiManager( exchange='binance.com-futures', process_stream_data=soc_message, output_default='UnicornFy' )
bwam.create_stream( api=True, api_key=API, api_secret=SECRET, stream_label='trader_1', stream_buffer_name='trader_1' )
while True: bwam.api.ping() time.sleep(10) `
Have tried this with numerous virtual envs is there a solution to this problem? Thanks in advance Oliver for the fantastic work your doing!
At the time I implemented websocket api, it was only available for binance.com spot+testnet. Futures was not available from Binance side at that time...
Make WS API available for Binance Futures: https://developers.binance.com/docs/derivatives/usds-margined-futures/websocket-api-general-info
Binance has added the ability to send requests to the Binance API directly via websocket: https://developers.binance.com/docs/binance-trading-api/websocket_api
I have started to add support for this in the UNICORN Binance WebSocket API.
I have added the following functions:
ubwa.api.cancel_open_orders()
ubwa.api.cancel_order()
ubwa.api.create_order()
ubwa.api.get_account_status()
ubwa.api.get_exchange_info()
ubwa.api.get_open_orders()
ubwa.api.get_order()
ubwa.api.get_order_book()
ubwa.api.get_server_time()
ubwa.api.ping()
ubwa.api.create_test_order()
ubwa.api.get_listen_key()
The implementation works, but is not yet complete. There are a lot of functions missing... will do that in the next time.
How To: https://medium.lucit.tech/create-and-cancel-orders-via-websocket-on-binance-7f828831404
Docs: https://unicorn-binance-websocket-api.docs.lucit.tech/unicorn_binance_websocket_api.html#unicorn-binance-websocket-api-ws-api-module
Todo: