I’m currently looking into the python bindings for the api to get a history of my portfolio performance (time frame = 1D):
Exemplary call:
self.api.get_portfolio_history(date_start='2022-05-25', timeframe='1D')
Response:
called at 2022-05-29T12:53:22.379648
{'timestamp': [1653523200, 1653609600, 1653696000], 'equity': [100000, 99999.60725501535, 100000.00437721757], 'profit_loss': [0, -0.36851750489, 0.42089110264875], 'profit_loss_pct': [0, -3.6851750489e-06, 5.237369972651851e-07], 'base_value': 0, 'timeframe': '1D'}
The problem here is that the last value (100000.00437721757, mapped to 2022-05-28, Saturday) seems to be wrong; the value of the portfolio was $99,998.89 according to the dashboard:
Internally however, the dashboard receives the same wrong value upon calling the api to display the values:
https://app.alpaca.markets/internal/paper_accounts/d63c2a51-c3ad-4612-8fbe-0154c3d522bf/portfolio/history?extended_hours=true&period=1M
{"arrays":[[1651104000000,1651190400000,1651276800000,1651536000000,1651622400000,1651708800000,1651795200000,1651881600000,1652140800000,1652227200000,1652313600000,1652400000000,1652486400000,1652745600000,1652832000000,1652918400000,1653004800000,1653091200000,1653350400000,1653436800000,1653523200000,1653609600000,1653696000000],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-0.36851750489,0.42089110264875],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-0.0000036851750489,5.237369972651851e-7],[100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,100000,99999.60725501535,100000.00437721757]],"attributes":[{"name":"Date","type":"date"},{"name":"ProfitLoss","type":"float64"},{"name":"ProfitLossPctChange","type":"float64"},{"name":"PortfolioValue","type":"float64"}],"timeframe":"1D","base_value":100000}
My question now is, does this error only happen on weekends / days when the exchanges are closed? And how does the dashboard combat this? Should I manually request data for e.g. smaller time frames for these days to get a correct value?