algobulls / pyalgotrading

Official Python Package for Algorithmic Trading APIs powered by AlgoBulls
https://algobulls.github.io/pyalgotrading/
MIT License
241 stars 76 forks source link

Alpaca Bug : Attribute Error #26

Open prithviraj-gotepatil-algobulls opened 1 year ago

prithviraj-gotepatil-algobulls commented 1 year ago

Occurred while runnig PT and RT jobs. Probable cause for this error, data in the queried time is not avaible at alpaca or alpaca is not allowing for trial users

Got this Error 2 times one for PT and one for RT, both on different strategies, The Instrument given in both the cases was TSLA (this could be a probable cause too if TSLA hist data is not available at Alpaca)

[2023-06-16 22:43:10] Waiting for 49.73 seconds until end of current candle (2023-06-16 13:14:00-04:00)...
[2023-06-16 22:44:08] Received event EXCEPTION. Stopping AlgoBulls Trading Core Engine...
[2023-06-16 22:44:08] Cancelling all open orders (if any)... Starting
[2023-06-16 22:44:08] Ignoring cancel. Order already completed... ac5f856a-678f-48d8-9fb7-429bf6ee8d3a
[2023-06-16 22:44:08] Ignoring cancel. Order already completed... ef17165f-595e-4e65-9908-a2a104b50c97
[2023-06-16 22:44:08] Ignoring cancel. Order already completed... 9a31b38d-066f-4db6-abf0-3e06eece9822
[2023-06-16 22:44:08] Ignoring cancel. Order already completed... f1ffe79e-db4d-4a1c-a9a8-d56aa3dbd04c
[2023-06-16 22:44:08] Ignoring cancel. Order already completed... 55e88853-0e2f-4c13-bafb-59adcdd9b221
[2023-06-16 22:44:08] Cancelling all open orders (if any)... Done
[2023-06-16 22:44:08] Exiting all open positions...
[2023-06-16 22:44:08] Exiting all open positions with order code: ORDER_CODE_INTRADAY (if any)...
[2023-06-16 22:44:23] Querying broker API "get_positions" was unsuccessful even after 10 number of attempts. Please check the above log for exception details
[2023-06-16 22:44:23] [ID:0e33d339377b4d3ca801618f8e4660a7] [SELL] [NASDAQ_EQ:TSLA] Order was exited manually. Not exiting...
[2023-06-16 22:44:23] Exiting all open positions with order code: ORDER_CODE_DELIVERY_T0 (if any)...
[2023-06-16 22:44:23] Exiting all open positions with order code: ORDER_CODE_DELIVERY_T1 (if any)...
[2023-06-16 22:44:23] Exiting all open positions with order code: ORDER_CODE_DELIVERY_T2 (if any)...
[2023-06-16 22:44:23] [User: PA3G7SFZOVVF] Trading session completed
[2023-06-16 22:44:23] Dumping Debug Stack to Python friendly Traceback Format for Python Build Customers: Uncaught exception | Exception Class: <class 'AttributeError'> | Exception Details: 'NoneType' object has no attribute 'items' | Traceback Below:
  File "/usr/local/lib/python3.10/site-packages/alpaca/data/historical/stock.py", line 102, in get_stock_bars
    return BarSet(raw_bars)
  File "/usr/local/lib/python3.10/site-packages/alpaca/data/models/bars.py", line 73, in __init__
    parsed_bars[symbol] = [Bar(symbol, bar) for bar in bars]
  File "/usr/local/lib/python3.10/site-packages/alpaca/data/models/bars.py", line 73, in <listcomp>
    parsed_bars[symbol] = [Bar(symbol, bar) for bar in bars]
  File "/usr/local/lib/python3.10/site-packages/alpaca/data/models/bars.py", line 43, in __init__
    BAR_MAPPING[key]: val for key, val in raw_data.items() if key in BAR_MAPPING

[2023-06-16 22:44:23] An error has occurred due to which the strategy execution cannot proceed anymore. Reason: 'NoneType' object has no attribute 'items'.
If the reason doesn't help, please double check the tweak parameters. If everything seems fine, please checkout https://community.algobulls.com/ or contact developers@algobulls.com for support.
pushpakdagade commented 9 months ago

This seems to be an issue from the Alpaca side. It hasn't occurred frequently in recent times, meaning it is probably fixed on the Alpaca end. We'll keep it open until we have a clear resolution here