DocsGuides

Adding a Market Provider

Extending t-server to pull in alternative financial market APIs.

When injecting a new data source into the system, strictly follow the provider abstraction structure.

  1. Create the Service File: Navigating to src/market/providers/ and establish a new class implementing the IMarketProvider interface.
  2. Wrap in Cache: Instantiate your class exclusively through the CacheService rather than calling it directly within an Express handler.
  3. Error Propagation: The provider must trap its own HTTP 400/500 errors and map them to internal structural defaults. If an upstream source fails, it shouldn't crash the server.
typescript
export class ExampleProvider { async fetchIndex() { try { const res = await fetch("..."); return await res.json(); } catch { return { _fallback: true, data: [] }; } } }

Trentarev