Skip to content

Commit

Permalink
More polish on runnign backtests from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Nov 21, 2022
1 parent 4dc9da2 commit b8ff8c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 3 additions & 8 deletions strategies/pancake-eth-usdc-sma.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,29 @@
# results.
trade-executor start \
--strategy-file=strategies/pancake-eth-usdc-sma.py \
--id=pancake-eth-usdc-sma \
--execution-type=backtest \
--trading-strategy-api-key=$TRADING_STRATEGY_API_KEY \
--cycle-duration=1d \
--stop-loss-check-frequency=1d \
--backtest-start=2021-06-01 \
--backtest-end=2022-09-01 \
--log-level=info
--backtest-end=2022-09-01
To backtest locally. This might take a long time depending on your CPU speed:
You can also do the full backtest run locally. This might take a long time depending on your CPU speed:
.. code-block:: shell
# Set your API key
export TRADING_STRATEGY_API_KEY=...
r
# Run the backtest of this module using local trade-executor command
# Tick size must match what the strategy is expecting
trade-executor start \
--strategy-file=strategies/pancake-eth-usdc-sma.py \
--id=pancake-eth-usdc-sma \
--execution-type=backtest \
--trading-strategy-api-key=$TRADING_STRATEGY_API_KEY \
--backtest-start=2021-06-01 \
--backtest-end=2022-09-01 \
--log-level=info
--backtest-end=2022-09-01
"""

Expand Down
8 changes: 7 additions & 1 deletion tradeexecutor/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def monkey_patch():
# Typer documentation https://typer.tiangolo.com/
@app.command()
def start(
id: str = typer.Option(None, envvar="EXECUTOR_ID", help="Executor id used when programmatically referring to this instance"),
id: str = typer.Option(None, envvar="EXECUTOR_ID", help="Executor id used when programmatically referring to this instance. If not given, take the base of --strategy-file."),
log_level: str = typer.Option(None, envvar="LOG_LEVEL", help="The Python default logging level. The defaults are 'info' is live execution, 'warning' if backtesting."),
name: Optional[str] = typer.Option(None, envvar="NAME", help="Executor name used in the web interface and notifications"),
short_description: Optional[str] = typer.Option(None, envvar="SHORT_DESCRIPTION", help="Short description for metadata"),
Expand Down Expand Up @@ -210,6 +210,12 @@ def start(
"""Launch Trade Executor instance."""
global logger

# Guess id from the strategy file
if not id:
if strategy_file:
name = os.path.basename(strategy_file)
id = Path(strategy_file).stem

check_good_id(id)

# We always need a name
Expand Down
2 changes: 1 addition & 1 deletion tradeexecutor/strategy/universe_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class UniverseOptions:
universe_options = UniverseOptions()
See
See :ref:`command-line-backtest` how these options are used.
"""

candle_time_bucket_override: Optional[TimeBucket] = None
Expand Down

0 comments on commit b8ff8c1

Please sign in to comment.