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

Integer quantity instead of decimal in PositionsEndpoint.close() #122

Closed DarioArena87 closed 2 years ago

DarioArena87 commented 2 years ago

Hi everyone, based on the official Alpaca API reference (https://alpaca.markets/docs/api-references/trading-api/positions/) when a position is closed using quantity, quantity could be fractional up to 9 decimal places. The close() method declaration in alpaca-java accepts only an Integer quantity parameter so it is impossible to close, as an example, 1.13 shares.

public Order close(String symbolOrAssetID, Integer quantity, Double percentage) throws AlpacaClientException

Is this all due to some conditions i don't know or is it a bug in the API?

Petersoj commented 2 years ago

Hey @DarioArena87, thanks for reporting this. I haven't updated this library in a while, but plan to update it in the coming weeks to be up-to-date with Alpaca's new additions and changes to their API. Thanks for your patience. Feel free to open a PR (or just make a patch version of a local fork) to address the issue if you need it urgently.

DarioArena87 commented 2 years ago

Hi @Petersoj, I finally found some time to submit a PR that should fix this: #123 Feel free to merge it if you are planning to release a new version of the library

Petersoj commented 2 years ago

Added to 9.1.1 release. Thanks!