-
Notifications
You must be signed in to change notification settings - Fork 31
/
Config.py
2864 lines (2739 loc) · 146 KB
/
Config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import streamlit as st
from pathlib import Path
import json
from pbgui_func import validateJSON, config_pretty_str, error_popup
import pbgui_help
import traceback
import multiprocessing
import datetime
class Config:
def __init__(self, file_name = None, config = None):
self._config_file = file_name
self._long_we = 1.0
self._short_we = 1.0
self._long_enabled = True
self._short_enabled = False
self._type = None
self._preview_grid = False
self._config_v7 = ConfigV7()
self._config_v7.bot.long.n_positions = 1.0
self._config_v7.bot.short.n_positions = 1.0
if config:
self.config = config
else:
self._config = None
@property
def type(self): return self._type
@property
def config_file(self): return self._config_file
@config_file.setter
def config_file(self, new_config_file):
if self._config_file != new_config_file:
self._config_file = new_config_file
@property
def config(self): return self._config
@property
def config_v7(self):
if self._config:
# long settings
self._config_v7.bot.long.close_grid_markup_range = json.loads(self._config)["long"]["markup_range"]
self._config_v7.bot.long.close_grid_min_markup = json.loads(self._config)["long"]["min_markup"]
self._config_v7.bot.long.close_grid_qty_pct = 1.0 / float(json.loads(self._config)["long"]["n_close_orders"])
self._config_v7.bot.long.close_trailing_grid_ratio = 0
self._config_v7.bot.long.close_trailing_qty_pct = 1
self._config_v7.bot.long.close_trailing_retracement_pct = 0
self._config_v7.bot.long.close_trailing_threshold_pct = 0
self._config_v7.bot.long.ema_span_0 = json.loads(self._config)["long"]["ema_span_0"]
self._config_v7.bot.long.ema_span_1 = json.loads(self._config)["long"]["ema_span_1"]
self._config_v7.bot.long.entry_grid_double_down_factor = json.loads(self._config)["long"]["ddown_factor"]
self._config_v7.bot.long.entry_grid_spacing_pct = json.loads(self._config)["long"]["rentry_pprice_dist"]
self._config_v7.bot.long.entry_grid_spacing_weight = json.loads(self._config)["long"]["rentry_pprice_dist_wallet_exposure_weighting"]
self._config_v7.bot.long.entry_initial_ema_dist = json.loads(self._config)["long"]["initial_eprice_ema_dist"]
self._config_v7.bot.long.entry_initial_qty_pct = json.loads(self._config)["long"]["initial_qty_pct"]
self._config_v7.bot.long.entry_trailing_grid_ratio = 0
self._config_v7.bot.long.entry_trailing_retracement_pct = 0
self._config_v7.bot.long.entry_trailing_threshold_pct = 0
# self._config_v7.bot.long.total_wallet_exposure_limit = json.loads(self._config)["long"]["wallet_exposure_limit"]
try:
self._config_v7.bot.long.unstuck_close_pct = json.loads(self._config)["long"]["auto_unstuck_qty_pct"]
except:
self._config_v7.bot.long.unstuck_close_pct = 0.025
self._config_v7.bot.long.unstuck_ema_dist = json.loads(self._config)["long"]["auto_unstuck_ema_dist"]
# short settings
self._config_v7.bot.short.close_grid_markup_range = json.loads(self._config)["short"]["markup_range"]
self._config_v7.bot.short.close_grid_min_markup = json.loads(self._config)["short"]["min_markup"]
self._config_v7.bot.short.close_grid_qty_pct = 1.0 / float(json.loads(self._config)["short"]["n_close_orders"])
self._config_v7.bot.short.close_trailing_grid_ratio = 0
self._config_v7.bot.short.close_trailing_qty_pct = 1
self._config_v7.bot.short.close_trailing_retracement_pct = 0
self._config_v7.bot.short.close_trailing_threshold_pct = 0
self._config_v7.bot.short.ema_span_0 = json.loads(self._config)["short"]["ema_span_0"]
self._config_v7.bot.short.ema_span_1 = json.loads(self._config)["short"]["ema_span_1"]
self._config_v7.bot.short.entry_grid_double_down_factor = json.loads(self._config)["short"]["ddown_factor"]
self._config_v7.bot.short.entry_grid_spacing_pct = json.loads(self._config)["short"]["rentry_pprice_dist"]
self._config_v7.bot.short.entry_grid_spacing_weight = json.loads(self._config)["short"]["rentry_pprice_dist_wallet_exposure_weighting"]
self._config_v7.bot.short.entry_initial_ema_dist = json.loads(self._config)["short"]["initial_eprice_ema_dist"]
self._config_v7.bot.short.entry_initial_qty_pct = json.loads(self._config)["short"]["initial_qty_pct"]
self._config_v7.bot.short.entry_trailing_grid_ratio = 0
self._config_v7.bot.short.entry_trailing_retracement_pct = 0
self._config_v7.bot.short.entry_trailing_threshold_pct = 0
# self._config_v7.bot.short.total_wallet_exposure_limit = json.loads(self._config)["short"]["wallet_exposure_limit"]
try:
self._config_v7.bot.short.unstuck_close_pct = json.loads(self._config)["short"]["auto_unstuck_qty_pct"]
except:
self._config_v7.bot.short.unstuck_close_pct = 0.025
self._config_v7.bot.short.unstuck_ema_dist = json.loads(self._config)["short"]["auto_unstuck_ema_dist"]
return json.dumps(self._config_v7.config, indent=4)
return None
@config.setter
def config(self, new_config):
if new_config != "None":
if validateJSON(new_config):
self._config = new_config
self.update_config()
if "error_config" in st.session_state:
del st.session_state.error_config
else:
st.session_state.error_config = "Config is invalid"
@config_file.setter
def config_file(self, new_config_file):
if self._config_file != new_config_file:
self._config_file = new_config_file
@property
def long_we(self): return self._long_we
@long_we.setter
def long_we(self, new_long_we):
self._long_we = round(new_long_we,2)
if self._config:
t = json.loads(self._config)
t["long"]["wallet_exposure_limit"] = self._long_we
self._config = config_pretty_str(t)
@property
def long_enabled(self): return self._long_enabled
@long_enabled.setter
def long_enabled(self, new_long_enabled):
self._long_enabled = new_long_enabled
if self._config:
t = json.loads(self._config)
t["long"]["enabled"] = self._long_enabled
self._config = config_pretty_str(t)
self._config_v7.bot.long.total_wallet_exposure_limit = self.long_we
if self.long_enabled:
self._config_v7.bot.long.n_positions = 1.0
else:
self._config_v7.bot.long.n_positions = 0.0
@property
def short_enabled(self): return self._short_enabled
@short_enabled.setter
def short_enabled(self, new_short_enabled):
self._short_enabled = new_short_enabled
if self._config:
t = json.loads(self._config)
t["short"]["enabled"] = self._short_enabled
self._config = config_pretty_str(t)
self._config_v7.bot.short.total_wallet_exposure_limit = self.short_we
if self.short_enabled:
self._config_v7.bot.short.n_positions = 1.0
else:
self._config_v7.bot.short.n_positions = 0.0
@property
def short_we(self): return self._short_we
@short_we.setter
def short_we(self, new_short_we):
self._short_we = round(new_short_we,2)
if self._config:
t = json.loads(self._config)
t["short"]["wallet_exposure_limit"] = self._short_we
self._config = config_pretty_str(t)
@property
def preview_grid(self): return self._preview_grid
@preview_grid.setter
def preview_grid(self, new_preview_grid):
self._preview_grid = new_preview_grid
def update_config(self):
self.long_we = json.loads(self._config)["long"]["wallet_exposure_limit"]
self.short_we = json.loads(self._config)["short"]["wallet_exposure_limit"]
self._config_v7.bot.long.total_wallet_exposure_limit = self.long_we
self._config_v7.bot.short.total_wallet_exposure_limit = self.short_we
self.long_enabled = json.loads(self._config)["long"]["enabled"]
self.short_enabled = json.loads(self._config)["short"]["enabled"]
if not self.long_enabled:
self._config_v7.bot.long.n_positions = 0.0
if not self.short_enabled:
self._config_v7.bot.short.n_positions = 0.0
long = json.loads(self._config)["long"]
if "ddown_factor" in long:
self._type = "recursive_grid"
elif "qty_pct_entry" in long:
self._type = "clock"
elif "grid_span" in long:
self._type = "neat_grid"
def load_config(self):
file = Path(f'{self._config_file}')
if file.exists():
with open(file, "r", encoding='utf-8') as f:
self._config = f.read()
self.update_config()
def save_config(self):
if self._config != None and self._config_file != None:
file = Path(f'{self._config_file}')
with open(file, "w", encoding='utf-8') as f:
f.write(self._config)
def edit_config(self):
# Init session_state for keys
if "config_long_enabled" in st.session_state:
if st.session_state.config_long_enabled != self.long_enabled:
self.long_enabled = st.session_state.config_long_enabled
if self.config:
st.session_state.config_instance_config = self.config
if "config_short_enabled" in st.session_state:
if st.session_state.config_short_enabled != self.short_enabled:
self.short_enabled = st.session_state.config_short_enabled
if self.config:
st.session_state.config_instance_config = self.config
if "config_long_we" in st.session_state:
if st.session_state.config_long_we != self.long_we:
self.long_we = st.session_state.config_long_we
if self.config:
st.session_state.config_instance_config = self.config
if "config_short_we" in st.session_state:
if st.session_state.config_short_we != self.short_we:
self.short_we = st.session_state.config_short_we
if self.config:
st.session_state.config_instance_config = self.config
if "config_preview_grid" in st.session_state:
if st.session_state.config_preview_grid != self.preview_grid:
self.preview_grid = st.session_state.config_preview_grid
if "config_instance_config" in st.session_state:
if st.session_state.config_instance_config != self.config:
self.config = st.session_state.config_instance_config
st.session_state.config_long_enabled = self.long_enabled
st.session_state.config_short_enabled = self.short_enabled
st.session_state.config_long_we = self.long_we
st.session_state.config_short_we = self.short_we
else:
if validateJSON(st.session_state.config_instance_config):
if "error_config" in st.session_state:
del st.session_state.error_config
# if self.config:
# self.config = st.session_state.config_instance_config
col1, col2, col3 = st.columns([1,1,1])
with col1:
st.toggle("Long enabled", value=self.long_enabled, key="config_long_enabled", help=None)
st.number_input("LONG_WALLET_EXPOSURE_LIMIT", min_value=0.0, max_value=100.0, value=float(round(self.long_we,2)), step=0.05, format="%.2f", key="config_long_we", help=pbgui_help.exposure)
with col2:
st.toggle("Short enabled", value=self.short_enabled, key="config_short_enabled", help=None)
st.number_input("SHORT_WALLET_EXPOSURE_LIMIT", min_value=0.0, max_value=100.0, value=float(round(self.short_we,2)), step=0.05, format="%.2f", key="config_short_we", help=pbgui_help.exposure)
with col3:
st.toggle("Preview Grid", value=self.preview_grid, key="config_preview_grid", help=None)
st.selectbox("Config Type", [self.type], index=0, key="config_type", help=None, disabled=True)
# Init height and color with defaults
height = 600
color = None
# Display Error
if "error_config" in st.session_state:
st.error(st.session_state.error_config, icon="🚨")
color = "red"
if not self.config is None:
height = len(self.config.splitlines()) *23
if height < 600:
height = 600
if not self.config:
color = "red"
col1, col2 = st.columns([1,1])
with col1:
if color:
st.text_area(f':{color}[config]', self.config, key="config_instance_config", height=height)
else:
st.text_area(f'config', self.config, key="config_instance_config", height=height)
with col2:
st.text_area(f'config converted to v7', self.config_v7, key="config_instance_config_v7", height=height, disabled=True)
# config template
# {"backtest": {"base_dir": "backtests",
# "compress_cache": true,
# "end_date": "now",
# "exchanges": ["binance", "bybit"],
# "start_date": "2021-05-01",
# "starting_balance": 100000.0},
# "bot": {"long": {"close_grid_markup_range": 0.0013425,
# "close_grid_min_markup": 0.0047292,
# "close_grid_qty_pct": 0.85073,
# "close_trailing_grid_ratio": 0.037504,
# "close_trailing_qty_pct": 0.54254,
# "close_trailing_retracement_pct": 0.021623,
# "close_trailing_threshold_pct": 0.065009,
# "ema_span_0": 469.33,
# "ema_span_1": 1120.5,
# "entry_grid_double_down_factor": 2.2661,
# "entry_grid_spacing_pct": 0.05224,
# "entry_grid_spacing_weight": 0.070246,
# "entry_initial_ema_dist": -0.015187,
# "entry_initial_qty_pct": 0.032679,
# "entry_trailing_grid_ratio": -0.29357,
# "entry_trailing_retracement_pct": 0.002646,
# "entry_trailing_threshold_pct": -0.043522,
# "filter_relative_volume_clip_pct": 0.51429,
# "filter_rolling_window": 330.17,
# "n_positions": 5.2399,
# "total_wallet_exposure_limit": 1.2788,
# "unstuck_close_pct": 0.05968,
# "unstuck_ema_dist": -0.027416,
# "unstuck_loss_allowance_pct": 0.035915,
# "unstuck_threshold": 0.45572},
# "short": {"close_grid_markup_range": 0.0020933,
# "close_grid_min_markup": 0.016488,
# "close_grid_qty_pct": 0.93256,
# "close_trailing_grid_ratio": 0.035892,
# "close_trailing_qty_pct": 0.98975,
# "close_trailing_retracement_pct": 0.0042704,
# "close_trailing_threshold_pct": -0.046918,
# "ema_span_0": 1174.4,
# "ema_span_1": 1217.3,
# "entry_grid_double_down_factor": 2.0966,
# "entry_grid_spacing_pct": 0.070355,
# "entry_grid_spacing_weight": 1.5293,
# "entry_initial_ema_dist": -0.090036,
# "entry_initial_qty_pct": 0.07003,
# "entry_trailing_grid_ratio": 0.075994,
# "entry_trailing_retracement_pct": 0.023943,
# "entry_trailing_threshold_pct": -0.079098,
# "filter_relative_volume_clip_pct": 0.49361,
# "filter_rolling_window": 57.016,
# "n_positions": 1.1103,
# "total_wallet_exposure_limit": 0.0,
# "unstuck_close_pct": 0.063395,
# "unstuck_ema_dist": -0.025704,
# "unstuck_loss_allowance_pct": 0.04867,
# "unstuck_threshold": 0.58437}},
# "live": {"approved_coins": [],
# "auto_gs": true,
# "coin_flags": {},
# "empty_means_all_approved": false,
# "execution_delay_seconds": 2.0,
# "filter_by_min_effective_cost": true,
# "forced_mode_long": "",
# "forced_mode_short": "",
# "ignored_coins": [],
# "leverage": 10.0,
# "max_n_cancellations_per_batch": 5,
# "max_n_creations_per_batch": 3,
# "max_n_restarts_per_day": 10,
# "minimum_coin_age_days": 30.0,
# "ohlcvs_1m_rolling_window_days": 4.0,
# "ohlcvs_1m_update_after_minutes": 10.0,
# "pnls_max_lookback_days": 30.0,
# "price_distance_threshold": 0.002,
# "time_in_force": "good_till_cancelled",
# "user": "bybit_01"},
# "optimize": {"bounds": {"long_close_grid_markup_range": [0.0, 0.03],
# "long_close_grid_min_markup": [0.001, 0.03],
# "long_close_grid_qty_pct": [0.05, 1.0],
# "long_close_trailing_grid_ratio": [-1.0, 1.0],
# "long_close_trailing_qty_pct": [0.05, 1.0],
# "long_close_trailing_retracement_pct": [0.0, 0.1],
# "long_close_trailing_threshold_pct": [-0.1, 0.1],
# "long_ema_span_0": [200.0, 1440.0],
# "long_ema_span_1": [200.0, 1440.0],
# "long_entry_grid_double_down_factor": [0.1, 3.0],
# "long_entry_grid_spacing_pct": [0.001, 0.12],
# "long_entry_grid_spacing_weight": [0.0, 10.0],
# "long_entry_initial_ema_dist": [-0.1, 0.003],
# "long_entry_initial_qty_pct": [0.005, 0.1],
# "long_entry_trailing_grid_ratio": [-1.0, 1.0],
# "long_entry_trailing_retracement_pct": [0.0, 0.1],
# "long_entry_trailing_threshold_pct": [-0.1, 0.1],
# "long_filter_relative_volume_clip_pct": [0.0, 1.0],
# "long_filter_rolling_window": [10.0, 360.0],
# "long_n_positions": [1.0, 20.0],
# "long_total_wallet_exposure_limit": [0.0, 5.0],
# "long_unstuck_close_pct": [0.001, 0.1],
# "long_unstuck_ema_dist": [-0.1, 0.01],
# "long_unstuck_loss_allowance_pct": [0.0, 0.05],
# "long_unstuck_threshold": [0.4, 0.95],
# "short_close_grid_markup_range": [0.0, 0.03],
# "short_close_grid_min_markup": [0.001, 0.03],
# "short_close_grid_qty_pct": [0.05, 1.0],
# "short_close_trailing_grid_ratio": [-1.0, 1.0],
# "short_close_trailing_qty_pct": [0.05, 1.0],
# "short_close_trailing_retracement_pct": [0.0, 0.1],
# "short_close_trailing_threshold_pct": [-0.1, 0.1],
# "short_ema_span_0": [200.0, 1440.0],
# "short_ema_span_1": [200.0, 1440.0],
# "short_entry_grid_double_down_factor": [0.1, 3.0],
# "short_entry_grid_spacing_pct": [0.001, 0.12],
# "short_entry_grid_spacing_weight": [0.0, 10.0],
# "short_entry_initial_ema_dist": [-0.1, 0.003],
# "short_entry_initial_qty_pct": [0.005, 0.1],
# "short_entry_trailing_grid_ratio": [-1.0, 1.0],
# "short_entry_trailing_retracement_pct": [0.0, 0.1],
# "short_entry_trailing_threshold_pct": [-0.1, 0.1],
# "short_filter_relative_volume_clip_pct": [0.0, 1.0],
# "short_filter_rolling_window": [10.0, 360.0],
# "short_n_positions": [1.0, 20.0],
# "short_total_wallet_exposure_limit": [0.0, 5.0],
# "short_unstuck_close_pct": [0.001, 0.1],
# "short_unstuck_ema_dist": [-0.1, 0.01],
# "short_unstuck_loss_allowance_pct": [0.0, 0.05],
# "short_unstuck_threshold": [0.4, 0.95]},
# "compress_results_file": true,
# "crossover_probability": 0.7,
# "iters": 30000,
# "limits": {"lower_bound_drawdown_worst": 0.25,
# "lower_bound_drawdown_worst_mean_1pct": 0.15,
# "lower_bound_equity_balance_diff_mean": 0.02,
# "lower_bound_loss_profit_ratio": 0.6},
# "mutation_probability": 0.2,
# "n_cpus": 5,
# "population_size": 500,
# "scoring": ["mdg", "sortino_ratio"]}}
class Backtest:
def __init__(self):
self._base_dir = "backtests"
self._compress_cache = True
self._end_date = "now"
self._exchanges = ["binance", "bybit"]
self._start_date = "2020-01-01"
self._starting_balance = 1000.0
self._backtest = {
"base_dir": self._base_dir,
"compress_cache": self._compress_cache,
"end_date": self._end_date,
"exchanges": self._exchanges,
"start_date": self._start_date,
"starting_balance": self._starting_balance
}
def __repr__(self):
return str(self._backtest)
@property
def backtest(self): return self._backtest
@backtest.setter
def backtest(self, new_backtest):
if "base_dir" in new_backtest:
self.base_dir = new_backtest["base_dir"]
if "compress_cache" in new_backtest:
self.compress_cache = new_backtest["compress_cache"]
if "end_date" in new_backtest:
self.end_date = new_backtest["end_date"]
if "exchanges" in new_backtest:
self.exchanges = new_backtest["exchanges"]
if "start_date" in new_backtest:
self.start_date = new_backtest["start_date"]
if "starting_balance" in new_backtest:
self.starting_balance = new_backtest["starting_balance"]
@property
def base_dir(self): return self._base_dir
@property
def compress_cache(self): return self._compress_cache
@property
def end_date(self):
if self._end_date == "now":
return datetime.datetime.now().strftime("%Y-%m-%d")
return self._end_date
@property
def exchanges(self): return self._exchanges
@property
def start_date(self): return self._start_date
@property
def starting_balance(self): return self._starting_balance
@base_dir.setter
def base_dir(self, new_base_dir):
self._base_dir = new_base_dir
self._backtest["base_dir"] = self._base_dir
@compress_cache.setter
def compress_cache(self, new_compress_cache):
self._compress_cache = new_compress_cache
self._backtest["compress_cache"] = self._compress_cache
@end_date.setter
def end_date(self, new_end_date):
self._end_date = new_end_date
self._backtest["end_date"] = self._end_date
@exchanges.setter
def exchanges(self, new_exchanges):
self._exchanges = new_exchanges
self._backtest["exchanges"] = self._exchanges
@start_date.setter
def start_date(self, new_start_date):
self._start_date = new_start_date
self._backtest["start_date"] = self._start_date
@starting_balance.setter
def starting_balance(self, new_starting_balance):
self._starting_balance = new_starting_balance
self._backtest["starting_balance"] = self._starting_balance
class Bot:
def __init__(self):
self._long = Long()
self._short = Short()
self._bot = {
"long": self._long._long,
"short": self._short._short
}
def __repr__(self):
return str(self._bot)
@property
def bot(self): return self._bot
@bot.setter
def bot(self, new_bot):
if "long" in new_bot:
self.long = new_bot["long"]
if "short" in new_bot:
self.short = new_bot["short"]
@property
def long(self): return self._long
@property
def short(self): return self._short
@long.setter
def long(self, new_long):
self._long.long = new_long
self._bot["long"] = self._long.long
@short.setter
def short(self, new_short):
self._short.short = new_short
self._bot["short"] = self._short.short
def edit(self):
# Init session_state for keys
if "edit_configv7_long_twe" in st.session_state:
if st.session_state.edit_configv7_long_twe != self.long.total_wallet_exposure_limit:
self.long.total_wallet_exposure_limit = round(st.session_state.edit_configv7_long_twe,2)
st.session_state.edit_configv7_long = json.dumps(self.bot["long"], indent=4)
if "edit_configv7_long_positions" in st.session_state:
if st.session_state.edit_configv7_long_positions != self.long.n_positions:
self.long.n_positions = round(st.session_state.edit_configv7_long_positions,0)
st.session_state.edit_configv7_long = json.dumps(self.bot["long"], indent=4)
if "edit_configv7_short_twe" in st.session_state:
if st.session_state.edit_configv7_short_twe != self.short.total_wallet_exposure_limit:
self.short.total_wallet_exposure_limit = round(st.session_state.edit_configv7_short_twe,2)
st.session_state.edit_configv7_short = json.dumps(self.bot["short"], indent=4)
if "edit_configv7_short_positions" in st.session_state:
if st.session_state.edit_configv7_short_positions != self.short.n_positions:
self.short.n_positions = round(st.session_state.edit_configv7_short_positions,0)
st.session_state.edit_configv7_short = json.dumps(self.bot["short"], indent=4)
if "edit_configv7_long" in st.session_state:
if st.session_state.edit_configv7_long != json.dumps(self.bot["long"], indent=4):
try:
self.long = json.loads(st.session_state.edit_configv7_long)
except:
error_popup("Invalid JSON")
st.session_state.edit_configv7_long = json.dumps(self.bot["long"], indent=4)
if "edit_configv7_short" in st.session_state:
if st.session_state.edit_configv7_short != json.dumps(self.bot["short"], indent=4):
try:
self.short = json.loads(st.session_state.edit_configv7_short)
except:
error_popup("Invalid JSON")
st.session_state.edit_configv7_short = json.dumps(self.bot["short"], indent=4)
col1, col2, col3, col4 = st.columns([1,1,1,1])
with col1:
st.number_input("long twe", min_value=0.0, max_value=100.0, value=float(self.long.total_wallet_exposure_limit), step=0.05, format="%.2f", key="edit_configv7_long_twe", help=pbgui_help.total_wallet_exposure_limit)
with col2:
st.number_input("long positions", min_value=0.0, max_value=100.0, value=float(self.long.n_positions), step=1.0, format="%.2f", key="edit_configv7_long_positions", help=pbgui_help.n_positions)
with col3:
st.number_input("short twe", min_value=0.0, max_value=100.0, value=float(self.short.total_wallet_exposure_limit), step=0.05, format="%.2f", key="edit_configv7_short_twe", help=pbgui_help.total_wallet_exposure_limit)
with col4:
st.number_input("short positions", min_value=0.0, max_value=100.0, value=float(self.short.n_positions), step=1.0, format="%.2f", key="edit_configv7_short_positions", help=pbgui_help.n_positions)
col1, col2 = st.columns([1,1])
with col1:
st.text_area(f'long', json.dumps(self.bot["long"], indent=4), key="edit_configv7_long", height=600)
with col2:
st.text_area(f'short', json.dumps(self.bot["short"], indent=4), key="edit_configv7_short", height=600)
def edit_cf(self):
# Init session_state for keys
if "edit_cf_configv7_long" in st.session_state:
if st.session_state.edit_cf_configv7_long != json.dumps(self.bot["long"], indent=4):
try:
self.long = json.loads(st.session_state.edit_cf_configv7_long)
except:
error_popup("Invalid JSON")
st.session_state.edit_cf_configv7_long = json.dumps(self.bot["long"], indent=4)
if "edit_cf_configv7_short" in st.session_state:
if st.session_state.edit_cf_configv7_short != json.dumps(self.bot["short"], indent=4):
try:
self.short = json.loads(st.session_state.edit_cf_configv7_short)
except:
error_popup("Invalid JSON")
st.session_state.edit_cf_configv7_short = json.dumps(self.bot["short"], indent=4)
col1, col2 = st.columns([1,1])
with col1:
st.text_area(f'long', json.dumps(self.bot["long"], indent=4), key="edit_cf_configv7_long", height=640)
with col2:
st.text_area(f'short', json.dumps(self.bot["short"], indent=4), key="edit_cf_configv7_short", height=640)
class Long:
def __init__(self):
self._close_grid_markup_range = 0.0015976
self._close_grid_min_markup = 0.012839
self._close_grid_qty_pct = 0.8195
self._close_trailing_grid_ratio = 0.042114
self._close_trailing_qty_pct = 1
self._close_trailing_retracement_pct = 0.066097
self._close_trailing_threshold_pct = 0.06726
self._ema_span_0 = 469.02
self._ema_span_1 = 1118.9
self._entry_grid_double_down_factor = 2.3738
self._entry_grid_spacing_pct = 0.052372
self._entry_grid_spacing_weight = 0.17715
self._entry_initial_ema_dist = -0.0060574
self._entry_initial_qty_pct = 0.019955
self._entry_trailing_grid_ratio = -0.28053
self._entry_trailing_retracement_pct = 0.0024762
self._entry_trailing_threshold_pct = 0.014956
self._filter_relative_volume_clip_pct = 0.51416
self._filter_rolling_window = 60.0
self._n_positions = 9.6662
self._total_wallet_exposure_limit = 0.8536
self._unstuck_close_pct = 0.049593
self._unstuck_ema_dist = -0.051669
self._unstuck_loss_allowance_pct = 0.044329
self._unstuck_threshold = 0.46953
self._long = {
"close_grid_markup_range": self._close_grid_markup_range,
"close_grid_min_markup": self._close_grid_min_markup,
"close_grid_qty_pct": self._close_grid_qty_pct,
"close_trailing_grid_ratio": self._close_trailing_grid_ratio,
"close_trailing_qty_pct": self._close_trailing_qty_pct,
"close_trailing_retracement_pct": self._close_trailing_retracement_pct,
"close_trailing_threshold_pct": self._close_trailing_threshold_pct,
"ema_span_0": self._ema_span_0,
"ema_span_1": self._ema_span_1,
"entry_grid_double_down_factor": self._entry_grid_double_down_factor,
"entry_grid_spacing_pct": self._entry_grid_spacing_pct,
"entry_grid_spacing_weight": self._entry_grid_spacing_weight,
"entry_initial_ema_dist": self._entry_initial_ema_dist,
"entry_initial_qty_pct": self._entry_initial_qty_pct,
"entry_trailing_grid_ratio": self._entry_trailing_grid_ratio,
"entry_trailing_retracement_pct": self._entry_trailing_retracement_pct,
"entry_trailing_threshold_pct": self._entry_trailing_threshold_pct,
"filter_relative_volume_clip_pct": self._filter_relative_volume_clip_pct,
"filter_rolling_window": self._filter_rolling_window,
"n_positions": self._n_positions,
"total_wallet_exposure_limit": self._total_wallet_exposure_limit,
"unstuck_close_pct": self._unstuck_close_pct,
"unstuck_ema_dist": self._unstuck_ema_dist,
"unstuck_loss_allowance_pct": self._unstuck_loss_allowance_pct,
"unstuck_threshold": self._unstuck_threshold
}
def __repr__(self):
return str(self._long)
@property
def long(self): return self._long
@long.setter
def long(self, new_long):
if "close_grid_markup_range" in new_long:
self.close_grid_markup_range = new_long["close_grid_markup_range"]
if "close_grid_min_markup" in new_long:
self.close_grid_min_markup = new_long["close_grid_min_markup"]
if "close_grid_qty_pct" in new_long:
self.close_grid_qty_pct = new_long["close_grid_qty_pct"]
if "close_trailing_grid_ratio" in new_long:
self.close_trailing_grid_ratio = new_long["close_trailing_grid_ratio"]
if "close_trailing_qty_pct" in new_long:
self.close_trailing_qty_pct = new_long["close_trailing_qty_pct"]
if "close_trailing_retracement_pct" in new_long:
self.close_trailing_retracement_pct = new_long["close_trailing_retracement_pct"]
if "close_trailing_threshold_pct" in new_long:
self.close_trailing_threshold_pct = new_long["close_trailing_threshold_pct"]
if "ema_span_0" in new_long:
self.ema_span_0 = new_long["ema_span_0"]
if "ema_span_1" in new_long:
self.ema_span_1 = new_long["ema_span_1"]
if "entry_grid_double_down_factor" in new_long:
self.entry_grid_double_down_factor = new_long["entry_grid_double_down_factor"]
if "entry_grid_spacing_pct" in new_long:
self.entry_grid_spacing_pct = new_long["entry_grid_spacing_pct"]
if "entry_grid_spacing_weight" in new_long:
self.entry_grid_spacing_weight = new_long["entry_grid_spacing_weight"]
if "entry_initial_ema_dist" in new_long:
self.entry_initial_ema_dist = new_long["entry_initial_ema_dist"]
if "entry_initial_qty_pct" in new_long:
self.entry_initial_qty_pct = new_long["entry_initial_qty_pct"]
if "entry_trailing_grid_ratio" in new_long:
self.entry_trailing_grid_ratio = new_long["entry_trailing_grid_ratio"]
if "entry_trailing_retracement_pct" in new_long:
self.entry_trailing_retracement_pct = new_long["entry_trailing_retracement_pct"]
if "entry_trailing_threshold_pct" in new_long:
self.entry_trailing_threshold_pct = new_long["entry_trailing_threshold_pct"]
if "filter_relative_volume_clip_pct" in new_long:
self.filter_relative_volume_clip_pct = new_long["filter_relative_volume_clip_pct"]
if "filter_rolling_window" in new_long:
self.filter_rolling_window = new_long["filter_rolling_window"]
if "n_positions" in new_long:
self.n_positions = new_long["n_positions"]
if "total_wallet_exposure_limit" in new_long:
self.total_wallet_exposure_limit = new_long["total_wallet_exposure_limit"]
if "unstuck_close_pct" in new_long:
self.unstuck_close_pct = new_long["unstuck_close_pct"]
if "unstuck_ema_dist" in new_long:
self.unstuck_ema_dist = new_long["unstuck_ema_dist"]
if "unstuck_loss_allowance_pct" in new_long:
self.unstuck_loss_allowance_pct = new_long["unstuck_loss_allowance_pct"]
if "unstuck_threshold" in new_long:
self.unstuck_threshold = new_long["unstuck_threshold"]
@property
def close_grid_markup_range(self): return self._close_grid_markup_range
@property
def close_grid_min_markup(self): return self._close_grid_min_markup
@property
def close_grid_qty_pct(self): return self._close_grid_qty_pct
@property
def close_trailing_grid_ratio(self): return self._close_trailing_grid_ratio
@property
def close_trailing_qty_pct(self): return self._close_trailing_qty_pct
@property
def close_trailing_retracement_pct(self): return self._close_trailing_retracement_pct
@property
def close_trailing_threshold_pct(self): return self._close_trailing_threshold_pct
@property
def ema_span_0(self): return self._ema_span_0
@property
def ema_span_1(self): return self._ema_span_1
@property
def entry_grid_double_down_factor(self): return self._entry_grid_double_down_factor
@property
def entry_grid_spacing_pct(self): return self._entry_grid_spacing_pct
@property
def entry_grid_spacing_weight(self): return self._entry_grid_spacing_weight
@property
def entry_initial_ema_dist(self): return self._entry_initial_ema_dist
@property
def entry_initial_qty_pct(self): return self._entry_initial_qty_pct
@property
def entry_trailing_grid_ratio(self): return self._entry_trailing_grid_ratio
@property
def entry_trailing_retracement_pct(self): return self._entry_trailing_retracement_pct
@property
def entry_trailing_threshold_pct(self): return self._entry_trailing_threshold_pct
@property
def filter_relative_volume_clip_pct(self): return self._filter_relative_volume_clip_pct
@property
def filter_rolling_window(self): return self._filter_rolling_window
@property
def n_positions(self): return self._n_positions
@property
def total_wallet_exposure_limit(self): return self._total_wallet_exposure_limit
@property
def unstuck_close_pct(self): return self._unstuck_close_pct
@property
def unstuck_ema_dist(self): return self._unstuck_ema_dist
@property
def unstuck_loss_allowance_pct(self): return self._unstuck_loss_allowance_pct
@property
def unstuck_threshold(self): return self._unstuck_threshold
@close_grid_markup_range.setter
def close_grid_markup_range(self, new_close_grid_markup_range):
self._close_grid_markup_range = new_close_grid_markup_range
self._long["close_grid_markup_range"] = self._close_grid_markup_range
@close_grid_min_markup.setter
def close_grid_min_markup(self, new_close_grid_min_markup):
self._close_grid_min_markup = new_close_grid_min_markup
self._long["close_grid_min_markup"] = self._close_grid_min_markup
@close_grid_qty_pct.setter
def close_grid_qty_pct(self, new_close_grid_qty_pct):
self._close_grid_qty_pct = new_close_grid_qty_pct
self._long["close_grid_qty_pct"] = self._close_grid_qty_pct
@close_trailing_grid_ratio.setter
def close_trailing_grid_ratio(self, new_close_trailing_grid_ratio):
self._close_trailing_grid_ratio = new_close_trailing_grid_ratio
self._long["close_trailing_grid_ratio"] = self._close_trailing_grid_ratio
@close_trailing_qty_pct.setter
def close_trailing_qty_pct(self, new_close_trailing_qty_pct):
self._close_trailing_qty_pct = new_close_trailing_qty_pct
self._long["close_trailing_qty_pct"] = self._close_trailing_qty_pct
@close_trailing_retracement_pct.setter
def close_trailing_retracement_pct(self, new_close_trailing_retracement_pct):
self._close_trailing_retracement_pct = new_close_trailing_retracement_pct
self._long["close_trailing_retracement_pct"] = self._close_trailing_retracement_pct
@close_trailing_threshold_pct.setter
def close_trailing_threshold_pct(self, new_close_trailing_threshold_pct):
self._close_trailing_threshold_pct = new_close_trailing_threshold_pct
self._long["close_trailing_threshold_pct"] = self._close_trailing_threshold_pct
@ema_span_0.setter
def ema_span_0(self, new_ema_span_0):
self._ema_span_0 = new_ema_span_0
self._long["ema_span_0"] = self._ema_span_0
@ema_span_1.setter
def ema_span_1(self, new_ema_span_1):
self._ema_span_1 = new_ema_span_1
self._long["ema_span_1"] = self._ema_span_1
@entry_grid_double_down_factor.setter
def entry_grid_double_down_factor(self, new_entry_grid_double_down_factor):
self._entry_grid_double_down_factor = new_entry_grid_double_down_factor
self._long["entry_grid_double_down_factor"] = self._entry_grid_double_down_factor
@entry_grid_spacing_pct.setter
def entry_grid_spacing_pct(self, new_entry_grid_spacing_pct):
self._entry_grid_spacing_pct = new_entry_grid_spacing_pct
self._long["entry_grid_spacing_pct"] = self._entry_grid_spacing_pct
@entry_grid_spacing_weight.setter
def entry_grid_spacing_weight(self, new_entry_grid_spacing_weight):
self._entry_grid_spacing_weight = new_entry_grid_spacing_weight
self._long["entry_grid_spacing_weight"] = self._entry_grid_spacing_weight
@entry_initial_ema_dist.setter
def entry_initial_ema_dist(self, new_entry_initial_ema_dist):
self._entry_initial_ema_dist = new_entry_initial_ema_dist
self._long["entry_initial_ema_dist"] = self._entry_initial_ema_dist
@entry_initial_qty_pct.setter
def entry_initial_qty_pct(self, new_entry_initial_qty_pct):
self._entry_initial_qty_pct = new_entry_initial_qty_pct
self._long["entry_initial_qty_pct"] = self._entry_initial_qty_pct
@entry_trailing_grid_ratio.setter
def entry_trailing_grid_ratio(self, new_entry_trailing_grid_ratio):
self._entry_trailing_grid_ratio = new_entry_trailing_grid_ratio
self._long["entry_trailing_grid_ratio"] = self._entry_trailing_grid_ratio
@entry_trailing_retracement_pct.setter
def entry_trailing_retracement_pct(self, new_entry_trailing_retracement_pct):
self._entry_trailing_retracement_pct = new_entry_trailing_retracement_pct
self._long["entry_trailing_retracement_pct"] = self._entry_trailing_retracement_pct
@entry_trailing_threshold_pct.setter
def entry_trailing_threshold_pct(self, new_entry_trailing_threshold_pct):
self._entry_trailing_threshold_pct = new_entry_trailing_threshold_pct
self._long["entry_trailing_threshold_pct"] = self._entry_trailing_threshold_pct
@filter_relative_volume_clip_pct.setter
def filter_relative_volume_clip_pct(self, new_filter_relative_volume_clip_pct):
self._filter_relative_volume_clip_pct = new_filter_relative_volume_clip_pct
self._long["filter_relative_volume_clip_pct"] = self._filter_relative_volume_clip_pct
@filter_rolling_window.setter
def filter_rolling_window(self, new_filter_rolling_window):
self._filter_rolling_window = new_filter_rolling_window
self._long["filter_rolling_window"] = self._filter_rolling_window
@n_positions.setter
def n_positions(self, new_n_positions):
self._n_positions = new_n_positions
self._long["n_positions"] = self._n_positions
@total_wallet_exposure_limit.setter
def total_wallet_exposure_limit(self, new_total_wallet_exposure_limit):
self._total_wallet_exposure_limit = new_total_wallet_exposure_limit
self._long["total_wallet_exposure_limit"] = self._total_wallet_exposure_limit
@unstuck_close_pct.setter
def unstuck_close_pct(self, new_unstuck_close_pct):
self._unstuck_close_pct = new_unstuck_close_pct
self._long["unstuck_close_pct"] = self._unstuck_close_pct
@unstuck_ema_dist.setter
def unstuck_ema_dist(self, new_unstuck_ema_dist):
self._unstuck_ema_dist = new_unstuck_ema_dist
self._long["unstuck_ema_dist"] = self._unstuck_ema_dist
@unstuck_loss_allowance_pct.setter
def unstuck_loss_allowance_pct(self, new_unstuck_loss_allowance_pct):
self._unstuck_loss_allowance_pct = new_unstuck_loss_allowance_pct
self._long["unstuck_loss_allowance_pct"] = self._unstuck_loss_allowance_pct
@unstuck_threshold.setter
def unstuck_threshold(self, new_unstuck_threshold):
self._unstuck_threshold = new_unstuck_threshold
self._long["unstuck_threshold"] = self._unstuck_threshold
class Short:
def __init__(self):
self._close_grid_markup_range = 0.028266
self._close_grid_min_markup = 0.013899
self._close_grid_qty_pct = 0.63174
self._close_trailing_grid_ratio = 0.93658
self._close_trailing_qty_pct = 1
self._close_trailing_retracement_pct = 0.098179
self._close_trailing_threshold_pct = -0.059383
self._ema_span_0 = 794.32
self._ema_span_1 = 1176.7
self._entry_grid_double_down_factor = 2.1256
self._entry_grid_spacing_pct = 0.072906
self._entry_grid_spacing_weight = 0.98867
self._entry_initial_ema_dist = -0.060333
self._entry_initial_qty_pct = 0.066426
self._entry_trailing_grid_ratio = -0.026647
self._entry_trailing_retracement_pct = 0.016626
self._entry_trailing_threshold_pct = 0.052728
self._filter_relative_volume_clip_pct = 0.50001
self._filter_rolling_window = 68.072
self._n_positions = 0.0
self._total_wallet_exposure_limit = 0.0
self._unstuck_close_pct = 0.052992
self._unstuck_ema_dist = -0.0465
self._unstuck_loss_allowance_pct = 0.045415
self._unstuck_threshold = 0.92228
self._short = {
"close_grid_markup_range": self._close_grid_markup_range,
"close_grid_min_markup": self._close_grid_min_markup,
"close_grid_qty_pct": self._close_grid_qty_pct,
"close_trailing_grid_ratio": self._close_trailing_grid_ratio,
"close_trailing_qty_pct": self._close_trailing_qty_pct,
"close_trailing_retracement_pct": self._close_trailing_retracement_pct,
"close_trailing_threshold_pct": self._close_trailing_threshold_pct,
"ema_span_0": self._ema_span_0,
"ema_span_1": self._ema_span_1,
"entry_grid_double_down_factor": self._entry_grid_double_down_factor,
"entry_grid_spacing_pct": self._entry_grid_spacing_pct,
"entry_grid_spacing_weight": self._entry_grid_spacing_weight,
"entry_initial_ema_dist": self._entry_initial_ema_dist,
"entry_initial_qty_pct": self._entry_initial_qty_pct,
"entry_trailing_grid_ratio": self._entry_trailing_grid_ratio,
"entry_trailing_retracement_pct": self._entry_trailing_retracement_pct,
"entry_trailing_threshold_pct": self._entry_trailing_threshold_pct,
"filter_relative_volume_clip_pct": self._filter_relative_volume_clip_pct,
"filter_rolling_window": self._filter_rolling_window,
"n_positions": self._n_positions,
"total_wallet_exposure_limit": self._total_wallet_exposure_limit,
"unstuck_close_pct": self._unstuck_close_pct,
"unstuck_ema_dist": self._unstuck_ema_dist,
"unstuck_loss_allowance_pct": self._unstuck_loss_allowance_pct,
"unstuck_threshold": self._unstuck_threshold
}
def __repr__(self):
return str(self._short)
@property
def short(self): return self._short
@short.setter
def short(self, new_short):
if "close_grid_markup_range" in new_short:
self.close_grid_markup_range = new_short["close_grid_markup_range"]
if "close_grid_min_markup" in new_short:
self.close_grid_min_markup = new_short["close_grid_min_markup"]
if "close_grid_qty_pct" in new_short:
self.close_grid_qty_pct = new_short["close_grid_qty_pct"]
if "close_trailing_grid_ratio" in new_short:
self.close_trailing_grid_ratio = new_short["close_trailing_grid_ratio"]
if "close_trailing_qty_pct" in new_short:
self.close_trailing_qty_pct = new_short["close_trailing_qty_pct"]
if "close_trailing_retracement_pct" in new_short:
self.close_trailing_retracement_pct = new_short["close_trailing_retracement_pct"]
if "close_trailing_threshold_pct" in new_short:
self.close_trailing_threshold_pct = new_short["close_trailing_threshold_pct"]
if "ema_span_0" in new_short:
self.ema_span_0 = new_short["ema_span_0"]
if "ema_span_1" in new_short:
self.ema_span_1 = new_short["ema_span_1"]
if "entry_grid_double_down_factor" in new_short:
self.entry_grid_double_down_factor = new_short["entry_grid_double_down_factor"]
if "entry_grid_spacing_pct" in new_short:
self.entry_grid_spacing_pct = new_short["entry_grid_spacing_pct"]
if "entry_grid_spacing_weight" in new_short:
self.entry_grid_spacing_weight = new_short["entry_grid_spacing_weight"]
if "entry_initial_ema_dist" in new_short:
self.entry_initial_ema_dist = new_short["entry_initial_ema_dist"]
if "entry_initial_qty_pct" in new_short:
self.entry_initial_qty_pct = new_short["entry_initial_qty_pct"]
if "entry_trailing_grid_ratio" in new_short:
self.entry_trailing_grid_ratio = new_short["entry_trailing_grid_ratio"]
if "entry_trailing_retracement_pct" in new_short:
self.entry_trailing_retracement_pct = new_short["entry_trailing_retracement_pct"]
if "entry_trailing_threshold_pct" in new_short:
self.entry_trailing_threshold_pct = new_short["entry_trailing_threshold_pct"]
if "filter_relative_volume_clip_pct" in new_short:
self.filter_relative_volume_clip_pct = new_short["filter_relative_volume_clip_pct"]
if "filter_rolling_window" in new_short:
self.filter_rolling_window = new_short["filter_rolling_window"]
if "n_positions" in new_short:
self.n_positions = new_short["n_positions"]
if "total_wallet_exposure_limit" in new_short:
self.total_wallet_exposure_limit = new_short["total_wallet_exposure_limit"]
if "unstuck_close_pct" in new_short:
self.unstuck_close_pct = new_short["unstuck_close_pct"]
if "unstuck_ema_dist" in new_short:
self.unstuck_ema_dist = new_short["unstuck_ema_dist"]
if "unstuck_loss_allowance_pct" in new_short:
self.unstuck_loss_allowance_pct = new_short["unstuck_loss_allowance_pct"]
if "unstuck_threshold" in new_short:
self.unstuck_threshold = new_short["unstuck_threshold"]
@property
def close_grid_markup_range(self): return self._close_grid_markup_range
@property
def close_grid_min_markup(self): return self._close_grid_min_markup
@property
def close_grid_qty_pct(self): return self._close_grid_qty_pct
@property
def close_trailing_grid_ratio(self): return self._close_trailing_grid_ratio
@property
def close_trailing_qty_pct(self): return self._close_trailing_qty_pct
@property
def close_trailing_retracement_pct(self): return self._close_trailing_retracement_pct
@property
def close_trailing_threshold_pct(self): return self._close_trailing_threshold_pct
@property
def ema_span_0(self): return self._ema_span_0
@property
def ema_span_1(self): return self._ema_span_1
@property
def entry_grid_double_down_factor(self): return self._entry_grid_double_down_factor
@property
def entry_grid_spacing_pct(self): return self._entry_grid_spacing_pct
@property
def entry_grid_spacing_weight(self): return self._entry_grid_spacing_weight
@property
def entry_initial_ema_dist(self): return self._entry_initial_ema_dist
@property
def entry_initial_qty_pct(self): return self._entry_initial_qty_pct
@property