tigerfintech / openapi-python-sdk

Python SDK for Tiger Open API
https://quant.itiger.com/#openapi
76 stars 15 forks source link

get_account_info() returns error code 1010 #41

Closed gnimnix closed 3 years ago

gnimnix commented 3 years ago

Using the sample codes provided in the examples directory and replacing the values with my own account details. I am trying to access my simulation account here:

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('rsa_private_key.pem')
    client_config.tiger_id = '201*****'
    client_config.account = '202***********'
    client_config.language = Language.en_US
    return client_config

def get_account_info():
    client_config = get_client_config()
    openapi_client = TigerOpenClient(client_config)
    account = AccountsParams()
    account.account = 'DU575569'
    request = OpenApiRequest(method=ACCOUNTS, biz_model=account)

    response_content = None
    try:
        response_content = openapi_client.execute(request)
    except Exception as e:
        print(traceback.format_exc())
    if not response_content:
        print("failed to execute")
    else:
        response = TigerResponse()
        response.parse_response_content(response_content)
        if response.is_success():
            print("get response data:" + response.data)
        else:
            print(response.code + "," + response.msg + "," + response.data)

Running get_account_info() gives me the following error:

Traceback (most recent call last):
  File "main.py", line 89, in <module>
    get_account_info()
  File "main.py", line 49, in get_account_info
    print(response.code + "," + response.msg + "," + response.data)
TypeError: unsupported operand type(s) for +: 'int' and 'str'

Upon further investigating to find out what the response code was:

print(response.code)
# print(response.code + "," + response.msg + "," + response.data)

Now the output prints 1010, which according to the list of error codes, says that there is an error with a business parameter. Am I missing something here?

hotea commented 3 years ago

What's the error message detail?

gnimnix commented 3 years ago

Problem solved.

client_config.account = '' and account.account = '' should both use my main account ID