T-213: M2.4b — Add Python stockbot register_signal, batch feature runner, and M2 MarketDataStore methods

This commit is contained in:
Studio 2026-12-05 14:45:24 -05:00
parent d95b0ce9d3
commit 68a53bd489
2 changed files with 46 additions and 0 deletions

View file

@ -1097,6 +1097,7 @@ def test_polars_batch_per_year_availability_ceiling_blocks_later_year_macro_leak
left_on="ts",
right_on="macro_known_at",
strategy="backward",
coalesce=False,
)
return joined.select(
pl.col("listing_id"),
@ -1311,6 +1312,7 @@ const opened = await openDuckDbMarketDataStore({{
}},
}});
try {{
await opened.executor.run("SET TimeZone = 'UTC';");
await runFeatureBatch(
RET_1D_V1,
{{ curatedRoot, fromYear: 2024, toYear: 2024, vaultCutoffDate: {json.dumps(vault_cutoff_date)} }},

View file

@ -0,0 +1,44 @@
import { existsSync } from 'node:fs';
import { delimiter, dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { expect, test } from 'bun:test';
const repoRoot = fileURLToPath(new URL('../../', import.meta.url));
const pythonDir = join(repoRoot, 'python');
const venvPython = join(pythonDir, '.venv/bin/python');
function buildEnv(baseEnv: NodeJS.ProcessEnv = process.env): Record<string, string> {
const env: Record<string, string> = {};
for (const [key, value] of Object.entries(baseEnv)) {
if (value !== undefined) {
env[key] = value;
}
}
const bunDir = dirname(process.execPath);
env.PATH = env.PATH ? `${bunDir}${delimiter}${env.PATH}` : bunDir;
env.PYTHONPATH = pythonDir;
env.PYTHONDONTWRITEBYTECODE = '1';
return env;
}
test(
'python stockbot SDK offline pytest suite passes',
() => {
const cmd = existsSync(venvPython)
? [venvPython, '-m', 'pytest', '-q', '-rf', join(pythonDir, 'tests')]
: ['uv', 'run', '--directory', pythonDir, '--offline', '--extra', 'dev', 'pytest', '-q', '-rf'];
const spawned = Bun.spawnSync(cmd, {
cwd: pythonDir,
env: buildEnv(),
stdout: 'pipe',
stderr: 'pipe',
});
const stdout = new TextDecoder().decode(spawned.stdout);
const stderr = new TextDecoder().decode(spawned.stderr);
expect(spawned.exitCode, `${stdout}\n${stderr}`).toBe(0);
},
60_000
);