Skip to content

Commit 3cb443c

Browse files
committed
docs: Add UnifiedBrokerCache to cache developer guide (#469)
- Add new section documenting UnifiedBrokerCache API - Update last updated date - Link to database-first caching design document
1 parent 8531889 commit 3cb443c

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

docs/04_development/04_cache_developer_guide.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Cache System Developer Guide
22

33
**Audience**: Developers integrating with or extending the cache system
4-
**Last Updated**: November 2025 (Issue #336)
4+
**Last Updated**: December 2025 (Issue #469)
55

66
---
77

@@ -61,6 +61,44 @@ cache_adapter.set_market_data(
6161
)
6262
```
6363

64+
### Using UnifiedBrokerCache (Issue #469)
65+
66+
For broker state caching (account, positions, orders) with database-first architecture:
67+
68+
```python
69+
from src.data_sources.cache import unified_broker_cache
70+
71+
# Get cached account (fetches if stale, returns from DB)
72+
account = unified_broker_cache.get_account(
73+
account_id="paper_main",
74+
fetcher=lambda: alpaca_monitor.get_account_status(),
75+
max_age_seconds=60
76+
)
77+
78+
# Get cached positions
79+
positions = unified_broker_cache.get_positions(
80+
account_id="paper_main",
81+
fetcher=lambda: alpaca_monitor.get_positions()
82+
)
83+
84+
# Store position snapshots for historical tracking
85+
unified_broker_cache.store_position_snapshot("paper_main", positions)
86+
87+
# Audit display events
88+
unified_broker_cache.audit_display(
89+
display_type="portfolio",
90+
data=positions,
91+
cache_source="cached",
92+
cache_age_seconds=30.5
93+
)
94+
95+
# Get cache info
96+
info = unified_broker_cache.get_cache_info("paper_main")
97+
print(f"Account cache: {info['cache_entries'].get('account', {})}")
98+
```
99+
100+
See [Database-First Caching Design](../design/469-database-first-caching.md) for architecture details.
101+
64102
---
65103

66104
## API Reference

0 commit comments

Comments
 (0)