예제 #1
0
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
예제 #2
0
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.secret_key = None  # 机构交易员专有密钥 (机构用户需要填写, 个人开发者无需填写)
    client_config.language = Language.en_US
    return client_config
예제 #3
0
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
예제 #4
0
    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}')
예제 #5
0
파일: bc_tiger.py 프로젝트: dxcv/quant-1
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
예제 #6
0
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
예제 #7
0
from tigeropen.common.consts import Language
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)