本文整理汇总了Python中position.Position.calculate_profit方法的典型用法代码示例。如果您正苦于以下问题:Python Position.calculate_profit方法的具体用法?Python Position.calculate_profit怎么用?Python Position.calculate_profit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类position.Position
的用法示例。
在下文中一共展示了Position.calculate_profit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import calculate_profit [as 别名]
def execute(tick, account, signals):
#create positions
for signal in signals:
#open
if signal.order_type == OPEN:
units = account.risk()
pos = Position(signal.pair, signal.direction, tick.datetime, units)
pos.open(tick.datetime, tick.bid, tick.ask)
account.positions.append(pos)
#close
if signal.order_type == CLOSE:
for pos in account.positions:
if signal.pair == pos.pair and signal.direction == pos.direction:
pos.close(tick.datetime, tick.bid, tick.ask)
pos.calculate_profit()
print pos
account.settle(pos)
print account
return []