Skip to content

Commit 439153c

Browse files
committed
Contract add fields
1 parent 807cc20 commit 439153c

File tree

4 files changed

+56
-14
lines changed

4 files changed

+56
-14
lines changed

tigeropen/trade/domain/contract.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ class Contract(object):
1111
def __init__(self, symbol, currency, contract_id=None, sec_type=None, exchange=None, origin_symbol=None,
1212
local_symbol=None, expiry=None, strike=None, put_call=None, multiplier=None, name=None,
1313
short_margin=None, short_fee_rate=None, shortable=None, long_initial_margin=None,
14-
long_maintenance_margin=None, contract_month=None, identifier=None):
14+
long_maintenance_margin=None, contract_month=None, identifier=None, primary_exchange=None,
15+
market=None, min_tick=None, trading_class=None, status=None, continuous=None, trade=None,
16+
last_trading_date=None, first_notice_date=None, last_bidding_close_time=None):
1517
self.contract_id = contract_id
1618
self.symbol = symbol
1719
self.currency = currency
1820
self.sec_type = sec_type
1921
self.exchange = exchange
2022
self.origin_symbol = origin_symbol
2123
self.local_symbol = local_symbol
24+
# 到期日
2225
self.expiry = expiry
2326
# 行权价
2427
self.strike = strike
@@ -42,6 +45,26 @@ def __init__(self, symbol, currency, contract_id=None, sec_type=None, exchange=N
4245
self.contract_month = contract_month
4346
# 合约标识符
4447
self.identifier = identifier
48+
# 股票上市交易所
49+
self.primary_exchange = primary_exchange
50+
# 市场
51+
self.market = market
52+
# 最小报价单位
53+
self.min_tick = min_tick
54+
# 合约的交易级别名称
55+
self.trading_class = trading_class
56+
# 状态
57+
self.status = status
58+
# 期货专有,是否连续合约
59+
self.continuous = continuous
60+
# 期货专有,是否可交易
61+
self.trade = trade
62+
# 期货专有,最后交易日
63+
self.last_trading_date = last_trading_date
64+
# 期货专有,第一通知日,合约在第一通知日后无法开多仓. 已有的多仓会在第一通知日之前(通常为前三个交易日)被强制平仓
65+
self.first_notice_date = first_notice_date
66+
# 期货专有,竞价截止时间
67+
self.last_bidding_close_time = last_bidding_close_time
4568

4669
def __repr__(self):
4770
identifier = self.identifier if self.identifier else self.symbol

tigeropen/trade/response/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
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', 'contract_month', 'identifier'])
10+
'shortable', 'long_initial_margin', 'long_maintenance_margin', 'contract_month', 'identifier',
11+
'primary_exchange', 'min_tick', 'trading_class', 'status', 'continuous', 'trade',
12+
'last_trading_date', 'first_notice_date', 'last_bidding_close_time'])
1113

tigeropen/trade/response/contracts_response.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
from tigeropen.trade.response import CONTRACT_FIELDS
1313

1414
CONTRACT_FIELD_MAPPINGS = {'secType': 'sec_type', 'localSymbol': 'local_symbol', 'originSymbol': 'origin_symbol',
15-
'conid': 'contract_id', 'contractId': 'contract_id', 'lastTradingDate': 'expiry',
15+
'conid': 'contract_id', 'contractId': 'contract_id',
1616
'shortMargin': 'short_margin', 'shortFeeRate': 'short_fee_rate',
1717
'longInitialMargin': 'long_initial_margin', 'contractMonth': 'contract_month',
18-
'longMaintenanceMargin': 'long_maintenance_margin'}
18+
'longMaintenanceMargin': 'long_maintenance_margin', 'primaryExchange': 'primary_exchange',
19+
'tradingClass': 'trading_class', 'lastTradingDate': 'last_trading_date',
20+
'minTick': 'min_tick', 'firstNoticeDate': 'first_notice_date',
21+
'lastBiddingCloseTime': 'last_bidding_close_time'}
1922

2023

2124
class ContractsResponse(TigerResponse):
@@ -62,10 +65,24 @@ def parse_response_content(self, response_content):
6265
long_maintenance_margin = contract_fields.get('long_maintenance_margin')
6366
contract_month = contract_fields.get('contract_month')
6467
identifier = contract_fields.get('identifier')
68+
primary_exchange = contract_fields.get('primary_exchange')
69+
market = contract_fields.get('market')
70+
min_tick = contract_fields.get('min_tick')
71+
trading_class = contract_fields.get('trading_class')
72+
status = contract_fields.get('status')
73+
continuous = contract_fields.get('continuous')
74+
trade = contract_fields.get('trade')
75+
last_trading_date = contract_fields.get('last_trading_date')
76+
first_notice_date = contract_fields.get('first_notice_date')
77+
last_bidding_close_time = contract_fields.get('last_bidding_close_time')
6578
contract = Contract(symbol, currency, contract_id=contract_id, sec_type=sec_type, exchange=exchange,
6679
origin_symbol=origin_symbol, local_symbol=local_symbol, expiry=expiry,
6780
strike=strike, put_call=put_call, multiplier=multiplier, name=name,
6881
short_margin=short_margin, short_fee_rate=short_fee_rate, shortable=shortable,
6982
long_initial_margin=long_initial_margin, contract_month=contract_month,
70-
long_maintenance_margin=long_maintenance_margin, identifier=identifier)
83+
long_maintenance_margin=long_maintenance_margin, identifier=identifier,
84+
primary_exchange=primary_exchange, market=market, min_tick=min_tick,
85+
trading_class=trading_class, status=status, continuous=continuous, trade=trade,
86+
last_trading_date=last_trading_date, first_notice_date=first_notice_date,
87+
last_bidding_close_time=last_bidding_close_time)
7188
self.contracts.append(contract)

tigeropen/trade/trade_client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def get_contracts(self, symbol, sec_type=SecurityType.STK, currency=None, exchan
6868
"""
6969
批量获取合约
7070
:param symbol:
71-
:param sec_type:
72-
:param currency:
73-
:param exchange:
71+
:param sec_type: 合约类型 tigeropen.common.consts.SecurityType
72+
:param currency: 币种 tigeropen.common.consts.Currency
73+
:param exchange: 交易所
7474
:return: 合约对象列表, 每个列表项的对象信息同 get_contract 返回
7575
"""
7676
params = ContractParams()
@@ -100,12 +100,12 @@ def get_contract(self, symbol, sec_type=SecurityType.STK, currency=None, exchang
100100
"""
101101
获取合约
102102
:param symbol:
103-
:param sec_type:
104-
:param currency:
105-
:param exchange:
106-
:param expiry:
107-
:param strike:
108-
:param right:
103+
:param sec_type: 合约类型 tigeropen.common.consts.SecurityType
104+
:param currency: 币种 tigeropen.common.consts.Currency
105+
:param exchange: 交易所
106+
:param expiry: 合约到期日(期货/期权) yyyyMMdd
107+
:param strike: 行权价(期权)
108+
:param right: CALL/PUT
109109
:return: Contract 对象. 有如下属性:
110110
symbol: 合约 symbol
111111
identifier: 合约唯一标识

0 commit comments

Comments
 (0)