Skip to content

Commit 3deccc5

Browse files
Feat: Add crudWs (sammchardy#1464)
* first commit * ruff check fix * ruff format fix * fix lint warnings and error * type fix for 3.7 * add testnet to test_Ws_api * change to testnet * ruff@ * return test to async in test * format with ruff * remove blank line * remove default tif * add ws_futures, refactor and add tests * lint * fix tests * ruff * add tests * remove utils * ruff format and pr comments * ruff format * fix live tests and add env vars for testnet * github action * add tox env * fix and test without tox * move tox command * fix test * fix pyright * type ignore * jump test until whitelist * remove print * add examples * improve docs * lint and format * lint and format * add tests for failed requests * fix for 3.7 * merge master * lint and format * pyright --------- Co-authored-by: carlosmiei <43336371+carlosmiei@users.noreply.github.com>
1 parent 23e17d6 commit 3deccc5

40 files changed

+5857
-3969
lines changed

.github/workflows/python-app.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ jobs:
3636
runs-on: ubuntu-latest
3737
env:
3838
PROXY: "http://51.83.140.52:16301"
39+
TEST_TESTNET: "true"
40+
TEST_API_KEY: "u4L8MG2DbshTfTzkx2Xm7NfsHHigvafxeC29HrExEmah1P8JhxXkoOu6KntLICUc"
41+
TEST_API_SECRET: "hBZEqhZUUS6YZkk7AIckjJ3iLjrgEFr5CRtFPp5gjzkrHKKC9DAv4OH25PlT6yq5"
42+
TEST_FUTURES_API_KEY: "227719da8d8499e8d3461587d19f259c0b39c2b462a77c9b748a6119abd74401"
43+
TEST_FUTURES_API_SECRET: "b14b935f9cfacc5dec829008733c40da0588051f29a44625c34967b45c11d73c"
3944
strategy:
4045
matrix:
4146
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

README.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Features
6868
- No need to generate timestamps yourself, the wrapper does it for you
6969
- Response exception handling
7070
- Websocket handling with reconnection and multiplexed connections
71+
- CRUDE over websockets, create/fetch/edit through websockets for minimum latency.
7172
- Symbol Depth Cache
7273
- Historical Kline/Candle fetching function
7374
- Withdraw functionality
@@ -160,6 +161,9 @@ pass `testnet=True` when creating the client.
160161
# fetch weekly klines since it listed
161162
klines = client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan, 2017")
162163
164+
# create order through websockets
165+
order_ws = client.ws_create_order( symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
166+
163167
# socket manager using threads
164168
twm = ThreadedWebsocketManager()
165169
twm.start()
@@ -237,10 +241,13 @@ for more information.
237241
print(kline)
238242
239243
# fetch 30 minute klines for the last month of 2017
240-
klines = client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018")
244+
klines = await client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018")
241245
242246
# fetch weekly klines since it listed
243-
klines = client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan, 2017")
247+
klines = await client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan, 2017")
248+
249+
# create order through websockets
250+
order_ws = await client.ws_create_order( symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
244251
245252
# setup an async context the Depth Cache and exit after 5 messages
246253
async with DepthCacheManager(client, symbol='ETHBTC') as dcm_socket:

binance/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66

77
__version__ = "1.0.22"
88

9-
from binance.client import Client, AsyncClient # noqa
10-
from binance.depthcache import DepthCacheManager, OptionsDepthCacheManager, ThreadedDepthCacheManager # noqa
11-
from binance.streams import BinanceSocketManager, ThreadedWebsocketManager, BinanceSocketType # noqa
12-
from binance.enums import * # noqa
9+
from binance.async_client import AsyncClient # noqa
10+
from binance.client import Client # noqa
11+
from binance.ws.depthcache import (
12+
DepthCacheManager, # noqa
13+
OptionsDepthCacheManager, # noqa
14+
ThreadedDepthCacheManager, # noqa
15+
)
16+
from binance.ws.streams import (
17+
BinanceSocketManager, # noqa
18+
ThreadedWebsocketManager, # noqa
19+
BinanceSocketType, # noqa
20+
)
21+
from binance.enums import * # noqa

0 commit comments

Comments
 (0)