feat: FX bid/ask spread modeling for realized-rate accuracy - #660
Open
Toyosi5566 wants to merge 1 commit into
Open
feat: FX bid/ask spread modeling for realized-rate accuracy#660Toyosi5566 wants to merge 1 commit into
Toyosi5566 wants to merge 1 commit into
Conversation
Model bid/ask per provider and automatically select the appropriate side based on conversion direction. Default to bid (sell side) which reflects the actual cost — mid-market understates the spread. - Add `resolveDefaultSide` method: picks bid when spread exists, falls back to mid when bid===ask and emits `fx.rate.spread_missing` - Add `inferSideFromRate` helper for hop provenance in triangulation - Track `wasInverted` flag to preserve context for side selection - Update all tests to assert default bid behavior - Add zero-spread fallback test coverage and spread-missing metric tests Closes RevoraOrg#513
|
@Toyosi5566 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds bid/ask spread modeling to the FX conversion engine. Previously,
fxConversionEngineused a single mid-market rate, which understates conversion cost by the spread. Now each provider's bid/ask data is used, with the appropriate side selected per direction.Related Issue
Closes #513
Changes
📈 Bid/Ask Spread Modeling
[ADD]
resolveDefaultSide()method infxConversionEngine.tsbid(sell side) to reflect the actual costmidand emits afx.rate.spread_missing_totalcounter so operators can identify providers lacking spread data[ADD]
inferSideFromRate()helper for hop provenance in triangulation, mirroring the default side logic[TRACK]
wasInvertedflag to preserve context of whether a rate was derived by inverting another pair, enabling correct side application[ADD] New
METRIC_SPREAD_MISSINGconstant for thefx_rate_spread_missing_totalPrometheus counter🧪 Updated Test Coverage
zero-spread fallbacktest suite — 5 new tests:fx_rate_spread_missing_totalmetric emission when spread is absentVerification Results
ExchangeRateschema; rate table unchangedfx.rate.spread_missingcounter emitted on zero-spread fallbackfx_rate_spread_missing_totalconvert()without side equalsconvert({ side: 'mid' })when bid===ask