Skip to main content

REST API and WebSocket asyncio wrapper with grpc powered multiplexer server

Project description

Crypto exchanges API/WSS wrapper with grpc powered server

Binance, Bitfinex, Huobi, OKX, Bybit,

For SPOT markets


PyPI version DeepSource DeepSource sonarcloud Downloads


From v1.4.0 must be updated exch_srv_cfg.toml


exchanges-wrapper vs binance.py

The main difference is the development of the project for trading with many exchanges.

Next is adding a new module exchanges_wrapper/exch_srv.py as a multiplexer layer, providing simultaneous async interaction for many accounts and many trading pairs through one connection. It's powered by gRPC Remote Procedure Call framework.

Warning. Coverage of overridden binance.py packages is significant but not complete. Served methods describes into example/exch_client.py

Initial capabilities (inherited from binance.py)

  • Covers general endpoints (test connectivity and get exchange information's)
  • Covers market data endpoints
  • Covers Account endpoints (create and manage orders)
  • Covers user data stream (receive real time user updates)
  • Covers web socket streams (receive real time market updates)
  • Async support
  • Auto reconnect after exchanges API or network failure
  • Completely free and without limitations

Added Features

  • Multi exchanges support
  • Adaptive algorithm to ensure maximum performance and avoid exceeding the rates limits
  • Passthrough logging
  • WSS keepalive
  • Reuse session for new client sessions
  • Utilizing Websocket API (bidirectional) for the most commonly used methods:
    • Binance ws-api/v3
    • Bitfinex Websocket Authenticated Inputs v2
    • OKX WS v5

Extra exchanges implementation features

  • Binance REST API and WSS are accepted as basic, connection of other exchanges wrapped their API to Binance compatible
  • For other, some data cannot be obtained by directly calling one method, it is generated by a synthetic or calculation method
  • Some exchanges have not any testing or "paper trading" features, therefore, application development and testing is possible only at real bidding. First, run applications on the Binance Spot Test Network or (Bitfinex, OKX, Bybit) test account.

Get started

Prepare exchange account

  • Create account on Binance and get 10% discount on all trading fee

  • Create account on Bitfinex and get 6% rebate fee

  • Create account on HUOBI and get 10% cashback on all trading fee

  • Create account on OKX and get Mystery Boxes worth up to $10,000

  • Create account on Bybit and get exclusive referral rewards

  • For test purpose log in at Binance Spot Test Network

  • Create API Key

  • After install and create environment specify api_key and api_secret in /home/ubuntu/.MartinBinance/config/exch_srv_cfg.toml

Install use PIP

To install just run the following command:

pip install exchanges-wrapper

After first install create environment by run exchanges-wrapper-init in terminal window.

The structure of the working directory will be created and the necessary files will be copied: For Ubuntu it will be here: home/user/.MartinBinance/

For upgrade to latest versions use:

pip install -U exchanges-wrapper

Start server

  • Run in terminal window
    exchanges-wrapper-init
    

and

exchanges-wrapper-srv
  • Use an example to study

Use Docker image

docker pull ghcr.io/dogstailfarmer/exchanges-wrapper:latest

First run

The structure of the working directory will be created and the necessary files will be copied: For Ubuntu it will be here: home/user/.MartinBinance/

docker run --rm --entrypoint /bin/sh exchanges-wrapper -c "cat ./exchanges_wrapper/__init__.py" > init.py && \
docker run --rm --entrypoint /bin/sh exchanges-wrapper -c "cat ./exchanges_wrapper/exch_srv_cfg.toml.template" > exch_srv_cfg.toml.template &&\
 python3 init.py && rm init.py && rm exch_srv_cfg.toml.template

Start server

docker run -itP \
 --mount type=bind,source=/home/ubuntu/.MartinBinance,target=/home/appuser/.MartinBinance \
 --network=host \
 --restart=always \
 --name=exchanges-wrapper \
 exchanges-wrapper

Documentations

  • Served methods and examples of their use are described at example/exch_client.py
  • For Protocol Buffers serializing structured data see exchanges_wrapper/proto/martin.proto

Donate

USDT (TRC20) TN8F3Dz8BU8VwECRh3LTKi7FrsU8eWfsZz

Powered by exchanges-wrapper

martin-binance

Free trading system for crypto exchanges SPOT markets. Adaptive customizable reverse grid strategy based on martingale.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exchanges_wrapper-2.1.13.tar.gz (57.5 kB view details)

Uploaded Source

Built Distribution

exchanges_wrapper-2.1.13-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

Details for the file exchanges_wrapper-2.1.13.tar.gz.

File metadata

  • Download URL: exchanges_wrapper-2.1.13.tar.gz
  • Upload date:
  • Size: 57.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for exchanges_wrapper-2.1.13.tar.gz
Algorithm Hash digest
SHA256 4101d06b96193ce6eb88a9b3d7e6fe8a071755d795c2d5363cdf2dfad67fc0da
MD5 3b01f986822f544a6ad4186bca0cac75
BLAKE2b-256 26f83ed242ae77b00dadbc8322c41145b9a8a44169a6e3ff59c6fe86fed9cd6f

See more details on using hashes here.

File details

Details for the file exchanges_wrapper-2.1.13-py3-none-any.whl.

File metadata

File hashes

Hashes for exchanges_wrapper-2.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 da93e619d65447d34f0cda394e94c8428d81959292eca13a3453429d818193aa
MD5 d4fd483e33d015367ddc867a05edb1d3
BLAKE2b-256 5c67fbf590766247d870426555485bb21f2127eb093d97ab02e9a9104d3b3a35

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page