Skip to content

feat: expose indexGetConstituents as AI tool #198

@fprivitera

Description

@fprivitera

Summary

SDKIndexClient.getConstituents() exists in the domain layer (src/domain/market-data/client/typebb/index-client.ts) but is never registered as an AI-callable tool. The indexClient instance is already created in main.ts for the typebb-sdk backend but not wired into ToolCenter.

Change required

  1. Add src/tool/index-data.ts — thin wrapper exposing indexGetConstituents:
export function createIndexTools(indexClient: IndexClientLike) {
  return {
    indexGetConstituents: tool({
      description: 'Get constituents of a market index (e.g. S&P 500 via "^GSPC")',
      inputSchema: z.object({
        symbol: z.string(),
        provider: z.string().optional(),
      }),
      execute: async ({ symbol, provider }) =>
        indexClient.getConstituents({ symbol, ...(provider ? { provider } : {}) }),
    }),
  }
}
  1. Register in main.ts after indexClient is instantiated:
if (indexClient) toolCenter.register(createIndexTools(indexClient), 'index')

Why

Needed as a prerequisite for any strategy that scans index universes (e.g. S&P 500 mean-reversion scans). Without this tool the AI cannot fetch constituent symbols at runtime.

Notes

  • Only available when marketData.backend === 'typebb-sdk' (the openbb-api path does not instantiate SDKIndexClient)
  • ~15 LOC total, no new dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions