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 { 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({
|
const logger = createLogger({
|
||||||
transports: [new transports.Console()],
|
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 {
|
export interface Account {
|
||||||
fetchPortfolio: () => Portfolio;
|
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 symbol: string;
|
||||||
|
|
||||||
readonly quantity: number;
|
constructor(lastTrade: number, lastTradeTime: Date, change: number, changePercent: number, earningsPerShare: number, marketCap: number, symbol: string) {
|
||||||
|
this.lastTrade = lastTrade;
|
||||||
readonly dateAcquired: Date;
|
this.lastTradeTime = lastTradeTime;
|
||||||
|
this.change = change;
|
||||||
readonly pricePaid: number;
|
this.changePercent = changePercent;
|
||||||
readonly price: number;
|
this.earningsPerShare = earningsPerShare;
|
||||||
|
this.marketCap = marketCap;
|
||||||
readonly change: number;
|
this.symbol = symbol;
|
||||||
readonly changePct: number;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Portfolio {
|
export class Portfolio {
|
||||||
readonly positions: Position[];
|
readonly positions: Position[];
|
||||||
}
|
|
||||||
|
constructor(positions: Position[]) {
|
||||||
|
this.positions = positions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
export class Quote {
|
export class Quote {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user