22 lines
887 B
JavaScript
22 lines
887 B
JavaScript
#!/usr/bin/env node
|
|
|
|
const Database = require('better-sqlite3');
|
|
const path = require('path');
|
|
const { initAutonomySchema } = require('../src/autonomy/schema');
|
|
|
|
const symbol = String(process.argv[2] || '').trim().toUpperCase();
|
|
if (!/^[A-Z0-9._/-]+$/.test(symbol)) {
|
|
console.error('usage: node scripts/set-autonomy-instrument.js SYMBOL [broker]');
|
|
process.exit(2);
|
|
}
|
|
const broker = String(process.argv[3] || 'simulator');
|
|
const db = new Database(process.env.INTELLIGENCE_DB || path.resolve(process.cwd(), 'intelligence.sqlite'));
|
|
initAutonomySchema(db);
|
|
db.prepare(`
|
|
INSERT INTO autonomy_instruments(symbol, broker, active, tradable)
|
|
VALUES (?, ?, 1, 1)
|
|
ON CONFLICT(symbol) DO UPDATE SET broker=excluded.broker, active=1, tradable=1, updated_at=datetime('now')
|
|
`).run(symbol, broker);
|
|
console.log(JSON.stringify({ symbol, broker, active: true, tradable: true }));
|
|
db.close();
|