commit
e94680f497
@ -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.
|
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.
|
5. Tutorials about how to use vn.py to solve real world trading issues.
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ config = open('config.json')
|
|||||||
setting = json.load(config)
|
setting = json.load(config)
|
||||||
config.close()
|
config.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MONGO_HOST = setting['MONGO_HOST']
|
MONGO_HOST = setting['MONGO_HOST']
|
||||||
MONGO_PORT = setting['MONGO_PORT']
|
MONGO_PORT = setting['MONGO_PORT']
|
||||||
SYMBOLS = setting['SYMBOLS']
|
SYMBOLS = setting['SYMBOLS']
|
||||||
@ -57,6 +59,18 @@ def generateVtBar(row):
|
|||||||
|
|
||||||
bar.date = str(row['trade_date'])
|
bar.date = str(row['trade_date'])
|
||||||
bar.time = str(row['time']).rjust(6, '0')
|
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')
|
bar.datetime = datetime.strptime(' '.join([bar.date, bar.time]), '%Y%m%d %H%M%S')
|
||||||
|
|
||||||
return bar
|
return bar
|
||||||
|
@ -819,12 +819,18 @@ class PositionDetail(object):
|
|||||||
cost = self.longPrice * self.longPos
|
cost = self.longPrice * self.longPos
|
||||||
cost += trade.volume * trade.price
|
cost += trade.volume * trade.price
|
||||||
newPos = self.longPos + trade.volume
|
newPos = self.longPos + trade.volume
|
||||||
self.longPrice = cost / newPos
|
if newPos:
|
||||||
|
self.longPrice = cost / newPos
|
||||||
|
else:
|
||||||
|
self.longPrice = 0
|
||||||
else:
|
else:
|
||||||
cost = self.shortPrice * self.shortPos
|
cost = self.shortPrice * self.shortPos
|
||||||
cost += trade.volume * trade.price
|
cost += trade.volume * trade.price
|
||||||
newPos = self.shortPos + trade.volume
|
newPos = self.shortPos + trade.volume
|
||||||
self.shortPrice = cost / newPos
|
if newPos:
|
||||||
|
self.shortPrice = cost / newPos
|
||||||
|
else:
|
||||||
|
self.shortPrice = 0
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def calculatePosition(self):
|
def calculatePosition(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user