Hello!
I want to develop an algorithm for trading Bitcoins. For this purpose I need to import the data.
According to the documentation ( https://www.quantconnect.com/docs#python ) you need to create your own class (subclass of PythonData) in order to access custom data. That subclass must override the GetSource and Reader methods:
class Weather(PythonData):
''' Weather based rebalancing'''
def GetSource(self, config, date, isLive):
source = "https://www.wunderground.com/history/airport/{0}/{1}/1/1/CustomHistory.html?dayend=31&monthend=12&yearend={1}&format=1".format(config.Symbol, date.year);
return SubscriptionDataSource(source, SubscriptionTransportMedium.RemoteFile);
def Reader(self, config, line, date, isLive):
# If first character is not digit, pass
if not (line.strip() and line[0].isdigit()): return None
data = line.split(',')
weather = Weather()
weather.Symbol = config.Symbol
weather.Time = datetime.strptime(data[0], '%Y-%m-%d') + timedelta(hours=20) # Make sure we only get this data AFTER trading day - don't want forward bias.
weather.Value = decimal.Decimal(data[2])
weather["MaxC"] = float(data[1])
weather["MinC"] = float(data[3])
return weather
However, this seems to be a CSV data source, whereas the Quandl Bitcoin data are in JSON format.
What do I need to do in order to be able to use Quandl Bitcoin data in QuantConnect for backtesting?
I found a class PythonQuandl.cs in the same directory as PythonData, but unfortunately no documentation on how to use it.
Thanks in advance
Dmitri Pisarenko
Alexandre Catarino
Please checkout CustomDataRegressionAlgorithm.
It is an example using CSV data from Quandl and JSON data from BitStamp.
Petio Petrov
Hello,
Is there an example of subclassing PythonData for option chains?
Thank you
Shile Wen
Hi Petio,
We have built-in support for option chain data here.
Best,
Shile Wen
Petio Petrov
Thanks Shile, but I was refering to adding custom options data by implementing the `PythonData` class.
Alexandre Catarino
Hi Petio Petrov ,
There is no example of subclassing PythonData to create options data since QuantConnect supports that data.
It should be implemented similarly to the example above.
Please note that options have some particularities that are handled under-the-hood by the algorithm that will not work with a custom data type.
Dmitri Pisarenko
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!