Skip to content

Commit

Permalink
Feat: Add crudWs (#1464)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
pcriadoperez and carlosmiei authored Nov 20, 2024
1 parent 23e17d6 commit 3deccc5
Show file tree
Hide file tree
Showing 40 changed files with 5,857 additions and 3,969 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
runs-on: ubuntu-latest
env:
PROXY: "http://51.83.140.52:16301"
TEST_TESTNET: "true"
TEST_API_KEY: "u4L8MG2DbshTfTzkx2Xm7NfsHHigvafxeC29HrExEmah1P8JhxXkoOu6KntLICUc"
TEST_API_SECRET: "hBZEqhZUUS6YZkk7AIckjJ3iLjrgEFr5CRtFPp5gjzkrHKKC9DAv4OH25PlT6yq5"
TEST_FUTURES_API_KEY: "227719da8d8499e8d3461587d19f259c0b39c2b462a77c9b748a6119abd74401"
TEST_FUTURES_API_SECRET: "b14b935f9cfacc5dec829008733c40da0588051f29a44625c34967b45c11d73c"
strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
Expand Down
11 changes: 9 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Features
- No need to generate timestamps yourself, the wrapper does it for you
- Response exception handling
- Websocket handling with reconnection and multiplexed connections
- CRUDE over websockets, create/fetch/edit through websockets for minimum latency.
- Symbol Depth Cache
- Historical Kline/Candle fetching function
- Withdraw functionality
Expand Down Expand Up @@ -160,6 +161,9 @@ pass `testnet=True` when creating the client.
# fetch weekly klines since it listed
klines = client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan, 2017")
# create order through websockets
order_ws = client.ws_create_order( symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
# socket manager using threads
twm = ThreadedWebsocketManager()
twm.start()
Expand Down Expand Up @@ -237,10 +241,13 @@ for more information.
print(kline)
# fetch 30 minute klines for the last month of 2017
klines = client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018")
klines = await client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018")
# fetch weekly klines since it listed
klines = client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan, 2017")
klines = await client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan, 2017")
# create order through websockets
order_ws = await client.ws_create_order( symbol="LTCUSDT", side="BUY", type="MARKET", quantity=0.1)
# setup an async context the Depth Cache and exit after 5 messages
async with DepthCacheManager(client, symbol='ETHBTC') as dcm_socket:
Expand Down
17 changes: 13 additions & 4 deletions binance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@

__version__ = "1.0.22"

from binance.client import Client, AsyncClient # noqa
from binance.depthcache import DepthCacheManager, OptionsDepthCacheManager, ThreadedDepthCacheManager # noqa
from binance.streams import BinanceSocketManager, ThreadedWebsocketManager, BinanceSocketType # noqa
from binance.enums import * # noqa
from binance.async_client import AsyncClient # noqa
from binance.client import Client # noqa
from binance.ws.depthcache import (
DepthCacheManager, # noqa
OptionsDepthCacheManager, # noqa
ThreadedDepthCacheManager, # noqa
)
from binance.ws.streams import (
BinanceSocketManager, # noqa
ThreadedWebsocketManager, # noqa
BinanceSocketType, # noqa
)
from binance.enums import * # noqa
Loading

0 comments on commit 3deccc5

Please sign in to comment.