Skip to content

Commit

Permalink
Merge pull request #415 from enarjord/v5.9.12_AU_delay
Browse files Browse the repository at this point in the history
V5.9.12 au delay
  • Loading branch information
enarjord authored Oct 1, 2023
2 parents abfa7ab + 1bcd7da commit 043299f
Show file tree
Hide file tree
Showing 626 changed files with 26,109 additions and 4,410 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:

v5.9.11
v5.9.12


## Overview
Expand Down
4 changes: 1 addition & 3 deletions auto_profit_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +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 = [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 All @@ -88,9 +89,6 @@ async def main():
try:
transferred = await bot.transfer_from_derivatives_to_spot(args.quote, to_transfer)
logging.info(f"income: {profit} transferred {to_transfer} {args.quote}")
if exchange == "bybit":
if "ret_msg" not in transferred or transferred["ret_msg"] not in ["OK", "success"]:
print(f"error with transfer {transferred}")
logging.info(f"{transferred}")
already_transferred_ids.update([e["transaction_id"] for e in income])
json.dump(list(already_transferred_ids), open(transfer_log_fpath, "w"))
Expand Down
27 changes: 7 additions & 20 deletions backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas as pd

from downloader import Downloader, load_hlc_cache
from njit_funcs import backtest_static_grid, round_
from njit_funcs import round_
from njit_funcs_recursive_grid import backtest_recursive_grid
from njit_funcs_neat_grid import backtest_neat_grid
from njit_clock import backtest_clock
Expand Down Expand Up @@ -61,14 +61,6 @@ def backtest(config: dict, data: np.ndarray, do_print=False) -> (list, bool):
config["maker_fee"],
**xk,
)
elif passivbot_mode == "static_grid":
return backtest_static_grid(
data,
config["starting_balance"],
config["latency_simulation_ms"],
config["maker_fee"],
**xk,
)
else:
raise Exception(f"unknown passivbot mode {passivbot_mode}")

Expand Down Expand Up @@ -172,17 +164,12 @@ async def main():
help="disable plotting",
)
args = parser.parse_args()
if args.symbol is None:
tmp_cfg = load_hjson_config(args.backtest_config_path)
symbols = (
tmp_cfg["symbol"] if type(tmp_cfg["symbol"]) == list else tmp_cfg["symbol"].split(",")
)
else:
symbols = args.symbol.split(",")
for symbol in symbols:
args = parser.parse_args()
args.symbol = symbol
config = await prepare_backtest_config(args)
config = prepare_backtest_config(args)
for symbol in config["symbols"]:
if "symbol" not in config or symbol != config["symbol"]:
args = parser.parse_args()
args.symbols = symbol
config = prepare_backtest_config(args)
config["n_parts"] = args.n_parts
live_config = load_live_config(args.live_config_path)
if "spot" in config["market_type"]:
Expand Down
26 changes: 24 additions & 2 deletions configs/backtest/default.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,29 @@
# exchange from api-keys.json is used
user: binance_01

symbol: specify_symbol
# symbols with data since earlier than 2021-05-01
symbols: [
"BTCUSDT", "ETHUSDT", "BCHUSDT", "XRPUSDT", "EOSUSDT",
"LTCUSDT", "TRXUSDT", "ETCUSDT", "LINKUSDT", "XLMUSDT",
"ADAUSDT", "XMRUSDT", "DASHUSDT", "ZECUSDT", "XTZUSDT",
"BNBUSDT", "ATOMUSDT", "ONTUSDT", "IOTAUSDT", "BATUSDT",
"VETUSDT", "NEOUSDT", "QTUMUSDT", "IOSTUSDT", "THETAUSDT",
"ALGOUSDT", "ZILUSDT", "KNCUSDT", "ZRXUSDT", "COMPUSDT",
"OMGUSDT", "DOGEUSDT", "SXPUSDT", "KAVAUSDT", "BANDUSDT",
"RLCUSDT", "WAVESUSDT", "MKRUSDT", "SNXUSDT", "DOTUSDT",
"DEFIUSDT", "YFIUSDT", "BALUSDT", "CRVUSDT", "TRBUSDT",
"RUNEUSDT", "SUSHIUSDT", "EGLDUSDT", "SOLUSDT", "ICXUSDT",
"STORJUSDT", "BLZUSDT", "UNIUSDT", "AVAXUSDT", "FTMUSDT",
"ENJUSDT", "FLMUSDT", "TOMOUSDT", "RENUSDT", "KSMUSDT",
"NEARUSDT", "AAVEUSDT", "FILUSDT", "RSRUSDT", "LRCUSDT",
"MATICUSDT", "OCEANUSDT", "BELUSDT", "CTKUSDT", "AXSUSDT",
"ALPHAUSDT", "ZENUSDT", "SKLUSDT", "GRTUSDT", "1INCHUSDT",
"CHZUSDT", "SANDUSDT", "ANKRUSDT", "LITUSDT", "UNFIUSDT",
"REEFUSDT", "RVNUSDT", "SFPUSDT", "XEMUSDT", "COTIUSDT",
"CHRUSDT", "MANAUSDT", "ALICEUSDT", "HBARUSDT", "ONEUSDT",
"LINAUSDT", "STMXUSDT", "DENTUSDT", "CELRUSDT", "HOTUSDT",
"MTLUSDT", "OGNUSDT", "NKNUSDT", "DGBUSDT",
]
latency_simulation_ms: 1000

