Fixes python algorithm to be python 3 compliant

This commit is contained in:
AlexCatarino
2018-02-02 15:07:00 +00:00
parent a02553c524
commit 84282503d0
49 changed files with 117 additions and 132 deletions
+4 -8
View File
@@ -13,16 +13,12 @@
from clr import AddReference
AddReference("System")
AddReference("System.Collections")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Indicators")
AddReference("QuantConnect.Common")
from System import *
from System.Collections.Generic import List
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
import numpy as np
import decimal as d
@@ -46,7 +42,7 @@ class CustomChartingAlgorithm(QCAlgorithm):
self.AddEquity("SPY", Resolution.Daily)
# In your initialize method:
# Chart - Master Container for the Chart:
# Chart - Master Container for the Chart:
stockPlot = Chart("Trade Plot")
# On the Trade Plotter Chart we want 3 series: trades and price:
stockPlot.AddSeries(Series("Buy", SeriesType.Scatter, 0))
@@ -71,8 +67,8 @@ class CustomChartingAlgorithm(QCAlgorithm):
self.lastPrice = slice["SPY"].Close
if self.fastMA == 0: self.fastMA = self.lastPrice
if self.slowMA == 0: self.slowMA = self.lastPrice
self.fastMA = (d.Decimal(0.01) * self.lastPrice) + (d.Decimal(0.99) * self.fastMA);
self.slowMA = (d.Decimal(0.001) * self.lastPrice) + (d.Decimal(0.999) * self.slowMA);
self.fastMA = (d.Decimal(0.01) * self.lastPrice) + (d.Decimal(0.99) * self.fastMA)
self.slowMA = (d.Decimal(0.001) * self.lastPrice) + (d.Decimal(0.999) * self.slowMA)
if self.Time > self.resample:
self.resample = self.Time + self.resamplePeriod
@@ -89,4 +85,4 @@ class CustomChartingAlgorithm(QCAlgorithm):
def OnEndOfDay(self):
#Log the end of day prices:
self.Plot("Trade Plot", "Price", self.lastPrice);
self.Plot("Trade Plot", "Price", self.lastPrice)