RISE Framework Specification
Spec ID: 03
Version: 1.0
Document ID: caishen-rise-pds-v1.0
Last Updated: 2025-01-31
What PDS Enables Users to Create:
Desired Outcomes:
The primary service interface for price data operations.
Behavior:
Historical price data provider.
Behavior:
Console application for batch price updates.
Behavior:
Interface IPDSService:
Method GetPriceHistory:
Input:
- instrument: string
- timeframe: string
- nbBars: int
- dtEnd: string (optional, default "now")
Output: PriceHistoryBase
Behavior: Returns OHLCV bars for specified range
Method GetPriceHistoryRange:
Input:
- instrument: string
- timeframe: string
- dtStart: string
- dtEnd: string
Output: PriceHistoryBase
Behavior: Returns all bars within date range
Method GetLatestQuote:
Input:
- instrument: string
Output: QuoteBase
Behavior: Returns most recent bid/ask quote
Method RefreshPrices:
Input:
- instruments: string (comma-separated)
- timeframe: string
Output: RefreshPricesResponse
Behavior: Updates price cache from source
PriceHistoryBase:
- Instrument: string
- Timeframe: string
- Bars: List<PriceBar>
- StartDate: DateTime
- EndDate: DateTime
- Source: string
PriceBar implements IQuote:
- Date: DateTime
- Open: decimal
- High: decimal
- Low: decimal
- Close: decimal
- Volume: long
- Ask: QuoteSide (optional)
- Bid: QuoteSide (optional)
QuoteSide:
- O: decimal # Open
- H: decimal # High
- L: decimal # Low
- C: decimal # Close
PovBase:
- Instrument: string # "EUR/USD"
- Timeframe: string # "H4"
Constructor: PovBase(string povString)
# Parses "EUR-USD_H4" format
Method ToString():
Returns "{Instrument}_{Timeframe}"
PDSEngine2203.exe <instruments> <timeframe> <startDate> <endDate> [avg] [full]
Parameters:
instruments - Comma-separated instrument list or "*.pair" for currency base
timeframe - m5, m15, H1, H2, H3, H4, H6, H8, D1, W1, M1
startDate - Date string or "L" for last available
endDate - Date string or "L" for latest
avg - "avg" to calculate average of bid/ask, "noavg" for raw
full - "full" for complete export, "nofull" for incremental
# Update 5-minute data for EUR/USD
PDSEngine2203.exe EUR-USD m5 L L avg
# Update H4 data for all USD pairs
PDSEngine2203.exe USD.pair H4 L L avg
# Update multiple instruments
PDSEngine2203.exe "EUR-USD,GBP-USD,USD-JPY" H4 L L avg
Creative Advancement Scenario: Get Price History for Analysis
Desired Outcome: 300 bars of EUR/USD H4 data for CDB calculation
Current Reality: ADS needs price data to build chaos chart
Natural Progression Steps:
1. ADS calls PDSService.GetPriceHistory("EUR/USD", "H4", 300)
2. PDS checks cache for recent data
3. If stale, PDS fetches from data source
4. Data normalized to PriceHistoryBase format
5. Returned to ADS for indicator calculation
Achieved Outcome: Complete OHLCV data for analysis
Supporting Features: PDSPHistoryServices, data caching
Creative Advancement Scenario: Update All Currency Pair Prices
Desired Outcome: Fresh H4 data for all USD pairs
Current Reality: Scheduled update needed for strategy monitoring
Natural Progression Steps:
1. Scheduler triggers PDSEngine with "USD.pair H4"
2. Engine resolves USD pairs from config
3. Each pair's data fetched from source
4. Data saved to JSON files in data directory
5. Completion logged
Achieved Outcome: All USD pairs have current H4 data
Supporting Features: PDSEngine console app, ForexConnect API
┌─────────────────┐
│ Data Source │
│ (ForexConnect) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ PDSEngine │
│ (Batch Update) │
└────────┬────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐
│ JSON Files │ │ SQL Database │
│ (CDB-DTO Dir) │ │ (Historical) │
└────────┬────────┘ └────────┬────────┘
│ │
└───────────┬───────────┘
▼
┌─────────────────┐
│ PDSService │
│ (Read API) │
└─────────────────┘
| Code | Description | Bars/Day |
|---|---|---|
| m1 | 1 minute | 1440 |
| m5 | 5 minutes | 288 |
| m15 | 15 minutes | 96 |
| H1 | 1 hour | 24 |
| H2 | 2 hours | 12 |
| H3 | 3 hours | 8 |
| H4 | 4 hours | 6 |
| H6 | 6 hours | 4 |
| H8 | 8 hours | 3 |
| D1 | 1 day | 1 |
| W1 | 1 week | ~0.2 |
| M1 | 1 month | ~0.03 |
Standard Forex pairs with format {Base}-{Quote}:
from dataclasses import dataclass
from datetime import datetime
from decimal import Decimal
from typing import List, Optional
@dataclass
class PriceBar:
date: datetime
open: Decimal
high: Decimal
low: Decimal
close: Decimal
volume: int = 0
@dataclass
class PriceHistoryBase:
instrument: str
timeframe: str
bars: List[PriceBar]
start_date: datetime
end_date: datetime
source: str = "local"
class PDSService:
async def get_price_history(
self,
instrument: str,
timeframe: str,
nb_bars: int = 300,
dt_end: str = "now"
) -> PriceHistoryBase:
"""Retrieve price history for instrument"""
pass
async def refresh_prices(
self,
instruments: List[str],
timeframe: str
) -> bool:
"""Update price cache from data source"""
pass
interface PriceBar {
date: Date;
open: number;
high: number;
low: number;
close: number;
volume: number;
}
interface PriceHistoryBase {
instrument: string;
timeframe: string;
bars: PriceBar[];
startDate: Date;
endDate: Date;
source: string;
}
interface IPDSService {
getPriceHistory(
instrument: string,
timeframe: string,
nbBars?: number,
dtEnd?: string
): Promise<PriceHistoryBase>;
refreshPrices(
instruments: string[],
timeframe: string
): Promise<boolean>;
}