feat(hyperliquid): add stock symbol market data support

- Add Hyperliquid/XYZ symbol normalization tests and backend coverage

- Extend kline and market data lookup paths for US stock symbols

- Wire frontend data API types for stock-oriented market requests
This commit is contained in:
tinklefund
2026-05-25 01:24:49 +08:00
parent 908fc09aca
commit f37fc9f887
12 changed files with 551 additions and 109 deletions

View File

@@ -9,7 +9,35 @@ import type {
} from '../../types'
import { API_BASE, httpClient } from './helpers'
export interface MarketSymbol {
symbol: string
display?: string
name: string
category: 'crypto' | 'stock' | 'forex' | 'commodity' | 'index' | string
exchange?: string
volume_24h?: number
mark_price?: number
change_24h_pct?: number
prev_day_price?: number
maxLeverage?: number
sz_decimals?: number
}
export interface SymbolListResponse {
exchange: string
symbols: MarketSymbol[]
count: number
}
export const dataApi = {
async getSymbols(exchange = 'hyperliquid-xyz'): Promise<SymbolListResponse> {
const result = await httpClient.get<SymbolListResponse>(
`${API_BASE}/symbols?exchange=${encodeURIComponent(exchange)}`
)
if (!result.success) throw new Error('Failed to fetch symbol list')
return result.data || { exchange, symbols: [], count: 0 }
},
async getStatus(traderId?: string, silent?: boolean): Promise<SystemStatus> {
const url = traderId
? `${API_BASE}/status?trader_id=${traderId}`

View File

@@ -3,6 +3,7 @@ import { strategyApi } from './strategies'
import { configApi } from './config'
import { dataApi } from './data'
import { telegramApi } from './telegram'
import { walletApi } from './wallet'
export const api = {
...traderApi,
@@ -10,4 +11,5 @@ export const api = {
...configApi,
...dataApi,
...telegramApi,
...walletApi,
}

View File

@@ -105,7 +105,7 @@ export interface GridStrategyConfig {
}
export interface CoinSourceConfig {
source_type: 'static' | 'ai500' | 'oi_top' | 'oi_low';
source_type: 'static' | 'ai500' | 'oi_top' | 'oi_low' | 'hyper_all' | 'hyper_main' | 'hyper_rank';
static_coins?: string[];
excluded_coins?: string[]; // 排除的币种列表
use_ai500: boolean;
@@ -114,6 +114,12 @@ export interface CoinSourceConfig {
oi_top_limit?: number;
use_oi_low: boolean;
oi_low_limit?: number;
use_hyper_all?: boolean;
use_hyper_main?: boolean;
hyper_main_limit?: number;
hyper_rank_category?: 'stock' | 'commodity' | 'index' | 'forex' | 'pre_ipo' | 'crypto' | 'all';
hyper_rank_direction?: 'gainers' | 'losers' | 'volume';
hyper_rank_limit?: number;
// Note: API URLs are now built automatically using nofxos_api_key from IndicatorConfig
}