|
13 | 13 |
|
14 | 14 | #include <pineforge/pineforge.h> |
15 | 15 |
|
| 16 | +#include <stddef.h> |
16 | 17 | #include <stdio.h> |
17 | 18 | #include <string.h> |
18 | 19 | #include <stdint.h> |
@@ -50,6 +51,46 @@ int main(void) { |
50 | 51 | CHECK(m.all.num_trades == 42, "m.all.num_trades roundtrip"); |
51 | 52 | CHECK(m.equity.sharpe_tv == 1.5, "m.equity.sharpe_tv roundtrip"); |
52 | 53 | CHECK(p.time_ms == 1700000000000LL, "p.time_ms roundtrip"); |
| 54 | + |
| 55 | + /* R5 gap lane P2c: sharpe_monthly / sortino_monthly are the generic |
| 56 | + * spelling of the fields this ABI shipped as sharpe_tv / sortino_tv. |
| 57 | + * The old names are DEPRECATED aliases, removed at the next |
| 58 | + * PF_ABI_VERSION (ADR-0001, "Deprecated public spellings"). Both |
| 59 | + * spellings must name ONE double at ONE offset, in both directions, |
| 60 | + * with no growth of the struct. Checked from C because that is the |
| 61 | + * language of the contract. */ |
| 62 | + CHECK(m.equity.sharpe_monthly == 1.5, |
| 63 | + "m.equity.sharpe_monthly reads what sharpe_tv wrote"); |
| 64 | + m.equity.sharpe_monthly = -0.25; |
| 65 | + CHECK(m.equity.sharpe_tv == -0.25, |
| 66 | + "m.equity.sharpe_tv reads what sharpe_monthly wrote"); |
| 67 | + m.equity.sortino_monthly = 3.75; |
| 68 | + CHECK(m.equity.sortino_tv == 3.75, |
| 69 | + "m.equity.sortino_tv reads what sortino_monthly wrote"); |
| 70 | + m.equity.sortino_tv = -1.125; |
| 71 | + CHECK(m.equity.sortino_monthly == -1.125, |
| 72 | + "m.equity.sortino_monthly reads what sortino_tv wrote"); |
| 73 | + CHECK(offsetof(pf_equity_stats_t, sharpe_monthly) |
| 74 | + == offsetof(pf_equity_stats_t, sharpe_tv), |
| 75 | + "sharpe_monthly / sharpe_tv share one offset"); |
| 76 | + CHECK(offsetof(pf_equity_stats_t, sortino_monthly) |
| 77 | + == offsetof(pf_equity_stats_t, sortino_tv), |
| 78 | + "sortino_monthly / sortino_tv share one offset"); |
| 79 | + /* The offsets and the size measured on 1974e87e, the commit before |
| 80 | + * the alias: the union must not move or grow anything. */ |
| 81 | + CHECK(offsetof(pf_equity_stats_t, sharpe_monthly) == 48, |
| 82 | + "pf_equity_stats_t::sharpe_monthly is still at offset 48"); |
| 83 | + CHECK(offsetof(pf_equity_stats_t, sortino_monthly) == 56, |
| 84 | + "pf_equity_stats_t::sortino_monthly is still at offset 56"); |
| 85 | + CHECK(offsetof(pf_equity_stats_t, sharpe_bar) == 64, |
| 86 | + "pf_equity_stats_t::sharpe_bar is still at offset 64"); |
| 87 | + CHECK(offsetof(pf_equity_stats_t, open_pl) == 112, |
| 88 | + "pf_equity_stats_t::open_pl is still at offset 112"); |
| 89 | + CHECK(sizeof(pf_equity_stats_t) == 120, |
| 90 | + "sizeof(pf_equity_stats_t) is still 120"); |
| 91 | + CHECK(offsetof(pf_metrics_t, equity) == 648, |
| 92 | + "pf_metrics_t::equity is still at offset 648"); |
| 93 | + CHECK(sizeof(pf_metrics_t) == 768, "sizeof(pf_metrics_t) is still 768"); |
53 | 94 | } |
54 | 95 |
|
55 | 96 | /* ── Bar field access ────────────────────────────────────────── */ |
|
0 commit comments