Package: crypto-strategy
crypto-strategyA repository to perform backtests and create trading strategies for cryptocurrencies.Installpip install crypto-strategy[full]UsageBacktest StrategyMoving Average StrategyDescriptionBestMaStrategy(symbols, freq, res_dir, flag_filter, flag_stop)symbols: asset name, e.g., BTCUSDTfreq: data frequency to use, 1h | 4hres_dir: results directoryflag_filter: filter to use, [mmi | ang]mmi: Market Meanness Index filterang: Linear Regression Angle filterflag_stop: early stop flag, [ts_stop | sl_stop | tp_stop]ts_stop: trailing stopsl_stop: stop losstp_stop: take profitExample: Find the best params using 1h data with mmi filter and ts_stopBestMaStrategy(
    symbols=['BTCUSDT', 'ETHUSDT'], 
    freq='1h', 
    res_dir='results/best-1h-ma-mmi-filter', 
    flag_filters='mmi',
    flag_stop='ts_stop'
)Breakout StrategyDescription: A method to optimize the BO strategysymbols: a list of symbols to be optimzied on, e.g., 'BTCUSDT'freq: currently supported values: '1h' or '4h'res_dir: the output directoryflag_filter: currently supported filters: 'vol', 'ang', default: Noneflag_stop: early stop flag, [ts_stop | sl_stop | tp_stop]ts_stop: trailing stopsl_stop: stop losstp_stop: take profitExample: Find the best params for bo strategy with vol filter using BTCUSDT 4h data and sl_stopBestBoStrategy(
    symbols = 'BTCUSDT',
    freq = '4h', 
    res_dir = 'results/best-4h-bo_rev-vol-filter', 
    flag_filters = 'vol',
    flag_stop = 'sl_stop',
)MACD StrategyBestMacdStrategy(symbols, freq, res_dir, flag_filter)symbols: asset name, e.g., BTCUSDTfreq: data frequency to use, 1h | 4hres_dir: results directoryflag_filter: filter to use, [mmi | ang | stoch | sma]vol: Volume filterang: Linear Regression Angle filterInspect StrategyMA StrategyDescription: A method to inspect the MA strategy with given paramsInspectMaStrategy(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, 50timeperiod: param used in either mmi or ang filterthreshold: param used in ang filterflag_filter: currently supported fitlers: 'mmi', 'ang', default: Nonestop_vars: dictionary of stop vars, currently support 'ts_stop', 'sl_stop', 'tp_stop', default NoneExample: Inspect MA strategylinear_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})BO StrategyDescription: A method to inspect the BO strategyInspectBoStrategy(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 paramsflag_filter: currently supported fitlers: 'vol', 'ang', default: Nonetimeperiod, multiplier: volume filter paramstimeperiod, threshold: angle filter paramsstop_vars: dictionary of stop vars, currently support 'ts_stop', 'sl_stop', 'tp_stop', default NoneExample: Inspect 4h BTCUSDT breakout strategy with volume filter and trailing stopInspectBoStrategy(
    'BTCUSDT', 
    freq='4h', 
    long_window=100, short_window=50,
    flag_filter='vol', timeperiod=20, multiplier=2,
    stop_vars={'ts_stop':0.1})CLIBacktests can also be carried out in command line. To find out morecrypto --helpExample 1: Find the best params for BO strategy with vol filter using 4h datacrypto best-bo-strategy -f 4h -r results/best-4h-bo-vol-filter -g vol -e boExample 2: Find the best params for MA strategy with mmi filter and ts_stop using 1h datacrypto best-ma-strategy -f 1h -r results/best-1h-ma-mmi-filter -g mmi -t ts_stopTestspytest