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.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(riskManager)
#me.addApp(ctaStrategy) me.addApp(ctaStrategy)
# 创建主窗口 # 创建主窗口
mw = MainWindow(me, ee) mw = MainWindow(me, ee)

View File

@ -3,5 +3,5 @@
"mdAddress": "tcp://180.168.146.187:10031", "mdAddress": "tcp://180.168.146.187:10031",
"tdAddress": "tcp://180.168.146.187:10030", "tdAddress": "tcp://180.168.146.187:10030",
"userID": "000300", "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) collection.ensure_index([('datetime', pymongo.ASCENDING)], unique=True)
# 读取数据和插入到数据库 # 读取数据和插入到数据库
reader = csv.DictReader(file(fileName, 'r')) with open(fileName, 'r') as f:
for d in reader: reader = csv.DictReader(f)
bar = VtBarData() for d in reader:
bar.vtSymbol = symbol bar = VtBarData()
bar.symbol = symbol bar.vtSymbol = symbol
bar.open = float(d['Open']) bar.symbol = symbol
bar.high = float(d['High']) bar.open = float(d['Open'])
bar.low = float(d['Low']) bar.high = float(d['High'])
bar.close = float(d['Close']) bar.low = float(d['Low'])
bar.date = datetime.strptime(d['Date'], '%Y-%m-%d').strftime('%Y%m%d') bar.close = float(d['Close'])
bar.time = d['Time'] bar.date = datetime.strptime(d['Date'], '%Y-%m-%d').strftime('%Y%m%d')
bar.datetime = datetime.strptime(bar.date + ' ' + bar.time, '%Y%m%d %H:%M:%S') bar.time = d['Time']
bar.volume = d['TotalVolume'] 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) flt = {'datetime': bar.datetime}
print(bar.date, bar.time) collection.update_one(flt, {'$set':bar.__dict__}, upsert=True)
print(bar.date, bar.time)
print(u'插入完毕,耗时:%s' % (time()-start)) print(u'插入完毕,耗时:%s' % (time()-start))