MCPcopy Create free account
hub / github.com/QuantiaAI/helm-agents / computeReturns

Function computeReturns

packages/dataflows/src/returns.ts:81–100  ·  view source on GitHub ↗
(
  symbol: string,
  fromDate: string,
  holdDays: number,
  benchmark: string,
  fetchImpl: typeof fetch = globalThis.fetch,
)

Source from the content-addressed store, hash-verified

79}
80
81export async function computeReturns(
82 symbol: string,
83 fromDate: string,
84 holdDays: number,
85 benchmark: string,
86 fetchImpl: typeof fetch = globalThis.fetch,
87): Promise<ReturnsResult> {
88 const endDate = addDays(fromDate, holdDays);
89 const [symSeries, benchSeries] = await Promise.all([
90 fetchSeries(symbol, fetchImpl),
91 fetchSeries(benchmark, fetchImpl),
92 ]);
93 const symbolReturn = pctChange(symSeries, fromDate, endDate);
94 const benchmarkReturn = pctChange(benchSeries, fromDate, endDate);
95 const alpha =
96 symbolReturn != null && benchmarkReturn != null
97 ? symbolReturn - benchmarkReturn
98 : null;
99 return { symbolReturn, benchmarkReturn, alpha };
100}

Callers 2

resolvePendingFunction · 0.90
returns.test.tsFile · 0.85

Calls 4

addDaysFunction · 0.85
fetchSeriesFunction · 0.85
pctChangeFunction · 0.85
allMethod · 0.65

Tested by

no test coverage detected