21 KiB
Price Tracking & Analysis
**Referenced Files in This Document** - [VendorBuyAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorBuyAgentEntry.cs) - [VendorSellAgentEntry.cs](file://ClassicAssist.Shared/Data/Vendors/VendorSellAgentEntry.cs) - [ShopListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/ShopListEntry.cs) - [SellListEntry.cs](file://ClassicAssist.Shared/Data/Vendors/SellListEntry.cs) - [XYComparer.cs](file://ClassicAssist.Shared/Data/Vendors/XYComparer.cs) - [VendorBuyTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorBuyTabControl.xaml.cs) - [VendorSellTabControl.xaml.cs](file://ClassicAssist.Avalonia/Views/Agents/VendorSellTabControl.xaml.cs) - [VendorBuyTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorBuyTabViewModel.cs) - [VendorSellTabViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/Agents/VendorSellTabViewModel.cs) - [IncomingPacketHandlers.cs](file://ClassicAssist.Shared/UO/Network/IncomingPacketHandlers.cs) - [VendorBuy.cs](file://ClassicAssist.Shared/UO/Network/Packets/VendorBuy.cs)Table of Contents
- Introduction
- Project Structure
- Core Components
- Architecture Overview
- Detailed Component Analysis
- Dependency Analysis
- Performance Considerations
- Troubleshooting Guide
- Conclusion
- Appendices
Introduction
This document explains the Price Tracking and Analysis system within vendor management. It covers how NPC prices are monitored, historical pricing data is tracked, and cost analysis supports trading decisions. It also documents the XYComparer utility for price comparisons, price threshold configurations, market trend analysis, best vendor selection, price alerting, profit margin calculations, integration with buy and sell agents, optimization strategies (bulk purchase timing and market speculation), data storage considerations, performance characteristics for large datasets, and export capabilities for financial analysis.
Project Structure
The price tracking and analysis features are implemented across shared data models, UI view models, and network packet handling:
- Data models define entries for shop listings, sell lists, and agent-specific configuration for buying and selling.
- A dedicated comparer utility enables consistent ordering and comparison of items by key attributes such as name and price.
- UI tabs and view models expose controls and bindings to configure thresholds, display trends, and trigger actions.
- Network handlers integrate with incoming vendor packets to capture live pricing updates.
graph TB
subgraph "Shared Data"
VBA["VendorBuyAgentEntry.cs"]
VSA["VendorSellAgentEntry.cs"]
SLE["ShopListEntry.cs"]
SEL["SellListEntry.cs"]
XYC["XYComparer.cs"]
end
subgraph "UI"
VBTV["VendorBuyTabViewModel.cs"]
VSTV["VendorSellTabViewModel.cs"]
VBTC["VendorBuyTabControl.xaml.cs"]
VSTC["VendorSellTabControl.xaml.cs"]
end
subgraph "Network"
IPH["IncomingPacketHandlers.cs"]
VBP["VendorBuy.cs"]
end
VBA --> VBTV
VSA --> VSTV
SLE --> VBTV
SEL --> VSTV
XYC --> VBTV
XYC --> VSTV
IPH --> VBP
VBP --> VBTV
VBP --> VSTV
Diagram sources
- VendorBuyAgentEntry.cs
- VendorSellAgentEntry.cs
- ShopListEntry.cs
- SellListEntry.cs
- XYComparer.cs
- VendorBuyTabViewModel.cs
- VendorSellTabViewModel.cs
- VendorBuyTabControl.xaml.cs
- VendorSellTabControl.xaml.cs
- IncomingPacketHandlers.cs
- VendorBuy.cs
Section sources
- VendorBuyAgentEntry.cs
- VendorSellAgentEntry.cs
- ShopListEntry.cs
- SellListEntry.cs
- XYComparer.cs
- VendorBuyTabViewModel.cs
- VendorSellTabViewModel.cs
- VendorBuyTabControl.xaml.cs
- VendorSellTabControl.xaml.cs
- IncomingPacketHandlers.cs
- VendorBuy.cs
Core Components
- Shop listing entry: Represents an item available from a vendor with properties used for price tracking and filtering.
- Sell list entry: Represents an item configured for automated selling with thresholds and preferences.
- Buy agent entry: Holds configuration for automated purchasing behavior, including thresholds and target vendors.
- Sell agent entry: Holds configuration for automated selling behavior, including thresholds and target vendors.
- XYComparer: Provides consistent comparison logic for sorting and ranking items by multiple criteria (e.g., name, price).
- UI View Models: VendorBuyTabViewModel and VendorSellTabViewModel coordinate user interactions, thresholds, and display of price analytics.
- Network Integration: IncomingPacketHandlers and VendorBuy packet types feed live vendor pricing into the system.
Key responsibilities:
- Capture and store current and historical prices.
- Compare and rank vendors based on price and other criteria.
- Apply thresholds to trigger alerts or automated actions.
- Compute profit margins and support decision-making.
Section sources
- ShopListEntry.cs
- SellListEntry.cs
- VendorBuyAgentEntry.cs
- VendorSellAgentEntry.cs
- XYComparer.cs
- VendorBuyTabViewModel.cs
- VendorSellTabViewModel.cs
- IncomingPacketHandlers.cs
- VendorBuy.cs
Architecture Overview
The system integrates real-time vendor pricing via network packets, persists and analyzes price history, and exposes controls for thresholds and automation. The flow below shows how incoming vendor data is processed and consumed by UI and automation components.
sequenceDiagram
participant Game as "Game Client"
participant Net as "IncomingPacketHandlers.cs"
participant Packet as "VendorBuy.cs"
participant VM as "VendorBuyTabViewModel.cs / VendorSellTabViewModel.cs"
participant Model as "ShopListEntry.cs / SellListEntry.cs"
participant Agent as "VendorBuyAgentEntry.cs / VendorSellAgentEntry.cs"
participant Comp as "XYComparer.cs"
Game->>Net : "Vendor price update"
Net->>Packet : "Parse VendorBuy packet"
Packet-->>VM : "Item price data"
VM->>Model : "Update current price and history"
VM->>Agent : "Evaluate thresholds and rules"
VM->>Comp : "Compare vendors and sort candidates"
VM-->>Game : "Trigger buy/sell actions if conditions met"
Diagram sources
- IncomingPacketHandlers.cs
- VendorBuy.cs
- VendorBuyTabViewModel.cs
- VendorSellTabViewModel.cs
- ShopListEntry.cs
- SellListEntry.cs
- VendorBuyAgentEntry.cs
- VendorSellAgentEntry.cs
- XYComparer.cs
Detailed Component Analysis
Shop Listing Entry
Purpose:
- Captures item details and pricing information from vendor listings.
- Supports filtering and historical tracking by maintaining fields for current and past prices.
Key aspects:
- Fields for item identification and price values.
- Methods or properties that enable updating and querying price history.
- Compatibility with comparers for sorting and ranking.
Use cases:
- Displaying current vendor prices.
- Computing average, min, max over time windows.
- Feeding trend analysis and alerting logic.
Section sources
Sell List Entry
Purpose:
- Defines items intended for automated selling with configurable thresholds and preferences.
Key aspects:
- Thresholds for minimum sell price or profit margin.
- Flags or options controlling when to sell (e.g., immediate vs. delayed).
- Integration with sell agent logic to execute sales.
Use cases:
- Automated liquidation of inventory above configured thresholds.
- Profit margin enforcement before selling.
- Bulk sell operations guided by price trends.
Section sources
Buy Agent Entry
Purpose:
- Configures automated purchasing behavior, including target vendors and price constraints.
Key aspects:
- Thresholds for maximum buy price.
- Best vendor selection criteria using comparers.
- Rules for bulk purchases and timing.
Use cases:
- Selecting the lowest-cost vendor meeting quality constraints.
- Triggering purchases when prices drop below configured levels.
- Coordinating with market trend analysis to optimize timing.
Section sources
Sell Agent Entry
Purpose:
- Configures automated selling behavior, including thresholds and execution policies.
Key aspects:
- Minimum acceptable sell price or profit margin.
- Timing strategies (immediate vs. wait for better price).
- Integration with sell list entries and price history.
Use cases:
- Selling at optimal times based on historical highs.
- Enforcing profit targets before executing sales.
- Managing risk by avoiding sells during downward trends.
Section sources
XYComparer Utility
Purpose:
- Provides consistent comparison logic for items, enabling reliable sorting and ranking across multiple criteria.
Key aspects:
- Comparison by name, then by price or other attributes.
- Stable ordering to ensure deterministic results.
- Reusable across buy and sell workflows.
Use cases:
- Ranking vendors by price for best vendor selection.
- Sorting historical price snapshots for trend visualization.
- Deterministic ordering for exports and reports.
Section sources
UI Tabs and View Models
Purpose:
- Expose configuration and analytics for price tracking and automation.
Key aspects:
- VendorBuyTabViewModel coordinates buy-related thresholds, vendor selection, and trend displays.
- VendorSellTabViewModel coordinates sell-related thresholds, profit margins, and alerting.
- Tab control code-behinds manage UI lifecycle and binding contexts.
Use cases:
- Setting price thresholds and viewing alerts.
- Analyzing trends and selecting optimal vendors.
- Triggering manual or automated buy/sell actions.
Section sources
- VendorBuyTabViewModel.cs
- VendorSellTabViewModel.cs
- VendorBuyTabControl.xaml.cs
- VendorSellTabControl.xaml.cs
Network Integration
Purpose:
- Captures live vendor pricing updates and feeds them into the system.
Key aspects:
- IncomingPacketHandlers processes vendor-related packets.
- VendorBuy packet type carries item price data.
- Updates propagate to view models and data entries.
Use cases:
- Real-time price monitoring.
- Immediate threshold evaluation and alerting.
- Updating historical records for trend analysis.
Section sources
Price Alerting Flow
flowchart TD
Start(["Price Update Received"]) --> CheckThresholds["Check Buy/Sell Thresholds"]
CheckThresholds --> BelowBuy{"Below Buy Threshold?"}
BelowBuy --> |Yes| AlertBuy["Generate Buy Alert"]
BelowBuy --> |No| AboveSell{"Above Sell Threshold?"}
AboveSell --> |Yes| AlertSell["Generate Sell Alert"]
AboveSell --> |No| NoAction["No Action"]
AlertBuy --> EvaluateRules["Apply Automation Rules"]
AlertSell --> EvaluateRules
EvaluateRules --> ExecuteAction["Execute Buy/Sell or Notify User"]
NoAction --> End(["End"])
ExecuteAction --> End
[No sources needed since this diagram shows conceptual workflow, not actual code structure]
Dependency Analysis
The following diagram maps dependencies among core components involved in price tracking and analysis.
classDiagram
class ShopListEntry {
+item_id
+price
+history
}
class SellListEntry {
+item_id
+sell_threshold
+profit_margin
}
class VendorBuyAgentEntry {
+buy_threshold
+best_vendor_strategy
}
class VendorSellAgentEntry {
+sell_threshold
+timing_strategy
}
class XYComparer {
+compare(itemA, itemB) int
}
class VendorBuyTabViewModel {
+updatePrices()
+evaluateBuy()
+getBestVendor()
}
class VendorSellTabViewModel {
+updatePrices()
+evaluateSell()
+computeMargin()
}
class IncomingPacketHandlers {
+handleVendorBuy(packet)
}
class VendorBuy {
+item_id
+price
}
VendorBuyTabViewModel --> ShopListEntry : "reads/writes"
VendorSellTabViewModel --> SellListEntry : "reads/writes"
VendorBuyTabViewModel --> VendorBuyAgentEntry : "uses config"
VendorSellTabViewModel --> VendorSellAgentEntry : "uses config"
VendorBuyTabViewModel --> XYComparer : "sort/rank"
VendorSellTabViewModel --> XYComparer : "sort/rank"
IncomingPacketHandlers --> VendorBuy : "parses"
IncomingPacketHandlers --> VendorBuyTabViewModel : "updates"
IncomingPacketHandlers --> VendorSellTabViewModel : "updates"
Diagram sources
- ShopListEntry.cs
- SellListEntry.cs
- VendorBuyAgentEntry.cs
- VendorSellAgentEntry.cs
- XYComparer.cs
- VendorBuyTabViewModel.cs
- VendorSellTabViewModel.cs
- IncomingPacketHandlers.cs
- VendorBuy.cs
Section sources
- ShopListEntry.cs
- SellListEntry.cs
- VendorBuyAgentEntry.cs
- VendorSellAgentEntry.cs
- XYComparer.cs
- VendorBuyTabViewModel.cs
- VendorSellTabViewModel.cs
- IncomingPacketHandlers.cs
- VendorBuy.cs
Performance Considerations
- Efficient Comparisons: Use XYComparer consistently to avoid repeated custom sorting logic and ensure stable orderings.
- History Management: Implement bounded buffers or rolling windows for price history to limit memory growth and maintain query performance.
- Batch Updates: Coalesce frequent price updates into batched processing to reduce UI churn and computation overhead.
- Indexing: Maintain indexes on frequently queried fields (e.g., item_id, timestamp) to speed up trend queries and exports.
- Lazy Loading: Load detailed price histories on demand rather than upfront to improve startup and responsiveness.
- Concurrency: Ensure thread-safe access to shared price data structures; use queues or locks where necessary to prevent race conditions.
[No sources needed since this section provides general guidance]
Troubleshooting Guide
Common issues and resolutions:
- Missing price updates: Verify IncomingPacketHandlers is wired to VendorBuy packets and that UI view models receive updates.
- Incorrect vendor ranking: Confirm XYComparer is applied consistently and that comparison keys match expected semantics.
- Thresholds not triggering: Check configuration in VendorBuyAgentEntry and VendorSellAgentEntry, and ensure thresholds are evaluated after each price update.
- High memory usage: Inspect price history retention policies and implement rolling windows or periodic pruning.
- Export failures: Validate data integrity and schema consistency before exporting; handle missing fields gracefully.
Section sources
Conclusion
The Price Tracking and Analysis system integrates live vendor pricing with robust data models, comparers, and UI-driven configuration. It supports best vendor selection, price alerting, profit margin calculations, and automation through buy and sell agents. By applying efficient comparison, careful history management, and clear threshold rules, users can make informed trading decisions, optimize bulk purchases, and engage in market speculation with confidence.
[No sources needed since this section summarizes without analyzing specific files]
Appendices
Price Optimization Strategies
- Best Vendor Selection: Rank vendors using XYComparer and select the lowest-cost option meeting quality constraints.
- Bulk Purchase Timing: Accumulate demand and execute purchases when prices fall below configured thresholds or when trend indicators suggest favorable conditions.
- Market Speculation Tools: Monitor historical highs/lows and volatility; set dynamic thresholds that adapt to recent trends.
[No sources needed since this section provides general guidance]
Data Storage for Price History
- Store per-item price snapshots with timestamps.
- Retain rolling windows to balance detail and performance.
- Provide APIs for querying averages, minima, maxima, and trend metrics.
[No sources needed since this section provides general guidance]
Export Capabilities for Financial Analysis
- Export current prices and historical series to CSV or similar formats.
- Include metadata such as item identifiers, vendor IDs, timestamps, and computed metrics (e.g., moving averages).
- Ensure deterministic ordering using XYComparer for reproducible outputs.
[No sources needed since this section provides general guidance]