Virtual Power Plant Battery Arbitrage Agent Pipeline Script
Build an autonomous agent execution script for BESS dispatch and day-ahead wholesale electricity arbitrage.
Deploy this template to establish an agentic automation script that computes battery state-of-charge versus nodal pricing signals. Ideal for virtual power plant operators seeking deterministic market execution with safety guardrails.
Role: Senior Energy Trading & Virtual Power Plant (VPP) Automation Engineer specializing in algorithmic battery energy storage system (BESS) dispatch.
Context
- Fleet Identifier: {{asset_fleet_id}}
- ISO Market Data Endpoint: {{iso_market_feed}}
- Minimum State-of-Charge Floor: {{min_soc_threshold}}
- Marginal Degradation Cost per MWh: {{degradation_cost_per_mwh}}
- Settlement Integration URL: {{settlement_api_key}}
- Telemetry Polling Interval: {{telemetry_poll_interval_sec}}
Task
Author a production-grade Python orchestration script for an autonomous market agent that polls Locational Marginal Pricing (LMP), assesses distributed battery storage telemetry across {{asset_fleet_id}}, runs profitability calculations against cycle degradation, and issues automated charge/discharge schedules.
Method
- Ingest five-minute LMP and ancillary service pricing arrays from {{iso_market_feed}}.
- Poll live telemetry across {{asset_fleet_id}} at intervals governed by {{telemetry_poll_interval_sec}}.
- Compute net arbitrage spreads by factoring in round-trip efficiency and {{degradation_cost_per_mwh}}.
- Calculate available inverter capacity while respecting {{min_soc_threshold}} safety boundaries.
- Generate optimal 15-minute dispatch setpoints using linear optimization logic.
- Execute validation routines to prevent thermal runaway risk or breach of local interconnection limits.
- Submit signed dispatch payloads to {{settlement_api_key}} using secure HMAC headers.
- Output structured performance metrics including estimated revenue and avoided carbon intensity.
Constraints
- MUST abort automated discharge if asset state-of-charge approaches {{min_soc_threshold}}.
- MUST NOT submit market bids when the price delta is lower than {{degradation_cost_per_mwh}}.
- Include exponential backoff retry logic for all {{iso_market_feed}} polling operations.
- The script must run without external runtime database dependencies using in-memory state tracking.
Output format
Provide a clean Python automation script containing:
- Configuration constants and typed payload schemas.
- Arbitrage mathematical optimization engine class.
- Fleet telemetry aggregation and dispatch execution handler.
- Main evaluation loop demonstrating a full 24-hour pricing cycle.
Self-review
- Verify that battery degradation costs are subtracted prior to generating discharge triggers.
- Confirm {{telemetry_poll_interval_sec}} properly sets asynchronous polling delays.
- Ensure strict assertions prevent violation of {{min_soc_threshold}}.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.