請問如何得知目前登入正式或模擬環境?

有任何提問的都來這
回覆文章
Ahan
文章: 2
註冊時間: 2023-08-21, 09:02

請問如何得知目前登入正式或模擬環境?

文章 Ahan »

Version: Shioaji v1.1.11

Code:
api = sj.Shioaji(simulation=True)
accounts = api.login(API_KEY, SECRET_KEY)
print(accounts)

Ouput:
Response Code: 0 | Event Code: 0 | Info: host '203.66.91.161:80', hostname '203.66.91.161:80' IP 203.66.91.161:80 (host 1 of 1) (host connection attempt 1 of 1) (total connection attempt 1 of 1) | Event: Session up
[StockAccount(person_id='***', broker_id='***', account_id='***', signed=True, username='***')]

Question:
發現simulation為True或False時,得到的output都一樣,請問於登入後是否有方法確認目前登入的環境?謝謝!
Ahan
文章: 2
註冊時間: 2023-08-21, 09:02

Re: 請問如何得知目前登入正式或模擬環境?

文章 Ahan »

目前的判斷方式是call一個模擬環境不支援的method: e.g. print(api.account_balance())

Output while simulation == True:
2023-08-21 09:15:16.113 | WARNING | shioaji.shioaji:account_balance:953 - Simulation not support account_balance yet
status=<FetchStatus.Fetched: 'Fetched'> acc_balance=0.0 date='' errmsg=''

Output while simulation == False:
status=<FetchStatus.Fetching: 'Fetching'> acc_balance=*** date='2023-08-21 09:15:34.454960' errmsg=''

如果有正式的判斷方法還請告知,謝謝!
回覆文章