feat(options) cover store and execution cases#40
Conversation
There was a problem hiding this comment.
Pull request overview
Adds/updates unit tests to improve coverage for the options store and executor, and makes existing Greeks aggregation assertions more robust to floating-point precision.
Changes:
- Add a new options store test suite (including concurrent-access test) and benchmarks.
- Add a new options executor test suite covering happy paths and input validation/error paths.
- Update existing Greeks aggregation tests to use tolerant numeric comparisons.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/markets/options/views/views_test.go | Use tolerant float assertions for portfolio Greeks aggregation. |
| pkg/markets/options/store/store_test.go | New store suite covering positions, prices, Greeks/IV, aggregation, concurrency; adds benchmarks. |
| pkg/markets/options/executor/executor_test.go | New executor suite covering PlaceOrder/CancelOrder success and validation failures. |
| pkg/markets/options/analytics/service_test.go | Use tolerant float assertions for portfolio Greeks aggregation. |
| pkg/markets/options/activity/pnl_test.go | Use tolerant float assertions for portfolio Greeks aggregation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| contract1 = optionsTypes.OptionContract{ | ||
| Pair: btcPair, | ||
| Strike: 50000, | ||
| Expiration: expiration, | ||
| OptionType: "CALL", | ||
| } |
There was a problem hiding this comment.
The store’s contract keying logic is currently unsafe for non-integer or large strike values: pkg/markets/options/store/store.go uses floatToString(f) = string(rune(f)), which truncates decimals and can collapse many strikes to the same rune (and values > unicode.MaxRune collapse to U+FFFD). These tests only use small integer strikes, so they won’t catch key collisions/overwrites. Add a regression test that stores two contracts differing only by strike (e.g., fractional strikes and/or strikes above 0x10FFFF) and expects both positions/greeks to be retrievable independently; then update the store to use a stable string encoding for float strikes (e.g., strconv/decimal formatting) to make the test pass.
Resolves: #39