订单 :ivar id: 成交编号 :vartype id: :class:`OrderID` :ivar contract: 合约。 :vartype contract: :class:`Contract` :ivar direction: 多空方向。 :vartype direction: :class:`Direction` :ivar price: 成交价格。 :vartype price: float :ivar quantit
| 202 | |
| 203 | |
| 204 | class Order(object): |
| 205 | """ 订单 |
| 206 | |
| 207 | :ivar id: 成交编号 |
| 208 | :vartype id: :class:`OrderID` |
| 209 | |
| 210 | :ivar contract: 合约。 |
| 211 | :vartype contract: :class:`Contract` |
| 212 | |
| 213 | :ivar direction: 多空方向。 |
| 214 | :vartype direction: :class:`Direction` |
| 215 | |
| 216 | :ivar price: 成交价格。 |
| 217 | :vartype price: float |
| 218 | |
| 219 | :ivar quantity: 成交数量。 |
| 220 | :vartype quantity: float |
| 221 | |
| 222 | :ivar side: 开平仓标志。 |
| 223 | :vartype side: :class:`TradeSide` |
| 224 | |
| 225 | :ivar datetime: 成交时间 |
| 226 | :vartype datetime: :class:`datetime` |
| 227 | |
| 228 | :ivar price_type: 下单类型。 |
| 229 | :vartype price_type: :class:`PriceType` |
| 230 | """ |
| 231 | def __init__(self, dt, contract, type_, side, direction, price, quantity): |
| 232 | self.id = OrderID.next_order_id() |
| 233 | self.contract = contract |
| 234 | self.direction = direction |
| 235 | self.price = price |
| 236 | self.quantity = quantity |
| 237 | self.side = side |
| 238 | self.datetime = dt |
| 239 | self.price_type = type_ |
| 240 | |
| 241 | def print_order(self): |
| 242 | #print "Order: Symbol=%s, Type=%s, Quantity=%s, Direction=%s" % \ |
| 243 | #(self.symbol, self.order_type, self.quantity, self.direction) |
| 244 | pass |
| 245 | |
| 246 | def __hash__(self): |
| 247 | if hasattr(self, '_hash'): |
| 248 | return self._hash |
| 249 | else: |
| 250 | self._hash = hash(self.id) |
| 251 | return self._hash |
| 252 | |
| 253 | |
| 254 | class Contract(object): |