2727 filemode = 'a' , )
2828logger = logging .getLogger ('TigerOpenApi' )
2929
30- client_config = get_client_config (private_key_path = 'your private key file path' ,
31- tiger_id = 'your tiger id' ,
32- account = 'your account' )
30+ _demo_config = get_client_config (private_key_path = 'your private key file path' ,
31+ tiger_id = 'your tiger id' ,
32+ account = 'your account' )
3333
3434
3535def get_contract_apis ():
36- openapi_client = TradeClient (client_config , logger = logger )
36+ openapi_client = TradeClient (_demo_config , logger = logger )
3737 contract = openapi_client .get_contracts ('AAPL' )[0 ]
3838 print (contract )
3939 contract = openapi_client .get_contract ('AAPL' , SecurityType .STK , currency = Currency .USD )
@@ -43,7 +43,7 @@ def get_contract_apis():
4343 print (contracts )
4444
4545def get_account_apis ():
46- openapi_client = TradeClient (client_config , logger = logger )
46+ openapi_client = TradeClient (_demo_config , logger = logger )
4747 openapi_client .get_managed_accounts ()
4848 # 获取订单
4949 openapi_client .get_orders ()
@@ -73,7 +73,7 @@ def get_account_apis():
7373
7474def test_get_orders_by_page ():
7575 """分页获取订单"""
76- trade_client = TradeClient (client_config )
76+ trade_client = TradeClient (_demo_config )
7777 result = list ()
7878 # 每次返回数量(需 <= 300)
7979 limit = 300
@@ -96,8 +96,8 @@ def test_get_orders_by_page():
9696
9797
9898def trade_apis ():
99- account = client_config .account
100- openapi_client = TradeClient (client_config , logger = logger )
99+ account = _demo_config .account
100+ openapi_client = TradeClient (_demo_config , logger = logger )
101101
102102 # 通过请求获取合约
103103 contract = openapi_client .get_contracts ('AAPL' )[0 ]
@@ -159,8 +159,8 @@ def trade_apis():
159159
160160
161161def algo_order_demo ():
162- account = client_config .account
163- openapi_client = TradeClient (client_config , logger = logger )
162+ account = _demo_config .account
163+ openapi_client = TradeClient (_demo_config , logger = logger )
164164 contract = stock_contract (symbol = 'AAPL' , currency = 'USD' )
165165 params = algo_order_params (start_time = 1686147201000 , end_time = 1686150801000 , no_take_liq = True ,
166166 allow_past_end_time = True , participation_rate = 0.1 )
@@ -175,9 +175,9 @@ def get_account_info():
175175 :return:
176176 """
177177 from tigeropen .common .consts .service_types import ACCOUNTS
178- openapi_client = TigerOpenClient (client_config )
178+ openapi_client = TigerOpenClient (_demo_config )
179179 account = AccountsParams ()
180- account .account = client_config .account
180+ account .account = _demo_config .account
181181 request = OpenApiRequest (method = ACCOUNTS , biz_model = account )
182182
183183 response_content = None
@@ -197,7 +197,7 @@ def get_account_info():
197197
198198
199199class TestTradeClient (unittest .TestCase ):
200- trade_client = TradeClient (client_config )
200+ trade_client = TradeClient (_demo_config )
201201
202202 def test_transfer_segment_fund (self ):
203203 """资金划转"""
0 commit comments