Files
cargo-cxai-energy-0.1.0/src/ercot.rs
T
2026-04-26 16:48:11 +00:00

64 lines
2.0 KiB
Rust

use cxai_sdk::models::energy::*;
use tracing::debug;
/// High-level ERCOT energy market client.
pub struct ErcotClient {
platform: cxai_sdk::CxPlatform,
}
impl ErcotClient {
pub fn new(platform: cxai_sdk::CxPlatform) -> Self {
Self { platform }
}
/// Get day-ahead market prices for a settlement point.
pub async fn dam_prices(&self, settlement_point: &str) -> cxai_sdk::CxResult<Vec<DamPrice>> {
debug!(settlement_point, "Fetching DAM prices");
self.platform.energy().dam_prices(settlement_point).await
}
/// Get real-time prices for a settlement point.
pub async fn rt_prices(&self, settlement_point: &str) -> cxai_sdk::CxResult<Vec<RtPrice>> {
debug!(settlement_point, "Fetching RT prices");
self.platform.energy().rt_prices(settlement_point).await
}
/// Get current system demand.
pub async fn system_demand(&self) -> cxai_sdk::CxResult<SystemDemand> {
self.platform.energy().system_demand().await
}
/// Get current wind generation.
pub async fn wind(&self) -> cxai_sdk::CxResult<WindGeneration> {
self.platform.energy().wind_generation().await
}
/// Get current solar generation.
pub async fn solar(&self) -> cxai_sdk::CxResult<SolarGeneration> {
self.platform.energy().solar_generation().await
}
/// Get full market summary.
pub async fn market_summary(&self) -> cxai_sdk::CxResult<MarketSummary> {
self.platform.energy().market_summary().await
}
/// Get ML prediction for energy data.
pub async fn predict(
&self,
prediction_type: &str,
model: &str,
target_date: &str,
target_hour: u8,
) -> cxai_sdk::CxResult<ErcotMlPrediction> {
debug!(
prediction_type,
model, target_date, target_hour, "ERCOT predict"
);
self.platform
.energy()
.predict(prediction_type, model, target_date, target_hour)
.await
}
}