package controllers import ( "me.thuanle/bbot/internal/configs/strategy" "me.thuanle/bbot/internal/data" "sort" ) // GetTopPrices returns the top symbol, price and rate func GetTopPrices() ([]string, []float64, []float64) { n := len(strategy.TopPriceSymbols) topSym := make([]string, n) 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 { p, ok := all[sym] if !ok { continue } topSym[i] = sym topPrice[i] = p.MarkPrice topRate[i] = p.FundingRate } return topSym, topPrice, topRate } // GetTopFundingFee returns the top funding fee: symbol, rate and cd time func GetTopFundingFee() ([]string, []float64, []int64) { allRates, allCd := data.Market.GetAllFundRate() var resSym []string for sym, rate := range allRates { if strategy.FundRateBuyThreshold < rate && rate < strategy.FundRateSellThreshold { continue } resSym = append(resSym, sym) } sort.Slice(resSym, func(i, j int) bool { return allRates[resSym[i]] < allRates[resSym[j]] }) resRate := make([]float64, len(resSym)) resCd := make([]int64, len(resSym)) for i, sym := range resSym { resRate[i] = allRates[sym] resCd[i] = allCd[sym] } return resSym, resRate, resCd }