update our alpaca calls to be separate bid and ask

This commit is contained in:
Jon
2026-02-03 13:58:42 -07:00
parent 8872803563
commit e32e30af47
11 changed files with 116 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
import { Alpaca } from "./alpaca";
import { Strategy } from "./strategy";
import { Executor } from "./executor";
import { waitForNextOpen } from "./trading";
import { isMarketOpen, waitForNextOpen } from "./trading";
export class Bot {
private alpaca: Alpaca;
@@ -21,15 +21,18 @@ export class Bot {
}
async runDay(): Promise<void> {
console.log('waiting for open');
await waitForNextOpen(this.alpaca);
const account = await this.alpaca.getAccount();
const totalCapital = parseFloat(account.cash);
const open = await isMarketOpen(this.alpaca);
if (!open) {
console.log('waiting for open');
await waitForNextOpen(this.alpaca);
}
const account = await this.alpaca.getAccount();
const totalCapital = parseFloat(account.cash);
await Promise.all(
this.strategies.map(async (strategy) => {
const signals = await strategy.execute(this.alpaca);
await this.executor.executeSignals(strategy, signals, totalCapital);
})
);