Skip to content

Instantly share code, notes, and snippets.

@adrake33
Last active April 2, 2019 22:00
Show Gist options
  • Select an option

  • Save adrake33/563b2e1500645629501257d1a221b798 to your computer and use it in GitHub Desktop.

Select an option

Save adrake33/563b2e1500645629501257d1a221b798 to your computer and use it in GitHub Desktop.
// Should not require any additional logging
export interface Timestamped {
timestamp: number;
}
export interface FrozenFunds {
frozenFunds: BigNumber; // in whole tokens (eg. ETH)
}
export interface ProfitLossResult extends
Timestamped, // profit and loss as of this timestamp
FrozenFunds { // funds the user froze to be in this position (see FrozenFunds docs)
marketId: Address; // user's position is in this market
outcome: number; // user's position is in this market outcome
netPosition: BigNumber; // current quantity of shares in user's position for this market outcome. "net" position because if user bought 4 shares and sold 6 shares, netPosition would be -2 shares (ie. 4 - 6 = -2). User is "long" this market outcome (gets paid if this outcome occurs) if netPosition is positive. User is "short" this market outcome (gets paid if this outcome does not occur) if netPosition is negative
averagePrice: BigNumber; // denominated in tokens/share. average price user paid for shares in the current open position
realized: BigNumber; // realized profit in tokens (eg. ETH) user already got from this market outcome. "realized" means the user bought/sold shares in such a way that the profit is already in the user's wallet
unrealized: BigNumber; // unrealized profit in tokens (eg. ETH) user could get from this market outcome. "unrealized" means the profit isn't in the user's wallet yet; the user could close the position to "realize" the profit, but instead is holding onto the shares. Computed using last trade price.
total: BigNumber; // total profit in tokens (eg. ETH). Always equal to realized + unrealized
unrealizedCost: BigNumber; // denominated in tokens. Cost of shares in netPosition
realizedCost: BigNumber; // denominated in tokens. Cumulative cost of shares included in realized profit
totalCost: BigNumber; // denominated in tokens. Always equal to unrealizedCost + realizedCost
realizedPercent: BigNumber; // realized profit percent (ie. profit/cost)
unrealizedPercent: BigNumber; // unrealized profit percent (ie. profit/cost)
totalPercent: BigNumber; // total profit percent (ie. profit/cost)
currentValue: BigNumber; // current value of netPosition, always equal to unrealized minus frozenFunds
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment