Skip to content

Commit 3ca2edd

Browse files
author
Kai Su
committed
modified: tigeropen/common/util/contract_utils.py
modified: tigeropen/push/push_client.py modified: tigeropen/trade/domain/contract.py modified: tigeropen/trade/domain/order.py modified: tigeropen/trade/response/__init__.py modified: tigeropen/trade/response/contracts_response.py
1 parent fec46ac commit 3ca2edd

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

tigeropen/common/util/contract_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def option_contract(identifier, multiplier=100, currency='USD'):
2626
multiplier=multiplier)
2727

2828

29-
def future_contract(symbol, currency, expiry, exchange, multiplier=None, local_symbol=None):
30-
return Contract(symbol, currency, sec_type='FUT', expiry=expiry, exchange=exchange, multiplier=multiplier,
31-
local_symbol=local_symbol)
29+
def future_contract(symbol, currency, expiry=None, exchange=None, contract_month=None, multiplier=None, local_symbol=None):
30+
return Contract(symbol, currency, sec_type='FUT', expiry=expiry, exchange=exchange, contract_month=contract_month,
31+
multiplier=multiplier, local_symbol=local_symbol)
3232

3333

3434
def future_option_contract(symbol, currency, expiry, strike, put_call, multiplier=None, local_symbol=None,

tigeropen/push/push_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
'unrealizedPnl': 'unrealized_pnl', 'secType': 'sec_type', 'localSymbol': 'local_symbol',
3737
'originSymbol': 'origin_symbol', 'contractId': 'contract_id', 'symbol': 'symbol',
3838
'currency': 'currency', 'strike': 'strike', 'expiry': 'expiry', 'right': 'right',
39-
'segment': 'segment'}
39+
'segment': 'segment', 'identifier': 'identifier'}
4040

4141
ORDER_KEYS_MAPPINGS = {'parentId': 'parent_id', 'orderId': 'order_id', 'orderType': 'order_type',
4242
'limitPrice': 'limit_price', 'auxPrice': 'aux_price', 'avgFillPrice': 'avg_fill_price',
@@ -47,7 +47,7 @@
4747
'latestTime': 'trade_time', 'contractId': 'contract_id', 'trailStopPrice': 'trail_stop_price',
4848
'trailingPercent': 'trailing_percent', 'percentOffset': 'percent_offset', 'action': 'action',
4949
'status': 'status', 'currency': 'currency', 'remaining': 'remaining', 'id': 'id',
50-
'segment': 'segment'}
50+
'segment': 'segment', 'identifier': 'identifier'}
5151

5252
if sys.platform == 'linux' or sys.platform == 'linux2':
5353
KEEPALIVE = True

tigeropen/trade/domain/contract.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Contract(object):
1010
def __init__(self, symbol, currency, contract_id=None, sec_type=None, exchange=None, origin_symbol=None,
1111
local_symbol=None, expiry=None, strike=None, put_call=None, multiplier=None, name=None,
1212
short_margin=None, short_fee_rate=None, shortable=None, long_initial_margin=None,
13-
long_maintenance_margin=None):
13+
long_maintenance_margin=None, contract_month=None):
1414
self.contract_id = contract_id
1515
self.symbol = symbol
1616
self.currency = currency
@@ -28,6 +28,7 @@ def __init__(self, symbol, currency, contract_id=None, sec_type=None, exchange=N
2828
self.shortable = shortable
2929
self.long_initial_margin = long_initial_margin
3030
self.long_maintenance_margin = long_maintenance_margin
31+
self.contract_month = contract_month
3132

3233
def __repr__(self):
3334
if self.symbol:

tigeropen/trade/domain/order.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Order(object):
1919
def __init__(self, account, contract, action, order_type, quantity, limit_price=None, aux_price=None,
2020
trail_stop_price=None, trailing_percent=None, percent_offset=None, time_in_force=None,
2121
outside_rth=None, filled=0, avg_fill_price=0, commission=None, realized_pnl=None,
22-
id=None, order_id=None, parent_id=None):
22+
id=None, order_id=None, parent_id=None, order_time=None, trade_time=None):
2323
"""
2424
- account: 订单所属的账户
2525
- id: 全局订单 id
@@ -69,8 +69,8 @@ def __init__(self, account, contract, action, order_type, quantity, limit_price=
6969
self.trail_stop_price = trail_stop_price
7070
self.trailing_percent = trailing_percent
7171
self.percent_offset = percent_offset
72-
self.order_time = None
73-
self.trade_time = None
72+
self.order_time = order_time
73+
self.trade_time = trade_time
7474

7575
def to_dict(self):
7676
dct = {name: getattr(self, name) for name in self.__slots__ if name not in ORDER_FIELDS_TO_IGNORE}

tigeropen/trade/response/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
CONTRACT_FIELDS = set(['symbol', 'market', 'multiplier', 'sec_type', 'currency', 'local_symbol', 'origin_symbol',
99
'expiry', 'strike', 'right', 'contract_id', 'exchange', 'name', 'short_margin', 'short_fee_rate',
10-
'shortable', 'long_initial_margin', 'long_maintenance_margin'])
10+
'shortable', 'long_initial_margin', 'long_maintenance_margin', 'contract_month'])
1111

tigeropen/trade/response/contracts_response.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
CONTRACT_FIELD_MAPPINGS = {'secType': 'sec_type', 'localSymbol': 'local_symbol', 'originSymbol': 'origin_symbol',
1515
'conid': 'contract_id', 'contractId': 'contract_id', 'lastTradingDate': 'expiry',
1616
'shortMargin': 'short_margin', 'shortFeeRate': 'short_fee_rate',
17-
'longInitialMargin': 'long_initial_margin',
17+
'longInitialMargin': 'long_initial_margin', 'contractMonth': 'contract_month',
1818
'longMaintenanceMargin': 'long_maintenance_margin'}
1919

2020

@@ -60,11 +60,11 @@ def parse_response_content(self, response_content):
6060
shortable = contract_fields.get('shortable')
6161
long_initial_margin = contract_fields.get('long_initial_margin')
6262
long_maintenance_margin = contract_fields.get('long_maintenance_margin')
63-
63+
contract_month = contract_fields.get('contract_month')
6464
contract = Contract(symbol, currency, contract_id=contract_id, sec_type=sec_type, exchange=exchange,
6565
origin_symbol=origin_symbol, local_symbol=local_symbol, expiry=expiry,
6666
strike=strike, put_call=put_call, multiplier=multiplier, name=name,
6767
short_margin=short_margin, short_fee_rate=short_fee_rate, shortable=shortable,
68-
long_initial_margin=long_initial_margin,
68+
long_initial_margin=long_initial_margin, contract_month=contract_month,
6969
long_maintenance_margin=long_maintenance_margin)
7070
self.contracts.append(contract)

0 commit comments

Comments
 (0)