Skip to content

Commit

Permalink
spot api
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-zehentleitner committed Nov 13, 2024
1 parent 866277f commit 8eb97a6
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 52 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- `manager.api.spot.get_klines()`
- `manager.api.spot.get_ui_klines()`
- `manager.api.spot.get_recent_trades()`
- `manager.api.spot.get_unfilled_order_count()`
- Support for `Websocket API Futures`:
- `manager.api.futures.get_aggregate_trades()`
### Changed
Expand Down
28 changes: 12 additions & 16 deletions binance_websocket_api_spot.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,37 @@ async def handle_socket_message(stream_id=None):
print(f"Orderbook, lastUpdateId={order_book['result']['lastUpdateId']}: {order_book['result']['asks']}, "
f"{order_book['result']['bids']}\r\n")

aggregate_trades = ubwa.api.spot.get_aggregate_trades(stream_id=api_stream, symbol=market, return_response=True)
print(f"aggregate_trades: {aggregate_trades['result'][:5]}\r\n")

historical_trades = ubwa.api.spot.get_historical_trades(stream_id=api_stream, symbol=market, return_response=True)
print(f"historical_trades: {historical_trades['result'][:5]}\r\n")

recent_trades = ubwa.api.spot.get_recent_trades(stream_id=api_stream, symbol=market, return_response=True)
print(f"recent_trades: {recent_trades['result'][:5]}\r\n")

klines = ubwa.api.spot.get_klines(stream_id=api_stream, symbol=market, interval="1m", return_response=True)
print(f"A few klines: {klines['result'][:5]}\r\n")

ui_klines = ubwa.api.spot.get_ui_klines(stream_id=api_stream, symbol=market, interval="1d", return_response=True)
print(f"A few ui_klines: {ui_klines['result'][:5]}\r\n")

ubwa.api.spot.get_open_orders(stream_id=api_stream, symbol=market)

ubwa.api.spot.get_open_orders(stream_id=api_stream)

replaced_client_order_id = ubwa.api.spot.cancel_and_replace_order(stream_id=api_stream, price=1.1,
order_type="LIMIT",
quantity=15.0, side="SELL", symbol=market,
cancel_orig_client_order_id=orig_client_order_id)

ubwa.api.spot.cancel_order(stream_id=api_stream, symbol=market, orig_client_order_id=replaced_client_order_id)

ubwa.api.spot.get_open_orders(stream_id=api_stream, symbol=market)

ubwa.api.spot.get_open_orders(stream_id=api_stream)

ubwa.api.spot.cancel_open_orders(stream_id=api_stream, symbol=market)

ubwa.api.spot.get_order(stream_id=api_stream, symbol=market, orig_client_order_id=replaced_client_order_id)

print(f"Finished! Waiting for responses:")
await asyncio.sleep(5)
aggregate_trades = ubwa.api.spot.get_aggregate_trades(stream_id=api_stream, symbol=market, return_response=True)
print(f"aggregate_trades: {aggregate_trades['result'][:5]}\r\n")

historical_trades = ubwa.api.spot.get_historical_trades(stream_id=api_stream, symbol=market, return_response=True)
print(f"historical_trades: {historical_trades['result'][:5]}\r\n")

recent_trades = ubwa.api.spot.get_recent_trades(stream_id=api_stream, symbol=market, return_response=True)
print(f"recent_trades: {recent_trades['result'][:5]}\r\n")

print(f"Stopping!")
ubwa.stop_manager()

if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG,
Expand Down
Loading

0 comments on commit 8eb97a6

Please sign in to comment.