Basic crypto trading API for developing trading bots with transparent access to Coinbase Pro, Binance, Kraken, and Bitfinex
Project description
Writing your own crypto-trade bot is easy now!
cryptrade is a project that offers a a high level abstraction of a crypto-currency trade API. It offers classes for:
- Accounts, holding both fiat currency (EUR, USD, etc) as well as crypto currencies (BTH, ETH, etc)
- Products, representing what you can actually trade on a crypto exchange, eg. BTC-EUR (buy BTC pay in EUR) or ETH-BTC (buy ETH pay in BTC)
- Currencies, representing fiat and crypro currencies and their IDs used by exchanges
- Orders, the actual trade (buying or selling) of crypto currency
- Tickers, providing 'real-time' info on market-price and bid/ask prices
The (abstract) exchange interfaces provide the basic validations needed to successfully trade on an online exchange, make the necessary API calls, and handle the responses. To make the underlying exchange transparent, the API is provided using an Abstract Factory pattern.
On top of this, classes are provided for:
- Ticker, Account, and Order monitoring (implemented using the Observer pattern)
- Transactions, representing the total of buying/selling transactions
- Logger, providing logging classes for logging to console, file, and through PushBullet. These classes are implemented as Singletons.
At this moment, the following crypto exchanges are supported:
- Coinbase Pro (http://pro.coinbase.com), formerly known as GDAX
- Binance (http://binance.com)
- Kraken (http://www.kraken.com)
- Bitfinex (http://bitfinex.com)
The interfaces can be used in a synchronous manner, however they also include asynchronous interfaces so it is possible to make use of the asyncio package for cooperative multitasking using an event-loop.
Two sample programs are included:
- cryptrade.py, a sample program that shows the usage of this package. It's operation can be directed using commandline parameters. It will trade according a very simple algorithm.
usage: cryptrade.py [-h] [-c {eur,btc}] [-d TRADE_DELTA] [-a TRADE_AMOUNT]
exchange currency
positional arguments:
exchange Exchange to trade on. Currently supported: coinbase,
binance, kraken, bitfinex
currency Currency to trade in: btc, eth, xrp, ltc, bch, ...
optional arguments:
-h, --help show this help message and exit
-c CURRENCY, --currency CURRENCY
(Crypto) currency to use for buying.
-d TRADE_DELTA, --delta TRADE_DELTA
Percentage (0.0 < trade < 100.0) by which market price
should change before making a trade (accepts
fractional numbers).
-a TRADE_AMOUNT, --amount TRADE_AMOUNT
Initial amount to start trading with (btc>=0.001,
eth>=0.01, xrp>=1, ltc=0.1).
- tickermonitor.py, shows how the asynchronous interfaces can be used by implementing a tickermonitor for all supported exchanges in parallel.
Make sure you provide your credentials (API key & secret) before using it. They should be stored in a json file like:
{
"coinbase" :
{
"api_key" : "your api key",
"api_secret" : "your api secret",
"api_pass" : "you api password"
},
"binance" :
{
"api_key" : "your api key",
"api_secret" : "your api secret"
},
"kraken" :
{
"api_key" : "your api key",
"api_secret" : "your api secret"
},
"bitfinex" :
{
"api_key" : "your api key",
"api_secret" : "your api secret"
},
"pushbullet" :
{
"api_key" : "your api key"
}
}
The cryptrade module contains the following packages:
- logging (logging interfaces)
- parameters (interfaces for dealing with -commandline- parameters)
- exceptions (containing module-specific exceptions)
- observers (containing base classes for observables and observers)
- exchange_api (containing the abstract interface for trading)
- monitor (containing monitoring classes using asyncio)
- binance (containing concrete implementation for Binance)
- bitfinex (containing concrete implementation for Bitfinex)
- kraken (containing concrete implementation for Kraken)
- coinbase (containing concrete implementation for Coinbase Pro)
This project uses the official python interface for binance.com as well as the 'unofficial' python interface for Coinbase Pro by Daniel Paquin, the official python interface for Kraken.com, and the official python interface from bitfinex.com.
Special requests or questions: send me a message!
Want to stimulate the ongoing development? Your BTCs are welcome! Send them to bitcoin:15pqCjD7pPPraGJ8T4yfbkrtFTBX8M4jyw
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
Built Distribution
File details
Details for the file cryptrade-1.103.tar.gz
.
File metadata
- Download URL: cryptrade-1.103.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e4797468f13c91d7ad74a00361a926242273f7040c0d579a84f1fb0d4f71c48 |
|
MD5 | 2bccd55e22aaa74bf9e168c40df0b614 |
|
BLAKE2b-256 | dd0353a372ef3aeb10607ad286acfbe310f1f636e0855338875eb216771b0596 |
File details
Details for the file cryptrade-1.103-py3-none-any.whl
.
File metadata
- Download URL: cryptrade-1.103-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 486040da554b493141460095a835092f1e52134b00d4affed1e175f66fffbf15 |
|
MD5 | 90a629d07f7e799e3bc042f9a823cb7d |
|
BLAKE2b-256 | e600b57f80456fc5ea85b39023be8ca3dae39d0b60a0f50ada8aafb0f1a83469 |