Setup basic Alpaca action fetch and test.

This commit is contained in:
2023-10-27 17:41:57 -04:00
parent 8437515904
commit 327ab308bf
3 changed files with 27 additions and 3 deletions

View File

@ -1,6 +1,21 @@
import { describe, expect, test } from '@jest/globals';
import 'dotenv/config';
import { AlpacaExchange } from '../src/index';
import { ActionFetchOptions, AlpacaExchange } from '../src/index';
import { createLogger, transports, format } from "winston";
const logger = createLogger({
transports: [new transports.Console()],
format: format.combine(
format.colorize(),
format.timestamp(),
format.printf(({ timestamp, level, message, service }) => {
return `[${timestamp}] ${service} ${level}: ${message}`;
})
),
defaultMeta: {
service: "AlpacaTest",
},
});
describe('Alpaca Tests', () => {
test('portfolio fetch', () => {
@ -16,4 +31,11 @@ describe('Alpaca Tests', () => {
const exchange = new AlpacaExchange(process.env.ALPACA_API_KEY!, process.env.ALPACA_SECRET_KEY!, true);
expect(exchange.quoteProvider.fetchQuote("AAPL")).resolves.toBeDefined();
});
test('action fetch', async () => {
expect(process.env.ALPACA_API_KEY).toBeDefined();
expect(process.env.ALPACA_SECRET_KEY).toBeDefined();
const exchange = new AlpacaExchange(process.env.ALPACA_API_KEY!, process.env.ALPACA_SECRET_KEY!, true);
expect(exchange.actionProvider.fetchActions(new ActionFetchOptions)).resolves.toBeDefined();
});
});