# specify starting balance in terms of margin token (i.e. usdt for usdt-m, coin for inverse coin-m)
Expand All @@ -14,7 +36,7 @@
# format YYYY-MM-DD
# end_date may be set to "now" or "today" to use current day (UTC) as end_date
start_date: 2020-01-01
end_date: 2023-07-24
end_date: now

# Reduce disk usage and improve some optimize speed with the slim analysis
slim_analysis: true
Expand Down
62 changes: 48 additions & 14 deletions configs/forager/example_config.hjson
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// supported exchanges: [kucoin, okx, bybit, binance]
user: binance_01
// supported exchanges: [kucoin, okx, bybit, binance, bitget]
user: bybit_01
twe_long: 1.6
twe_short: 0.8
n_longs: 6
Expand All @@ -10,14 +10,21 @@
ohlcv_interval: 1h
leverage: 10
price_distance_threshold: 0.3
passivbot_root_dir: "~/passivbot"

// set to zero to disable
volume_clip_threshold: 0.51 // include 51% of the highest volume coins
unilateralness_clip_threshold: 0.49 // include 49% of symbols with lowest unilateralness
noisiness_clip_threshold: 0.52 // include 52% of symbols with highest noisiness

// don't allow symbols younger than threshold. Format YYYY-MM. Set to 0 to allow all symbols.
market_age_threshold: 2021-06

max_n_panes: 8

// start bots with x seconds delay
sleep_interval: 5

// forager restarts bots every x minutes
update_interval_minutes: 60

Expand All @@ -27,35 +34,62 @@
SYM2USDT
]

// if symbol is missing from live_configs_map, default to this config
default_config_path: configs/live/clock_mode.example.json
// if approved_symbols_long is empty, all symbols are approved for longs
approved_symbols_long: [
BTCUSDT
XMRUSDT
XRPUSDT
BCHUSDT
]

// if true, allow only symbols present in live_configs_map or live_configs_map_{long/short}
// if false, will use default_config_path when symbol is missing from live_configs_map
approved_symbols_only: false
// if approved_symbols_short is empty, all symbols are approved for shorts
approved_symbols_short: [
BTCUSDT
ETHUSDT
DOGEUSDT
EOSUSDT
]

// if symbol is present in live_configs_map_{long/short}, use that config for {long/short}
// elif symbol is present in live_configs_map, use that config for {long/short}
// else use default_config_path for {long/short}
// 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_long: "configs/live/single_symbol_optimizations/recursive_grid/"
live_configs_dir_short: "configs/live/single_symbol_optimizations/clock/"

// overrides live_configs_dir
live_configs_map: {
BTCUSDT: configs/live/clock_mode.example.json
ETHUSDT: configs/live/neat_grid_mode.example.json
DOGEUSDT: configs/live/recursive_grid_mode.example.json
DOGEUSDT: configs/live/single_symbol_optimizations/recursive_grid/DOGEUSDT.json
LTCUSDT: configs/live/single_symbol_optimizations/recursive_grid/LTCUSDT.json
ADAUSDT: configs/live/neat_grid_mode.example.json
}

