Address PR #15 review: batch API calls and admin-guard /refresh

1. Add GetAllPremiumIndex() to fetch all futures data in one call,
   used by GetTopPrices instead of per-symbol sequential calls.
2. Add ADMIN_CHAT_ID env check to /refresh command to restrict
   access to authorized users only.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 15:40:00 +07:00
parent 9c39423315
commit c7128ff516
5 changed files with 49 additions and 12 deletions
+8 -4
View File
@@ -13,15 +13,19 @@ func GetTopPrices() ([]string, []float64, []float64) {
topPrice := make([]float64, n)
topRate := make([]float64, n)
all, err := data.Market.GetAllPremiumIndex()
if err != nil {
return topSym, topPrice, topRate
}
for i, sym := range strategy.TopPriceSymbols {
price, rate, _, ok := data.Market.GetFuturePrice(sym)
p, ok := all[sym]
if !ok {
continue
}
topSym[i] = sym
topPrice[i] = price
topRate[i] = rate
topPrice[i] = p.MarkPrice
topRate[i] = p.FundingRate
}
return topSym, topPrice, topRate
}