"multi-strategy parameter optimization cannot be easier than this"
# uncomment to install in colab
# !pip3 install fastquant
from fastquant import backtest, get_stock_data
df = get_stock_data("JFC", "2018-01-01", "2019-01-01")
# Utilize single set of parameters
strats = {
"smac": {"fast_period": 35, "slow_period": 50},
"rsi": {"rsi_lower": 30, "rsi_upper": 70}
}
res = backtest("multi", df, strats=strats)
res.shape
# (1, 16)
Starting Portfolio Value: 100000.00 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 35 slow_period : 50 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 30 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 100000.0 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 395 2018-07-06, Afforded size: 395 2018-07-06, Final size: 395 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 99145.00, Comm 743.59 2018-08-01, SELL CREATE, 276.00 2018-08-02, SELL EXECUTED, Price: 276.00, Cost: 99145.00, Comm 817.65 2018-08-02, OPERATION PROFIT, GROSS 9875.00, NET 8313.76 2018-08-29, BUY CREATE, 287.40 2018-08-29, Cash: 108313.76250000001 2018-08-29, Price: 287.4 2018-08-29, Buy prop size: 373 2018-08-29, Afforded size: 373 2018-08-29, Final size: 373 2018-08-30, BUY EXECUTED, Price: 287.40, Cost: 107200.20, Comm 804.00 2018-10-08, SELL CREATE, 252.40 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 309.5610000000147 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 1 2018-10-08, Afforded size: 1 2018-10-08, Final size: 1 2018-10-09, SELL EXECUTED, Price: 252.40, Cost: 107200.20, Comm 706.09 2018-10-09, OPERATION PROFIT, GROSS -13055.00, NET -14565.09 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 243.00, Comm 1.82 2018-11-22, BUY CREATE, 285.00 2018-11-22, Cash: 93503.84950000003 2018-11-22, Price: 285.0 2018-11-22, Buy prop size: 325 2018-11-22, Afforded size: 325 2018-11-22, Final size: 325 2018-11-23, BUY EXECUTED, Price: 285.00, Cost: 92625.00, Comm 694.69 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 92868.00, Comm 740.83 Final PnL: -1778.67 Final PnL: -1778.67 ================================================== Number of strat runs: 1 Number of strats per run: 2 Strat names: ['smac', 'rsi'] ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 35, 'smac.slow_period': 50, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 30} OrderedDict([('rtot', -0.0179468149815959), ('ravg', -7.385520568557983e-05), ('rnorm', -0.018439387134145634), ('rnorm100', -1.8439387134145633)]) OrderedDict([('sharperatio', None)]) Time used (seconds): 0.06001472473144531 Optimal parameters: {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 35, 'smac.slow_period': 50, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 30} Optimal metrics: {'rtot': -0.0179468149815959, 'ravg': -7.385520568557983e-05, 'rnorm': -0.018439387134145634, 'rnorm100': -1.8439387134145633, 'sharperatio': None, 'pnl': -1778.67, 'final_value': 98221.32700000002}
(1, 16)
strats_opt = {
"smac": {"fast_period": [10,15], "slow_period": [40, 60]},
"rsi": {"rsi_lower": [20, 30], "rsi_upper": [70, 80]}
}
res_opt = backtest("multi", df, strats=strats_opt)
res_opt.shape
# (4, 16)
Starting Portfolio Value: 100000.00 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 10 slow_period : 40 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 20 2018-04-12, BUY CREATE, 300.00 2018-04-12, Cash: 100000.0 2018-04-12, Price: 300.0 2018-04-12, Buy prop size: 330 2018-04-12, Afforded size: 330 2018-04-12, Final size: 330 2018-04-13, BUY EXECUTED, Price: 300.00, Cost: 99000.00, Comm 742.50 2018-04-13, SELL CREATE, 291.60 2018-04-16, SELL EXECUTED, Price: 291.60, Cost: 99000.00, Comm 721.71 2018-04-16, OPERATION PROFIT, GROSS -2772.00, NET -4236.21 2018-08-03, BUY CREATE, 277.00 2018-08-03, Cash: 95763.79 2018-08-03, Price: 277.0 2018-08-03, Buy prop size: 342 2018-08-03, Afforded size: 342 2018-08-03, Final size: 342 2018-08-06, BUY EXECUTED, Price: 277.00, Cost: 94734.00, Comm 710.50 2018-09-19, SELL CREATE, 271.00 2018-09-20, SELL EXECUTED, Price: 271.00, Cost: 94734.00, Comm 695.12 2018-09-20, OPERATION PROFIT, GROSS -2052.00, NET -3457.62 2018-10-30, BUY CREATE, 264.00 2018-10-30, Cash: 92306.16999999998 2018-10-30, Price: 264.0 2018-10-30, Buy prop size: 346 2018-10-30, Afforded size: 346 2018-10-30, Final size: 346 2018-10-31, BUY EXECUTED, Price: 264.00, Cost: 91344.00, Comm 685.08 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 91344.00, Comm 786.28 Final PnL: 4328.8 Final PnL: 4328.8 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 10 slow_period : 40 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 80 rsi_lower : 20 2018-04-12, BUY CREATE, 300.00 2018-04-12, Cash: 100000.0 2018-04-12, Price: 300.0 2018-04-12, Buy prop size: 330 2018-04-12, Afforded size: 330 2018-04-12, Final size: 330 2018-04-13, BUY EXECUTED, Price: 300.00, Cost: 99000.00, Comm 742.50 2018-04-13, SELL CREATE, 291.60 2018-04-16, SELL EXECUTED, Price: 291.60, Cost: 99000.00, Comm 721.71 2018-04-16, OPERATION PROFIT, GROSS -2772.00, NET -4236.21 2018-08-03, BUY CREATE, 277.00 2018-08-03, Cash: 95763.79 2018-08-03, Price: 277.0 2018-08-03, Buy prop size: 342 2018-08-03, Afforded size: 342 2018-08-03, Final size: 342 2018-08-06, BUY EXECUTED, Price: 277.00, Cost: 94734.00, Comm 710.50 2018-09-19, SELL CREATE, 271.00 2018-09-20, SELL EXECUTED, Price: 271.00, Cost: 94734.00, Comm 695.12 2018-09-20, OPERATION PROFIT, GROSS -2052.00, NET -3457.62 2018-10-30, BUY CREATE, 264.00 2018-10-30, Cash: 92306.16999999998 2018-10-30, Price: 264.0 2018-10-30, Buy prop size: 346 2018-10-30, Afforded size: 346 2018-10-30, Final size: 346 2018-10-31, BUY EXECUTED, Price: 264.00, Cost: 91344.00, Comm 685.08 Final PnL: 1239.89 Final PnL: 1239.89 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 10 slow_period : 40 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 30 2018-04-12, BUY CREATE, 300.00 2018-04-12, Cash: 100000.0 2018-04-12, Price: 300.0 2018-04-12, Buy prop size: 330 2018-04-12, Afforded size: 330 2018-04-12, Final size: 330 2018-04-13, BUY EXECUTED, Price: 300.00, Cost: 99000.00, Comm 742.50 2018-04-13, SELL CREATE, 291.60 2018-04-16, SELL EXECUTED, Price: 291.60, Cost: 99000.00, Comm 721.71 2018-04-16, OPERATION PROFIT, GROSS -2772.00, NET -4236.21 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 95763.79 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 378 2018-07-06, Afforded size: 378 2018-07-06, Final size: 378 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 94878.00, Comm 711.59 2018-08-01, SELL CREATE, 276.00 2018-08-02, SELL EXECUTED, Price: 276.00, Cost: 94878.00, Comm 782.46 2018-08-02, OPERATION PROFIT, GROSS 9450.00, NET 7955.95 2018-08-03, BUY CREATE, 277.00 2018-08-03, Cash: 103719.74499999998 2018-08-03, Price: 277.0 2018-08-03, Buy prop size: 371 2018-08-03, Afforded size: 371 2018-08-03, Final size: 371 2018-08-06, BUY EXECUTED, Price: 277.00, Cost: 102767.00, Comm 770.75 2018-09-19, SELL CREATE, 271.00 2018-09-20, SELL EXECUTED, Price: 271.00, Cost: 102767.00, Comm 754.06 2018-09-20, OPERATION PROFIT, GROSS -2226.00, NET -3750.81 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 99968.93499999998 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 407 2018-10-08, Afforded size: 407 2018-10-08, Final size: 407 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 98901.00, Comm 741.76 2018-10-30, BUY CREATE, 264.00 2018-10-30, Cash: 326.1774999999832 2018-10-30, Price: 264.0 2018-10-30, Buy prop size: 1 2018-10-30, Afforded size: 1 2018-10-30, Final size: 1 2018-10-31, BUY EXECUTED, Price: 264.00, Cost: 264.00, Comm 1.98 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 99165.00, Comm 927.18 Final PnL: 22757.02 Final PnL: 22757.02 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 10 slow_period : 40 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 80 rsi_lower : 30 2018-04-12, BUY CREATE, 300.00 2018-04-12, Cash: 100000.0 2018-04-12, Price: 300.0 2018-04-12, Buy prop size: 330 2018-04-12, Afforded size: 330 2018-04-12, Final size: 330 2018-04-13, BUY EXECUTED, Price: 300.00, Cost: 99000.00, Comm 742.50 2018-04-13, SELL CREATE, 291.60 2018-04-16, SELL EXECUTED, Price: 291.60, Cost: 99000.00, Comm 721.71 2018-04-16, OPERATION PROFIT, GROSS -2772.00, NET -4236.21 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 95763.79 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 378 2018-07-06, Afforded size: 378 2018-07-06, Final size: 378 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 94878.00, Comm 711.59 2018-09-19, SELL CREATE, 271.00 2018-09-20, SELL EXECUTED, Price: 271.00, Cost: 94878.00, Comm 768.28 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 101843.91999999998 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 415 2018-10-08, Afforded size: 415 2018-10-08, Final size: 415 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 100845.00, Comm 756.34 Final PnL: 21339.58 Final PnL: 21339.58 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 10 slow_period : 60 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 20 2018-04-23, BUY CREATE, 294.00 2018-04-23, Cash: 100000.0 2018-04-23, Price: 294.0 2018-04-23, Buy prop size: 337 2018-04-23, Afforded size: 337 2018-04-23, Final size: 337 2018-04-24, BUY EXECUTED, Price: 294.00, Cost: 99078.00, Comm 743.08 2018-04-26, SELL CREATE, 282.00 2018-04-27, SELL EXECUTED, Price: 282.00, Cost: 99078.00, Comm 712.75 2018-04-27, OPERATION PROFIT, GROSS -4044.00, NET -5499.84 2018-08-08, BUY CREATE, 276.80 2018-08-08, Cash: 94500.15999999999 2018-08-08, Price: 276.8 2018-08-08, Buy prop size: 338 2018-08-08, Afforded size: 338 2018-08-08, Final size: 338 2018-08-09, BUY EXECUTED, Price: 276.80, Cost: 93558.40, Comm 701.69 2018-09-28, SELL CREATE, 252.00 2018-10-01, SELL EXECUTED, Price: 252.00, Cost: 93558.40, Comm 638.82 2018-10-01, OPERATION PROFIT, GROSS -8382.40, NET -9722.91 2018-11-06, BUY CREATE, 278.60 2018-11-06, Cash: 84777.25199999998 2018-11-06, Price: 278.6 2018-11-06, Buy prop size: 301 2018-11-06, Afforded size: 301 2018-11-06, Final size: 301 2018-11-07, BUY EXECUTED, Price: 278.60, Cost: 83858.60, Comm 628.94 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 83858.60, Comm 684.02 Final PnL: -9191.31 Final PnL: -9191.31 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 10 slow_period : 60 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 80 rsi_lower : 20 2018-04-23, BUY CREATE, 294.00 2018-04-23, Cash: 100000.0 2018-04-23, Price: 294.0 2018-04-23, Buy prop size: 337 2018-04-23, Afforded size: 337 2018-04-23, Final size: 337 2018-04-24, BUY EXECUTED, Price: 294.00, Cost: 99078.00, Comm 743.08 2018-04-26, SELL CREATE, 282.00 2018-04-27, SELL EXECUTED, Price: 282.00, Cost: 99078.00, Comm 712.75 2018-04-27, OPERATION PROFIT, GROSS -4044.00, NET -5499.84 2018-08-08, BUY CREATE, 276.80 2018-08-08, Cash: 94500.15999999999 2018-08-08, Price: 276.8 2018-08-08, Buy prop size: 338 2018-08-08, Afforded size: 338 2018-08-08, Final size: 338 2018-08-09, BUY EXECUTED, Price: 276.80, Cost: 93558.40, Comm 701.69 2018-09-28, SELL CREATE, 252.00 2018-10-01, SELL EXECUTED, Price: 252.00, Cost: 93558.40, Comm 638.82 2018-10-01, OPERATION PROFIT, GROSS -8382.40, NET -9722.91 2018-11-06, BUY CREATE, 278.60 2018-11-06, Cash: 84777.25199999998 2018-11-06, Price: 278.6 2018-11-06, Buy prop size: 301 2018-11-06, Afforded size: 301 2018-11-06, Final size: 301 2018-11-07, BUY EXECUTED, Price: 278.60, Cost: 83858.60, Comm 628.94 Final PnL: -11878.49 Final PnL: -11878.49 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 10 slow_period : 60 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 30 2018-04-23, BUY CREATE, 294.00 2018-04-23, Cash: 100000.0 2018-04-23, Price: 294.0 2018-04-23, Buy prop size: 337 2018-04-23, Afforded size: 337 2018-04-23, Final size: 337 2018-04-24, BUY EXECUTED, Price: 294.00, Cost: 99078.00, Comm 743.08 2018-04-26, SELL CREATE, 282.00 2018-04-27, SELL EXECUTED, Price: 282.00, Cost: 99078.00, Comm 712.75 2018-04-27, OPERATION PROFIT, GROSS -4044.00, NET -5499.84 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 94500.15999999999 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 373 2018-07-06, Afforded size: 373 2018-07-06, Final size: 373 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 93623.00, Comm 702.17 2018-08-01, SELL CREATE, 276.00 2018-08-02, SELL EXECUTED, Price: 276.00, Cost: 93623.00, Comm 772.11 2018-08-02, OPERATION PROFIT, GROSS 9325.00, NET 7850.72 2018-08-08, BUY CREATE, 276.80 2018-08-08, Cash: 102350.87749999999 2018-08-08, Price: 276.8 2018-08-08, Buy prop size: 366 2018-08-08, Afforded size: 366 2018-08-08, Final size: 366 2018-08-09, BUY EXECUTED, Price: 276.80, Cost: 101308.80, Comm 759.82 2018-09-28, SELL CREATE, 252.00 2018-10-01, SELL EXECUTED, Price: 252.00, Cost: 101308.80, Comm 691.74 2018-10-01, OPERATION PROFIT, GROSS -9076.80, NET -10528.36 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 91822.52149999997 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 374 2018-10-08, Afforded size: 374 2018-10-08, Final size: 374 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 90882.00, Comm 681.61 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 90882.00, Comm 849.91 2018-12-20, OPERATION PROFIT, GROSS 22440.00, NET 20908.47 Final PnL: 12730.99 Final PnL: 12730.99 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 10 slow_period : 60 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 80 rsi_lower : 30 2018-04-23, BUY CREATE, 294.00 2018-04-23, Cash: 100000.0 2018-04-23, Price: 294.0 2018-04-23, Buy prop size: 337 2018-04-23, Afforded size: 337 2018-04-23, Final size: 337 2018-04-24, BUY EXECUTED, Price: 294.00, Cost: 99078.00, Comm 743.08 2018-04-26, SELL CREATE, 282.00 2018-04-27, SELL EXECUTED, Price: 282.00, Cost: 99078.00, Comm 712.75 2018-04-27, OPERATION PROFIT, GROSS -4044.00, NET -5499.84 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 94500.15999999999 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 373 2018-07-06, Afforded size: 373 2018-07-06, Final size: 373 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 93623.00, Comm 702.17 2018-09-28, SELL CREATE, 252.00 2018-10-01, SELL EXECUTED, Price: 252.00, Cost: 93623.00, Comm 704.97 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 93466.01749999999 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 381 2018-10-08, Afforded size: 381 2018-10-08, Final size: 381 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 92583.00, Comm 694.37 Final PnL: 11364.44 Final PnL: 11364.44 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 15 slow_period : 40 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 20 2018-08-07, BUY CREATE, 270.00 2018-08-07, Cash: 100000.0 2018-08-07, Price: 270.0 2018-08-07, Buy prop size: 367 2018-08-07, Afforded size: 367 2018-08-07, Final size: 367 2018-08-08, BUY EXECUTED, Price: 270.00, Cost: 99090.00, Comm 743.17 2018-09-21, SELL CREATE, 271.00 2018-09-24, SELL EXECUTED, Price: 271.00, Cost: 99090.00, Comm 745.93 2018-09-24, OPERATION PROFIT, GROSS 367.00, NET -1122.10 2018-11-05, BUY CREATE, 280.00 2018-11-05, Cash: 98877.89749999999 2018-11-05, Price: 280.0 2018-11-05, Buy prop size: 350 2018-11-05, Afforded size: 350 2018-11-05, Final size: 350 2018-11-06, BUY EXECUTED, Price: 280.00, Cost: 98000.00, Comm 735.00 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 98000.00, Comm 795.38 Final PnL: 5397.52 Final PnL: 5397.52 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 15 slow_period : 40 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 80 rsi_lower : 20 2018-08-07, BUY CREATE, 270.00 2018-08-07, Cash: 100000.0 2018-08-07, Price: 270.0 2018-08-07, Buy prop size: 367 2018-08-07, Afforded size: 367 2018-08-07, Final size: 367 2018-08-08, BUY EXECUTED, Price: 270.00, Cost: 99090.00, Comm 743.17 2018-09-21, SELL CREATE, 271.00 2018-09-24, SELL EXECUTED, Price: 271.00, Cost: 99090.00, Comm 745.93 2018-09-24, OPERATION PROFIT, GROSS 367.00, NET -1122.10 2018-11-05, BUY CREATE, 280.00 2018-11-05, Cash: 98877.89749999999 2018-11-05, Price: 280.0 2018-11-05, Buy prop size: 350 2018-11-05, Afforded size: 350 2018-11-05, Final size: 350 2018-11-06, BUY EXECUTED, Price: 280.00, Cost: 98000.00, Comm 735.00 Final PnL: 2272.9 Final PnL: 2272.9 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 15 slow_period : 40 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 30 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 100000.0 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 395 2018-07-06, Afforded size: 395 2018-07-06, Final size: 395 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 99145.00, Comm 743.59 2018-08-01, SELL CREATE, 276.00 2018-08-02, SELL EXECUTED, Price: 276.00, Cost: 99145.00, Comm 817.65 2018-08-02, OPERATION PROFIT, GROSS 9875.00, NET 8313.76 2018-08-07, BUY CREATE, 270.00 2018-08-07, Cash: 108313.76250000001 2018-08-07, Price: 270.0 2018-08-07, Buy prop size: 397 2018-08-07, Afforded size: 397 2018-08-07, Final size: 397 2018-08-08, BUY EXECUTED, Price: 270.00, Cost: 107190.00, Comm 803.92 2018-09-21, SELL CREATE, 271.00 2018-09-24, SELL EXECUTED, Price: 271.00, Cost: 107190.00, Comm 806.90 2018-09-24, OPERATION PROFIT, GROSS 397.00, NET -1213.83 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 107099.93500000001 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 437 2018-10-08, Afforded size: 437 2018-10-08, Final size: 437 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 106191.00, Comm 796.43 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 106191.00, Comm 993.08 2018-12-20, OPERATION PROFIT, GROSS 26220.00, NET 24430.49 Final PnL: 31530.42 Final PnL: 31530.42 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 15 slow_period : 40 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 80 rsi_lower : 30 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 100000.0 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 395 2018-07-06, Afforded size: 395 2018-07-06, Final size: 395 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 99145.00, Comm 743.59 2018-09-21, SELL CREATE, 271.00 2018-09-24, SELL EXECUTED, Price: 271.00, Cost: 99145.00, Comm 802.84 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 106353.57500000001 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 433 2018-10-08, Afforded size: 433 2018-10-08, Final size: 433 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 105219.00, Comm 789.14 2018-11-05, BUY CREATE, 280.00 2018-11-05, Cash: 345.4325000000116 2018-11-05, Price: 280.0 2018-11-05, Buy prop size: 1 2018-11-05, Afforded size: 1 2018-11-05, Final size: 1 2018-11-06, BUY EXECUTED, Price: 280.00, Cost: 280.00, Comm 2.10 Final PnL: 26704.53 Final PnL: 26704.53 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 15 slow_period : 60 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 20 2018-08-14, BUY CREATE, 273.40 2018-08-14, Cash: 100000.0 2018-08-14, Price: 273.4 2018-08-14, Buy prop size: 362 2018-08-14, Afforded size: 362 2018-08-14, Final size: 362 2018-08-15, BUY EXECUTED, Price: 273.40, Cost: 98970.80, Comm 742.28 2018-10-01, SELL CREATE, 250.00 2018-10-02, SELL EXECUTED, Price: 250.00, Cost: 98970.80, Comm 678.75 2018-10-02, OPERATION PROFIT, GROSS -8470.80, NET -9891.83 2018-11-08, BUY CREATE, 280.00 2018-11-08, Cash: 90108.16900000001 2018-11-08, Price: 280.0 2018-11-08, Buy prop size: 319 2018-11-08, Afforded size: 319 2018-11-08, Final size: 319 2018-11-09, BUY EXECUTED, Price: 280.00, Cost: 89320.00, Comm 669.90 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 89320.00, Comm 724.93 Final PnL: -3949.66 Final PnL: -3949.66 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 15 slow_period : 60 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 80 rsi_lower : 20 2018-08-14, BUY CREATE, 273.40 2018-08-14, Cash: 100000.0 2018-08-14, Price: 273.4 2018-08-14, Buy prop size: 362 2018-08-14, Afforded size: 362 2018-08-14, Final size: 362 2018-08-15, BUY EXECUTED, Price: 273.40, Cost: 98970.80, Comm 742.28 2018-10-01, SELL CREATE, 250.00 2018-10-02, SELL EXECUTED, Price: 250.00, Cost: 98970.80, Comm 678.75 2018-10-02, OPERATION PROFIT, GROSS -8470.80, NET -9891.83 2018-11-08, BUY CREATE, 280.00 2018-11-08, Cash: 90108.16900000001 2018-11-08, Price: 280.0 2018-11-08, Buy prop size: 319 2018-11-08, Afforded size: 319 2018-11-08, Final size: 319 2018-11-09, BUY EXECUTED, Price: 280.00, Cost: 89320.00, Comm 669.90 Final PnL: -6797.53 Final PnL: -6797.53 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 15 slow_period : 60 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 70 rsi_lower : 30 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 100000.0 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 395 2018-07-06, Afforded size: 395 2018-07-06, Final size: 395 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 99145.00, Comm 743.59 2018-08-01, SELL CREATE, 276.00 2018-08-02, SELL EXECUTED, Price: 276.00, Cost: 99145.00, Comm 817.65 2018-08-02, OPERATION PROFIT, GROSS 9875.00, NET 8313.76 2018-08-14, BUY CREATE, 273.40 2018-08-14, Cash: 108313.76250000001 2018-08-14, Price: 273.4 2018-08-14, Buy prop size: 392 2018-08-14, Afforded size: 392 2018-08-14, Final size: 392 2018-08-15, BUY EXECUTED, Price: 273.40, Cost: 107172.80, Comm 803.80 2018-10-01, SELL CREATE, 250.00 2018-10-02, SELL EXECUTED, Price: 250.00, Cost: 107172.80, Comm 735.00 2018-10-02, OPERATION PROFIT, GROSS -9172.80, NET -10711.60 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 97602.16650000002 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 398 2018-10-08, Afforded size: 398 2018-10-08, Final size: 398 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 96714.00, Comm 725.36 2018-12-19, SELL CREATE, 303.00 2018-12-20, SELL EXECUTED, Price: 303.00, Cost: 96714.00, Comm 904.45 2018-12-20, OPERATION PROFIT, GROSS 23880.00, NET 22250.19 Final PnL: 19852.36 Final PnL: 19852.36 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== fast_period : 15 slow_period : 60 ===Global level arguments=== init_cash : 100000 buy_prop : 1 sell_prop : 1 ===Strategy level arguments=== rsi_period : 14 rsi_upper : 80 rsi_lower : 30 2018-07-06, BUY CREATE, 251.00 2018-07-06, Cash: 100000.0 2018-07-06, Price: 251.0 2018-07-06, Buy prop size: 395 2018-07-06, Afforded size: 395 2018-07-06, Final size: 395 2018-07-09, BUY EXECUTED, Price: 251.00, Cost: 99145.00, Comm 743.59 2018-10-01, SELL CREATE, 250.00 2018-10-02, SELL EXECUTED, Price: 250.00, Cost: 99145.00, Comm 740.62 2018-10-08, BUY CREATE, 243.00 2018-10-08, Cash: 98120.7875 2018-10-08, Price: 243.0 2018-10-08, Buy prop size: 400 2018-10-08, Afforded size: 400 2018-10-08, Final size: 400 2018-10-09, BUY EXECUTED, Price: 243.00, Cost: 97200.00, Comm 729.00 Final PnL: 16911.79 Final PnL: 16911.79 ================================================== Number of strat runs: 16 Number of strats per run: 2 Strat names: ['smac', 'rsi'] ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 10, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 20} OrderedDict([('rtot', 0.042377312386123134), ('ravg', 0.000174392232041659), ('rnorm', 0.04492680768865365), ('rnorm100', 4.492680768865364)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 10, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 80, 'rsi.rsi_lower': 20} OrderedDict([('rtot', 0.012322663161177035), ('ravg', 5.071054798838286e-05), ('rnorm', 0.012861059182548444), ('rnorm100', 1.2861059182548444)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 10, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 30} OrderedDict([('rtot', 0.2050367480952209), ('ravg', 0.0008437726259062589), ('rnorm', 0.23692777159818812), ('rnorm100', 23.69277715981881)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 10, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 80, 'rsi.rsi_lower': 30} OrderedDict([('rtot', 0.19342289577512692), ('ravg', 0.00079597899495937), ('rnorm', 0.2221195736378016), ('rnorm100', 22.21195736378016)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 10, 'smac.slow_period': 60, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 20} OrderedDict([('rtot', -0.0964152001144457), ('ravg', -0.0003967703708413403), ('rnorm', -0.0951500349055751), ('rnorm100', -9.51500349055751)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 10, 'smac.slow_period': 60, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 80, 'rsi.rsi_lower': 20} OrderedDict([('rtot', -0.12645350010683382), ('ravg', -0.0005203847741021968), ('rnorm', -0.12290236382425088), ('rnorm100', -12.290236382425087)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 10, 'smac.slow_period': 60, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 30} OrderedDict([('rtot', 0.11983418838139474), ('ravg', 0.0004931448081538878), ('rnorm', 0.13232437790797075), ('rnorm100', 13.232437790797075)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 10, 'smac.slow_period': 60, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 80, 'rsi.rsi_lower': 30} OrderedDict([('rtot', 0.10763792539049269), ('ravg', 0.00044295442547527856), ('rnorm', 0.11809295492841805), ('rnorm100', 11.809295492841805)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 20} OrderedDict([('rtot', 0.052568944150307696), ('ravg', 0.00021633310349920864), ('rnorm', 0.05602931158519976), ('rnorm100', 5.602931158519977)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 80, 'rsi.rsi_lower': 20} OrderedDict([('rtot', 0.022474520295117782), ('ravg', 9.248773783999087e-05), ('rnorm', 0.02358063841261683), ('rnorm100', 2.358063841261683)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 30} OrderedDict([('rtot', 0.2740679696753637), ('ravg', 0.0011278517270591098), ('rnorm', 0.3287234047301618), ('rnorm100', 32.87234047301618)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 80, 'rsi.rsi_lower': 30} OrderedDict([('rtot', 0.23668767417980946), ('ravg', 0.0009740233505341953), ('rnorm', 0.2782013371264516), ('rnorm100', 27.820133712645163)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 60, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 20} OrderedDict([('rtot', -0.04029774133997106), ('ravg', -0.00016583432650193853), ('rnorm', -0.04092907566388783), ('rnorm100', -4.092907566388783)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 60, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 80, 'rsi.rsi_lower': 20} OrderedDict([('rtot', -0.07039597323112812), ('ravg', -0.00028969536309106223), ('rnorm', -0.07040217397345756), ('rnorm100', -7.0402173973457565)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 60, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 30} OrderedDict([('rtot', 0.18109043677660316), ('ravg', 0.0007452281348831406), ('rnorm', 0.20658914422764327), ('rnorm100', 20.658914422764326)]) OrderedDict([('sharperatio', None)]) ************************************************** -------------------------------------------------- {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 60, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 80, 'rsi.rsi_lower': 30} OrderedDict([('rtot', 0.15624951145271396), ('ravg', 0.0006430021047436788), ('rnorm', 0.1759031967451431), ('rnorm100', 17.59031967451431)]) OrderedDict([('sharperatio', None)]) Time used (seconds): 0.9437069892883301 Optimal parameters: {'init_cash': 100000, 'buy_prop': 1, 'sell_prop': 1, 'execution_type': 'close', 'smac.fast_period': 15, 'smac.slow_period': 40, 'rsi.rsi_period': 14, 'rsi.rsi_upper': 70, 'rsi.rsi_lower': 30} Optimal metrics: {'rtot': 0.2740679696753637, 'ravg': 0.0011278517270591098, 'rnorm': 0.3287234047301618, 'rnorm100': 32.87234047301618, 'sharperatio': None, 'pnl': 31530.42, 'final_value': 131530.42}
(16, 16)
res_opt
init_cash | buy_prop | sell_prop | execution_type | smac.fast_period | smac.slow_period | rsi.rsi_period | rsi.rsi_upper | rsi.rsi_lower | rtot | ravg | rnorm | rnorm100 | sharperatio | pnl | final_value | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 100000 | 1 | 1 | close | 15 | 40 | 14 | 70 | 30 | 0.274068 | 0.001128 | 0.328723 | 32.872340 | None | 31530.42 | 131530.4200 |
1 | 100000 | 1 | 1 | close | 15 | 40 | 14 | 80 | 30 | 0.236688 | 0.000974 | 0.278201 | 27.820134 | None | 26704.53 | 126704.5325 |
2 | 100000 | 1 | 1 | close | 10 | 40 | 14 | 70 | 30 | 0.205037 | 0.000844 | 0.236928 | 23.692777 | None | 22757.02 | 122757.0175 |
3 | 100000 | 1 | 1 | close | 10 | 40 | 14 | 80 | 30 | 0.193423 | 0.000796 | 0.222120 | 22.211957 | None | 21339.58 | 121339.5825 |
4 | 100000 | 1 | 1 | close | 15 | 60 | 14 | 70 | 30 | 0.181090 | 0.000745 | 0.206589 | 20.658914 | None | 19852.36 | 119852.3565 |
5 | 100000 | 1 | 1 | close | 15 | 60 | 14 | 80 | 30 | 0.156250 | 0.000643 | 0.175903 | 17.590320 | None | 16911.79 | 116911.7875 |
6 | 100000 | 1 | 1 | close | 10 | 60 | 14 | 70 | 30 | 0.119834 | 0.000493 | 0.132324 | 13.232438 | None | 12730.99 | 112730.9915 |
7 | 100000 | 1 | 1 | close | 10 | 60 | 14 | 80 | 30 | 0.107638 | 0.000443 | 0.118093 | 11.809295 | None | 11364.44 | 111364.4450 |
8 | 100000 | 1 | 1 | close | 15 | 40 | 14 | 70 | 20 | 0.052569 | 0.000216 | 0.056029 | 5.602931 | None | 5397.52 | 105397.5225 |
9 | 100000 | 1 | 1 | close | 10 | 40 | 14 | 70 | 20 | 0.042377 | 0.000174 | 0.044927 | 4.492681 | None | 4328.80 | 104328.8050 |
10 | 100000 | 1 | 1 | close | 15 | 40 | 14 | 80 | 20 | 0.022475 | 0.000092 | 0.023581 | 2.358064 | None | 2272.90 | 102272.8975 |
11 | 100000 | 1 | 1 | close | 10 | 40 | 14 | 80 | 20 | 0.012323 | 0.000051 | 0.012861 | 1.286106 | None | 1239.89 | 101239.8900 |
12 | 100000 | 1 | 1 | close | 15 | 60 | 14 | 70 | 20 | -0.040298 | -0.000166 | -0.040929 | -4.092908 | None | -3949.66 | 96050.3415 |
13 | 100000 | 1 | 1 | close | 15 | 60 | 14 | 80 | 20 | -0.070396 | -0.000290 | -0.070402 | -7.040217 | None | -6797.53 | 93202.4690 |
14 | 100000 | 1 | 1 | close | 10 | 60 | 14 | 70 | 20 | -0.096415 | -0.000397 | -0.095150 | -9.515003 | None | -9191.31 | 90808.6900 |
15 | 100000 | 1 | 1 | close | 10 | 60 | 14 | 80 | 20 | -0.126454 | -0.000520 | -0.122902 | -12.290236 | None | -11878.49 | 88121.5125 |