Reputation: 11
AttributeError: 'REST' object has no attribute 'get_last_trade_for_symbol' when using Alpaca API in Python for CL crude oil futures trading. What is the alternative method to retrieve the current price of a contract symbol?
We tried to use the Alpaca Trade API to retrieve the current price of a crude oil futures contract. We expected the script to retrieve the current price and use it to place a trade. However, we kept encountering an "AttributeError" related to the "get_last_trade_for_symbol" method, indicating that the method was not recognized by the API.
We tried multiple solutions such as updating the Alpaca API, modifying the line of code to use the "get_last_trade" method instead of "get_last_trade_for_symbol", and replacing the code block entirely. We expected that at least one of these solutions would work to retrieve the current price of the contract. However, we kept encountering the same error, indicating that the solution did not work as expected.
"Encountering 'AttributeError' with 'get_last_trade_for_symbol' method in Alpaca Trade API. Tried updating API, modifying code, and replacing code block. Still encountering error. What could be causing this issue, and what other solutions could I try?
Upvotes: 1
Views: 463