Unify Stock/Instrument/Share trading system with database persistence#136
Merged
Unify Stock/Instrument/Share trading system with database persistence#136
Conversation
Co-authored-by: MaksyKun <77341370+MaksyKun@users.noreply.github.com>
Co-authored-by: MaksyKun <77341370+MaksyKun@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor stock mechanics for instruments and shares
Unify Stock/Instrument/Share trading system with database persistence
Nov 17, 2025
Contributor
|
@copilot The way stocks are gaining/losing amount is kind of unrealistic again. The factors should be undeterminable, yet logical when greater things occur. Dont use not too high random numbers , please. |
- Reduce base noise multiplier from 0.5 to 0.3 for smaller variations - Lower random event chance from 1% to 0.5% and reduce impact from 2-5x to 1.5-2.5x - Make major market events much rarer (0.05% vs 0.1%) with smaller impacts (0.15 vs 0.3) - Change volume updates from arbitrary ±50k to realistic ±10% of current volume - Reduce market influence fluctuations from 20% to 10% per update - Make intensity changes smaller (±2.5% vs ±5%) for gradual accumulation Price movements are now more predictable with logical market factors driving changes, while still maintaining randomness for variety. Co-authored-by: MaksyKun <77341370+MaksyKun@users.noreply.github.com>
Contributor
Author
Adjusted price movements to be more realistic in commit fddde3e: Changes Made:
Price movements are now primarily driven by logical market factors (economic indicators, sector performance, technical analysis) with subtle random variations that accumulate over time rather than extreme jumps. |
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.
Stock/Instrument/Share Unification - COMPLETE ✅
Recent Update: More Realistic Price Movements ✅
Addressed feedback: Made stock price movements more realistic and less random
Changes to price calculation:
Result: Price movements are now more predictable and logical, driven primarily by market factors rather than extreme random variations. Prices accumulate changes gradually over time with occasional modest events.
Implementation Summary
Successfully unified the stock/instrument/share trading system by eliminating the disconnect between in-memory Stock objects and database Instrument records.
Changes Completed ✅
Phase 1: Database Synchronization ✅
InstrumentSyncServiceto bridge Stock and Instrument modelsStockMarketServiceto load from and save to databaseinstrumentstableinstrument_stateandinstrument_price_historyPhase 2: Price Update System ✅
startMarketPriceUpdateTask()in QuickStocksPluginPhase 3: Optional Item Trading ✅
ItemSeederServicefor Minecraft item tradingmarket.items.enabledandseedOnStartupPhase 4: Realistic Price Movements ✅
What Was Fixed
✅ Selling Now Works
user_holdingstable✅ Prices Persist Across Restarts
instrument_statetableinstrument_price_historytable✅ Single Source of Truth
✅ Unified Trading System
TradingServiceworks for all types✅ Realistic Price Movements
Configuration
Added to
market.yml:Testing Checklist
Crypto Trading (should work immediately):
/crypto createCompany Shares (should work immediately):
/company market enable)Item Trading (requires seeding):
seedOnStartup: trueinmarket.ymlPersistence & Price Movements:
Performance Note
Default update interval is 5 seconds. For production, consider:
Files Changed
Modified (recent update):
StockPriceCalculator.java- More realistic random noise and eventsStockMarketService.java- Percentage-based volume changesMarketInfluence.java- Reduced fluctuation rangesModified (original):
StockMarketService.java- Database sync integrationQuickStocksPlugin.java- Price update schedulermarket.yml- Items configurationMarketCfg.java- Config loadingCreated:
InstrumentSyncService.java- Sync layerItemSeederService.java- Item seedingTradableStock.java- Unified wrapperDocumentation/STOCK_UNIFICATION.md- Full docsBackward Compatibility
✅ Fully backward compatible
Result
The plugin now has a clean, unified system where:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.