psemdel / py-trading-bot

Trading-bot in python using django, vertorbt lib and interactive-brokers
MIT License
166 stars 38 forks source link

@connect_ib problem #47

Closed Fun1628 closed 3 months ago

Fun1628 commented 3 months ago

What does this @connect_ib does? I know it is called before the function, but it looks like the function is not called at all even after a successful connect.

In my case, during retireve_data_online, it calls retrieve_data_ib which has the @connect_id decorator, after it call ib_global["connected"] is true, which should mean IB is connected and the IBKR_gateway confirmed it is connected, but the retireve_data_ib never get called, and it give this following message

INFO 63 IB retrieval of symbol failed, fallback on YF AMD: Period '3y' is invalid, must be one of ['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']

Fun1628 commented 3 months ago

Okay, found out what the problem is by adding

except Exception as error:

1/ Multiple arguments for it_is_index: that's due to the used_api being added to the function retrieve_data_ib. The first time it's working because both it_is_index and use_api is false. Second time use_api is true while it_is_index is false. Remove used_api argument solve that.

# cours, symbols, index_symbol=retrieve_data_ib(used_api,actions,period,it_is_index=it_is_index)
                cours, symbols, index_symbol=retrieve_data_ib(actions,period,it_is_index=it_is_index)

2/ Unexpected 'client' keyword, remove kwargs['client'] resolve problem

   def wrapper(*args,**kwargs):
        #kwargs['client'] = IBData.resolve_client(None)
        IBData.resolve_client(None)
        return func(*args,**kwargs)
    return wrapper

3/ now I got ERROR 159 IBData.init() got an unexpected keyword argument 'single_key'

Looks like there are multiple problem, so further troubleshoot is required.

psemdel commented 3 months ago

I will try to understand.