diff --git a/README-en.md b/README-en.md index a808f598..fdd3993f 100644 --- a/README-en.md +++ b/README-en.md @@ -63,7 +63,7 @@ Using the vn.py project, institutional investors and professional traders, such 3. RPC framework (vn.rpc) which also supports pushing data from server to client, aimed at implementing distributed trading systems. -4. Ready to use trading platform (vn.trader), which has intergrated all the trading APIs in vn.api, and provides easy to use strategy engines for developing different types of quantitative strategies and trading algorithms. +4. Ready to use trading platform (vn.trader), which has integrated all the trading APIs in vn.api, and provides easy to use strategy engines for developing different types of quantitative strategies and trading algorithms. 5. Tutorials about how to use vn.py to solve real world trading issues. diff --git a/examples/QuantosDataService/dataService.py b/examples/QuantosDataService/dataService.py index 470a3e16..4246f6d8 100644 --- a/examples/QuantosDataService/dataService.py +++ b/examples/QuantosDataService/dataService.py @@ -27,6 +27,8 @@ config = open('config.json') setting = json.load(config) config.close() + + MONGO_HOST = setting['MONGO_HOST'] MONGO_PORT = setting['MONGO_PORT'] SYMBOLS = setting['SYMBOLS'] @@ -57,6 +59,18 @@ def generateVtBar(row): bar.date = str(row['trade_date']) bar.time = str(row['time']).rjust(6, '0') + + #将bar的时间改成提前一分钟 + hour=bar.time[0:2] + minute=bar.time[2:4] + sec=bar.time[4:6] + if minute=="00": + minute="59" + hour=str(int(hour)-1).rjust(2,'0') + else: + minute=str(int(minute)-1).rjust(2,'0') + bar.time=hour+minute+sec + bar.datetime = datetime.strptime(' '.join([bar.date, bar.time]), '%Y%m%d %H%M%S') return bar diff --git a/vnpy/trader/vtEngine.py b/vnpy/trader/vtEngine.py index b3c0482e..41430b44 100644 --- a/vnpy/trader/vtEngine.py +++ b/vnpy/trader/vtEngine.py @@ -819,12 +819,18 @@ class PositionDetail(object): cost = self.longPrice * self.longPos cost += trade.volume * trade.price newPos = self.longPos + trade.volume - self.longPrice = cost / newPos + if newPos: + self.longPrice = cost / newPos + else: + self.longPrice = 0 else: cost = self.shortPrice * self.shortPos cost += trade.volume * trade.price newPos = self.shortPos + trade.volume - self.shortPrice = cost / newPos + if newPos: + self.shortPrice = cost / newPos + else: + self.shortPrice = 0 #---------------------------------------------------------------------- def calculatePosition(self):