Other Questions

About 3 min

Q1: How to use your paper trading account?

When you finish the registration process on the API developer info page, a paper trading account will be generated. You can also check the status of your paper trading account in Tiger trade APP 『Trade』tab.

When you are placing orders, use your paper account number as your account id.

Q2: What are the difference between sandbox, paper, live account/environments?

Demo and live trading needs to be done on production environment, while sandbox is an independent developing environment,and it is used for development only under certain senarios. A different set of Tigerid and RSA keys are required if you want to use the sandbox environment

Using the paper account is recommended over sandbox.

Q3: Questions or Comments?

If you have questions regarding use OpenAPI or SDK, please join our official QQ chat group. Group ID: 441334668 Please provide us with the following information when you are reporting an issue

  • Details of the Request, including the name of the interface and the parameters passed in
  • Error message

Q4: invalid signature

{"code":40013,"data":"","message":"invalid signature","timestamp":1527732508206}

Reason: You have probably altered the openapi public key (tiger_public_key) by mistake. Alse check for your private key too see if it has the correct value.

Q5: certificate verify failed

File "....../tigeropen/tiger_open_client.py", line ..., in execute
self.__config.charset)
File "....../tigeropen/common/util/web_utils.py", line ..., in do_post
raise RequestException('[' + THREAD_LOCAL.uuid + ']post connect failed. ' + str(e))
tigeropen.common.exceptions.RequestException: post connect failed. 
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)

OR
response sign varify faild. Varification Failed

Reason: A possible cause is that the openapi public key has been lost or altered. A solution is to use online platform to re-generate the RSA key pairs. Format needs to be set as pkcs#1

Q6: load_pkcs1_der error

rsa/key.py:492 _load_pkcs1_der
ValueError: Unable to read this file, version 136 != 0

python sdk only supports pkcs#1. PKCS#8 is not supported. Make sure to have the RSA key in the right format

Q7: common param error(public key error)

Reason: a possible cause is that you have filled in a wrong account id. Please check if the value of TigerOpenClientConfig.account is correnct

Q8: common param error(public key error)

{"code":1000,"message":"common param error(public key error)", "timestamp":1574386825800}

Reason: tiger_id is incorrect, or you do not have a valid public key on file. Other possible reason is that "is_sandbox" is set as True

Q9: permission denied(Current user and device do not have permissions in the US market)

Reason: You do not have API quote permission(Note that Quote permissions for app will not grant you the same prevailage for API). Please go to the Tiger Trade app to buy API Market Data. If you already have an active API quote permission, use QuoteClient.grab_quote_permission() and see if the problem still presists

Q10:user token error(user token cannot be empty)

{code=2400, message=user token error(user token cannot be empty), timestamp=1676447219319}

Reason:Hong Kong license needs to specify the token path

# Use the props_path parameter to specify the token path, such as '/Users/xxx/xxx/', if not specified, take the current path
client_config = TigerOpenClientConfig(props_path='.')

Q11: protobuf Version Issue

Our long links use the proto3 version protocol, if you install a lower version of the protobuf library, you will encounter problems, please make sure to use the new version

Q12: Error in Windows system

OSError: [Error 22] Invalid argument: 'D:\\Profram files\\xxx........'
Or
request sign failed. Short octet stream on tag decoding

Reason: Need to add prefix "r" to the string, like r'D:\Foo\Bar\xxx.pem'

Q13: local issuer certificate**

error as follows:

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate

try pip install certifi, reference:https://stackoverflow.com/questions/51925384/unable-to-get-local-issuer-certificate-when-using-requests

then and following code at the start of your program:

import certifi
from urllib3 import PoolManager
from tigeropen.common.util import web_utils

web_utils.http_pool = PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())

Timestamp Conversion

The default time format in Open API is UNIX timestamp. Refer to the following example for how to convert a timestamp into human readable time in your timezone:

from datetime import datetime
from pytz import timezone

time_stamp = 1546635600
tz = timezone('Asia/Chongqing')

datetime.fromtimestamp(time_stamp, tz)
datetime.datetime(2019, 1, 5, 5, 0, tzinfo=<DstTzInfo 'Asia/Chongqing' CST+8:00:00 STD>)


MarketStatus Object

Use get_market_status as an example. This API returns a MarketStatus object。

a_list = [MarketStatus({'market': 'US', 'status': 'PreMarket', 'open_time': datetime.datetime(2019, 1, 7, 9, 30, tzinfo=<DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>)})]
us_market_status = a_list[0]
us_market_status.market
'US'
Last update: