Here’s a bit of context:
- a user’s balance is the
select cumulative_sum(sum(amount)) as balance from actions group by time(xx),assetCode,userId fill(0)
- the market value of an asset is
select median(usdRate) as rate from rates group by time(xx),assetCode fill(previous)
- a user’s balance’s market value is the
balance * rate
- a user’s portfolio’s market value is the
sum(balance * rate)
1 & 2 are easy to store in influxdb
3 is easy to do continuously by joining the 1 & 2 streams with kapacitor
However, I’m having trouble figuring out how keep a user’s data accurate if one of my users is to add new data in the past (for instance, adding trades that happened in the past by uploading some CSV file)
What I’d like to do is only replay the marketValue task when actions have been created before the continuous query window. And only for the user who’se data changed.
How would you go about this?
A script that calls replay-live ?
Can I provide arguments to kapacitor tasks?