qstrader icon indicating copy to clipboard operation
qstrader copied to clipboard

installation issue:

Open drazr432 opened this issue 8 years ago • 7 comments

os:windows 7

mkdir -p ~/venv/qstraderp3 cd ~/venv/qstraderp3 virtualenv --no-site-packages -p /usr/bin/python3 . source ~/venv/qstraderp3/bin/activate

i am getting a syntax command is in correct can you help.

drazr432 avatar Feb 18 '17 11:02 drazr432

Hi drazr,

This is because the commands you are using are designed for Linux, rather than Windows. I suggest you downloading Continuum Analytics Anaconda, which will make the installation significantly easier.

I will be adding comprehensive installation instructions for Windows in the near future.

Mike.

mhallsmoore avatar Feb 23 '17 11:02 mhallsmoore

I install QSTrader on my Windows 10 machine via Anaconda. Here's my process:

conda create --name qstrader
activate qstrader
pip install git+https://github.com/mhallsmoore/qstrader.git

This part works fine. But if I use pip install -r https://raw.githubusercontent.com/mhallsmoore/qstrader/master/requirements.txt it threw me errors, specifically, pyyaml package not found.

So I manually goes down the list in requirements.txt and use conda install <package-name> to isntall the individual packages one by one. However, some packages are not registered w/ Anaconda, e.g., pandas_datareader, requests_cache, pexpect. The other problematic package is enum34, where if I install using conda, it raised version conflict error (enum34 on Anaconda only works w/ python 2.7), so I had to install using pip install enum34 and hope for the best.

I've also cloned the whole qstrader repository instead of using wget to grab the data and examples.

Here I encountered a problem:

  1. buy_and_hold_backtest.py example states it uses SP500TR.csv, but in the actual code, it uses ticker "SPY"
  2. the code does not execute properly. I cloned the whole repository and there is indeed SPY.csv inside qstrader/data, and executing the code from qstrader/examples, it fails to find the CSV file.
Could not subscribe ticker SPY as no data CSV found for pricing.
Traceback (most recent call last):
  File "buy_and_hold_backtest.py", line 71, in <module>
    run(config, testing, tickers, filename)
  File "buy_and_hold_backtest.py", line 56, in run
    events_queue, title=title
  File "C:\Anaconda3\envs\qstrader\lib\site-packages\qstrader\trading_session\backtest.py", line 50, in __init__
    self._config_backtest()
  File "C:\Anaconda3\envs\qstrader\lib\site-packages\qstrader\trading_session\backtest.py", line 62, in _config_backtest
    end_date=self.end_date
  File "C:\Anaconda3\envs\qstrader\lib\site-packages\qstrader\price_handler\yahoo_daily_csv_bar.py", line 38, in __init__
    self.bar_stream = self._merge_sort_ticker_data()
  File "C:\Anaconda3\envs\qstrader\lib\site-packages\qstrader\price_handler\yahoo_daily_csv_bar.py", line 68, in _merge_sort_ticker_data
    df = pd.concat(self.tickers_data.values()).sort_index()
  File "C:\Anaconda3\envs\qstrader\lib\site-packages\pandas\tools\merge.py", line 1451, in concat
    copy=copy)
  File "C:\Anaconda3\envs\qstrader\lib\site-packages\pandas\tools\merge.py", line 1484, in __init__
    raise ValueError('No objects to concatenate')
ValueError: No objects to concatenate

Any help in getting the examples up and running will be greatly appreciated.

leehanchung avatar Feb 25 '17 00:02 leehanchung

@cnimativ have you ensured the config flag is passed to QSTrader correctly? It should be --config=<path-to-your-config>.yml. This file defines where QSTrader will be looking for your CSV data files.

Kinda seems to be a recurring issue so we should probably document that a bit more clearly.

Also yeah you are right, the README.md needs an update to refer to SPY.csv instead of SP500TR.csv

ryankennedyio avatar Feb 26 '17 02:02 ryankennedyio

@ryankennedyio Thank you for the help. I've looked into the issue. In the buy_and_hold_backtest.py, it did

    config = settings.from_file(
        settings.DEFAULT_CONFIG_FILENAME, testing
    )

I have no idea where DEFAULT_CONFIG_FILENAME resides, so I went into C:\Anaconda3\envs\qstrader\Lib\site-packages\qstrader and look at settings.py and found this line:

DEFAULT_CONFIG_FILENAME = '~/qstrader.yml'

But there's no qstrader.yml in the same directory where settings.py resides.

By the way, I cloned the whole package into my backtesting directory and ran buy_and_hold_backtest.py from there.

So how should I produce a DEFAULT_CONFIG_FILENAME .yml file to set my qstrader backtesting environment? The .travis.yml file in the qstrader package doesn't seem to be a config file w/ directory structures.

leehanchung avatar Mar 01 '17 20:03 leehanchung

@cnimativ -- I believe the default config file should be generated automatically in your home directory the first time that you try to run qstrader -- I haven't touched much of that side of things, maybe @mhallsmoore can chime in.

For reference, mine looks just like:

---
CSV_DATA_DIR: data
OUTPUT_DIR: out

i.e. data and out are directories in the same directory as my config file.

ryankennedyio avatar Mar 07 '17 22:03 ryankennedyio

@cnimativ The issue for us is that on windows the 'settings.py' file looks to the default path of the user (e.g., for me it was C:/Users/BMcDonie/qstrader.yml). If you run this code after importing os you will see where it's looking for the .yml file: os.path.expanduser('~/qstrader.yml')

So if we create the .yml file in that location, it should work. The .yml file needs to have the path to the data & out folders. Examples for the .yml file are below.

1st Example (data and out folders are in the 'test' environment within the qstrader site package) qstrader.yml (do not include quotes): "--- CSV_DATA_DIR: C:/Anaconda3/envs/test/lib/site-packages/qstrader/data OUTPUT_DIR: C:/Anaconda3/envs/test/lib/site-packages/qstrader/out"

2nd Example (data and out folders are stored separately from the qstrader package) qstrader.yml: "--- CSV_DATA_DIR: C:/my_python_lib/spyder_projects/qstrader/data OUTPUT_DIR: C:/my_python_lib/spyder_projects/qstrader/out"

------- Code Suggestion ------ I started to play around with the code to see if we could look in the specific environment site-packages/qstrader folder. Let me know what you think, it seems to work for me and allows me to put the qstrader.yml file into the qstrader site-packages folder.

Add another try statement after the first IOError in the settings.py file from the "from_file" function. To use this we need to import inspect.

except IOError:
    try:
        with open(os.path.dirname(inspect.getfile(inspect)) + '/site-packages/qstrader' + fname.strip('~')) as fd:
            conf = yaml.load(fd)
        conf = munchify(conf)
        return conf
    except IOError:
        print("A configuration file named '%s' is missing" % fname)

.....

BMcDonie avatar Mar 17 '17 14:03 BMcDonie

@BMcDonie, you saved my day! =)

drlima avatar Apr 07 '17 01:04 drlima