alpacahq / alpacahq/Alpaca-API

Closed positions

未关闭
#163 0 条评论 9 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
没有语言数据
星标
173
派生
17
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。