Feature: Add functions (and/or interfaces) for calculating Position Outcomes
Currently, a lot of the math and logic for calculating Contract Outcomes would have to be rewritten third-parties integrating AnyHedge into their services (very easy to make mistakes doing this).
To simplify this task, it would be nice to have either:
- Several utility functions for calculating a given Outcome.
- A single function that returns a
PositionOutcome
interface (or similar).
If the latter approach is taken (2), there is code in the Whitelabel Frontend that might work as a good starting point: https://gitlab.com/GeneralProtocols/anyhedge/whitelabel/frontend/-/blob/development/source/scripts/ui/views/position.ts
On approach (1): smaller utility functions are a better design, but will rely on the results of previous calculations which can make it hard for integrators. So, it might be best to have both where (2) is also provided to simplify the task for third-parties and internally leverages functions in (1).