Back

How to import custom data in JSON format?

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
 

Update Backtest








Please checkout CustomDataRegressionAlgorithm.
It is an example using CSV data from Quandl and JSON data from BitStamp.

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed