Skip to content

Commit

Permalink
Merge branch 'v6.1.0_multi_symbol_backtest' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
enarjord authored Dec 19, 2023
2 parents c9e09d2 + 4ca7699 commit 6b9d3b6
Show file tree
Hide file tree
Showing 1,275 changed files with 57,720 additions and 12,073 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

:warning: **Use at own risk** :warning:

v6.0.1
v6.1.0


## Overview
Expand Down
2 changes: 1 addition & 1 deletion auto_profit_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def main():
# traceback.print_exc()
income = []
income = [e for e in income if e["transaction_id"] not in already_transferred_ids]
income = [x for x in income if x['timestamp'] > now - 1000 * 60 * 60 * 24]
income = [x for x in income if x["timestamp"] > now - 1000 * 60 * 60 * 24]
income = [e for e in income if e["token"] == args.quote]
profit = sum([e["income"] for e in income])
to_transfer = round_dynamic(profit * args.percentage, 4)
Expand Down
8 changes: 6 additions & 2 deletions backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def plot_wrap(config, data):

async def main():
parser = argparse.ArgumentParser(prog="Backtest", description="Backtest given passivbot config.")
parser.add_argument("live_config_path", type=str, help="path to live config to test, comma separated for multiple configs serially")
parser.add_argument(
"live_config_path",
type=str,
help="path to live config to test, comma separated for multiple configs serially",
)
parser = add_argparse_args(parser)
parser.add_argument(
"-lw",
Expand Down Expand Up @@ -164,7 +168,7 @@ async def main():
help="disable plotting",
)
args = parser.parse_args()
live_config_paths = args.live_config_path.split(',')
live_config_paths = args.live_config_path.split(",")
config = prepare_backtest_config(args)
for ix, live_config_path in enumerate(live_config_paths):
for symbol in config["symbols"]:
Expand Down
53 changes: 53 additions & 0 deletions configs/live/example_config.hjson
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
// fetch API key/secret from api-keys.json
user: bybit_01

// multisym auto unstuck: will use profits from other positions to offset losses realized on stuck positions
multisym_auto_unstuck_enabled: true

// how far into the past to fetch pnl history
pnls_max_lookback_days: 60

// how much below past peak balance to allow losses (default 1% == 0.01)
loss_allowance_pct: 0.01

// if wallet_exposure / wallet_exposure_limit > stuck_threshold: consider position as stuck
stuck_threshold: 0.95

// percentage of balance * wallet_exposure_limit to close for each unstucking order (default 1% == 0.01)
unstuck_close_pct: 0.01

// delay between executions to exchange. Set to 60 to simulate 1m ohlcv backtest.
execution_delay_seconds: 2

TWE_long: 2.0 // total wallet exposure limit long. Exposure limit for each bot will be TWE_long / len(symbols_long)
TWE_short: 0.1 // total wallet exposure limit short. Exposure limit for each bot will be TWE_short / len(symbols_short)

// Flags:
// -lm str: long mode. Choices: [n (normal), m (manual), gs (graceful_stop), p (panic), t (take_profit_only)].
// -sm str: short mode. Choices: [n (normal), m (manual), gs (graceful_stop), p (panic), t (take_profit_only)].
// normal mode: passivbot manages the position as normal
// manual mode: passivbot ignores the position
// graceful stop: if there is a position, passivbot will manage it, otherwise passivbot will not make new positions
// take profit only: passivbot will only manage closing orders
// -pp float: price precision multiplier. Override price step with market_price * price_precision_multiplier rounded to one significant digit. Suggested val 0.0001. Set to 0.0 to disable.
// -ps float: price step custom. Override price step with custom price step. Takes precedence over -pp. Set to 0.0 to disable.
// -lw float: wallet exposure limit long. Overrides value from live config. If absent, WE long is TWE_long / len(active_symbols_long)
// -sw: float: wallet exposure limit short. Overrides value from live config.
// -lev int: leverage set on exchange, if applicable. Default is 10.
// -lc str: live config path. Specify live config path to override config from live_configs_dir and default_config_path.

