Skip to content

Commit

Permalink
feat(backtest): add fast argument for backtesting
Browse files Browse the repository at this point in the history
  • Loading branch information
yakir4123 committed Mar 10, 2024
1 parent 626de15 commit 8f71f14
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
6 changes: 4 additions & 2 deletions jesse/modes/backtest_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,11 @@ def load_candles(start_date_str: str, finish_date_str: str) -> Dict[str, Dict[st
return candles


def simulator(*args, **kwargs) -> dict:
def simulator(*args, fast_simulation: bool = False, **kwargs) -> dict:
if fast_simulation:
return _skip_simulator(*args, **kwargs)

return _step_simulator(*args, **kwargs)
# return _skip_simulator(*args, **kwargs)


def _step_simulator(
Expand Down
12 changes: 8 additions & 4 deletions jesse/research/backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def backtest(
generate_csv: bool = False,
generate_json: bool = False,
generate_logs: bool = False,
hyperparameters: dict = None
hyperparameters: dict = None,
fast_simulation: bool = True
) -> dict:
"""
An isolated backtest() function which is perfect for using in research, and AI training
Expand Down Expand Up @@ -64,7 +65,8 @@ def backtest(
generate_json=generate_json,
generate_equity_curve=generate_equity_curve,
generate_hyperparameters=generate_hyperparameters,
generate_logs=generate_logs
generate_logs=generate_logs,
fast_simulation=fast_simulation,
)


Expand All @@ -83,7 +85,8 @@ def _isolated_backtest(
generate_json: bool = False,
generate_equity_curve: bool = False,
generate_hyperparameters: bool = False,
generate_logs: bool = False
generate_logs: bool = False,
fast_simulation: bool = True,
) -> dict:
from jesse.services.validators import validate_routes
from jesse.modes.backtest_mode import simulator
Expand Down Expand Up @@ -159,7 +162,8 @@ def _isolated_backtest(
generate_json=generate_json,
generate_equity_curve=generate_equity_curve,
generate_hyperparameters=generate_hyperparameters,
generate_logs=generate_logs
generate_logs=generate_logs,
fast_simulation=fast_simulation,
)

result = {
Expand Down
3 changes: 1 addition & 2 deletions jesse/store/state_candles.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ def add_multiple_1m_candles(
exchange: str,
symbol: str,
) -> None:
# assuming the functionality is only for '1m' candles for now
if jh.is_collecting_data():
raise NotImplemented("Collecting data is deactivated at the moment")
# make sure it's a complete (and not a forming) candle
Expand All @@ -417,7 +416,7 @@ def add_multiple_1m_candles(
# For now it's only implemented for backtesting
return

arr: DynamicNumpyArray = self.get_storage(exchange, symbol, timeframe)
arr: DynamicNumpyArray = self.get_storage(exchange, symbol, '1m')

# initial
if len(arr) == 0:
Expand Down

0 comments on commit 8f71f14

Please sign in to comment.