Skip to content

Commit

Permalink
Extend unit tests and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonabreul committed May 7, 2024
1 parent 5c85bbd commit 8f9333e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Usage: lean backtest [OPTIONS] PROJECT
Options:
--output DIRECTORY Directory to store results in (defaults to PROJECT/backtests/TIMESTAMP)
-d, --detach Run the backtest in a detached Docker container and return immediately
--debug [pycharm|ptvsd|vsdbg|rider|local-platform]
--debug [pycharm|ptvsd|debugpy|vsdbg|rider|local-platform]
Enable a certain debugging method (see --help for more information)
--data-provider-historical [Interactive Brokers|Oanda|Bitfinex|Coinbase Advanced Trade|Binance|Kraken|IQFeed|Polygon|FactSet|IEX|AlphaVantage|CoinApi|ThetaData|QuantConnect|Local|Terminal Link|Bybit]
Update the Lean configuration file to retrieve data from the given historical provider
Expand Down
2 changes: 1 addition & 1 deletion lean/commands/backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _migrate_csharp_csproj(project_dir: Path) -> None:
default=False,
help="Run the backtest in a detached Docker container and return immediately")
@option("--debug",
type=Choice(["pycharm", "ptvsd", "vsdbg", "rider", "local-platform"], case_sensitive=False),
type=Choice(["pycharm", "ptvsd", "debugpy", "vsdbg", "rider", "local-platform"], case_sensitive=False),
help="Enable a certain debugging method (see --help for more information)")
@option("--data-provider-historical",
type=Choice([dp.get_name() for dp in cli_data_downloaders], case_sensitive=False),
Expand Down
7 changes: 5 additions & 2 deletions tests/commands/test_backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ def _ensure_rider_debugger_config_files_exist(project_dir: Path) -> None:
("PTVSD", DebuggingMethod.PTVSD),
("vsdbg", DebuggingMethod.VSDBG),
("VSDBG", DebuggingMethod.VSDBG),
("debugpy", DebuggingMethod.DebugPy),
("DebugPy", DebuggingMethod.DebugPy),
("rider", DebuggingMethod.Rider),
("Rider", DebuggingMethod.Rider)])
def test_backtest_passes_correct_debugging_method_to_lean_runner(value: str, debugging_method: DebuggingMethod) -> None:
Expand Down Expand Up @@ -348,7 +350,8 @@ def test_backtest_auto_updates_outdated_python_pycharm_debug_config() -> None:
assert workspace_xml.find(".//mapping[@remote-root='/Lean/Launcher/bin/Debug']") is None


def test_backtest_auto_updates_outdated_python_vscode_debug_config() -> None:
@pytest.mark.parametrize("value", ["ptvsd", "debugpy"])
def test_backtest_auto_updates_outdated_python_vscode_debug_config(value) -> None:
create_fake_lean_cli_directory()

lean_config_manager = container.lean_config_manager
Expand Down Expand Up @@ -380,7 +383,7 @@ def test_backtest_auto_updates_outdated_python_vscode_debug_config() -> None:
]
}))

result = CliRunner().invoke(lean, ["backtest", "Python Project", "--debug", "ptvsd"])
result = CliRunner().invoke(lean, ["backtest", "Python Project", "--debug", value])

assert result.exit_code == 0

Expand Down

0 comments on commit 8f9333e

Please sign in to comment.