Modifies python example algorithms to show implicit convertion benefits

This commit is contained in:
AlexCatarino
2017-06-15 18:40:34 +01:00
parent 6ca9d7cf14
commit 6242706342
22 changed files with 189 additions and 212 deletions
@@ -41,18 +41,17 @@ class CustomDataBitcoinAlgorithm(QCAlgorithm):
# Define the symbol and "type" of our generic data:
self.AddData(Bitcoin, "BTC")
self.btc = self.Securities["BTC"].Symbol
def OnData(self, data):
if self.btc not in data: return
if "BTC" not in data: return
close = data[self.btc].Close
close = data["BTC"].Close
# If we don't have any weather "SHARES" -- invest"
if not self.Portfolio.Invested:
# Weather used as a tradable asset, like stocks, futures etc.
self.SetHoldings(self.btc, 1)
self.SetHoldings("BTC", 1)
self.Debug("Buying BTC 'Shares': BTC: {0}".format(close))
self.Debug("Time: {0} {1}".format(datetime.now(), close))