MCPcopy Create free account
hub / github.com/QuantFans/quantdigger / Transaction

Class Transaction

quantdigger/kernel/datastruct.py:92–166  ·  view source on GitHub ↗

成交记录。 :ivar id: 成交编号 :vartype id: :class:`OrderID` :ivar contract: 合约。 :vartype contract: :class:`Contract` :ivar direction: 多空方向。 :vartype direction: :class:`Direction` :ivar price: 成交价格。 :vartype price: float :ivar quantity: 成交数量。 :vartype quantity:

Source from the content-addressed store, hash-verified

90
91
92class Transaction(object):
93 """ 成交记录。
94
95 :ivar id: 成交编号
96 :vartype id: :class:`OrderID`
97
98 :ivar contract: 合约。
99 :vartype contract: :class:`Contract`
100
101 :ivar direction: 多空方向。
102 :vartype direction: :class:`Direction`
103
104 :ivar price: 成交价格。
105 :vartype price: float
106
107 :ivar quantity: 成交数量。
108 :vartype quantity: float
109
110 :ivar side: 开平仓标志。
111 :vartype side: :class:`TradeSide`
112
113 :ivar datetime: 成交时间
114 :vartype datetime: :class:`datetime`
115
116 :ivar price_type: 下单类型。
117 :vartype price_type: :class:`PriceType`
118
119 :ivar commission: 佣金百分比
120 :vartype commission: float
121
122 :ivar assure_ratio: 保证金比例。
123 :vartype assure_ratio: float
124 """
125 def __init__(self, order=None):
126 if order:
127 self.id = order.id
128 self.contract = order.contract
129 self.direction = order.direction
130 self.price = order.price
131 self.quantity = order.quantity
132 self.side = order.side
133 self.datetime = order.datetime
134 self.price_type = order.price_type
135 self.commission = 0
136 self.assure_ratio = 1
137
138 def __hash__(self):
139 if hasattr(self, '_hash'):
140 return self._hash
141 else:
142 self._hash = hash(self.id)
143 return self._hash
144
145 def profit(self, new_price):
146 """ 根据当前的价格计算盈亏。
147
148 :param float new_price: 当前价格。
149 :return: 盈亏数额。

Callers 1

make_marketMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected