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
Metadata
Release files for cryptrade 1.103
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cryptrade-1.103.tar.gz | 13.9 kB | Without provenance | Details for cryptrade-1.103.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cryptrade-1.103-py3-none-any.whl | Python 3 | none | any | Details for cryptrade-1.103-py3-none-any.whl |
Total release size: 31.8 kB
Release files / cryptrade-1.103.tar.gz
| Download URL | cryptrade-1.103.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e4797468f13c91d7ad74a00361a926242273f7040c0d579a84f1fb0d4f71c48
|
|
BLAKE2b-256 checksum How to use checksums |
dd0353a372ef3aeb10607ad286acfbe310f1f636e0855338875eb216771b0596
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / cryptrade-1.103-py3-none-any.whl
| Download URL | cryptrade-1.103-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
486040da554b493141460095a835092f1e52134b00d4affed1e175f66fffbf15
|
|
BLAKE2b-256 checksum How to use checksums |
e600b57f80456fc5ea85b39023be8ca3dae39d0b60a0f50ada8aafb0f1a83469
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for cryptrade 1.103
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.