Last active
January 22, 2020 19:07
-
-
Save bobbyflowstate/c3bc21649e9fdbf9efa7124c85635dce to your computer and use it in GitHub Desktop.
Portfolio Positions Orders Trades
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Trade { | |
id: string | |
security: Security | |
strategy: Strategy | |
legs: Legs[] | |
} | |
interface TradePosition { | |
id: string | |
portfolioId?: string // null until order FILLED | |
tradeId: string | |
contracts: number | |
startPrice: number | |
premiumCaptured: number | |
gainLoss: number | |
gainLossPct: number | |
fillDate: number | |
// rolled up values | |
isExiting: boolean // if SELECT * FROM trade_order WHERE trade_position_id = x AND status = EXIT_REQUEST | |
isClosed: boolean // if SELECT * FROM trade_order WHERE trade_position_id = x AND status = CLOSED | |
} | |
interface TradeOrder { | |
id: string | |
userId: string | |
tradePositionId: string | |
orderDate: number | |
status: TradeOrderStatus // {OPEN, FILLED, EXPIRED, EXIT_REQUEST, CLOSED} | |
expectedGain: number // non-nill for EXIT_REQUEST orders | |
} | |
interface Portfolio { | |
id: string | |
userId: string | |
cash: number | |
buyingPower: number | |
invested: number | |
// Calculate accountValue, gainLoss(Pct) on demand as they will change depending on performance of positions | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Order Creation:
Exiting TradePosition