Fix timestamps in custom data algorithms (#5426)

* Correct custom data timestamp and match performance across languages

* Add EndTime property

* Add comment for crypto SetHoldings
This commit is contained in:
Derek Melchin
2021-03-30 15:48:59 -06:00
committed by GitHub
parent 4a1485a291
commit 5ed61db2bb
8 changed files with 51 additions and 37 deletions
+3 -1
View File
@@ -72,7 +72,7 @@ class CustomDataNIFTYAlgorithm(QCAlgorithm):
if self.Time.weekday() != 2: return
cur_qnty = self.Portfolio["NIFTY"].Quantity
quantity = math.floor(self.Portfolio.MarginRemaining * 0.9) / data["NIFTY"].Close
quantity = int(self.Portfolio.MarginRemaining * 0.9 / data["NIFTY"].Close)
hi_nifty = max(price.NiftyPrice for price in self.prices)
lo_nifty = min(price.NiftyPrice for price in self.prices)
@@ -103,6 +103,7 @@ class Nifty(PythonData):
# 2011-09-13 7792.9 7799.9 7722.65 7748.7 116534670 6107.78
data = line.split(',')
index.Time = datetime.strptime(data[0], "%Y-%m-%d")
index.EndTime = index.Time + timedelta(days=1)
index.Value = data[4]
index["Open"] = float(data[1])
index["High"] = float(data[2])
@@ -132,6 +133,7 @@ class DollarRupee(PythonData):
try:
data = line.split(',')
currency.Time = datetime.strptime(data[0], "%Y-%m-%d")
currency.EndTime = currency.Time + timedelta(days=1)
currency.Value = data[1]
currency["Close"] = float(data[1])