Petersoj / alpaca-java

A Java API for Alpaca, the commission free, algo friendly, stock trading broker. https://alpaca.markets
https://petersoj.github.io/alpaca-java/
MIT License
198 stars 84 forks source link

get latest trade price in Crypto API is not working #146

Closed Andys52621 closed 6 months ago

Andys52621 commented 7 months ago

I tried the latest quote and latest traded bars , but getPrice() method is not returning correct last traded price for the crypto (BTC/USD) however getAsk or getBid are correctly working.

Is this a known issue ?

Petersoj commented 7 months ago

Thanks for reporting this. I will look into this later this week.

Andys52621 commented 7 months ago

Hi Jacob, please let us know when this issue is fixed. Currently the last traded prices is not working. Ask and Bid prices are working correctly.

Map<String, CryptoSnapshot> latestSnapShotMap =null; latestSnapShotMap = alpacaAPI.cryptoMarketData().getSnapshots(a).getSnapshots();

Double currentPrice = Double.parseDouble(String.format("%.2f", latestSnapShotMap.get(Property.stockSymbol).getLatestTrade().getPrice()));

Double askPrice = Double.parseDouble(String.format("%.2f", latestSnapShotMap.get(Property.stockSymbol).getLatestQuote().getAskPrice()));

Double bidPrice = Double.parseDouble(String.format("%.2f", latestSnapShotMap.get(Property.stockSymbol).getLatestQuote().getBidPrice()));

Andys52621 commented 7 months ago

Also cryptoSnapShot.getLatestTrade().getSize();

the latest trade size is not coming correctly. its coming as a huge large negative number like riceSize: 1.949E-5

Petersoj commented 6 months ago

Should be fixed in 10.0.0. Re-open if not.