Skip to content

Instantly share code, notes, and snippets.

@rajuashok
Last active January 22, 2020 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajuashok/8cf2f6a77123dbc56e51e319934a55db to your computer and use it in GitHub Desktop.
Save rajuashok/8cf2f6a77123dbc56e51e319934a55db to your computer and use it in GitHub Desktop.
Portfolio Positions Orders Trades
interface Trade {
id: string
security: Security
strategy: Strategy
legs: Legs[]
}
interface TradePosition {
id: string
portfolioId: string
tradeId: string
status: TradePositionStatus // {OPEN, FILLED, EXPIRED, EXIT_REQUEST, CLOSED}
contracts: number
startPrice: number
premiumCaptured: number
gainLoss: number
gainLossPct: number
fillDate: number
}
interface TradeOrder {
id: string
userId: string
tradePositionId: string
orderDate: number
status: TradeOrderStatus // {OPEN, FILLED, EXPIRED, EXIT_REQUEST, CLOSED}
expectedGain?: number // non-null 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