Skip to content

Commit

Permalink
improvement: update trade bar timestamp only if it's newer then last …
Browse files Browse the repository at this point in the history
…updated one
  • Loading branch information
thaaddeus committed Jul 26, 2024
1 parent 53d98fa commit 7302ab3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/computable/tradebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ class TradeBarComputable implements Computable<TradeBar> {
inProgressBar.vwap = (inProgressBar.vwap * inProgressBar.volume + trade.price * trade.amount) / (inProgressBar.volume + trade.amount)
// volume needs to be updated after vwap otherwise vwap calc will go wrong
inProgressBar.volume += trade.amount
inProgressBar.timestamp = trade.timestamp

if (trade.timestamp.valueOf() > inProgressBar.timestamp.valueOf()) {
inProgressBar.timestamp = trade.timestamp
}
}

private _reset() {
Expand Down

0 comments on commit 7302ab3

Please sign in to comment.