本文整理汇总了Python中vnpy.trader.vtObject.VtBarData.__dict__方法的典型用法代码示例。如果您正苦于以下问题:Python VtBarData.__dict__方法的具体用法?Python VtBarData.__dict__怎么用?Python VtBarData.__dict__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vnpy.trader.vtObject.VtBarData
的用法示例。
在下文中一共展示了VtBarData.__dict__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadBar
# 需要导入模块: from vnpy.trader.vtObject import VtBarData [as 别名]
# 或者: from vnpy.trader.vtObject.VtBarData import __dict__ [as 别名]
def loadBar(self, dbName, collectionName, days):
"""从数据库中读取Bar数据,startDate是datetime对象"""
startDate = self.today - timedelta(days)
d = {'datetime':{'$gte':startDate}}
barData = self.mainEngine.dbQuery(dbName, collectionName, d)
l = []
for d in barData:
bar = VtBarData()
bar.__dict__ = d
l.append(bar)
return l
示例2: loadBar
# 需要导入模块: from vnpy.trader.vtObject import VtBarData [as 别名]
# 或者: from vnpy.trader.vtObject.VtBarData import __dict__ [as 别名]
def loadBar(self, dbName, collectionName, days):
"""从数据库中读取Bar数据,startDate是datetime对象"""
print "%s.%s.%s" % (__name__, self.__class__.__name__, get_current_function_name())
startDate = self.today - timedelta(days)
d = {'datetime': {'$gte': startDate}}
barData = self.mainEngine.dbQuery(dbName, collectionName, d, 'datetime')
l = []
for d in barData:
bar = VtBarData()
bar.__dict__ = d
l.append(bar)
return l
示例3: loadBar
# 需要导入模块: from vnpy.trader.vtObject import VtBarData [as 别名]
# 或者: from vnpy.trader.vtObject.VtBarData import __dict__ [as 别名]
def loadBar(self, dbName, collectionName, days):
"""从数据库中读取Bar数据,startDate是datetime对象"""
# 优先尝试从RQData获取数据
if dbName == MINUTE_DB_NAME and collectionName.upper() in self.rqSymbolSet:
l = self.loadRqBar(collectionName, days)
return l
# 如果没有则从数据库中读取数据
startDate = self.today - timedelta(days)
d = {'datetime':{'$gte':startDate}}
barData = self.mainEngine.dbQuery(dbName, collectionName, d, 'datetime')
l = []
for d in barData:
bar = VtBarData()
bar.__dict__ = d
l.append(bar)
return l
示例4: loadData
# 需要导入模块: from vnpy.trader.vtObject import VtBarData [as 别名]
# 或者: from vnpy.trader.vtObject.VtBarData import __dict__ [as 别名]
def loadData(self):
"""加载数据"""
mc = MongoClient()
db = mc[DAILY_DB_NAME]
for vtSymbol in self.vtSymbolList:
flt = {'datetime':{'$gte':self.startDt,
'$lte':self.endDt}}
collection = db[vtSymbol]
cursor = collection.find(flt).sort('datetime')
for d in cursor:
bar = VtBarData()
bar.__dict__ = d
barDict = self.dataDict.setdefault(bar.datetime, OrderedDict())
barDict[bar.vtSymbol] = bar
self.output(u'%s数据加载完成,总数据量:%s' %(vtSymbol, cursor.count()))
self.output(u'全部数据加载完成')