Setup basic portfolio interface

This commit is contained in:
Carter Bertolini 2023-10-06 16:21:31 -04:00
parent 76cfbc8090
commit b42d974c56
5 changed files with 44 additions and 25 deletions

View File

@ -1,9 +0,0 @@
import { Account } from "./interface/account";
import {Quote} from "./interface/quote"
interface Exchange {
name: string;
fetchAccounts: () => Account[];
fetchQuote: (symbol: string) => Quote;
}

View File

@ -1,4 +1,14 @@
import { createLogger, transports, format } from "winston";
import { Account } from "./interface/account";
import { Quote } from "./interface/quote"
export interface Exchange {
name: string;
fetchAccounts: () => Account[];
fetchQuote: (symbol: string) => Quote;
}
const logger = createLogger({
transports: [new transports.Console()],
@ -10,5 +20,5 @@ const logger = createLogger({
})
),
});
logger.info("Hello world!");
logger.info("Hello world!");

View File

@ -1,3 +1,5 @@
import { Portfolio } from "./portfolio";
export interface Account {
fetchPortfolio: () => Portfolio;
}
}

View File

@ -1,17 +1,31 @@
export interface Position {
export class Position {
readonly lastTrade: number;
readonly lastTradeTime: Date;
readonly change: number;
readonly changePercent: number;
readonly earningsPerShare: number;
readonly marketCap: number;
readonly symbol: string;
readonly quantity: number;
readonly dateAcquired: Date;
readonly pricePaid: number;
readonly price: number;
readonly change: number;
readonly changePct: number;
constructor(lastTrade: number, lastTradeTime: Date, change: number, changePercent: number, earningsPerShare: number, marketCap: number, symbol: string) {
this.lastTrade = lastTrade;
this.lastTradeTime = lastTradeTime;
this.change = change;
this.changePercent = changePercent;
this.earningsPerShare = earningsPerShare;
this.marketCap = marketCap;
this.symbol = symbol;
}
}
export interface Portfolio {
export class Portfolio {
readonly positions: Position[];
}
constructor(positions: Position[]) {
this.positions = positions;
}
}

View File

@ -1,3 +1,5 @@
export class Quote {
}
}