Skip to content

Commit

Permalink
3.0.1rc3
Browse files Browse the repository at this point in the history
  • Loading branch information
DogsTailFarmer committed Mar 21, 2024
1 parent b51f242 commit 10aceac
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 204 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 3.0.1rc3 - 2024-03-21
### Added for new features
:rocket: `Backtesting`: handling of partially filling events

### Update
* Up requirements for exchanges-wrapper==2.1.3

## 3.0.1rc1 - 2024-03-19
### Fix
* Cyclic Backtesting workflow
Expand Down
2 changes: 1 addition & 1 deletion martin_binance/__init__.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__ = "3.0.1rc1"
__version__ = "3.0.1rc3"
__maintainer__ = "Jerry Fedorenko"
__contact__ = "https://github.com/DogsTailFarmer"

Expand Down
110 changes: 56 additions & 54 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__ = "3.0.1rc1"
__version__ = "3.0.1rc3"
__maintainer__ = "Jerry Fedorenko"
__contact__ = "https://github.com/DogsTailFarmer"

Expand All @@ -24,56 +24,56 @@


def main():
questions = [
inquirer.List(
"path",
message="Select from saved: exchange_PAIR with the strategy you want to optimize",
choices=[f.name for f in BACKTEST_PATH.iterdir() if f.is_dir() and f.name.count('_') == 1],
),
inquirer.List(
"mode",
message="New study session or analise from saved one",
choices=["New", "Analise saved study session"],
),
inquirer.Text(
"n_trials",
message="Enter number of cycles, from 10 to 1000",
ignore=lambda x: x["mode"] == "Analise saved study session",
default='150',
validate=lambda _, c: 10 <= int(c) <= 1000,
),
]

answers = inquirer.prompt(questions, theme=GreenPassion())

study_name = answers.get('path') # Unique identifier of the study
storage_name = f"sqlite:///{Path(BACKTEST_PATH, study_name, 'study.db')}"

if answers.get('mode') == 'New':
Path(BACKTEST_PATH, study_name, 'study.db').unlink(missing_ok=True)
try:
strategy = next(Path(BACKTEST_PATH, study_name).glob("cli_*.py"))
except StopIteration:
raise UserWarning(f"Can't find cli_*.py in {Path(BACKTEST_PATH, study_name)}")

study = optimize(
study_name,
strategy,
int(answers.get('n_trials', '0')),
storage_name,
skip_log=SKIP_LOG,
show_progress_bar=SKIP_LOG
)
print_study_result(study)
print(f"Study instance saved to {storage_name} for later use")
elif answers.get('mode') == 'Analise saved study session':
# noinspection PyArgumentList
study = optuna.load_study(study_name=study_name, storage=storage_name)

print(f"Best value: {study.best_value}")
print(f"Original value: {study.get_trials()[0].value}")

while 1:
while 1:
questions = [
inquirer.List(
"path",
message="Select from saved: exchange_PAIR with the strategy you want to optimize",
choices=[f.name for f in BACKTEST_PATH.iterdir() if f.is_dir() and f.name.count('_') == 1],
),
inquirer.List(
"mode",
message="New study session or analise from saved one",
choices=["New", "Analise saved study session", "Exit"],
),
inquirer.Text(
"n_trials",
message="Enter number of cycles, from 2 to 1000",
ignore=lambda x: x["mode"] in ("Analise saved study session", "Exit"),
default='150',
validate=lambda _, c: 15 <= int(c) <= 1000,
),
]

answers = inquirer.prompt(questions, theme=GreenPassion())

study_name = answers.get('path') # Unique identifier of the study
storage_name = f"sqlite:///{Path(BACKTEST_PATH, study_name, 'study.db')}"

if answers.get('mode') == 'New':
Path(BACKTEST_PATH, study_name, 'study.db').unlink(missing_ok=True)
try:
strategy = next(Path(BACKTEST_PATH, study_name).glob("cli_*.py"))
except StopIteration:
raise UserWarning(f"Can't find cli_*.py in {Path(BACKTEST_PATH, study_name)}")

study = optimize(
study_name,
strategy,
int(answers.get('n_trials', '0')),
storage_name,
skip_log=SKIP_LOG,
show_progress_bar=SKIP_LOG
)
print_study_result(study)
print(f"Study instance saved to {storage_name} for later use")
elif answers.get('mode') == 'Analise saved study session':
# noinspection PyArgumentList
study = optuna.load_study(study_name=study_name, storage=storage_name)

print(f"Best value: {study.best_value}")
print(f"Original value: {study.get_trials()[0].value}")

questions = [
inquirer.List(
"mode",
Expand Down Expand Up @@ -106,12 +106,14 @@ def main():
print("Can't find GUI, you can copy study instance to another environment for analyze it")
elif answers.get('mode') == 'Get parameters for specific trial':
trial = study.get_trials()[int(answers.get('n_trial', '0'))]
print(trial.number)
print(f"number: {trial.number}")
print(trial.state)
print(trial.value)
print(trial.params)
print(f"value: {trial.value}")
print(f"params: {trial.params}")
else:
break
else:
break


def print_study_result(study):
Expand Down
Loading

0 comments on commit 10aceac

Please sign in to comment.