quantconnect - 打印问题或未定义变量
问题描述
我有这个代码类 Main(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2012, 1, 1)
self.SetEndDate(2020, 1, 1)
self.SetCash(100000)
self.dji = self.AddEquity("DJI", Resolution.Daily).Symbol
self.AddEquity("IBM", Resolution.Hour) ## Subscribe to hourly TradeBars
def OnData(self, data):
## You can access the TradeBar dictionary in the slice object and then subset by symbol
## to get the TradeBar for IBM
tradeBars = data.Bars
ibmTradeBar = tradeBars['IBM']
ibmOpen = ibmTradeBar.Open ## Open price
ibmClose = ibmTradeBar.Close ## Close price
## Or you can access the IBM TradeBar by directly subsetting the slice object
## (since you are subscribed to IBM equity data, this will return a TradeBar rather than a QuoteBar)
##ibmOpen = data['IBM'].Open ## Open price
##imbClose = data['IBM'].Close ## Close price
ibmmove = "100*(imbClose-ibmOpen)/ibmOpen"
print(ibmmove)
它完全忽略了打印语句,如果我减少缩进,我会得到 ibmmove 未定义
解决方案
推荐阅读
- firebase - 为什么在 Kotlin 中迭代 firebase 数据库时元素值添加了两次?
- mysql - MySQL GROUP_CONCAT 与内部 CONCAT 剪切值?无关紧要的结果
- google-sheets - 谷歌表格将单元格组合成标准
- authentication - 两因素身份验证不起作用:SMS 没有联系到我
- java - 在 DialogFlow (api.ai) Android SDK 中增加监听超时
- javascript - 将 JS 文件与 firefox-addon 一起使用时的内容安全策略问题
- angularjs - 如何在提交表单上传递更改数据切换值
- video - 带有表情符号的 FFMPEG drawtext
- scala - 在数据框火花中使用爆炸功能
- mysql - 使用 mysql-workbench 时“在此位置创建无效输入”