Skip to content

Commit 3e01ef5

Browse files
committed
log file conf;
fix future contract field
1 parent 307470b commit 3e01ef5

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

tigeropen/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
55
@author: gaoan
66
"""
7-
__VERSION__ = '2.2.6'
7+
__VERSION__ = '2.2.7'

tigeropen/quote/response/future_briefs_response.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
from tigeropen.common.response import TigerResponse
1010

1111
COLUMNS = ['identifier', 'ask_price', 'ask_size', 'bid_price', 'bid_size', 'pre_close', 'latest_price', 'latest_size',
12-
'latest_time', 'volume', 'open_interest', 'open', 'high', 'low', 'limit_up', 'limit_down']
12+
'latest_time', 'volume', 'open_interest', 'open', 'high', 'low', 'limit_up', 'limit_down', 'settlement',
13+
'settle_date']
1314
BRIEF_FIELD_MAPPINGS = {'askPrice': 'ask_price', 'askSize': 'ask_size', 'bidPrice': 'bid_price', 'bidSize': 'bid_size',
1415
'latestPrice': 'latest_price', 'openInterest': 'open_interest', 'preClose': 'pre_close',
1516
'right': 'put_call', 'latestTime': 'latest_time', 'latestSize': 'latest_size',
16-
'limitUp': 'limit_up', 'limitDown': 'limit_down', 'contractCode': 'identifier'}
17+
'limitUp': 'limit_up', 'limitDown': 'limit_down', 'contractCode': 'identifier',
18+
'settleDate': 'settle_date'}
1719

1820

1921
class FutureBriefsResponse(TigerResponse):

tigeropen/quote/response/future_contract_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
from tigeropen.common.response import TigerResponse
1010

11-
COLUMNS = ['contract_code', 'symbol', 'type', 'name', 'contract_month', 'multiplier', 'exchange', 'currency',
11+
COLUMNS = ['contract_code', 'symbol', 'type', 'name', 'contract_month', 'multiplier', 'exchange', 'exchange_code', 'currency',
1212
'first_notice_date', 'last_bidding_close_time', 'last_trading_date', 'trade', 'continuous', 'min_tick']
13-
CONTRACT_FIELD_MAPPINGS = {'contractCode': 'contract_code', 'exchangeCode': 'exchange', 'ibCode': 'symbol',
13+
CONTRACT_FIELD_MAPPINGS = {'contractCode': 'contract_code', 'exchangeCode': 'exchange_code', 'ibCode': 'symbol',
1414
'contractMonth': 'contract_month', 'firstNoticeDate': 'first_notice_date',
1515
'lastBiddingCloseTime': 'last_bidding_close_time', 'lastTradingDate': 'last_trading_date',
1616
'minTick': 'min_tick'}

tigeropen/tiger_open_client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77
import datetime
88
import json
9+
import logging
910
import uuid
1011

1112
from tigeropen import __VERSION__
@@ -26,6 +27,8 @@
2627
def get_mac_address():
2728
return ':'.join(("%012x" % uuid.getnode())[i:i + 2] for i in range(0, 12, 2))
2829

30+
LOG_FORMATTER = logging.Formatter('%(asctime)s %(name)s %(levelname)s: %(message)s')
31+
2932

3033
class TigerOpenClient:
3134
"""
@@ -35,7 +38,14 @@ class TigerOpenClient:
3538

3639
def __init__(self, client_config, logger=None):
3740
self.__config = client_config
38-
self.__logger = logger
41+
if logger:
42+
if client_config.log_level:
43+
logger.setLevel(logging.getLevelName(client_config.log_level))
44+
if client_config.log_path:
45+
file_handler = logging.FileHandler(client_config.log_path)
46+
file_handler.setFormatter(LOG_FORMATTER)
47+
logger.addHandler(file_handler)
48+
self.__logger = logger
3949
self.__headers = {
4050
'Content-type': 'application/json;charset=' + self.__config.charset,
4151
"Cache-Control": "no-cache",

tigeropen/tiger_open_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
@author: gaoan
66
"""
77
import json
8+
import logging
9+
810
from pytz import timezone
911
from tigeropen.common.consts import Language, ServiceType
1012
from tigeropen.common.util.account_util import AccountUtil
@@ -90,6 +92,9 @@ def __init__(self, sandbox_debug=False, enable_dynamic_domain=True):
9092
self.domain_conf = self.query_domains()
9193
self.refresh_server_info()
9294

95+
self.log_level = None
96+
self.log_path = None
97+
9398
@property
9499
def tiger_id(self):
95100
return self._tiger_id

0 commit comments

Comments
 (0)