phase-1: optimize code
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* bin/import-portfolio.js — Portfolio CSV Importer
|
||||
*
|
||||
* Reads a holdings export from Robinhood, Vanguard, or Fidelity
|
||||
* and merges the positions into portfolio.json.
|
||||
*
|
||||
* Broker is auto-detected from CSV headers.
|
||||
* Existing entries are updated in-place; new tickers are added.
|
||||
*
|
||||
* How to export:
|
||||
* Robinhood → Account → Statements & History → Export → Holdings
|
||||
* Vanguard → My Accounts → Holdings → Download (top-right icon)
|
||||
* Fidelity → Accounts & Trade → Portfolio → Positions → Download CSV
|
||||
*
|
||||
* Usage:
|
||||
* npm run import-portfolio -- <file.csv>
|
||||
*/
|
||||
|
||||
import { PortfolioImporter } from '../src/finance/PortfolioImporter.js';
|
||||
|
||||
const csvPath = process.argv[2];
|
||||
|
||||
if (!csvPath) {
|
||||
console.error('Usage: npm run import-portfolio -- <path-to-csv>\n');
|
||||
console.error('Examples:');
|
||||
console.error(' npm run import-portfolio -- ~/Downloads/robinhood_holdings.csv');
|
||||
console.error(' npm run import-portfolio -- ~/Downloads/vanguard_holdings.csv');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
new PortfolioImporter().import(csvPath);
|
||||
} catch (err) {
|
||||
console.error(`\nImport failed: ${err.message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'dotenv/config';
|
||||
import { buildApp } from '../src/server/app.js';
|
||||
|
||||
const PORT = process.env.PORT ?? 3000;
|
||||
const HOST = process.env.HOST ?? '0.0.0.0';
|
||||
|
||||
const app = await buildApp();
|
||||
|
||||
try {
|
||||
await app.listen({ port: Number(PORT), host: HOST });
|
||||
} catch (err) {
|
||||
app.log.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user