def get_client_config(): client_config = TigerOpenClientConfig(sandbox_debug=False) client_config.language = Language.en_US client_config.private_key = read_private_key( '/Users/yunqiuliu/Tiger-Trade/rsa_private_key.pem') client_config.tiger_id = '20150081' client_config.account = 'U8317066' return client_config
def get_client_config(): """ 获取client_config https://www.itiger.com/openapi/info 开发者信息获取 """ client_config = TigerOpenClientConfig(sandbox_debug=False) client_config.private_key = read_private_key('/Users/yunqiuliu/Tiger-Trade/rsa_private_key.pem') client_config.tiger_id = '20150081' client_config.account = 'U8317066' client_config.language = Language.en_US return client_config
def get_client_config(): """ https://www.itiger.com/openapi/info 开发者信息获取 :return: """ is_sandbox = False client_config = TigerOpenClientConfig(sandbox_debug=is_sandbox) client_config.private_key = read_private_key('your private key file path') client_config.tiger_id = 'your tiger id' client_config.account = 'your account' client_config.language = Language.en_US return client_config
def get_client_config(account='global_account', info_path='drive/My Drive/tiger_quant/', is_sandbox=False): user_info = get_user_info(info_path=info_path) client_config = TigerOpenClientConfig(sandbox_debug=is_sandbox) client_config.private_key = read_private_key(info_path + user_info['private_key_name']) client_config.tiger_id = str(user_info['tiger_id']) client_config.account = str(user_info[account]) client_config.language = Language.en_US return client_config
def get_client_config(): """ https://www.itiger.com/openapi/info 开发者信息获取 :return: """ is_sandbox = False client_config = TigerOpenClientConfig(sandbox_debug=is_sandbox) client_config.private_key = read_private_key('your private key file path') client_config.tiger_id = 'your tiger id' client_config.account = 'your account' # 环球账户. # 只使用一个账户时,不论是环球账户, 标准账户或是模拟账户, 都填在 client_config.account 下, 默认只会使用这里的账户. # standard_account 属性和 paper_account 属性只是为多账户时取用方便, 一般可忽略 client_config.standard_account = None # 标准账户 client_config.paper_account = None # 模拟账户 client_config.language = Language.en_US return client_config
def __init__(self, account_type, config, sandbox_debug=False, logger_name=None, open_time_adj=0, close_time_adj=0): # get logger self.logger = Tiger.defualt_logger if ( logger_name is None) else logging.getLogger(logger_name) # read user info, position record from local files self.__user_info = io_util.read_config(file_path=config['tiger_path'], file_name='user_info.json') self.__position_record = io_util.read_config( file_path=config['config_path'], file_name='tiger_position_record.json') self.record = self.__position_record[account_type].copy() self.eod_api_key = config['api_key']['eod'] # set account, account type self.account = self.__user_info[account_type] self.account_type = account_type # initialize client_config self.client_config = TigerOpenClientConfig(sandbox_debug=sandbox_debug) self.client_config.private_key = read_private_key( config['tiger_path'] + self.__user_info['private_key_name']) self.client_config.tiger_id = str(self.__user_info['tiger_id']) self.client_config.language = Language.en_US self.client_config.account = self.account # get quote/trade clients, assets, positions self.quote_client = QuoteClient(self.client_config) self.trade_client = TradeClient(self.client_config) self.positions = self.trade_client.get_positions(account=self.account) self.assets = self.trade_client.get_assets(account=self.account) # get market status and trade time self.update_trade_time(open_time_adj=open_time_adj, close_time_adj=close_time_adj) # update position record self.synchronize_position_record(config=config) self.logger.info(f'[tiger]: Tiger instance created: {logger_name}')
def get_client_config(): """ https://www.itiger.com/openapi/info 开发者信息获取 :return: """ # Load tiger account information prop = Property() prop_loader = prop.load_property_files( os.path.expanduser('~/config/env.properties')) tiger_id = prop_loader.get('tiger_id') tiger_account = prop_loader.get('tiger_account') is_sandbox = False client_config = TigerOpenClientConfig(sandbox_debug=is_sandbox) client_config.private_key = read_private_key( os.path.expanduser('~/.ssh/tigerbroker_rsa_private_key.pem')) client_config.tiger_id = tiger_id client_config.account = tiger_account client_config.language = Language.en_US return client_config
def get_client_config(private_key_path, tiger_id, account, standard_account=None, paper_account=None, sandbox_debug=False, sign_type=None, timeout=None, language=None, charset=None, server_url=None, socket_host_port=None): """ 生成客户端配置 :param private_key_path: 私钥文件路径, 如 '/Users/tiger/.ssh/rsa_private_key.pem' :param tiger_id: 开发者应用 id :param account: 授权账户 (必填. 作为发送请求时的默认账户) :param standard_account: :param paper_account: :param sandbox_debug: 是否请求 sandbox 环境 :param sign_type: 签名类型 :param timeout: 请求超时时间, 单位秒 :param language: 语言, 取值为 tigeropen.common.consts.Language 中的枚举类型 :param charset: 字符集编码 :param server_url: 网关地址 :param socket_host_port: 推送长连接的域名端口, 值为协议, 域名, 端口构成的三元组 :return: """ config = TigerOpenClientConfig(sandbox_debug=sandbox_debug) config.private_key = read_private_key(private_key_path) config.tiger_id = tiger_id config.account = account if standard_account: config.standard_account = standard_account if paper_account: config.paper_account = paper_account if sign_type: config.sign_type = sign_type if timeout: config.timeout = timeout if language: config.language = language if charset: config.charset = charset if server_url: config.server_url = server_url if socket_host_port: config.socket_host_port = socket_host_port return config
from tigeropen.common.util.signature_utils import read_private_key from tigeropen.push.push_client import PushClient from tigeropen.tiger_open_config import TigerOpenClientConfig def on_query_subscribed_quote(symbols, focus_keys, limit, used): print(symbols, focus_keys, limit, used) def on_quote_changed(symbol, items, hour_trading): print(symbol, items, hour_trading) is_sandbox = True client_config = TigerOpenClientConfig(sandbox_debug=is_sandbox) client_config.private_key = read_private_key('your private key file path') # https://www.itiger.com/openapi/info 开发者信息获取 client_config.tiger_id = 'your tiger id' client_config.account = 'your account' client_config.language = Language.en_US protocol, host, port = client_config.socket_host_port push_client = PushClient(host, port, use_ssl=(protocol == 'ssl')) push_client.quote_changed = on_quote_changed push_client.subscribed_symbols = on_query_subscribed_quote push_client.connect(client_config.tiger_id, client_config.private_key) push_client.query_subscribed_quote() push_client.subscribe_quote(['AAPL', 'GOOG']) push_client.subscribe_asset() # time.sleep(600) push_client.disconnect()
from tigeropen.common.consts import Language from tigeropen.tiger_open_config import TigerOpenClientConfig from tigeropen.common.util.signature_utils import read_private_key rsa_private_key = read_private_key('../money/rsa_private_key.pem') def get_client_config(): """ https://www.itiger.com/openapi/info 开发者信息获取 :return: """ is_sandbox = False client_config = TigerOpenClientConfig(sandbox_debug=is_sandbox) client_config.private_key = rsa_private_key client_config.tiger_id = '20150137' client_config.account = None # 'U9923867' # 环球账户 client_config.standard_account = None # 标准账户 client_config.paper_account = '20190130122050760' # 模拟账户 client_config.language = Language.zh_CN return client_config