nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
1.7k stars 400 forks source link

Highlevel api tutorial document bugs #1678

Closed Leonz5288 closed 1 month ago

Leonz5288 commented 1 month ago
  1. https://github.com/nautechsystems/nautilus_trader/blob/3d8543c9a033677939d73f68d2766d172ee5f3d8/docs/tutorials/backtest_high_level.md?plain=1#L66 format here should be datetime_format in consistent with below otherwise error will be reported. https://github.com/nautechsystems/nautilus_trader/blob/3d8543c9a033677939d73f68d2766d172ee5f3d8/nautilus_trader/persistence/loaders.py#L28-L32

  2. https://github.com/nautechsystems/nautilus_trader/blob/3d8543c9a033677939d73f68d2766d172ee5f3d8/docs/tutorials/backtest_high_level.md?plain=1#L67 The dataset I downloaded from the source suggested in tutorial have three columns instead of two suggested here. So need another column name after ask_price here. Not sure if all datasets are consistent in this tho.

  3. https://github.com/nautechsystems/nautilus_trader/blob/3d8543c9a033677939d73f68d2766d172ee5f3d8/docs/tutorials/backtest_high_level.md?plain=1#L140-L148 The .value should be deleted here because some operations in loading data are treating instrument id as object instead of str. Otherwise errors will be thrown as below

    Traceback (most recent call last):
    File "/Users/leon5288/code/nautilus_trader/try/test1.py", line 88, in <module>
    node = BacktestNode(configs=[config])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/leon5288/code/nautilus_trader/nautilus_trader/backtest/node.py", line 75, in __init__
    self._validate_configs(configs)
    File "/Users/leon5288/code/nautilus_trader/nautilus_trader/backtest/node.py", line 186, in _validate_configs
    if instrument_id.venue not in venue_ids:
       ^^^^^^^^^^^^^^^^^^^
    AttributeError: 'str' object has no attribute 'venue'

    The catalog_path here is a bit of confusing because following the tutorial we have defined a CATALOG_PATH that we can use directly but here is using an environment variable that wasn't mentioned before. Could change this to CATALOG_PATH to make the tutorial clearer? Just a suggestion.

I'm happy to create a pull request if these errors are confirmed.

cjdsellers commented 1 month ago

Hey @Leonz5288

Thanks for the report on these errors.

I've gone ahead and fixed these on develop and credited you in the release notes. The nightly branch will be merged later today which is when the changes will be reflected on the docs site.

On your point 2, the two columns are fine at a minimum, as the timestamp is the index.

Part of the issue here is we don't have a good docs testing story, and because these code snippets are buried under docs/ in markdown, they aren't run.

There's a few options to improve this such as converting these to runnable jupyter notebooks or code modules which can then be inserted into the markdown at docs build time. It's just a matter of time before this improves.