This commit is contained in:
vn.py 2018-08-05 22:44:00 +08:00
parent 030e448d37
commit c430bc93c6
3 changed files with 21 additions and 20 deletions

View File

@ -12,7 +12,7 @@ from vnpy.trader.uiMainWindow import MainWindow
from vnpy.trader.gateway import futuGateway
# 加载上层应用
from vnpy.trader.app import riskManager#, ctaStrategy
from vnpy.trader.app import riskManager, ctaStrategy
#----------------------------------------------------------------------
@ -32,7 +32,7 @@ def main():
# 添加上层应用
me.addApp(riskManager)
#me.addApp(ctaStrategy)
me.addApp(ctaStrategy)
# 创建主窗口
mw = MainWindow(me, ee)

View File

@ -3,5 +3,5 @@
"mdAddress": "tcp://180.168.146.187:10031",
"tdAddress": "tcp://180.168.146.187:10030",
"userID": "000300",
"password": "19890624"
"password": "123456789"
}

View File

@ -84,23 +84,24 @@ def loadMcCsv(fileName, dbName, symbol):
collection.ensure_index([('datetime', pymongo.ASCENDING)], unique=True)
# 读取数据和插入到数据库
reader = csv.DictReader(file(fileName, 'r'))
for d in reader:
bar = VtBarData()
bar.vtSymbol = symbol
bar.symbol = symbol
bar.open = float(d['Open'])
bar.high = float(d['High'])
bar.low = float(d['Low'])
bar.close = float(d['Close'])
bar.date = datetime.strptime(d['Date'], '%Y-%m-%d').strftime('%Y%m%d')
bar.time = d['Time']
bar.datetime = datetime.strptime(bar.date + ' ' + bar.time, '%Y%m%d %H:%M:%S')
bar.volume = d['TotalVolume']
with open(fileName, 'r') as f:
reader = csv.DictReader(f)
for d in reader:
bar = VtBarData()
bar.vtSymbol = symbol
bar.symbol = symbol
bar.open = float(d['Open'])
bar.high = float(d['High'])
bar.low = float(d['Low'])
bar.close = float(d['Close'])
bar.date = datetime.strptime(d['Date'], '%Y-%m-%d').strftime('%Y%m%d')
bar.time = d['Time']
bar.datetime = datetime.strptime(bar.date + ' ' + bar.time, '%Y%m%d %H:%M:%S')
bar.volume = d['TotalVolume']
flt = {'datetime': bar.datetime}
collection.update_one(flt, {'$set':bar.__dict__}, upsert=True)
print(bar.date, bar.time)
flt = {'datetime': bar.datetime}
collection.update_one(flt, {'$set':bar.__dict__}, upsert=True)
print(bar.date, bar.time)
print(u'插入完毕,耗时:%s' % (time()-start))