|
| const Position & | get (InstrumentId id) const noexcept |
| |
| const Position & | operator[] (InstrumentId id) const noexcept |
| |
| void | on_fill (InstrumentId id, Side side, Price px, Qty qty, Notional fee, const Instrument &inst) noexcept |
| | Applies a fill.
|
| |
| void | correct_fill (InstrumentId id, Side side, Price est_px, Price px, Qty qty, Notional fee, const Instrument &inst) noexcept |
| | A fill booked from a venue's cumulative quantity, at the order's own price and with no fee, turned out to be an execution at px costing fee.
|
| |
| void | adjust (InstrumentId id, Qty delta, Price px, const Instrument &inst) noexcept |
| | A change of the position that no trade made (a token dividend, an airdrop, a deposit or a withdrawal of the asset; Engine base flows), booked as a fill of delta (signed) at px with no fee.
|
| |
| void | on_funding (InstrumentId id, Notional amount) noexcept |
| | A funding payment on the instrument's position, in its settlement currency (negative paid, positive received).
|
| |
| Notional | funding (InstrumentId id) const noexcept |
| | Funding booked on one instrument, in its settlement currency (part of its realized PnL).
|
| |
| std::uint64_t | changes () const noexcept |
| | How many times the tracker changed other than by a mark: a fill, a correction, funding, a position set or reset, the accounting or a rate.
|
| |
| Notional | unrealized_at (InstrumentId id, Price mid, const Instrument &inst) const noexcept |
| | The open position's PnL if it were marked at mid (mark() does not change it).
|
| |
| void | mark (InstrumentId id, Price mid, const Instrument &inst) noexcept |
| | Mark-to-market the open position, in the instrument's settlement currency.
|
| |
| void | set (InstrumentId id, Qty qty, Price avg_px, const Instrument &inst) noexcept |
| | Reconciliation: overwrite qty/avg with the venue's view.
|
| |
| void | reset (InstrumentId id) noexcept |
| |
| void | set_accounting (const FxPlan &plan) noexcept |
| | Accounting across settlement currencies.
|
| |
| void | set_rate (std::size_t c, FxRate r) noexcept |
| | The rate of currency c (an index of the plan): the totals in it are converted again.
|
| |
| bool | converting () const noexcept |
| |
| std::size_t | currency_count () const noexcept |
| |
| FxRate | rate (std::size_t c) const noexcept |
| |
| const Totals & | native (std::size_t c) const noexcept |
| |
| Notional | gross_exposure () const noexcept |
| | Totals over every instrument, kept up to date by the updates above (the engine checks net_pnl() on every market-data event; summing kMaxInstruments positions there cost more than the rest of the event).
|
| |
| Notional | net_exposure () const noexcept |
| |
| Notional | total_realized () const noexcept |
| |
| Notional | total_unrealized () const noexcept |
| |
| Notional | total_fees () const noexcept |
| |
| Notional | total_funding () const noexcept |
| | Funding over every instrument; part of total_realized().
|
| |
| Notional | native_funding (std::size_t c) const noexcept |
| | Funding of one currency, in that currency (converting() only).
|
| |
| Notional | net_pnl () const noexcept |
| |
| Portfolio | portfolio () const noexcept |
| |
Applies a fill.
PnL is scaled by the instrument's contract multiplier and, for an inverse (coin-margined) contract, computed in the base coin: qty * multiplier * (1/avg - 1/px). The average entry price of an inverse position is the size-weighted harmonic mean, which is what makes that exact.
Opening / adding: a new average over the old position and this fill.
Reducing / flipping: realise on the closed part in the position's direction.
< flipped through zero: the remainder opens at px
A fill booked from a venue's cumulative quantity, at the order's own price and with no fee, turned out to be an execution at px costing fee.
Its quantity is already in the position, so on_fill() would count it twice; what was never booked is what it cost. Paying px instead of est_px for qty is worth qty * (px - est_px), given up on a buy and received on a sell, and that difference is exactly the error the estimate left in this position's PnL. The average entry price keeps the estimate: moving it would need the position the fill was booked into, which is history, and the error it carries is the one this correction has already taken out.