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

@@ -32,8 +32,8 @@ export interface AlpacaClock {
}
export interface AlpacaQuote {
ap: number; // ask price
bp: number; // bid price
AskPrice: number;
BidPrice: number;
}
export interface AlpacaTrade {
@@ -83,8 +83,17 @@ export class Alpaca {
return this.alpaca.getClock();
}
public async getLatestQuote(symbol: string) {
return this.alpaca.getLatestQuote(symbol);
public async getLatestAsk(symbol: string): Promise<number> {
const quote = await this.alpaca.getLatestQuote(symbol);
return quote.AskPrice;
}
public async getLatestBid(symbol: string): Promise<number> {
const quote = await this.alpaca.getLatestQuote(symbol);
return quote.BidPrice;
}
public async getLatestSpread(symbol: string): Promise<number> {
const quote = await this.alpaca.getLatestQuote(symbol);
return quote.AskPrice - quote.BidPrice;
}
public async getLatestTrades(symbols: string[]) {
return this.alpaca.getLatestTrades(symbols);