FetchQuantData fetches quantitative data for a single coin
(symbol string)
| 1013 | |
| 1014 | // FetchQuantData fetches quantitative data for a single coin |
| 1015 | func (e *StrategyEngine) FetchQuantData(symbol string) (*QuantData, error) { |
| 1016 | if !e.config.Indicators.EnableQuantData { |
| 1017 | return nil, nil |
| 1018 | } |
| 1019 | if e.usesHyperliquidNativeUniverse() || market.IsXyzDexAsset(symbol) { |
| 1020 | logger.Infof("⏭️ Skipping NofxOS quant data for Hyperliquid symbol %s; using native Hyperliquid klines/mark data only", symbol) |
| 1021 | return nil, nil |
| 1022 | } |
| 1023 | |
| 1024 | // Use nofxos client with unified API key |
| 1025 | include := "oi,price" |
| 1026 | if e.config.Indicators.EnableQuantNetflow { |
| 1027 | include = "netflow,oi,price" |
| 1028 | } |
| 1029 | |
| 1030 | nofxosData, err := e.nofxosClient.GetCoinData(symbol, include) |
| 1031 | if err != nil { |
| 1032 | return nil, fmt.Errorf("failed to fetch quant data: %w", err) |
| 1033 | } |
| 1034 | |
| 1035 | if nofxosData == nil { |
| 1036 | return nil, nil |
| 1037 | } |
| 1038 | |
| 1039 | // Convert nofxos.QuantData to kernel.QuantData |
| 1040 | quantData := &QuantData{ |
| 1041 | Symbol: nofxosData.Symbol, |
| 1042 | Price: nofxosData.Price, |
| 1043 | PriceChange: nofxosData.PriceChange, |
| 1044 | } |
| 1045 | |
| 1046 | // Convert OI data |
| 1047 | if nofxosData.OI != nil { |
| 1048 | quantData.OI = make(map[string]*OIData) |
| 1049 | for exchange, oiData := range nofxosData.OI { |
| 1050 | if oiData != nil { |
| 1051 | kData := &OIData{ |
| 1052 | CurrentOI: oiData.CurrentOI, |
| 1053 | } |
| 1054 | if oiData.Delta != nil { |
| 1055 | kData.Delta = make(map[string]*OIDeltaData) |
| 1056 | for dur, delta := range oiData.Delta { |
| 1057 | if delta != nil { |
| 1058 | kData.Delta[dur] = &OIDeltaData{ |
| 1059 | OIDelta: delta.OIDelta, |
| 1060 | OIDeltaValue: delta.OIDeltaValue, |
| 1061 | OIDeltaPercent: delta.OIDeltaPercent, |
| 1062 | } |
| 1063 | } |
| 1064 | } |
| 1065 | } |
| 1066 | quantData.OI[exchange] = kData |
| 1067 | } |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | // Convert Netflow data |
| 1072 | if nofxosData.Netflow != nil { |
no test coverage detected