symbols: {
SYM1USDT: -lm n -sm gs -lc configs/live/custom/SYM1USDT.json
SYM2USDT: -lm n -sm gs -sw 0.4
SYM3USDT: -lm gs -sm n -lw 0.15 -lev 12
}

// Specify directory containing live configs.
// They are sorted alphabetically, then the first config whose filename includes symbol is selected.
// Set to "" to disable
live_configs_dir: "configs/live/multisymbol/no_AU/"

// if symbol is missing from live_configs_map, default to this config
default_config_path: configs/live/recursive_grid_mode.example.json
}
462 changes: 462 additions & 0 deletions configs/live/multisymbol/metrics_no_AU.txt

Large diffs are not rendered by default.

452 changes: 452 additions & 0 deletions configs/live/multisymbol/metrics_recursive_grid.txt

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions configs/live/multisymbol/no_AU/1000FLOKIUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{"config_name": "recursive_grid_0days",
"logging_level": 0,
"long": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 0.1,
"ema_span_0": 175.56035984110972,
"ema_span_1": 135.15928457669787,
"enabled": true,
"initial_eprice_ema_dist": -0.002511836326890987,
"initial_qty_pct": 0.014722912090139385,
"markup_range": 0.0040182300317002295,
"min_markup": 0.004697844342363275,
"n_close_orders": 3,
"rentry_pprice_dist": 0.027155563055711263,
"rentry_pprice_dist_wallet_exposure_weighting": 2.658133425713909,
"wallet_exposure_limit": 1},
"short": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 1.3233568692555762,
"ema_span_0": 140.1000218570828,
"ema_span_1": 158.8911229663274,
"enabled": true,
"initial_eprice_ema_dist": -0.020156825982646086,
"initial_qty_pct": 0.013576601084546138,
"markup_range": 0.0016366086741166916,
"min_markup": 0.0036789200257328247,
"n_close_orders": 8,
"rentry_pprice_dist": 0.038565893718937296,
"rentry_pprice_dist_wallet_exposure_weighting": 0.2805002590645441,
"wallet_exposure_limit": 1}}
36 changes: 36 additions & 0 deletions configs/live/multisymbol/no_AU/1000LUNCUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{"config_name": "recursive_grid_0days",
"logging_level": 0,
"long": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 0.1,
"ema_span_0": 340.6376838624222,
"ema_span_1": 327.30382150450987,
"enabled": true,
"initial_eprice_ema_dist": 0.002970401120999516,
"initial_qty_pct": 0.026949226779437802,
"markup_range": 0.003395219087017561,
"min_markup": 0.001679729879897897,
"n_close_orders": 3,
"rentry_pprice_dist": 0.01836913327854358,
"rentry_pprice_dist_wallet_exposure_weighting": 3.1091289377259486,
"wallet_exposure_limit": 1},
"short": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 1.3091588459918009,
"ema_span_0": 635.5815758559542,
"ema_span_1": 1214.8051385531357,
"enabled": true,
"initial_eprice_ema_dist": 0.003,
"initial_qty_pct": 0.010989306554467037,
"markup_range": 0.005151262096278822,
"min_markup": 0.005281647783923184,
"n_close_orders": 8,
"rentry_pprice_dist": 0.03396413799128969,
"rentry_pprice_dist_wallet_exposure_weighting": 8.747366897910728,
"wallet_exposure_limit": 1}}
36 changes: 36 additions & 0 deletions configs/live/multisymbol/no_AU/1000PEPEUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{"config_name": "recursive_grid_0days",
"logging_level": 0,
"long": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 0.7653697354559647,
"ema_span_0": 1254.6529894423643,
"ema_span_1": 1174.8252279310752,
"enabled": true,
"initial_eprice_ema_dist": 0.002967809678931789,
"initial_qty_pct": 0.014848566082789947,
"markup_range": 0.005307565777449499,
"min_markup": 0.006214289495789974,
"n_close_orders": 14,
"rentry_pprice_dist": 0.03835580412864876,
"rentry_pprice_dist_wallet_exposure_weighting": 5.250915249371453,
"wallet_exposure_limit": 1},
"short": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 2.2878884662576016,
"ema_span_0": 258.5386120268814,
"ema_span_1": 660.7382156688566,
"enabled": true,
"initial_eprice_ema_dist": 0.002997794432821678,
"initial_qty_pct": 0.022246857475513547,
"markup_range": 0.00018949393405573269,
"min_markup": 0.004145482905214101,
"n_close_orders": 15,
"rentry_pprice_dist": 0.03930460958932621,
"rentry_pprice_dist_wallet_exposure_weighting": 3.076942848133305,
"wallet_exposure_limit": 1}}
36 changes: 36 additions & 0 deletions configs/live/multisymbol/no_AU/1000SHIBUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{"config_name": "recursive_grid_0days",
"logging_level": 0,
"long": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 0.5885157318174555,
"ema_span_0": 1190.7660296250535,
"ema_span_1": 577.4547170275225,
"enabled": true,
"initial_eprice_ema_dist": -0.028611548928584866,
"initial_qty_pct": 0.015673315468663643,
"markup_range": 0.001577839623687586,
"min_markup": 0.004382186251308136,
"n_close_orders": 7,
"rentry_pprice_dist": 0.028232515423818286,
"rentry_pprice_dist_wallet_exposure_weighting": 2.5604728478827914,
"wallet_exposure_limit": 1},
"short": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 0.4321714465568106,
"ema_span_0": 55.168427697371904,
"ema_span_1": 162.4546295299272,
"enabled": true,
"initial_eprice_ema_dist": 0.002945721917182019,
"initial_qty_pct": 0.010644779525936399,
"markup_range": 0.0013482089662692676,
"min_markup": 0.0021454782885135604,
"n_close_orders": 5,
"rentry_pprice_dist": 0.026186269775718456,
"rentry_pprice_dist_wallet_exposure_weighting": 2.503421952674891,
"wallet_exposure_limit": 1}}
36 changes: 36 additions & 0 deletions configs/live/multisymbol/no_AU/1000XECUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{"config_name": "recursive_grid_0days",
"logging_level": 0,
"long": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 2.04659393273433,
"ema_span_0": 1394.727621278244,
"ema_span_1": 1401.5918225937091,
"enabled": true,
"initial_eprice_ema_dist": 0.0028632770875165127,
"initial_qty_pct": 0.010641658394578483,
"markup_range": 0.0010143082920238513,
"min_markup": 0.002014941297936092,
"n_close_orders": 15,
"rentry_pprice_dist": 0.024418150635967775,
"rentry_pprice_dist_wallet_exposure_weighting": 9.139093827897192,
"wallet_exposure_limit": 1},
"short": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 2.2878884662576016,
"ema_span_0": 258.5386120268814,
"ema_span_1": 660.7382156688566,
"enabled": true,
"initial_eprice_ema_dist": 0.002997794432821678,
"initial_qty_pct": 0.022246857475513547,
"markup_range": 0.00018949393405573269,
"min_markup": 0.004145482905214101,
"n_close_orders": 15,
"rentry_pprice_dist": 0.03930460958932621,
"rentry_pprice_dist_wallet_exposure_weighting": 3.076942848133305,
"wallet_exposure_limit": 1}}
36 changes: 36 additions & 0 deletions configs/live/multisymbol/no_AU/1INCHUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{"config_name": "recursive_grid_0days",
"logging_level": 0,
"long": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 1.7278162955223653,
"ema_span_0": 49.47668509430399,
"ema_span_1": 1111.2651447713486,
"enabled": true,
"initial_eprice_ema_dist": 0.002999579319630603,
"initial_qty_pct": 0.01073178474741587,
"markup_range": 0.002831823527874105,
"min_markup": 0.003909362577445969,
"n_close_orders": 12,
"rentry_pprice_dist": 0.041803236724402955,
"rentry_pprice_dist_wallet_exposure_weighting": 3.3568999311412706,
"wallet_exposure_limit": 1},
"short": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 2.2878884662576016,
"ema_span_0": 258.5386120268814,
"ema_span_1": 660.7382156688566,
"enabled": true,
"initial_eprice_ema_dist": 0.002997794432821678,
"initial_qty_pct": 0.022246857475513547,
"markup_range": 0.00018949393405573269,
"min_markup": 0.004145482905214101,
"n_close_orders": 15,
"rentry_pprice_dist": 0.03930460958932621,
"rentry_pprice_dist_wallet_exposure_weighting": 3.076942848133305,
"wallet_exposure_limit": 1}}
36 changes: 36 additions & 0 deletions configs/live/multisymbol/no_AU/AAVEUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{"config_name": "recursive_grid_0days",
"logging_level": 0,
"long": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 2.815419886225072,
"ema_span_0": 1146.3068167506208,
"ema_span_1": 1254.7784846188367,
"enabled": true,
"initial_eprice_ema_dist": -0.015872100970266992,
"initial_qty_pct": 0.011622081725542731,
"markup_range": 0.00391286271664109,
"min_markup": 0.004922637704583438,
"n_close_orders": 13,
"rentry_pprice_dist": 0.03857957349361461,
"rentry_pprice_dist_wallet_exposure_weighting": 0.7617723571104548,
"wallet_exposure_limit": 1},
"short": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 1.6607528373675338,
"ema_span_0": 941.2214003305071,
"ema_span_1": 1388.1347948775729,
"enabled": true,
"initial_eprice_ema_dist": 0.0029928004980484756,
"initial_qty_pct": 0.010438683140754372,
"markup_range": 0.0062743153844938395,
"min_markup": 0.0023844486767568215,
"n_close_orders": 8,
"rentry_pprice_dist": 0.04903857035854818,
"rentry_pprice_dist_wallet_exposure_weighting": 0.062302905620518184,
"wallet_exposure_limit": 1}}
36 changes: 36 additions & 0 deletions configs/live/multisymbol/no_AU/ACHUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{"config_name": "recursive_grid_0days",
"logging_level": 0,
"long": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 1.7560468766278186,
"ema_span_0": 1197.266090087891,
"ema_span_1": 1371.087008083502,
"enabled": true,
"initial_eprice_ema_dist": 0.0008188190944102743,
"initial_qty_pct": 0.01,
"markup_range": 0.0033872534137404375,
"min_markup": 0.0014494001172908303,
"n_close_orders": 3,
"rentry_pprice_dist": 0.025829988005512266,
"rentry_pprice_dist_wallet_exposure_weighting": 1.5582174247173548,
"wallet_exposure_limit": 1},
"short": {"auto_unstuck_delay_minutes": 0,
"auto_unstuck_ema_dist": 0,
"auto_unstuck_qty_pct": 0,
"auto_unstuck_wallet_exposure_threshold": 0.0,
"backwards_tp": true,
"ddown_factor": 1.3145212916409037,
"ema_span_0": 314.9520051883545,
"ema_span_1": 548.0165468218102,
"enabled": true,
"initial_eprice_ema_dist": -0.013597593462538991,
"initial_qty_pct": 0.014233650083733156,
"markup_range": 0.005692336833173391,
"min_markup": 0.004446930540937299,
"n_close_orders": 7,
"rentry_pprice_dist": 0.02996164458775796,
"rentry_pprice_dist_wallet_exposure_weighting": 7.488053946679266,
"wallet_exposure_limit": 1}}
Loading

0 comments on commit 6b9d3b6

Please sign in to comment.