Skip to content

Fix: PSI-10 mirrored twice when multi-fund mode is enabled - #12

Open
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/double-fund-registration
Open

Fix: PSI-10 mirrored twice when multi-fund mode is enabled#12
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/double-fund-registration

Conversation

@mpont91

@mpont91 mpont91 commented Aug 27, 2026

Copy link
Copy Markdown

With hft.multi-fund.enabled: true (the default in both application-develop.yaml and application-production.yaml), startup logs:

INFO  MultiFundConfiguration : Initializing fund: PSI-10 with $15000.00 capital (15.0%)
ERROR MultiFundConfiguration : Failed to initialize fund PSI-10: Fund already registered: PSI-10
java.lang.IllegalStateException: Fund already registered: PSI-10
    at FundRegistry.registerFund(FundRegistry.java:29)
    at MultiFundConfiguration.initializeFunds(MultiFundConfiguration.java:98)

FundConfiguration is active on hft.fund.enabled=true and registers hft.fund.index-type (PSI-10) with hft.fund.capital-usd. MultiFundConfiguration then registers the same id with its allocation, and FundRegistry.registerFund rejects the duplicate.

Why it matters beyond the log line

MultiFundConfiguration catches only IllegalArgumentException around that call, so the IllegalStateException escapes to the outer handler and PSI-10 logs as failed — Successfully initialized PSI mirror fund: PSI-10 never prints.

But FundConfiguration does not just register: it also builds a FundPositionMirror, a FundTradeListener, a FundTradePoller on a 1s schedule and a FundSignalProcessor on a 100ms schedule, all for the same index. Those keep running. So PSI-10 is mirrored by two independent pipelines at once, and the registry reports hft.fund.capital-usd ($10,000 by default) rather than the multi-fund allocation ($15,000 at 15% of 100k) that the mirror actually sizes with.

Fix

The FundRegistry bean stays unconditional — multi-fund depends on it. Its single-fund registration returns early when multi-fund mode is on, and the two legacy schedulers are gated with @ConditionalOnProperty(prefix = "hft.multi-fund", name = "enabled", havingValue = "false", matchIfMissing = true), so single-fund deployments are unchanged.

After

INFO FundConfiguration     : Multi-fund mode is on; skipping single-fund registration of PSI-10
INFO FundRegistry          : Registered fund: PSI-10 (PSI-10) with $15000.00 capital
INFO MultiFundConfiguration: Successfully initialized PSI mirror fund: PSI-10

FundConfiguration builds a full single-fund pipeline for
hft.fund.index-type and MultiFundConfiguration builds another for every
fund in the roster. Both are enabled in the develop and production
profiles, and both cover PSI-10, so it was mirrored twice and the
registry held the wrong capital for it.

The registry bean stays unconditional since multi-fund depends on it;
its single-fund registration and the two legacy schedulers stand down
when multi-fund mode owns the roster.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant