Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifiy your own data file should load the data but fails due to variable problem #6

Closed
lleewwiiss opened this issue Nov 7, 2021 · 2 comments

Comments

@lleewwiiss
Copy link

Describe the bug
When specifying your own data file the AutoTrader initialisation fails due to a variable being referenced before the assignment.

To Reproduce
Steps to reproduce the behavior:

  1. Create a run file with any of the example strategies
  2. add your data file e.g. at.data_file = "ftx_data.csv"
  3. Run the backtesting
  4. See error:
    UnboundLocalError: local variable 'MTF_data' referenced before assignment

Expected behavior
Support for local files

Screenshots
n/a

Additional context
Additionally is there any planned support for MTF local files? Possibly specifying a dictionary e.g.

at.data_files = {'5m': '5m_data.csv', '4h': '4hr_data.csv'}

Or can create a csv that encapsulates this same structure, but might be harder to initialise consistently. Using version 0.4.27

@kieran-mackle
Copy link
Owner

kieran-mackle commented Nov 8, 2021

Hi Lewis, thanks for pointing this out, it slipped through when I first added MTF capability and rarely used local data files.

I've fixed this now, so if you update to version 0.5.4 it should work as expected.

Great suggestion! I have also added that in. The method you suggested is perfect, but I have changed the attribute name to 'MTF_data_files'. So, to import MTF data, you would use the following:

at.MTF_data_files = {'5m': '5m_data.csv', '4h': '4hr_data.csv'}

Thanks! Closing this issue now.

@kieran-mackle
Copy link
Owner

To anyone reading this issue, please note that as of AutoTrader v0.5.21, the preferred method of specifying local data files (both single timeframe and mult-timeframe) is the add_data method, documented here. This method allows providing price data from custom directories (outside of the project directory), as well as providing data for multi-instrument backtests.

Nonetheless, the methods discussed in the comments above are still functional.

kieran-mackle added a commit that referenced this issue Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants