Mercury Instance Architecture: Strategic Refinement of W/R/ABH System
TL;DR: The Strategic Breakthrough
After deep architectural analysis, we've discovered the true competitive advantage of Mercury's instance system:
- W Instance: Live trading with conservative risk management
- R Instance: Demo trading (Bybit testnet) mirroring W constraints
- ABH Instance: Shadow portfolio as unrestricted market intelligence engine
Key Insight: Shadow portfolio's value isn't simulation—it's complete data capture for strategy optimization that demo trading cannot provide.
Current Mercury Instance System
W Instance (Live Trading)
MERCURY_INSTANCE = W;
// Real Bybit API (testnet: false)
// Conservative risk management: strict RR requirements
// Selective execution: topL from topK based on risk constraints
// Time slot: 36-72 minutes in 3-hour blocks
// Database: postgres-mercury-w (port 5436)
R Instance (Shadow Production)
MERCURY_INSTANCE = R;
// No external API - pure internal simulation
// Same MAIN variant as W instance
// Time slot: 0-36 minutes in 3-hour blocks
// Database: postgres-mercury-r (port 5435)
ABH Instance (Experimental Consolidated)
MERCURY_INSTANCE = ABH;
// Runs experimental variants A, B, H
// Time-based variant selection within 72-180 minute window
// 24 tournaments per cycle: 8 base × 3 variants
// Database: postgres-mercury-abh (port 5439)
The Strategic Refinement: W/R/ABH Redesign
Proposed New Architecture
W Instance (Live Trading)
- API: Real Bybit production API
- Risk Management: Conservative - strict RR thresholds
- Position Creation: Only topL positions meeting risk criteria
- Purpose: Actual money trading with proven strategies
R Instance (Demo Trading)
- API: Bybit demo/testnet API (
api-demo.bybit.com) - Risk Management: Mirror W instance constraints exactly
- Position Creation: Same topL logic as W for validation
- Purpose: Risk-free validation of live trading strategies
ABH Instance (Market Intelligence Engine)
- API: No external API - pure shadow simulation
- Risk Management: UNRESTRICTED - ignore RR requirements
- Position Creation: ALL topK positions without filtering
- Purpose: Complete market intelligence for strategy optimization
The Game-Changing Insight: Why Shadow > Demo for Intelligence
What Demo Trading Cannot Provide
// Demo Trading (R instance) - CONSTRAINED DATA
const positions = topK.filter((signal) => {
return signal.riskReward >= MIN_RR_RATIO; // ❌ FILTERS OUT VALUABLE DATA
});
await createDemoPositions(positions);
What Shadow Portfolio Captures
// Shadow Portfolio (ABH instance) - COMPLETE DATA
const positions = topK.map((signal) => {
return createShadowPosition(signal); // ✅ CAPTURES EVERYTHING
});
// No filtering = complete market intelligence
Critical Research Questions Only Shadow Can Answer
-
Optimal RR Discovery
- "What if we lowered RR threshold from 2.0 to 1.5?"
- "Which RR threshold maximizes Sharpe ratio historically?"
-
Dynamic topL Optimization
- "Should we trade top 3 or top 7 positions?"
- "Do positions 6-10 consistently lose money?"
- "What's the optimal topL for each tournament type?"
-
Market Regime Analysis
- "Do all topK perform well during volatility breakouts?"
- "Which positions fail during range-bound markets?"
- "Should we skip certain positions in specific regimes?"
-
Strategy Refinement
- "Are momentum signals better than mean reversion in positions 4-6?"
- "What's the performance distribution across all tournament winners?"
The Analytics Pipeline
// Phase 1: Shadow Portfolio - Unrestricted Data Collection
shadowPortfolio.createAllPositions(topK); // Capture everything
// Phase 2: Post-hoc Analysis
const strategyAnalysis = {
rrThresholds: [1.2, 1.5, 2.0, 2.5, 3.0],
topLCounts: [1, 3, 5, 7, 10],
marketRegimes: ['trending', 'ranging', 'volatile'],
timeframes: ['1h', '4h', '1d'],
};
// Phase 3: Optimization Insights
const optimalStrategy = analyzeHistoricalPerformance(
shadowData,
strategyAnalysis,
);
// Result: "Use RR≥1.5, topL=5, skip positions 7+ in ranging markets"
Implementation Strategy
Phase 1: Instance Purpose Clarification
// W Instance: Live + Conservative
if (instance === MercuryInstance.W) {
const filteredPositions = topK.filter(meetsStrictRiskCriteria);
await bybitService.createLivePositions(filteredPositions);
}
// R Instance: Demo + Conservative (mirrors W exactly)
if (instance === MercuryInstance.R) {
const filteredPositions = topK.filter(meetsStrictRiskCriteria);
await bybitDemoService.createDemoPositions(filteredPositions);
}
// ABH Instance: Shadow + Unrestricted Intelligence
if (instance === MercuryInstance.ABH) {
const allPositions = topK; // No filtering!
await shadowPortfolioService.createShadowPositions(allPositions);
}
Phase 2: Bybit Demo Integration
// R Instance Configuration
const bybitDemoClient = new RestClientV5({
key: demoApiKey,
secret: demoApiSecret,
testnet: true, // 👈 Demo API
baseUrl: 'https://api-demo.bybit.com',
});
Phase 3: Analytics Dashboard Enhancement
- Historical RR threshold performance analysis
- Dynamic topL optimization recommendations
- Market regime correlation studies
- Strategy parameter backtesting interface
Competitive Advantages
1. Complete Market Intelligence
- No data loss from filtering
- Retroactive strategy optimization
- Comprehensive performance analytics
2. Risk-Free Strategy Validation
- R instance mirrors W exactly with demo API
- Zero risk validation of live strategies
- Perfect testing environment
3. Systematic Optimization
- Data-driven strategy refinement
- Evidence-based parameter tuning
- Continuous improvement loop
4. Hardware Isolation Safety
- Only W instance has live API keys
- Impossible accidental live trading from experiments
- Clean separation of concerns
The Strategic Value Proposition
This architecture transforms Mercury from "trading bot with experiments" into "adaptive trading intelligence system":
- W Instance: Executes proven strategies with real money
- R Instance: Validates strategies risk-free before live deployment
- ABH Instance: Continuously discovers better strategies through complete data analysis
Key Insight: Shadow portfolio isn't just simulation—it's our competitive moat for strategy optimization that no demo trading system can replicate.
Next Steps
- Refactor R instance to use Bybit demo API instead of shadow simulation
- Enhance ABH analytics to capture all topK positions without filtering
- Build optimization dashboard for historical strategy analysis
- Implement gradual rollout of optimized strategies from ABH to R to W
Bottom Line: We've discovered that our shadow portfolio system provides irreplaceable market intelligence that demo trading cannot match. This isn't just architecture—it's our strategic advantage for systematic trading optimization.
