day0market / pyalgotrader

Python algotrading framework with UI. Backtesting and Live trading. Crypto and US broker connectors
Other
137 stars 55 forks source link

Downloading historical data in CTA backtesting module does not work #4

Open chiefirr opened 5 years ago

chiefirr commented 5 years ago

I am trying to run backtesting module, using GUI. But when I select default IF88.CEFEX ticker - it fails to find the data, Same is for AAPL.NYMEX.

- 09:18:34  initialization CTA backtesting engine
- 09:18:34  strategy file loaded  
- 09:18:50  ----------------------------------------  
- 09:18:50  IF88.CFFEX-1m start downloading historical data  
- 09:18:50   data download failed , unable to get IF88.CFFEX historical data 
- 09:19:13  ----------------------------------------  
- 09:19:13  AAPL.NYMEX-1m start downloading historical data 
- 09:23:40   data download failed , unable to get AAPL.NYMEX historical data 

I am using Alpaca paper trading brocker. What is a proper way to fetch the data for selected stock and to start backtesting?

day0market commented 5 years ago

Note: I didn't test it with Alpaca.

You should specify symbol in following format: {ticker}.{gatewayname}. In case of AAPL and Alpaca symbol would be AAPL.ALPACA

Also make sure you're connected to Alpaca. If not go to main window -> system -> Alpaca, add your creds and connect

chiefirr commented 5 years ago

Yeah, I have connected to Alpaca and did as you said AAPL.ALPACA - it results with error in a console:

-   File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
-     self.run()
-   File "/usr/lib/python3.7/threading.py", line 865, in run
-     self._target(*self._args, **self._kwargs)
-   File "/home/andrii/PycharmProjects/ch-trading-platform/venv/lib/python3.7/site-packages/pyalgotrader-2.0.7-py3.7.egg/vnpy/app/cta_backtester/engine.py", line 345, in run_downloading
-     symbol, exchange = extract_vt_symbol(vt_symbol)
-   File "/home/andrii/PycharmProjects/ch-trading-platform/venv/lib/python3.7/site-packages/pyalgotrader-2.0.7-py3.7.egg/vnpy/trader/utility.py", line 22, in extract_vt_symbol
-     return symbol, Exchange(exchange_str)
-   File "/usr/lib/python3.7/enum.py", line 310, in __call__
-     return cls.__new__(cls, value)
-   File "/usr/lib/python3.7/enum.py", line 564, in __new__
-     raise exc
-   File "/usr/lib/python3.7/enum.py", line 548, in __new__
-     result = cls._missing_(value)
-   File "/usr/lib/python3.7/enum.py", line 577, in _missing_
-     raise ValueError("%r is not a valid %s" % (value, cls.__name__))
- ValueError: 'ALPACA' is not a valid Exchange