MCPcopy Create free account
hub / github.com/TheCSir/TerminalStart / fetchSymbol

Function fetchSymbol

src/hooks/useMarketData.ts:180–199  ·  view source on GitHub ↗
(
    symbol: string,
    provider: MarketProvider,
    apiKey?: string,
)

Source from the content-addressed store, hash-verified

178
179// --- Dispatcher ---
180async function fetchSymbol(
181 symbol: string,
182 provider: MarketProvider,
183 apiKey?: string,
184): Promise<MarketQuote> {
185 const hasPermission = await checkHostPermission(provider);
186 if (!hasPermission) throw new Error('Host permission not granted');
187
188 switch (provider) {
189 case 'finnhub':
190 if (!apiKey) throw new Error('Finnhub requires an API key');
191 return fetchFinnhub(symbol, apiKey);
192 case 'twelvedata':
193 if (!apiKey) throw new Error('Twelve Data requires an API key');
194 return fetchTwelveData(symbol, apiKey);
195 case 'yahoo':
196 default:
197 return fetchYahoo(symbol);
198 }
199}
200
201// --- Hook ---
202export function useMarketData(

Callers 1

useMarketDataFunction · 0.85

Calls 4

fetchFinnhubFunction · 0.85
fetchTwelveDataFunction · 0.85
fetchYahooFunction · 0.85
checkHostPermissionFunction · 0.70

Tested by

no test coverage detected