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

[Question]: Lack of latest trade example in docs #149

Closed
3 tasks done
sshcli opened this issue Aug 18, 2022 · 1 comment
Closed
3 tasks done

[Question]: Lack of latest trade example in docs #149

sshcli opened this issue Aug 18, 2022 · 1 comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@sshcli
Copy link
Contributor

sshcli commented Aug 18, 2022

Question form pre-submit checklist.

  • I have searched the existing issues to ensure there isn't already an issue about this question.
  • My question has to do with the Python SDK and isn't a general question about the API. (If it is please open your issue here)
  • My question isn't about how to do a specific algorithm or asking for trade advice (answers to these are outside the scope of this repo).

Question

I have searched in Google and documentation page:
https://alpaca.markets/docs/python-sdk/market_data.html

I couldn't find an example on how to get the latest trade with alpaca-py 0.5.3

With alpaca-trade-api 2.3.0 is as simple as this: api.get_latest_trade("AAPL")

Thanks in advance for your response.

Regards,

@haxdds haxdds added documentation Improvements or additions to documentation enhancement New feature or request labels Aug 18, 2022
@sshcli
Copy link
Contributor Author

sshcli commented Aug 21, 2022

Ok, finally, I got it.

Get latest trade with alpaca-trade-api 2.3.0

LT = api.get_latest_trade(symbol).p

Get latest trade with alpaca-py 0.5.4

pre_latest_trade = StockLatestTradeRequest(symbol_or_symbols=[symbol])
pre2_latest_trade = data.get_stock_latest_trade(pre_latest_trade)
LT = pre2_latest_trade[symbol].price

@sshcli sshcli closed this as completed Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants