alpacahq / alpacahq/Alpaca-API

Closed positions

Đang mở
#163 0 bình luận 9 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
173
Fork
17
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

There is an excelent api function to get open positions, but currently we have no good way to display positions that have been closed / historical positions.

This is important information too see what you have done good and what have gone bad in your algorithm.

I know about three ways to solve this, but none of them are ideal combied with having the excact same output as open positions for closed positions:
1. Have a local database combined with using "client_order_id" and only submit orders (not close positions function because then you loose track)
2. Parse all account activities ascending from the beginning to the end then loop them and create new "position" element when quantity goes to 0.
3. Parse all orders, it's possible but better to parse all account activities since it's contains side "sell_short" when starting a short position.

It would have been much easier to get this directly from Alpaca.

Example on what that output could have contained (almost same as i posted in Slack):
[symbol] --ticker
[side] --long/short
[openOrders] --varchar with a array of the 3 order id's, also used for counting the times it have bought/sell orders
[openAmount] --sum quantity, so if i buy/sell 100 stocks three times it have 300
[openPriceAvg] --average price of the 3 orders
[openPriceSum] --just price * amount
[openFeeSum] --order object by alpaca dont contain fee, but for Live accounts it could have been added after midnight
[openFirstDate] --date of the first order that opened the position
[openLastDate] --if only one order it has the date of the first order, if multiple it has the last
[.....] --all the same columns as "open" except for being named close (closeAmount etc.)
[statistics] --json object containing lowestPrice and date, highestprice, percentage change etc. (these data are being updaded every minute after the position is opened if higher/lower)
[profitUSD] --updated when closing the position
[profitPc] --updated when closing the position

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.