alpacahq / Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
https://alpaca.markets/
142 stars 13 forks source link

add date that a stock is bought #40

Open MarshallHunt opened 5 years ago

MarshallHunt commented 5 years ago

Have it tie to the position, so that you can see how long you have bought a stock. In my case I am wanting to see if I bought the stock today or not.

ViridianHawk commented 5 years ago

I'd day this feature already exists. It's just in the order history instead of in positions. I think it makes more sense that way.

While it might be convenient to see it in your positions, it becomes complicated if you add to or sell parts of a position. Not exactly clear what the expected behavior should be. Lots of complicated edge cases. Doesn't really make sense to have it in positions, unless they break positions out into the various lots and give you a timestamp for each lot.

Luckily, it's already super simple for you to keep track of when you bought a position within your own algorithm. When you place an order, save the timestamp. Or save the order ID, which you can use to look up the filled_at timestamp. Also, even if you don't save the timestamp or order_id when you place an order, you can look up your entire order history and see it there.

umitanuki commented 5 years ago

@ViridianHawk you are completely right on that position does not necessarily represent single order entry and thanks for the explanation. That said, we've been thinking about adding "raw" position API where each position entry is 1:1 with order execution. It is going to be more complicated and may not be for everyone, but it should be helpful in many cases as well.