mhallsmoore / qstrader

QuantStart.com - QSTrader backtesting simulation engine.
https://www.quantstart.com/qstrader/
MIT License
2.84k stars 851 forks source link

6040py #322

Closed tomahawktom closed 4 years ago

tomahawktom commented 4 years ago

Hi I installed qsttrader and wanted to try the sample example of 60/40. However, after running the file on jupyter, it ended into an error which i have searched and tried various solution, including updating the pyinstaller etc. but it is still stuck there. Believe that it got stuck at this portion. Could someone help me please?

~\anaconda3\envs\trader\lib\ntpath.py in join(path, paths) 74 # Join two (or more) paths. 75 def join(path, paths): ---> 76 path = os.fspath(path) 77 if isinstance(path, bytes): 78 sep = b'\'

TypeError: expected str, bytes or os.PathLike object, not NoneType

Thought that this is a solution but after updating my package it still iddn't run

https://github.com/pyinstaller/pyinstaller/issues/4200

mhallsmoore commented 4 years ago

Hi @tomahawktom,

Thanks for your question.

At first glance this seems like this could be due to Jupyter not picking up the QSTRADER_CSV_DATA_DIR environment variable and thus not finding the Yahoo Finance CSV data for SPY and AGG.

I'm actually planning for the next version (0.1.1) to default to looking in the same directory as the example scripts for the CSV files to make the 'quick start' easier and to ensure that this issue doesn't arise.

However, as a 'quick fix' for now, what you may be able to do is modify the sixty_forty.py file at line 26 (https://github.com/mhallsmoore/qstrader/blob/master/examples/sixty_forty.py#L26) from:

csv_dir = os.environ.get('QSTRADER_CSV_DATA_DIR')

to:

csv_dir = '.'

Which tells the script to look for the Yahoo Finance files in the same directory as sixty_forty.py. Of course, this will require that the CSV data files for SPY and AGG are placed in that directory!

This may not actually be the underlying problem. If you still receive the same error I will try and replicate the Jupyter error and see if I can determine a fix.

Kind regards,

Mike.

tomahawktom commented 4 years ago

Thanks Mike, that works but I think the initial code is more elegant, reference to a master data folder. I'll look forward to your next version

mhallsmoore commented 4 years ago

Hi @tomahawktom,

No problem! I released v0.1.1 last night and I actually went with this as the solution:

csv_dir = os.environ.get('QSTRADER_CSV_DATA_DIR', '.')

This essentially says to check for the presence of QSTRADER_CSV_DATA_DIR and if not found default to the current working directory.

Kind regards,

Mike.