Setup basic portfolio interface
This commit is contained in:
parent
76cfbc8090
commit
b42d974c56
@ -1,9 +0,0 @@
|
||||
import { Account } from "./interface/account";
|
||||
import {Quote} from "./interface/quote"
|
||||
|
||||
interface Exchange {
|
||||
name: string;
|
||||
|
||||
fetchAccounts: () => Account[];
|
||||
fetchQuote: (symbol: string) => Quote;
|
||||
}
|
14
src/index.ts
14
src/index.ts
@ -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!");
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { Portfolio } from "./portfolio";
|
||||
|
||||
export interface Account {
|
||||
fetchPortfolio: () => Portfolio;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
export class Quote {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user