Add endpoint to query historical prices in candlestick form#118
Add endpoint to query historical prices in candlestick form#118
Conversation
LCyson
left a comment
There was a problem hiding this comment.
lgtm pending a small test and comment
Also are we going to revert this change after we have an off-chain data store?
|
|
||
| func PricePrefix(contractAddr string) []byte { | ||
| return append(KeyPrefix(PriceKey), KeyPrefix(contractAddr)...) | ||
| func PricePrefix(contractAddr string, priceDenom string, assetDenom string) []byte { |
There was a problem hiding this comment.
can we add an example for how the prefix is added in a comment, and also a test for this
There was a problem hiding this comment.
added a comment and a test
| // set open | ||
| pricePtr := 0 | ||
| for i := range candlesticks { | ||
| for pricePtr < len(validPrices) && validPrices[pricePtr].SnapshotTimestampInSeconds > candlesticks[i].BeginTimestamp { |
There was a problem hiding this comment.
nit: is it better to sort the validPrices in time ascending order so it can reduce some code duplication here? guess the computation is not so important as it's a query endpoint, i'm also good with changing this in a separate PR
There was a problem hiding this comment.
i intentionally kept open/high/low/close logic separate just to make logic clear for each. If needed I can also consolidate all four computations, but it might be less readable
* Add historical price endpoint * add tests * linter * key test Co-authored-by: Tony Chen <tonychen@Tonys-MacBook-Pro.local>
…ocol#118) * Add historical price endpoint * add tests * linter * key test Co-authored-by: Tony Chen <tonychen@Tonys-MacBook-Pro.local>
## Describe your changes and provide context This adds the midblock interfaces and module manager functionality to sei-cosmos ## Testing performed to validate your change Added unit test for module manager behavior and also tested with local sei with sei-chain changes
## Describe your changes and provide context This adds the midblock interfaces and module manager functionality to sei-cosmos ## Testing performed to validate your change Added unit test for module manager behavior and also tested with local sei with sei-chain changes
* dbsync * snapshotting * add CLI script * fix * fix * fix * fix * post sync hook * add LoadLatest abci call * fix tests * fixes * fix * change toml name * rebase * add unit tests * nit * address comments * test parallel * config for snapshot worker count * make channel non-blocking * add logs * update default config * OnStop * fix race condition in tests
#118) This reverts commit c35c30a, reversing changes made to 302e86d. ## Describe your changes and provide context - Revert surfacing errors from db layer since the rpc / keeper / store layer hard codes a lot of handling of record not found and there needs to be a larger refactor - Can re introduce this error after a redesign and consideration of impact ## Testing performed to validate your change - Verified in unit tests and on node
Request format:
/sei-protocol/seichain/dex/get_historical_prices/{contractAddr}/{priceDenom}/{assetDenom}/{periodLengthInSeconds}/{numOfPeriods}For example, if you want to get a price bar of size 30s and you want 120 bars (for an hour),
periodLengthInSecondswould be 30 andnumOfPeriodswould be 120.Response format:
Prices are sorted in descending order based on time (i.e. the most recent price bar is at the top). In this PR we haven't populated
volumeyet so this field will always be 0 for the time being.Also changed price snapshotting to be tick-based rather than epoch-based, and extended price snapshot retention to 24 hours.