Setup Alpaca API implementation

This commit is contained in:
2023-10-20 16:32:41 -04:00
parent 4b0a2a284a
commit 6dc8ecaf26
7 changed files with 138 additions and 101 deletions

View File

@@ -1,9 +1,26 @@
import Alpaca from '@alpacahq/alpaca-trade-api'
import { AlpacaPortfolioProvider } from './portfolio'
import { AlpacaQuoteProvider } from './quote'
import { Exchange } from '../interface/exchange'
import { PortfolioProvider } from '../interface/portfolio'
import { QuoteProvider } from '../interface/quote'
export class AlpacaExchange implements Exchange {
readonly alpaca: Alpaca;
/**
* The portfolio provider for the exchange.
*/
readonly portfolioProvider: PortfolioProvider;
/**
* The quote provider for the exchange.
*/
readonly quoteProvider: QuoteProvider;
/**
* The name of the exchange.
*/
readonly name: string;
constructor(keyId: string, secretKey: string, paper: boolean) {
@@ -13,6 +30,9 @@ export class AlpacaExchange implements Exchange {
paper: paper
});
this.portfolioProvider = new AlpacaPortfolioProvider(this.alpaca);
this.quoteProvider = new AlpacaQuoteProvider(this.alpaca);
this.name = 'Alpaca';
}
}
}