Skip to content

Commit

Permalink
Clean data better for gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
ystxn committed Aug 8, 2024
1 parent e14de36 commit 732377a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion ibkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def get_positions(self):
'31': 'lastPrice',
'80': 'unrealizedPnlPercent',
'78': 'dailyPnl',
'83': 'changePercent'
}
client.portfolio_accounts()
marketdata = client.live_marketdata_snapshot(
Expand Down
6 changes: 3 additions & 3 deletions static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ const clean = (data) => data.map((row) => ({
ticker: row.ticker,
name: row.name,
lastPrice: row.lastPrice ? Number(row.lastPrice.replace(/C/g, '')) : 0,
dailyPnl: row.dailyPnl ? Number(row.dailyPnl) : 0,
changePercent: Number(row.changePercent),
unrealizedPnl: Number(row.unrealizedPnl),
dailyPnl: Number(row.dailyPnl || 0),
changePercent: (Number(row.dailyPnl || 0) * 100) / Number(row.mktValue - Number(row.dailyPnl || 0)),
unrealizedPnl: Number(row.unrealizedPnl || 0),
unrealizedPnlPercent: Number(row.unrealizedPnlPercent.replace(/%/g, '')),
mktValue: Number(row.mktValue),
}));
Expand Down

0 comments on commit 732377a

Please sign in to comment.