Robo-advisors and wealth managers (e.g., Wealthfront, Betterment) manage billions of dollars using algorithmic tax-loss harvesting. When a portfolio drifts from its target allocation, selling assets to rebalance triggers capital gains taxes. This environment tests a frontier LLM's ability to execute complex, multi-step combinatorial optimization: hitting a target portfolio allocation while mathematically minimizing tax drag and adhering to IRS wash-sale regulations.
- Observation: The agent sees
target_allocations, availablecash, a dynamically updatedrestricted_wash_sale_list, and a granular array ofTaxLots(each containing purchase price, current price, and long-term/short-term tax status). - Action: The agent outputs structured JSON dictating exact quantities to
buy(), and an array ofsellsthat target specificlot_idstrings to execute tax-loss harvesting.
-
Easy (Basic Rebalance): A tax-advantaged account (zero taxes). The agent must calculate
$L_1$ distances and execute trades to reach the target allocation within a 1% margin of error, penalizing unnecessary transaction fees. - Medium (Tax-Loss Harvesting): Taxable accounts. The agent must selectively target specific tax lots operating at a loss to offset the necessary sale of lots operating at a gain, aiming for a net-zero capital gains bill.
- Hard (Wash Sale Avoidance): Introduces temporal constraints. If the agent harvests a loss on an asset, it is dynamically added to a restricted list. The agent must comprehend this constraint, avoid buying the restricted asset, and identify proxy assets to satisfy the target portfolio allocation.
The environment includes inference.py, a reproducible baseline utilizing meta-llama/Meta-Llama-3-70B-Instruct via the OpenAI client. The script forces strict JSON outputs corresponding to the Pydantic Action model.
- Install dependencies:
pip install openenv-core pydantic openai numpy - Run validation:
openenv validate - Execute baseline:
export API_BASE_URL="[https://api-inference.huggingface.co/v1/](https://api-inference.huggingface.co/v1/)" export MODEL_NAME="meta-llama/Meta-Llama-3-70B-Instruct" export HF_TOKEN="your_token_here" python inference.py