package market import ( "context" "strconv" "time" "github.com/rs/zerolog/log" ) func (ms *MarketData) GetSpotPrice(symbol string) (float64, bool) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() prices, err := ms.spotClient.NewListPricesService().Symbol(symbol).Do(ctx) if err != nil { log.Error().Err(err).Str("symbol", symbol).Msg("Failed to fetch spot price") return ms.getAlphaPrice(symbol) } if len(prices) == 0 { return ms.getAlphaPrice(symbol) } price, err := strconv.ParseFloat(prices[0].Price, 64) if err != nil || price == 0 { return ms.getAlphaPrice(symbol) } return price, true } func (ms *MarketData) getAlphaPrice(symbol string) (float64, bool) { if ms.IsAlphaToken(symbol) { if alphaToken, exists := ms.GetAlphaToken(symbol); exists { if price := alphaToken.GetPrice(); price > 0 { return price, true } } } return 0, false }