Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Accelerate_backfill_TradeLogs_usd_value #56

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions pkg/pricefiller/price_fillter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ const (
NetworkETHChanID = 1
NetworkETH = "ETH"
updateAllCoinInfoInterval = time.Hour
backfillTradeLogsPriceInterval = time.Hour
backfillTradeLogsPriceInterval = 30 * time.Second
backfillTradeLogsLimit = 60
addressETH = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
coinUSDT = "USDT"
invalidSymbolErrString = "<APIError> code=-1121, msg=Invalid symbol."
)

var (
Expand Down Expand Up @@ -136,7 +138,7 @@ func (p *PriceFiller) runBackFillTradelogPriceRoutine() {
for range ticker.C {
tradeLogs, err := p.s.Get(storage.TradeLogsQuery{
State: string(storage.TradeLogStateNew),
Limit: 100,
Limit: backfillTradeLogsLimit,
})
if err != nil {
p.l.Errorw("Failed to get tradeLogs", "err", err)
Expand All @@ -157,8 +159,10 @@ func (p *PriceFiller) fullFillTradeLog(tradeLog storage.TradeLog) (storage.Trade
makerPrice, makerUsdAmount, err := p.getPriceAndAmountUsd(strings.ToLower(tradeLog.MakerToken),
tradeLog.MakerTokenAmount, int64(tradeLog.Timestamp))
if err != nil {
p.l.Errorw("Failed to getPriceAndAmountUsd for maker", "err", err)
return tradeLog, err
if err.Error() != invalidSymbolErrString {
p.l.Errorw("Failed to getPriceAndAmountUsd for maker", "err", err)
return tradeLog, err
}
}

tradeLog.MakerTokenPrice = makerPrice
Expand All @@ -167,8 +171,10 @@ func (p *PriceFiller) fullFillTradeLog(tradeLog storage.TradeLog) (storage.Trade
takerPrice, takerUsdAmount, err := p.getPriceAndAmountUsd(strings.ToLower(tradeLog.TakerToken),
tradeLog.TakerTokenAmount, int64(tradeLog.Timestamp))
if err != nil {
p.l.Errorw("Failed to getPriceAndAmountUsd for taker", "err", err)
return tradeLog, err
if err.Error() != invalidSymbolErrString {
p.l.Errorw("Failed to getPriceAndAmountUsd for taker", "err", err)
return tradeLog, err
}
}

tradeLog.TakerTokenPrice = takerPrice
Expand Down
Loading