Skip to content

Commit 162c8f5

Browse files
committed
Merge branch 'master' into feat_mcp
2 parents 7bfb096 + 3efde7a commit 162c8f5

File tree

10 files changed

+5348
-824
lines changed

10 files changed

+5348
-824
lines changed

tests/test_quote_client.py

Lines changed: 2429 additions & 0 deletions
Large diffs are not rendered by default.

tests/test_trade_client.py

Lines changed: 702 additions & 0 deletions
Large diffs are not rendered by default.

tigeropen/examples/nasdaq100.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
PRIVATE_KEY_PATH = "your private key path"
5959
TIGER_ID = "your tiger id"
6060
ACCOUNT = "your account"
61-
client_config = get_client_config(private_key_path=PRIVATE_KEY_PATH, tiger_id=TIGER_ID, account=ACCOUNT)
62-
quote_client = QuoteClient(client_config, logger=client_logger)
63-
trade_client = TradeClient(client_config, logger=client_logger)
61+
_client_config = get_client_config(private_key_path=PRIVATE_KEY_PATH, tiger_id=TIGER_ID, account=ACCOUNT)
62+
quote_client = QuoteClient(_client_config, logger=client_logger)
63+
trade_client = TradeClient(_client_config, logger=client_logger)
6464

6565

6666
def request(symbols, method, **kwargs):

tigeropen/quote/domain/quote_brief.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def __init__(self):
4444
self.low_price = None # 最低价
4545
self.change = None # 涨跌额
4646

47-
self.bid_price = None # 卖盘价
48-
self.bid_size = None # 卖盘数量
49-
self.ask_price = None # 买盘价
50-
self.ask_size = None # 买盘数量
47+
self.bid_price = None # 买盘价
48+
self.bid_size = None # 买盘数量
49+
self.ask_price = None # 卖盘价
50+
self.ask_size = None # 卖盘数量
5151

5252
self.halted = None # 是否停牌 0: 正常,3: 停牌,4: 退市
5353
self.delay = None # 延时分钟

tigeropen/quote/quote_client.py

Lines changed: 1661 additions & 649 deletions
Large diffs are not rendered by default.

tigeropen/tiger_open_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def is_us(self):
458458
return self.license and License.TBUS.value == get_enum_value(self.license)
459459

460460

461-
def get_client_config(private_key_path, tiger_id, account, sandbox_debug=False, sign_type=None, timeout=None,
461+
def get_client_config(private_key_path=None, tiger_id=None, account=None, sandbox_debug=False, sign_type=None, timeout=None,
462462
language=None, charset=None, server_url=None, socket_host_port=None, secret_key=None,
463463
enable_dynamic_domain=True, timezone=None, license=None, props_path=None):
464464
"""

tigeropen/trade/domain/contract.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ def __repr__(self):
104104
else:
105105
return '%s/%s/%s' % (identifier, self.sec_type, self.currency)
106106

107+
def to_dict(self):
108+
return self.__dict__
109+
107110
def to_str(self):
108-
return str(self.__dict__)
111+
return str(self.to_dict())
109112

110113
def is_cn_stock(self):
111114
"""

tigeropen/trade/domain/position.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,8 @@ def __init__(self, account, contract, quantity=0, average_cost=None, market_pric
4848
self.is_level0_price = kwargs.get('is_level0_price', None)
4949

5050
def __repr__(self):
51-
template = "contract: {contract}, quantity: {quantity}, average_cost: {average_cost}, " \
52-
"market_price: {market_price}"
53-
return template.format(
54-
contract=self.contract,
55-
quantity=self.quantity,
56-
average_cost=self.average_cost,
57-
market_price=self.market_price
58-
)
51+
return f"Position({self.__dict__})"
52+
5953

6054
def __str__(self):
6155
return self.__repr__()

tigeropen/trade/response/order_id_response.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def parse_response_content(self, response_content):
3030

3131
if 'orderId' in data_json:
3232
self.order_id = data_json['orderId']
33+
elif 'order_id' in data_json:
34+
self.order_id = data_json['order_id']
3335

3436
if 'id' in data_json:
3537
self.id = data_json['id']

tigeropen/trade/trade_client.py

Lines changed: 540 additions & 158 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)