What did you try and what were you expecting?
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.
Describe what you tried, what you expected to happen, and what actually resulted.
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.
Given this information, we could ask the following question on Stack Overflow:
"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?