crypto-strategy
A repository to perform backtests and create trading strategies for cryptocurrencies.
Install
pip install crypto-strategy[full]
Usage
Backtest Strategy
- Moving Average Strategy
-
Description
BestMaStrategy(symbols, freq, res_dir, flag_filter, flag_stop)- symbols: asset name, e.g., BTCUSDT
- freq: data frequency to use, 1h | 4h
- res_dir: results directory
- flag_filter: filter to use, [mmi | ang]
- mmi: Market Meanness Index filter
- ang: Linear Regression Angle filter
- flag_stop: early stop flag, [ts_stop | sl_stop | tp_stop]
- ts_stop: trailing stop
- sl_stop: stop loss
- tp_stop: take profit
-
Example: Find the best params using 1h data with mmi filter and ts_stop
BestMaStrategy( symbols=['BTCUSDT', 'ETHUSDT'], freq='1h', res_dir='results/best-1h-ma-mmi-filter', flag_filters='mmi', flag_stop='ts_stop' )
- Breakout Strategy
-
Description: A method to optimize the BO strategy
- symbols: a list of symbols to be optimzied on, e.g., 'BTCUSDT'
- freq: currently supported values: '1h' or '4h'
- res_dir: the output directory
- flag_filter: currently supported filters: 'vol', 'ang', default: None
- flag_stop: early stop flag, [ts_stop | sl_stop | tp_stop]
- ts_stop: trailing stop
- sl_stop: stop loss
- tp_stop: take profit
-
Example: Find the best params for bo strategy with vol filter using BTCUSDT 4h data and sl_stop
BestBoStrategy( symbols = 'BTCUSDT', freq = '4h', res_dir = 'results/best-4h-bo_rev-vol-filter', flag_filters = 'vol', flag_stop = 'sl_stop', )
-
- MACD Strategy
BestMacdStrategy(symbols, freq, res_dir, flag_filter)
- symbols: asset name, e.g., BTCUSDT
- freq: data frequency to use, 1h | 4h
- res_dir: results directory
- flag_filter: filter to use, [mmi | ang | stoch | sma]
- vol: Volume filter
- ang: Linear Regression Angle filter
Inspect Strategy
-
MA Strategy
- Description: A method to inspect the MA strategy with given params
InspectMaStrategy(symbols, freq, name, n1, n2, timeperiod, threshold, flag_filter, stop_vars)- symbol: the name of the crypto, e.g., 'BTCUSDT'
- freq: currently supported values are '1h' or '4h'
- name, n1, n2: the name and the params of the ma strategy, e.g., 'sma', 100, 50
- timeperiod: param used in either mmi or ang filter
- threshold: param used in ang filter
- flag_filter: currently supported fitlers: 'mmi', 'ang', default: None
- stop_vars: dictionary of stop vars, currently support 'ts_stop', 'sl_stop', 'tp_stop', default None
- Example: Inspect MA strategy
linear_regwithn1=30 & n2=280andsl_stop=0.1 & tp_stop=0.1InspectMaStrategy( symbols, freq='4h', name='linear_reg', n1=30, n2=280, stop_vars={'sl_stop':0.1, 'tp_stop':0.1})
- Description: A method to inspect the MA strategy with given params
-
BO Strategy
-
Description: A method to inspect the BO strategy
InspectBoStrategy(symbol, freq, long_window, short_window, ts_stop, timeperiod, multiplier, threshold, flag_filter, flag_ts_stop)- symbols: a list of symbols to be optimzied on, e.g., 'BTCUSDT'
- freq: currently supported values: '1h' or '4h'
- long_window, short_window: breakout params
- flag_filter: currently supported fitlers: 'vol', 'ang', default: None
- timeperiod, multiplier: volume filter params
- timeperiod, threshold: angle filter params
- stop_vars: dictionary of stop vars, currently support 'ts_stop', 'sl_stop', 'tp_stop', default None
-
Example: Inspect 4h BTCUSDT breakout strategy with volume filter and trailing stop
InspectBoStrategy( 'BTCUSDT', freq='4h', long_window=100, short_window=50, flag_filter='vol', timeperiod=20, multiplier=2, stop_vars={'ts_stop':0.1})
-
CLI
Backtests can also be carried out in command line. To find out more
crypto --help
Example 1: Find the best params for BO strategy with vol filter using 4h data
crypto best-bo-strategy -f 4h -r results/best-4h-bo-vol-filter -g vol -e bo
Example 2: Find the best params for MA strategy with mmi filter and ts_stop using 1h data
crypto best-ma-strategy -f 1h -r results/best-1h-ma-mmi-filter -g mmi -t ts_stop
Tests
pytest
Metadata
Release files for crypto-strategy 0.1.20
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 |
|---|---|---|---|---|
| crypto-strategy-0.1.20.tar.gz | 51.4 kB | Without provenance | Details for crypto-strategy-0.1.20.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| crypto_strategy-0.1.20-py3-none-any.whl | Python 3 | none | any | Details for crypto_strategy-0.1.20-py3-none-any.whl |
Total release size: 111.8 kB
Release files / crypto-strategy-0.1.20.tar.gz
| Download URL | crypto-strategy-0.1.20.tar.gz |
|---|---|
| Size | 51.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c64b339b61a606b5214d6200f3597bf73da9e9fd5a634a574afbcf08eb5da66
|
|
BLAKE2b-256 checksum How to use checksums |
30fb4110838303778af751ac6a5eb4f3b9c415f2c1818feab9b3805272272f26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / crypto_strategy-0.1.20-py3-none-any.whl
| Download URL | crypto_strategy-0.1.20-py3-none-any.whl |
|---|---|
| Size | 60.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4621f810f942fa6f31ac2b97a2ee32fb45da28c7df81e412b41299d15aa9506c
|
|
BLAKE2b-256 checksum How to use checksums |
f90fa00f624c49149e3f976a5f132c3deaf126cfeca1f78fc8f5bb3ab1a1e6ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for crypto-strategy 0.1.20
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.