update our alpaca calls to be separate bid and ask
This commit is contained in:
17
src/bot.ts
17
src/bot.ts
@@ -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);
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user