Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

huobi/utils/json_parser.py parameter not check. #153

Open
zentai opened this issue Dec 10, 2024 · 1 comment
Open

huobi/utils/json_parser.py parameter not check. #153

zentai opened this issue Dec 10, 2024 · 1 comment

Comments

@zentai
Copy link

zentai commented Dec 10, 2024

your example getbalance.py not working. base on the log, looks like you try to create instance from class_name, but didn't expected dictionary object.

`
huobi/utils/json_parser.py

def fill_obj(dict_data, class_name=object):
obj = class_name()
for ks, vs in dict_data.items():
obj_key = key_trans(ks)
# print("===== fill_obj =====", ks, obj_key, str(vs))
if hasattr(obj, obj_key):
setattr(obj, obj_key, vs)
continue
return obj
`

account/get_balance.py", line 21, in parse def parse(dict_data): data = dict_data.get("data", {}) return default_parse(data, AccountBalance, {}) <<<< but why you pass dictionary in?

Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/Users/zen/code/bayes_excersice/src/tradingfirm/platforms/huobi_api.py", line 326, in <module> list_obj = account_client.get_balance(account_id=spot_account_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/client/account.py", line 34, in get_balance return GetBalanceService(params).request(**self.__kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/service/account/get_balance.py", line 23, in request return RestApiSyncClient(**kwargs).request_process( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/connection/restapi_sync_client.py", line 155, in request_process return self.request_process_product(method, url, params, parse) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/connection/restapi_sync_client.py", line 160, in request_process_product return call_sync(request) ^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/connection/impl/restapi_invoker.py", line 62, in call_sync return request.json_parser(dict_data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/service/account/get_balance.py", line 21, in parse return default_parse(data, AccountBalance, {}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/utils/json_parser.py", line 46, in default_parse new_value = fill_obj_list(outer_value, inner_class_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/utils/json_parser.py", line 26, in fill_obj_list inner_obj = fill_obj(row, class_name) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/zen/code/bayes_excersice/huobi/utils/json_parser.py", line 12, in fill_obj obj = class_name() ^^^^^^^^^^^^ TypeError: 'dict' object is not callable

@zentai
Copy link
Author

zentai commented Dec 11, 2024

I guess you plan to assign Balance as a nested object.

def parse(dict_data): data = dict_data.get("data", {}) return default_parse(data, AccountBalance, Balance)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant