7
7
__author__ = "Jerry Fedorenko"
8
8
__copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM"
9
9
__license__ = "MIT"
10
- __version__ = "2.1 .0"
10
+ __version__ = "3.0 .0"
11
11
__maintainer__ = "Jerry Fedorenko"
12
12
__contact__ = "https://github.com/DogsTailFarmer"
13
13
"""
@@ -26,9 +26,9 @@ import sys
26
26
import asyncio
27
27
from pathlib import Path
28
28
import toml
29
- import martin_binance . executor as ex
29
+
30
30
from martin_binance import CONFIG_FILE , LOG_PATH , LAST_STATE_PATH
31
- from martin_binance .margin_wrapper import main , ask_exit , LogLevel , session_result # noqa
31
+ import martin_binance .params as ex
32
32
################################################################
33
33
# Exchange setup and parameter settings
34
34
################################################################
@@ -90,7 +90,7 @@ ex.MODE = 'T' # 'T' - Trade, 'TC' - Trade and Collect, 'S' - Simulate
90
90
ex .SAVE_DS = False # Save session result data (ticker, orders) for compare
91
91
ex .SAVE_PERIOD = 24 * 60 * 60 # sec, timetable for save data portion
92
92
ex .SELF_OPTIMIZATION = True # Cyclic self-optimization of parameters, together with MODE == 'TC'
93
- ex .N_TRIALS = 500 # Number of optimization cycles for optuna study in self optimization mode
93
+ ex .N_TRIALS = 250 # Number of optimization cycles for optuna study in self optimization mode
94
94
################################################################
95
95
# DO NOT EDIT UNDER THIS LINE ###
96
96
################################################################
@@ -110,9 +110,8 @@ for tlg in telegram:
110
110
break
111
111
112
112
113
- def trade ():
113
+ def trade (strategy = None ):
114
114
import logging .handlers
115
- loop = asyncio .get_event_loop ()
116
115
# For autoload last state
117
116
ex .LOAD_LAST_STATE = 1 if len (sys .argv ) > 1 else 0
118
117
#
@@ -126,21 +125,26 @@ def trade():
126
125
_logger .addHandler (handler )
127
126
_logger .propagate = False
128
127
#
128
+ if strategy is None :
129
+ from martin_binance .executor import Strategy
130
+ strategy = Strategy ()
131
+ loop = asyncio .get_event_loop ()
129
132
try :
130
- loop .create_task (main (ex .SYMBOL ))
133
+ loop .create_task (strategy . main (ex .SYMBOL ))
131
134
loop .run_forever ()
132
135
except KeyboardInterrupt :
133
136
pass
134
137
finally :
135
138
try :
136
- loop .run_until_complete (ask_exit ())
139
+ loop .run_until_complete (strategy . ask_exit ())
137
140
except asyncio .CancelledError :
138
141
pass
139
142
except Exception as _err :
140
143
print (f"Error: { _err } " )
141
144
loop .run_until_complete (loop .shutdown_asyncgens ())
142
145
if ex .MODE in ('T' , 'TC' ):
143
146
loop .close ()
147
+ return strategy
144
148
145
149
146
150
if __name__ == "__main__" :
0 commit comments