Skip to main content

REST API and WebSocket asyncio wrapper with grpc powered multiplexer server for crypto exchanges

Project description


Crypto exchanges API/WSS wrapper with grpc powered server

Binance, FTX, Bitfinex

For SPOT markets


PyPI version DeepSource DeepSource sonarcloud Downloads


From v1.2.5 work path relocated to home/user/.MartinBinance/


exchanges-wrapper vs binance.py

The main difference is the development of the project for trading with many exchanges, including DeFi platforms shortly.

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

FTX Implementation features

  • Binance REST API and WSS are accepted as basic, connection of FTX and other exchanges wrapped their API to Binance compatible
  • For FTX, some data cannot be obtained by directly calling one method, it is generated by a synthetic or calculation method
  • FTX 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.

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 FTX
  • For test purpose log in at Binance Spot Test Network
  • Create API Key
  • After install and first run specify api_key and api_secret in /home/ubuntu/.MartinBinance/config/exch_srv_cfg.toml

Use Docker image

  • pull image with last version
  • get IMAGE_ID from pulled image and use it when run next command

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/

sudo docker run --rm --entrypoint /bin/sh IMAGE_ID -c "cat /home/appuser/.local/lib/python3.10/site-packages/exchanges_wrapper/__init__.py" > init.py && \
sudo docker run --rm --entrypoint /bin/sh IMAGE_ID -c "cat /home/appuser/.local/lib/python3.10/site-packages/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

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

Install use PIP

To install the library, you can just run the following command:

pip install exchanges-wrapper

After first install run exchanges_wrapper/exch_srv.py You can find this where pip installs packages, often it's /home/ubuntu/.local/lib/python3.10/site-packages

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 martin-binance

Start server

  • Run exchanges_wrapper/exch_srv.py in terminal window
  • In example/ms_cfg.toml select desired exchange. Don't change exchange name.
  • Run example/exch_client.py in other terminal window

Documentations

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

Donate

BNB, BUSD, USDT (BEP20) 0x5b52c6ba862b11318616ee6cef64388618318b92

USDT (TRC20) TP1Y43dpY7rrRyTSLaSKDZmFirqvRcpopC

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-1.2.5.post2.tar.gz (55.1 kB view details)

Uploaded Source

Built Distribution

exchanges_wrapper-1.2.5.post2-py3-none-any.whl (52.8 kB view details)

Uploaded Python 3

File details

Details for the file exchanges-wrapper-1.2.5.post2.tar.gz.

File metadata

File hashes

Hashes for exchanges-wrapper-1.2.5.post2.tar.gz
Algorithm Hash digest
SHA256 f399f0f216d389c5709272a977c571d624251daf0afd062a9e0eeb979f78fc54
MD5 a3d8cba1f0a5747d508eb381c6693cf1
BLAKE2b-256 d36564363541a489f7badf97d3b78b352b62d77a0d114b288253e837a59d02f6

See more details on using hashes here.

File details

Details for the file exchanges_wrapper-1.2.5.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for exchanges_wrapper-1.2.5.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1ac9c3241731bfbaaad0df230c486dee121b4ef45427bd849661992eb364a00
MD5 1dca44213ad9c4ff0c28ab540a88e864
BLAKE2b-256 5f68c2b724074009dc48cc0874d372c65dadc0a5771eee3adc133db19657f2d9

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