Fix: Broken Regression Algorithms (#8366)
* fix: CustomData/RegisterIndicator-RegressionAlgorithm * fix: CustomDataPropertiesRegressionAlgorithm * fix: CustomDataRegressionAlgorithm py * fix: CustomDataPropertiesRegressionAlgorithm py * fix: RegisterIndicatorRegressionAlgorithm py * refactror: use nasdaq instead of quandl in proxy url
This commit is contained in:
@@ -25,8 +25,8 @@ class CustomDataRegressionAlgorithm(QCAlgorithm):
|
||||
|
||||
def initialize(self):
|
||||
|
||||
self.set_start_date(2011,9,14) # Set Start Date
|
||||
self.set_end_date(2015,12,1) # Set End Date
|
||||
self.set_start_date(2020,1,5) # Set Start Date
|
||||
self.set_end_date(2020,1,10) # Set End Date
|
||||
self.set_cash(100000) # Set Strategy Cash
|
||||
|
||||
resolution = Resolution.SECOND if self.live_mode else Resolution.DAILY
|
||||
@@ -54,7 +54,7 @@ class CustomDataRegressionAlgorithm(QCAlgorithm):
|
||||
raise ValueError("Security was not warmed up!")
|
||||
|
||||
class Bitcoin(PythonData):
|
||||
'''Custom Data Type: Bitcoin data from Quandl - http://www.quandl.com/help/api-for-bitcoin-data'''
|
||||
'''Custom Data Type: Bitcoin data from Quandl - https://data.nasdaq.com/databases/BCHAIN'''
|
||||
|
||||
def get_source(self, config, date, is_live_mode):
|
||||
if is_live_mode:
|
||||
@@ -62,7 +62,9 @@ class Bitcoin(PythonData):
|
||||
|
||||
#return "http://my-ftp-server.com/futures-data-" + date.to_string("Ymd") + ".zip"
|
||||
# OR simply return a fixed small data file. Large files will slow down your backtest
|
||||
return SubscriptionDataSource("https://www.quantconnect.com/api/v2/proxy/quandl/api/v3/datasets/BCHARTS/BITSTAMPUSD.csv?order=asc&api_key=WyAazVXnq7ATy_fefTqm", SubscriptionTransportMedium.REMOTE_FILE)
|
||||
subscription = SubscriptionDataSource("https://www.quantconnect.com/api/v2/proxy/nasdaq/api/v3/datatables/QDL/BITFINEX.csv?code=BTCUSD&api_key=WyAazVXnq7ATy_fefTqm")
|
||||
subscription.Sort = True
|
||||
return subscription
|
||||
|
||||
|
||||
def reader(self, config, line, date, is_live_mode):
|
||||
@@ -95,22 +97,22 @@ class Bitcoin(PythonData):
|
||||
return None
|
||||
|
||||
# Example Line Format:
|
||||
# Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price
|
||||
# 2011-09-13 5.8 6.0 5.65 5.97 58.37138238, 346.0973893944 5.929230648356
|
||||
if not (line.strip() and line[0].isdigit()): return None
|
||||
# code date high low mid last bid ask volume
|
||||
# BTCUSD 2024-10-08 63248.0 61940.0 62246.5 62245.0 62246.0 62247.0 477.91102114
|
||||
if not (line.strip() and line[7].isdigit()): return None
|
||||
|
||||
try:
|
||||
data = line.split(',')
|
||||
coin.time = datetime.strptime(data[0], "%Y-%m-%d")
|
||||
coin.time = datetime.strptime(data[1], "%Y-%m-%d")
|
||||
coin.end_time = coin.time + timedelta(days=1)
|
||||
coin.value = float(data[4])
|
||||
coin["Open"] = float(data[1])
|
||||
coin.value = float(data[5])
|
||||
coin["High"] = float(data[2])
|
||||
coin["Low"] = float(data[3])
|
||||
coin["Close"] = float(data[4])
|
||||
coin["VolumeBTC"] = float(data[5])
|
||||
coin["VolumeUSD"] = float(data[6])
|
||||
coin["WeightedPrice"] = float(data[7])
|
||||
coin["Mid"] = float(data[4])
|
||||
coin["Close"] = float(data[5])
|
||||
coin["Bid"] = float(data[6])
|
||||
coin["Ask"] = float(data[7])
|
||||
coin["VolumeBTC"] = float(data[8])
|
||||
return coin
|
||||
|
||||
except ValueError:
|
||||
|
||||
Reference in New Issue
Block a user