// will override long configs from live_configs_map
// overrides long configs from live_configs_map
live_configs_map_long: {
BTCUSDT: configs/live/clock_mode.example.json
XMRUSDT: configs/live/neat_grid_mode.example.json
XRPUSDT: configs/live/recursive_grid_mode.example.json
XRPUSDT: configs/live/single_symbol_optimizations/clock/XRPUSDT.json
BCHUSDT: configs/live/clock_mode.example.json
XLMUSDT: configs/live/neat_grid_mode.example.json
}

// will override short configs from live_configs_map
// overrides short configs from live_configs_map
live_configs_map_short: {
BTCUSDT: configs/live/clock_mode.example.json
ETHUSDT: configs/live/neat_grid_mode.example.json
DOGEUSDT: configs/live/recursive_grid_mode.example.json
EOSUSDT: configs/live/single_symbol_optimizations/clock/EOSUSDT.json
MATICUSDT: configs/live/neat_grid_mode.example.json
}

// if symbol is missing from live_configs_map, default to this config
default_config_path: configs/live/clock_mode.example.json

// if symbol is approved:
// if symbol is present in live_configs_map_{long/short}, use that config for {long/short}
// elif symbol is present in live_configs_map, use that config for {long/short}
// elif there is a filename in live_configs_dir_{long/short} containing symbol, use that config for {long/short}
// else use default_config_path for {long/short}

}
37 changes: 37 additions & 0 deletions configs/live/single_symbol_optimizations/clock/1000FLOKIUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{"config_name": "clock_0days",
"long": {"backwards_tp": true,
"delay_between_fills_minutes_close": 1397.8199291138544,
"delay_between_fills_minutes_entry": 793.1004339866311,
"delay_weight_close": 54.16698659813556,
"delay_weight_entry": 11.304365076226238,
"ema_dist_close": 0.002733527861907303,
"ema_dist_entry": -0.000346237700325354,
"ema_span_0": 521.6924137710201,
"ema_span_1": 754.3854297676163,
"enabled": true,
"markup_range": 0.00675618003034359,
"min_markup": 0.00964021986412634,
"n_close_orders": 3,
"qty_pct_close": 0.01270611205690984,
"qty_pct_entry": 0.012330519289802042,
"wallet_exposure_limit": 1,
"we_multiplier_close": 0,
"we_multiplier_entry": 46.15137992696264},
"short": {"backwards_tp": true,
"delay_between_fills_minutes_close": 566.728048226077,
"delay_between_fills_minutes_entry": 98.60896944334999,
"delay_weight_close": 0.0012662552903666487,
"delay_weight_entry": 10.46322317873434,
"ema_dist_close": 0.003,
"ema_dist_entry": -0.008628095599072209,
"ema_span_0": 226.33627318454913,
"ema_span_1": 225.73496090568048,
"enabled": true,
"markup_range": 0.0026059276449264266,
"min_markup": 0.0040488502429980484,
"n_close_orders": 2,
"qty_pct_close": 0.010878416974961412,
"qty_pct_entry": 0.010011407123709742,
"wallet_exposure_limit": 1,
"we_multiplier_close": 0,
"we_multiplier_entry": 23.220265927651216}}
37 changes: 37 additions & 0 deletions configs/live/single_symbol_optimizations/clock/1000LUNCUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{"config_name": "clock_0days",
"long": {"backwards_tp": true,
"delay_between_fills_minutes_close": 779.6536453291249,
"delay_between_fills_minutes_entry": 1214.798732179154,
"delay_weight_close": 28.14781741347243,
"delay_weight_entry": 16.16470641363938,
"ema_dist_close": -0.0032429746111499957,
"ema_dist_entry": -0.006282852707930733,
"ema_span_0": 1222.8727708274653,
"ema_span_1": 1303.9427372273854,
"enabled": true,
"markup_range": 0.059185801107474845,
"min_markup": 0.008944422760875825,
"n_close_orders": 9,
"qty_pct_close": 0.016598324712223573,
"qty_pct_entry": 0.010035975591842971,
"wallet_exposure_limit": 1,
"we_multiplier_close": 0,
"we_multiplier_entry": 45.50122992716007},
"short": {"backwards_tp": true,
"delay_between_fills_minutes_close": 927.5536393402995,
"delay_between_fills_minutes_entry": 76.65521428223664,
"delay_weight_close": 4.0912562091058975,
"delay_weight_entry": 0.4026069516881707,
"ema_dist_close": 0.0027286292890744213,
"ema_dist_entry": -0.0024395190240046735,
"ema_span_0": 1029.0821444294024,
"ema_span_1": 1110.6017165946846,
"enabled": true,
"markup_range": 0.0037852668244971474,
"min_markup": 0.0022884136867671575,
"n_close_orders": 6,
"qty_pct_close": 0.012226923140416623,
"qty_pct_entry": 0.010209693427915594,
"wallet_exposure_limit": 1,
"we_multiplier_close": 0,
"we_multiplier_entry": 30.520846381647537}}
37 changes: 37 additions & 0 deletions configs/live/single_symbol_optimizations/clock/1000PEPEUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{"config_name": "clock_0days",
"long": {"backwards_tp": true,
"delay_between_fills_minutes_close": 1283.4591567628113,
"delay_between_fills_minutes_entry": 847.3109094024388,
"delay_weight_close": 86.7018425814027,
"delay_weight_entry": 9.202275996516597,
"ema_dist_close": 0.001476526444402524,
"ema_dist_entry": -0.011085874949114493,
"ema_span_0": 1037.287459168743,
"ema_span_1": 833.8803170014027,
"enabled": true,
"markup_range": 0.05291181517152272,
"min_markup": 0.0010745438344220344,
"n_close_orders": 2,
"qty_pct_close": 0.010378997269844847,
"qty_pct_entry": 0.012389144143921827,
"wallet_exposure_limit": 1,
"we_multiplier_close": 0,
"we_multiplier_entry": 44.19997879451239},
"short": {"backwards_tp": true,
"delay_between_fills_minutes_close": 1440,
"delay_between_fills_minutes_entry": 770.6426023185443,
"delay_weight_close": 8.917925567623623,
"delay_weight_entry": 5.086389066337287,
"ema_dist_close": 0.0016710347504039428,
"ema_dist_entry": -0.01151431025507491,
"ema_span_0": 1312.4148910387232,
"ema_span_1": 388.665918167387,
"enabled": true,
"markup_range": 0.02047099068754597,
"min_markup": 0.008792030549710284,
"n_close_orders": 5,
"qty_pct_close": 0.012909025258383385,
"qty_pct_entry": 0.01,
"wallet_exposure_limit": 1,
"we_multiplier_close": 0,
"we_multiplier_entry": 37.37968923364722}}
37 changes: 37 additions & 0 deletions configs/live/single_symbol_optimizations/clock/1000SHIBUSDT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{"config_name": "clock_0days",
"long": {"backwards_tp": true,
"delay_between_fills_minutes_close": 1275.6988333409186,
"delay_between_fills_minutes_entry": 931.8437442632235,
"delay_weight_close": 53.37104892529714,
"delay_weight_entry": 40.28095136690261,
"ema_dist_close": 0.0009723204313784626,
"ema_dist_entry": -0.003149000025455873,
"ema_span_0": 1327.038010186341,
"ema_span_1": 1215.141691018625,
"enabled": true,
"markup_range": 0.00727310979516928,
"min_markup": 0.0022237885862061205,
"n_close_orders": 9,
"qty_pct_close": 0.02629128545232999,
"qty_pct_entry": 0.01610331987228494,
"wallet_exposure_limit": 1,
"we_multiplier_close": 0,
"we_multiplier_entry": 40.06507052070499},
"short": {"backwards_tp": true,
"delay_between_fills_minutes_close": 1363.0016361019966,
"delay_between_fills_minutes_entry": 1235.2899997332424,
"delay_weight_close": 54.455512306587714,
"delay_weight_entry": 17.364312169662973,
"ema_dist_close": 0.0029987754468503817,
"ema_dist_entry": -0.004092425393016123,
"ema_span_0": 21.340514779566984,
"ema_span_1": 1003.7073183223773,
"enabled": true,
"markup_range": 0.014174601672917621,
"min_markup": 0.008181892665205713,
"n_close_orders": 4,
"qty_pct_close": 0.010201652774253018,
"qty_pct_entry": 0.015023064343410681,
"wallet_exposure_limit": 1,
"we_multiplier_close": 0,
"we_multiplier_entry": 9.959537257387307}}
Loading

0 comments on commit 043299f

Please sign in to comment.