Skip to content

Commit

Permalink
2.0.3r
Browse files Browse the repository at this point in the history
  • Loading branch information
DogsTailFarmer committed Dec 1, 2023
1 parent ec95336 commit cb9aaf6
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 84 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 2.0.3 - 2023-11-xx
## 2.0.3 - 2023-12-01
### Fix
* Backtesting, Simulation mode

### Update
* solve(): The limit of attempts has been increased
* calc_over_price(): The range of changes in the number of orders has been expanded
Expand Down
22 changes: 15 additions & 7 deletions martin_binance/backtest/OoTSP.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__author__ = "Jerry Fedorenko"
__copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM"
__license__ = "MIT"
__version__ = "1.3.4"
__version__ = "2.0.3"
__maintainer__ = "Jerry Fedorenko"
__contact__ = "https://github.com/DogsTailFarmer"

Expand All @@ -23,7 +23,7 @@
vis = optuna.visualization
ii_params = []

PARAMS_FLOAT = ['PRICE_SHIFT', 'KBB']
PARAMS_FLOAT = ['KBB']


def try_trade(mbs, **kwargs):
Expand Down Expand Up @@ -70,7 +70,7 @@ def objective(_trial):
message="Enter number of cycles, from 50 to 500",
ignore=lambda x: x["mode"] == "Analise saved study session",
default='150',
validate=lambda _, c: 10 <= int(c) <= 500,
validate=lambda _, c: 50 <= int(c) <= 500,
),
]

Expand All @@ -85,6 +85,9 @@ def objective(_trial):
strategy = next(Path(BACKTEST_PATH, answers.get('path')).glob("cli_*.py"))
except StopIteration:
raise UserWarning(f"Can't find cli_*.py in {Path(BACKTEST_PATH, answers.get('path'))}")

print(f"Importing strategy from {strategy}")

spec = importlib.util.spec_from_file_location("strategy", strategy)
mbs = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mbs)
Expand Down Expand Up @@ -138,10 +141,15 @@ def objective(_trial):

def print_study_result(study):
print(f"Optimal parameters: {study.best_params} for get {study.best_value}")
importance_params = optuna.importance.get_param_importances(study)
print("Evaluate parameter importance based on completed trials in the given study:")
for p in importance_params.items():
print(p)
try:
importance_params = optuna.importance.get_param_importances(study)
except RuntimeError as e:
importance_params = {}
print(e)
else:
print("Evaluate parameter importance based on completed trials in the given study:")
for p in importance_params.items():
print(p)
return importance_params


Expand Down
7 changes: 4 additions & 3 deletions martin_binance/backtest/VCoSEL.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__author__ = "Jerry Fedorenko"
__copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM"
__license__ = "MIT"
__version__ = "1.3.0"
__version__ = "2.0.3"
__maintainer__ = "Jerry Fedorenko"
__contact__ = "https://github.com/DogsTailFarmer"

Expand All @@ -22,7 +22,8 @@
clrs = {'background': '#696969',
'text': '#7FDBFF'}

source_path = askdirectory(title='Pick a folder for base strategy', initialdir=str(BACKTEST_PATH))
source_path = askdirectory(title='Pick a folder for base strategy: "back_test/exchange_AAABBB/snapshot/"',
initialdir=str(BACKTEST_PATH))
s_ds = pd.read_pickle(Path(BACKTEST_PATH, source_path, "ticker.pkl"))
s_sell_df: pd.DataFrame = pd.read_pickle(Path(BACKTEST_PATH, source_path, "sell.pkl"))
s_buy_df = pd.read_pickle(Path(BACKTEST_PATH, source_path, "buy.pkl"))
Expand Down Expand Up @@ -65,7 +66,7 @@
fig.add_traces(go.Scatter(x=df_grid_buy.index, y=df_grid_buy[col], mode='lines', line_color='green',
showlegend=False))

fig.update_layout(xaxis_tickformat="%H:%M:%S", height=700, autosize=True)
fig.update_layout(xaxis_tickformat="%H:%M:%S.%L", height=700, autosize=True)

app.layout = html.Div(
[
Expand Down
4 changes: 2 additions & 2 deletions martin_binance/cli_0_BTCUSDT.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__author__ = "Jerry Fedorenko"
__copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM"
__license__ = "MIT"
__version__ = "2.0.0"
__version__ = "2.0.3"
__maintainer__ = "Jerry Fedorenko"
__contact__ = "https://github.com/DogsTailFarmer"
"""
Expand All @@ -28,7 +28,7 @@ from pathlib import Path
import toml
import martin_binance.executor as ex
from martin_binance import CONFIG_FILE, LOG_PATH, LAST_STATE_PATH
from martin_binance.margin_wrapper import main, ask_exit, LogLevel # noqa
from martin_binance.margin_wrapper import main, ask_exit, LogLevel, session_result # noqa
################################################################
# Exchange setup and parameter settings
################################################################
Expand Down
4 changes: 2 additions & 2 deletions martin_binance/cli_1_BTCUSDT.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__author__ = "Jerry Fedorenko"
__copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM"
__license__ = "MIT"
__version__ = "2.0.0"
__version__ = "2.0.3"
__maintainer__ = "Jerry Fedorenko"
__contact__ = "https://github.com/DogsTailFarmer"
"""
Expand All @@ -28,7 +28,7 @@ from pathlib import Path
import toml
import martin_binance.executor as ex
from martin_binance import CONFIG_FILE, LOG_PATH, LAST_STATE_PATH
from martin_binance.margin_wrapper import main, ask_exit, LogLevel # noqa
from martin_binance.margin_wrapper import main, ask_exit, LogLevel, session_result # noqa
################################################################
# Exchange setup and parameter settings
################################################################
Expand Down
4 changes: 2 additions & 2 deletions martin_binance/cli_2_TESTBTCTESTUSDT.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__author__ = "Jerry Fedorenko"
__copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM"
__license__ = "MIT"
__version__ = "2.0.0"
__version__ = "2.0.3"
__maintainer__ = "Jerry Fedorenko"
__contact__ = "https://github.com/DogsTailFarmer"
"""
Expand All @@ -28,7 +28,7 @@ from pathlib import Path
import toml
import martin_binance.executor as ex
from martin_binance import CONFIG_FILE, LOG_PATH, LAST_STATE_PATH
from martin_binance.margin_wrapper import main, ask_exit, LogLevel # noqa
from martin_binance.margin_wrapper import main, ask_exit, LogLevel, session_result # noqa
################################################################
# Exchange setup and parameter settings
################################################################
Expand Down
4 changes: 2 additions & 2 deletions martin_binance/cli_3_BTCUSDT.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__author__ = "Jerry Fedorenko"
__copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM"
__license__ = "MIT"
__version__ = "2.0.0"
__version__ = "2.0.3"
__maintainer__ = "Jerry Fedorenko"
__contact__ = "https://github.com/DogsTailFarmer"
"""
Expand All @@ -28,7 +28,7 @@ from pathlib import Path
import toml
import martin_binance.executor as ex
from martin_binance import CONFIG_FILE, LOG_PATH, LAST_STATE_PATH
from martin_binance.margin_wrapper import main, ask_exit, LogLevel # noqa
from martin_binance.margin_wrapper import main, ask_exit, LogLevel, session_result # noqa
################################################################
# Exchange setup and parameter settings
################################################################
Expand Down
Loading

0 comments on commit cb9aaf6

Please sign in to comment.