FastMM documentation
FastMM C++ API 0.14.0
Public headers, tier 1 and tier 2
Loading...
Searching...
No Matches
position.hpp
Go to the documentation of this file.
1#pragma once
2// Position tracking, average-cost method (5.8). All arithmetic is integer with __int128
3// intermediates; realized/unrealized/fees feed the max-loss kill switch.
4#include "fastmm/core/config_macros.hpp"
7#include "fastmm/core/fx.hpp"
10
11#include <array>
12#include <cstddef>
13#include <cstdint>
14#include <memory>
15
16namespace fastmm {
17
18struct alignas(kCacheLine) Position {
19 Qty qty{}; // signed net position (+ long / - short)
20 Price avg_px{}; // average entry price of the open position
21 Notional realized{}; // closed PnL (before fees)
22 Notional unrealized{}; // mark-to-market of the open position at the last mark()
23 Notional fees{}; // cumulative fees paid (negative = rebates)
24 Price last_mark{};
25 Qty gross_traded{}; // sum of |fill qty|
26 std::uint32_t fills = 0;
27 std::uint32_t pad_ = 0;
29 [[nodiscard]] Notional net_pnl() const noexcept { return realized + unrealized - fees; }
30 [[nodiscard]] bool flat() const noexcept { return qty.is_zero(); }
31 [[nodiscard]] Qty abs_qty() const noexcept { return qty.abs(); }
32};
33static_assert(sizeof(Position) == 64 && std::is_trivially_copyable_v<Position>);
34
35// The part of an order of `side` for `qty` that position `q` does not absorb once `ahead` (our
36// open orders on that side) has taken its share of the way to zero: what the order opens, raw.
37// Zero: the order only reduces the position. All raw Qty.
38[[nodiscard]] constexpr std::int64_t opening_qty(std::int64_t q,
39 Side side,
40 std::int64_t ahead,
41 std::int64_t qty) noexcept {
42 if (q == 0 || (q > 0) == (side == Side::Buy)) return qty;
43 const std::int64_t room = (q < 0 ? -q : q) - ahead;
44 if (room <= 0) return qty;
45 return qty > room ? qty - room : 0;
46}
47// Reduce-only mode: counted as opening_qty counts, the order leaves the position nearer zero than
48// `ahead` left it. It only closes, or it goes through zero by less than it closes (long 10, a sell
49// of 15 passes and one of 20 does not). Nothing passes on a flat position. All raw Qty.
50[[nodiscard]] constexpr bool nearer_zero(std::int64_t q,
51 Side side,
52 std::int64_t ahead,
53 std::int64_t qty) noexcept {
54 if (q == 0 || (q > 0) == (side == Side::Buy)) return false;
55 const std::int64_t room = (q < 0 ? -q : q) - ahead;
56 return room > 0 && qty - room < room;
57}
58// `part` of an order of `qty` whose notional is `n`, rounded up (a cap check is not lenient).
59[[nodiscard]] inline Notional notional_share(Notional n,
60 std::int64_t part,
61 std::int64_t qty) noexcept {
62 if (part >= qty || qty <= 0) return n;
63 const Int128 x = static_cast<Int128>(n.raw) * part;
64 return Notional::from_raw(static_cast<std::int64_t>((x + qty - 1) / qty));
65}
66
67// PnL totals over every instrument (StrategyContext::portfolio()), in the reporting currency when
68// the tracker converts (PositionTracker::set_accounting).
69struct Portfolio {
70 Notional realized{};
71 Notional unrealized{};
72 Notional fees{};
73 Notional net{}; // realized + unrealized - fees
74};
76class PositionTracker {
77 public:
78 [[nodiscard]] const Position& get(InstrumentId id) const noexcept {
79 FASTMM_ASSERT(id.value < kMaxInstruments);
80 return pos_[id.value];
81 }
82 [[nodiscard]] const Position& operator[](InstrumentId id) const noexcept { return get(id); }
83
84 // Applies a fill. PnL is scaled by the instrument's contract multiplier and, for an inverse
85 // (coin-margined) contract, computed in the base coin: qty * multiplier * (1/avg - 1/px). The
86 // average entry price of an inverse position is the size-weighted harmonic mean, which is what
87 // makes that exact.
88 void on_fill(InstrumentId id,
89 Side side,
91 Qty qty,
92 Notional fee,
93 const Instrument& inst) noexcept {
94 ++changes_;
95 Position& p = pos_[id.value];
96 const std::int64_t f = side == Side::Buy ? qty.raw : -qty.raw;
97 const std::int64_t cur = p.qty.raw;
98 const bool inv = inst.inverse();
99 p.fees += fee;
100 fees_total_ += fee;
101 book(id, &Totals::fees, fee);
102 p.gross_traded += qty;
103 ++p.fills;
104 if (cur == 0 || (cur > 0) == (f > 0)) {
105 // Opening / adding: a new average over the old position and this fill.
106 const std::int64_t denom = cur + f;
107 p.avg_px = inv ? harmonic_avg(cur, p.avg_px, f, px, denom)
108 : arithmetic_avg(cur, p.avg_px, f, px, denom);
109 p.qty = Qty::from_raw(denom);
110 } else {
111 // Reducing / flipping: realise on the closed part in the position's direction.
112 const std::int64_t abs_cur = cur < 0 ? -cur : cur;
113 const std::int64_t abs_f = f < 0 ? -f : f;
114 const std::int64_t closed = abs_f < abs_cur ? abs_f : abs_cur;
115 const std::int64_t dir = cur > 0 ? 1 : -1;
116 Notional r;
117 if (inv) {
118 r = inst.inverse_pnl(p.avg_px, px, Qty::from_raw(closed * dir));
119 } else {
120 const Int128 pnl = static_cast<Int128>(px.raw - p.avg_px.raw) * closed * dir / kFixedScale;
121 r = scale(Notional::from_raw(static_cast<std::int64_t>(pnl)), inst);
122 }
123 p.realized += r;
124 realized_total_ += r;
125 book(id, &Totals::realized, r);
126 const std::int64_t remaining = abs_f - closed;
127 if (remaining > 0) { // flipped through zero: the remainder opens at px
128 p.qty = Qty::from_raw(f > 0 ? remaining : -remaining);
129 p.avg_px = px;
130 } else {
131 p.qty = Qty::from_raw(cur + f);
132 if (p.qty.is_zero()) p.avg_px = Price{};
133 }
134 }
135 if (p.last_mark.is_positive()) {
136 mark(id, p.last_mark, inst);
137 } else {
138 set_exposure(id, signed_notional(p, px, inst));
139 }
140 }
141
142 // A fill booked from a venue's cumulative quantity, at the order's own price and with no fee,
143 // turned out to be an execution at `px` costing `fee`. Its quantity is already in the position,
144 // so on_fill() would count it twice; what was never booked is what it cost. Paying `px` instead
145 // of `est_px` for `qty` is worth qty * (px - est_px), given up on a buy and received on a sell,
146 // and that difference is exactly the error the estimate left in this position's PnL. The average
147 // entry price keeps the estimate: moving it would need the position the fill was booked into,
148 // which is history, and the error it carries is the one this correction has already taken out.
149 void correct_fill(InstrumentId id,
150 Side side,
151 Price est_px,
152 Price px,
153 Qty qty,
154 Notional fee,
155 const Instrument& inst) noexcept {
156 ++changes_;
157 Position& p = pos_[id.value];
158 const Notional diff =
159 inst.inverse()
160 ? inst.inverse_pnl(est_px, px, qty)
161 : scale(Notional::from_raw(detail::mul_div<kFixedScale>(px.raw - est_px.raw, qty.raw)),
162 inst);
163 const Notional adj = side == Side::Buy ? Notional{} - diff : diff;
164 p.realized += adj;
165 realized_total_ += adj;
166 book(id, &Totals::realized, adj);
167 p.fees += fee;
168 fees_total_ += fee;
169 book(id, &Totals::fees, fee);
170 }
171
172 // A change of the position that no trade made (a token dividend, an airdrop, a deposit or a
173 // withdrawal of the asset; Engine base flows), booked as a fill of `delta` (signed) at `px` with
174 // no fee. At the mark it moves no PnL: what enters adds to the position at its value, what leaves
175 // realises the open position's PnL on it. It is not a trade: gross_traded and fills stay.
176 void adjust(InstrumentId id, Qty delta, Price px, const Instrument& inst) noexcept {
177 if (delta.is_zero()) return;
178 Position& p = pos_[id.value];
179 const Qty gross = p.gross_traded;
180 const std::uint32_t fills = p.fills;
181 on_fill(id, delta.is_negative() ? Side::Sell : Side::Buy, px, delta.abs(), Notional{}, inst);
182 p.gross_traded = gross;
183 p.fills = fills;
184 }
185
186 // A funding payment on the instrument's position, in its settlement currency (negative paid,
187 // positive received). It is realized PnL, not a fee: it is not a cost of trading but the carry of
188 // holding the position, and a position that is never traded pays it all the same. funding() and
189 // total_funding() report the part of realized that it is.
190 void on_funding(InstrumentId id, Notional amount) noexcept {
191 ++changes_;
192 Position& p = pos_[id.value];
193 p.realized += amount;
194 realized_total_ += amount;
195 book(id, &Totals::realized, amount);
196 fund_->per[id.value] += amount;
197 fund_->total += amount;
198 if (FASTMM_UNLIKELY(converting())) fund_->native[ccy_[id.value]] += amount;
199 }
200 // Funding booked on one instrument, in its settlement currency (part of its realized PnL).
201 [[nodiscard]] Notional funding(InstrumentId id) const noexcept {
202 FASTMM_ASSERT(id.value < kMaxInstruments);
203 return fund_->per[id.value];
204 }
205
206 // How many times the tracker changed other than by a mark: a fill, a correction, funding, a
207 // position set or reset, the accounting or a rate.
208 [[nodiscard]] std::uint64_t changes() const noexcept { return changes_; }
209 // The open position's PnL if it were marked at `mid` (mark() does not change it).
210 [[nodiscard]] Notional unrealized_at(InstrumentId id,
211 Price mid,
212 const Instrument& inst) const noexcept {
213 return revalue(pos_[id.value], mid, inst);
214 }
215 // Mark-to-market the open position, in the instrument's settlement currency.
216 void mark(InstrumentId id, Price mid, const Instrument& inst) noexcept {
217 Position& p = pos_[id.value];
219 set_unrealized(id, p, revalue(p, mid, inst));
220 set_exposure(id, signed_notional(p, mid, inst));
221 }
222
223 // Reconciliation: overwrite qty/avg with the venue's view. Realized PnL and fees are history and
224 // are kept; the unrealized PnL of the new position is remeasured at the last mark, so the totals
225 // the max-loss budget reads stay consistent with the positions.
226 // A record without an average price (zero: the venue gave none, or none that could be read) keeps
227 // the tracked one when the position stays on the same side, else takes the last mark: valued at
228 // an average of 0, a short of 0.0014 BTC is a loss of its whole notional, which trips max_loss.
229 void set(InstrumentId id, Qty qty, Price avg_px, const Instrument& inst) noexcept {
230 ++changes_;
231 Position& p = pos_[id.value];
232 if (!qty.is_zero() && !avg_px.is_positive()) {
233 const bool same_side = !p.qty.is_zero() && p.qty.is_negative() == qty.is_negative();
234 avg_px = same_side && p.avg_px.is_positive() ? p.avg_px : p.last_mark;
235 }
236 p.qty = qty;
237 p.avg_px = qty.is_zero() ? Price{} : avg_px;
238 set_unrealized(id, p, revalue(p, p.last_mark, inst));
239 set_exposure(id, signed_notional(p, p.last_mark, inst));
240 }
241 void reset(InstrumentId id) noexcept {
242 ++changes_;
243 Position& p = pos_[id.value];
244 realized_total_ -= p.realized;
245 book(id, &Totals::realized, Notional{} - p.realized);
246 fees_total_ -= p.fees;
247 book(id, &Totals::fees, Notional{} - p.fees);
248 fund_->total -= fund_->per[id.value];
249 if (converting()) fund_->native[ccy_[id.value]] -= fund_->per[id.value];
250 fund_->per[id.value] = Notional{};
251 set_unrealized(id, p, Notional{});
252 set_exposure(id, Notional{});
253 p = Position{};
254 }
255
256 // Accounting across settlement currencies. With a plan of two or more currencies the tracker also
257 // keeps the totals per currency and converts them at the rate last set for each (set_rate), and
258 // the totals below are in the reporting currency. A currency whose rate was never set counts as
259 // zero. Without one (the default) nothing is converted and every Notional is added as it is.
260 void set_accounting(const FxPlan& plan) noexcept {
261 ++changes_;
262 ccy_count_ = plan.count;
263 for (std::size_t i = 0; i < kMaxInstruments; ++i) ccy_[i] = plan.ccy[i];
264 for (auto& r : rate_) r = FxRate{};
265 rate_[0] = FxRate::identity();
266 for (auto& t : native_) t = Totals{};
267 for (auto& t : conv_) t = Totals{};
268 conv_total_ = Totals{};
269 fund_->native = {};
270 if (!converting()) return;
271 for (std::size_t i = 0; i < kMaxInstruments; ++i) fund_->native[ccy_[i]] += fund_->per[i];
272 // What is booked already (a tracker configured after fills) moves into its currencies.
273 for (std::size_t i = 0; i < kMaxInstruments; ++i) {
274 const Position& p = pos_[i];
275 Totals& t = native_[ccy_[i]];
276 t.realized += p.realized;
277 t.unrealized += p.unrealized;
278 t.fees += p.fees;
279 t.gross += exposure_[i].abs();
280 t.net += exposure_[i];
281 }
282 reconvert(0);
283 }
284 // The rate of currency `c` (an index of the plan): the totals in it are converted again.
285 void set_rate(std::size_t c, FxRate r) noexcept {
286 if (c == 0 || c >= kMaxCurrencies) return;
287 ++changes_;
288 rate_[c] = r;
289 reconvert(c);
290 }
291 [[nodiscard]] bool converting() const noexcept { return ccy_count_ > 1; }
292 [[nodiscard]] std::size_t currency_count() const noexcept { return ccy_count_; }
293 [[nodiscard]] FxRate rate(std::size_t c) const noexcept {
294 return c < kMaxCurrencies ? rate_[c] : FxRate{};
296 // Totals of one currency, in that currency (converting() only).
297 struct Totals {
298 Notional realized{};
299 Notional unrealized{};
300 Notional fees{};
301 Notional gross{}; // sum of |position| at the last marks
302 Notional net{}; // signed sum
303 [[nodiscard]] Notional net_pnl() const noexcept { return realized + unrealized - fees; }
304 };
305 [[nodiscard]] const Totals& native(std::size_t c) const noexcept { return native_[c]; }
306
307 // Totals over every instrument, kept up to date by the updates above (the engine checks
308 // net_pnl() on every market-data event; summing kMaxInstruments positions there cost more
309 // than the rest of the event). Without conversion Notional carries no currency, so they are only
310 // meaningful when every instrument settles in the same one: InstrumentTable::settlement_mix()
311 // finds a table that mixes them, and fastmm-live refuses to start on one while [risk] max_loss
312 // is set and [accounting] does not cover it.
313 // Portfolio exposure at the last marks: the sum of |position| and the signed sum.
314 [[nodiscard]] Notional gross_exposure() const noexcept {
315 return FASTMM_UNLIKELY(converting()) ? conv_total_.gross : gross_exposure_;
317 [[nodiscard]] Notional net_exposure() const noexcept {
318 return FASTMM_UNLIKELY(converting()) ? conv_total_.net : net_exposure_;
320 [[nodiscard]] Notional total_realized() const noexcept {
321 return FASTMM_UNLIKELY(converting()) ? conv_total_.realized : realized_total_;
323 [[nodiscard]] Notional total_unrealized() const noexcept {
324 return FASTMM_UNLIKELY(converting()) ? conv_total_.unrealized : unrealized_total_;
326 [[nodiscard]] Notional total_fees() const noexcept {
327 return FASTMM_UNLIKELY(converting()) ? conv_total_.fees : fees_total_;
329 // Funding over every instrument; part of total_realized().
330 [[nodiscard]] Notional total_funding() const noexcept {
331 if (!converting()) return fund_->total;
333 for (std::size_t c = 0; c < ccy_count_; ++c) t += convert(fund_->native[c], rate_[c]);
334 return t;
335 }
336 // Funding of one currency, in that currency (converting() only).
337 [[nodiscard]] Notional native_funding(std::size_t c) const noexcept {
338 return c < kMaxCurrencies ? fund_->native[c] : Notional{};
340 [[nodiscard]] Notional net_pnl() const noexcept {
341 return total_realized() + total_unrealized() - total_fees();
343 [[nodiscard]] Portfolio portfolio() const noexcept {
344 Portfolio t;
345 t.realized = total_realized();
346 t.unrealized = total_unrealized();
347 t.fees = total_fees();
348 t.net = t.realized + t.unrealized - t.fees;
349 return t;
350 }
351
352 private:
353 static Notional scale(Notional n, const Instrument& inst) noexcept {
354 if (inst.contract_multiplier == Qty::from_int(1)) return n;
355 return Notional::from_raw(mul_raw(n, inst.contract_multiplier));
356 }
357 // (cur * avg + f * px) / (cur + f), in abs terms.
358 static Price arithmetic_avg(
359 std::int64_t cur, Price avg, std::int64_t f, Price px, std::int64_t denom) noexcept {
360 const Int128 num = static_cast<Int128>(cur) * avg.raw + static_cast<Int128>(f) * px.raw;
361 return Price::from_raw(static_cast<std::int64_t>(num / denom));
362 }
363 // An inverse contract costs multiplier / price coins, so the average that makes the coin PnL
364 // exact is the size-weighted harmonic mean: (cur + f) / (cur / avg + f / px).
365 static Price harmonic_avg(
366 std::int64_t cur, Price avg, std::int64_t f, Price px, std::int64_t denom) noexcept {
367 if (!px.is_positive()) return avg;
368 Int128 inv = static_cast<Int128>(f) * kFixedScale / px.raw;
369 if (cur != 0 && avg.is_positive()) inv += static_cast<Int128>(cur) * kFixedScale / avg.raw;
370 if (inv == 0) return px;
371 return Price::from_raw(
372 static_cast<std::int64_t>(static_cast<Int128>(denom) * kFixedScale / inv));
373 }
374 // Open-position PnL at `mark`, in the settlement currency.
375 // |position| valued at `mark`, carrying the position's sign.
376 static Notional signed_notional(const Position& p, Price mark, const Instrument& inst) noexcept {
377 if (p.qty.is_zero() || !mark.is_positive()) return Notional{};
378 const Notional n = inst.notional(mark, p.qty.abs());
379 return p.qty.raw < 0 ? Notional{} - n : n;
380 }
381 static Notional revalue(const Position& p, Price mark, const Instrument& inst) noexcept {
382 if (p.qty.is_zero() || !mark.is_positive()) return Notional{};
383 if (inst.inverse()) return inst.inverse_pnl(p.avg_px, mark, p.qty);
384 return scale(
385 Notional::from_raw(detail::mul_div<kFixedScale>(mark.raw - p.avg_px.raw, p.qty.raw)), inst);
386 }
387 // Every path that changes a position's quantity or its mark ends here, so the exposure totals
388 // cannot drift from the positions: one place updates both.
389 void set_exposure(InstrumentId id, Notional e) noexcept {
390 Notional& cur = exposure_[id.value];
391 const Notional dg = e.abs() - cur.abs();
392 const Notional dn = e - cur;
393 gross_exposure_ += dg;
394 net_exposure_ += dn;
395 book(id, &Totals::gross, dg);
396 book(id, &Totals::net, dn);
397 cur = e;
398 }
399 void set_unrealized(InstrumentId id, Position& p, Notional u) noexcept {
400 const Notional d = u - p.unrealized;
401 unrealized_total_ += d;
402 book(id, &Totals::unrealized, d);
403 p.unrealized = u;
404 }
405 // A change of one total in the instrument's currency, and of its converted value. Out of line:
406 // without [accounting] this is one predictable branch on the mark path.
407 FASTMM_FORCE_INLINE void book(InstrumentId id, Notional Totals::*f, Notional d) noexcept {
408 if (FASTMM_UNLIKELY(converting())) book_converted(id, f, d);
409 }
410 FASTMM_NOINLINE void book_converted(InstrumentId id, Notional Totals::*f, Notional d) noexcept {
411 const std::uint8_t c = ccy_[id.value];
412 Notional& n = native_[c].*f;
413 n += d;
414 const Notional v = convert(n, rate_[c]);
415 conv_total_.*f += v - conv_[c].*f;
416 conv_[c].*f = v;
417 }
418 void reconvert(std::size_t c) noexcept {
419 for (Notional Totals::*f :
420 {&Totals::realized, &Totals::unrealized, &Totals::fees, &Totals::gross, &Totals::net}) {
421 const Notional v = convert(native_[c].*f, rate_[c]);
422 conv_total_.*f += v - conv_[c].*f;
423 conv_[c].*f = v;
424 }
425 }
426 Position pos_[kMaxInstruments] = {};
427 Notional realized_total_{};
428 Notional unrealized_total_{};
429 Notional fees_total_{};
430 Notional exposure_[kMaxInstruments]{};
431 Notional gross_exposure_{};
432 Notional net_exposure_{};
433 std::uint8_t ccy_count_ = 0;
434 std::array<std::uint8_t, kMaxInstruments> ccy_{};
435 std::array<FxRate, kMaxCurrencies> rate_{FxRate::identity()};
436 std::array<Totals, kMaxCurrencies> native_{};
437 std::array<Totals, kMaxCurrencies> conv_{}; // native_ at rate_
438 Totals conv_total_{};
439 std::uint64_t changes_ = 0;
440 // Funding (on_funding), on the heap: it is rare, and the tracker's own layout, which the mark
441 // path reads, stays as it was. Copied with the tracker.
442 struct Funding {
443 Notional total{};
444 std::array<Notional, kMaxInstruments> per{};
445 std::array<Notional, kMaxCurrencies> native{}; // converting() only
446 };
447 struct FundingBox {
448 std::unique_ptr<Funding> p = std::make_unique<Funding>();
449 FundingBox() = default;
450 FundingBox(const FundingBox& o) : p(std::make_unique<Funding>(*o.p)) {}
451 FundingBox(FundingBox&&) noexcept = default;
452 FundingBox& operator=(const FundingBox& o) {
453 if (this != &o) *p = *o.p;
454 return *this;
455 }
456 FundingBox& operator=(FundingBox&&) noexcept = default;
457 ~FundingBox() = default;
458 Funding* operator->() const noexcept { return p.get(); }
459 };
460 FundingBox fund_;
461};
462
463} // namespace fastmm
Definition position.hpp:78
All engine enumerations.
Fixed<Tag>: int64 fixed point with a global 1e-8 scale (ADR-0001).
Instrument: the single definition of a tradable contract (5.3 / 5.15).
Definition strategy.hpp:23
constexpr std::int64_t kFixedScale
1e-8
Definition fixed_point.hpp:23
@ Funding
a perpetual funding payment booked by the venue (FundingMsg)
Side
Definition enums.hpp:12
Fixed< struct QtyTag > Qty
Definition fixed_point.hpp:333
Fixed< struct NotionalTag > Notional
Definition fixed_point.hpp:334
constexpr std::int64_t opening_qty(std::int64_t q, Side side, std::int64_t ahead, std::int64_t qty) noexcept
The part of an order of side for qty that position q does not absorb once ahead (our open orders on t...
Definition position.hpp:40
Fixed< struct PriceTag > Price
Definition fixed_point.hpp:332
constexpr std::size_t kMaxInstruments
Definition instrument.hpp:26
constexpr std::int64_t mul_raw(Fixed< A > a, Fixed< B > b) noexcept
Generic scaled multiply for fixed*fixed in one domain (e.g. qty * multiplier).
Definition fixed_point.hpp:367
constexpr Price mid(Price bid, Price ask) noexcept
Definition quoting.hpp:29
Strongly typed identifiers.
constexpr bool is_negative() const noexcept
Definition fixed_point.hpp:303
constexpr Fixed abs() const noexcept
Definition fixed_point.hpp:304
constexpr bool is_zero() const noexcept
Definition fixed_point.hpp:301
std::int64_t raw
Definition fixed_point.hpp:152
constexpr bool is_positive() const noexcept
Definition fixed_point.hpp:302
Definition instrument.hpp:29
PnL totals over every instrument (StrategyContext::portfolio()), in the reporting currency when the t...
Definition position.hpp:71
Totals of one currency, in that currency (converting() only).
Definition position.hpp:299
Definition position.hpp:20
Qty qty
signed net position (+ long / - short)
Definition position.hpp:21
Qty gross_traded
sum of |fill qty|
Definition position.hpp:27
std::uint32_t fills
Definition position.hpp:28
Notional unrealized
mark-to-market of the open position at the last mark()
Definition position.hpp:24
Notional fees
cumulative fees paid (negative = rebates)
Definition position.hpp:25
Price last_mark
Definition position.hpp:26
Price avg_px
average entry price of the open position
Definition position.hpp:22
Notional realized
closed PnL (before fees)
Definition position.hpp:23