Skip to content

Commit

Permalink
validate prove-backtesting config
Browse files Browse the repository at this point in the history
  • Loading branch information
Azulinho committed Mar 6, 2023
1 parent e660bf3 commit 14f4b26
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ A python based trading bot for Binance, which relies heavily on backtesting.
* [KLINES_CACHING_SERVICE_URL](#klines_caching_service_url)
* [CONCURRENCY](#concurrency)
* [SORT_BY](#sort_by)
* [maximum_profit_on_clean_wins](#maximum_profit_on_clean_wins)
* [max_profit_on_clean_wins](#max_profit_on_clean_wins)
* [number_of_clean_wins](#number_of_clean_wins)
* [greed](#greed)
10. [Bot command center](#bot-command-center)
Expand Down Expand Up @@ -924,13 +924,13 @@ How to order results from the different test runs in automated-backtesting in
order to choose the best config for each coin.


#### maximum_profit_on_clean_wins
#### max_profit_on_clean_wins

Use the config that provided the best profit for this coin and did not result
in any STOP_LOSSES or STALES or HOLDS at the end of the runs.

```
SORT_BY: "maximum_profit_on_clean_wins"
SORT_BY: "max_profit_on_clean_wins"
```

#### number_of_clean_wins
Expand Down
2 changes: 1 addition & 1 deletion tests/prove-backtesting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CONCURRENCY: 1

MIN: 1
FILTER_BY: "ETH"
SORT_BY: "maximum_profit_on_clean_wins"
SORT_BY: "greed"
FROM_DATE: 20211201
END_DATE: 20211209
ROLL_BACKWARDS: 3
Expand Down
13 changes: 13 additions & 0 deletions utils/prove-backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ def __init__(self, cfg) -> None:
)
self.sort_by: str = cfg["SORT_BY"]

def check_for_invalid_values(self):
"""check for invalid values in the config"""

if self.sort_by not in [
"max_profit_on_clean_wins",
"number_of_clean_wins",
"greed",
]:
log_msg("SORT_BY set to invalid value")
sys.exit(1)

def generate_start_dates(self, start_date, end_date, jump=7) -> list:
"""returns a list of dates, with a gap in 'jump' days"""
dates = pd.date_range(start_date, end_date, freq="d").strftime(
Expand Down Expand Up @@ -579,6 +590,8 @@ def run_optimized_config(self, s_balance) -> float:
n_cpus: Optional[int] = os.cpu_count()

pv: ProveBacktesting = ProveBacktesting(config)
pv.check_for_invalid_values()


# generate start_dates
log_msg(
Expand Down

0 comments on commit 14f4b26

Please sign in to comment.