File size: 1,384 Bytes
01a29cc 1b6e30f 01a29cc 1b6e30f 01a29cc 1b6e30f 01a29cc 5e2d662 01a29cc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
"""Data models for the Finenv environment."""
from enum import Enum
from typing import Any, Dict, Optional
from openenv.core.env_server.types import Action, Observation
from typing import Optional, Literal
class StockExchangeMarket(Enum):
BSE = "bse"
NSE = "nse"
class FinenvAction(Action):
"""
Action model for Finenv environment.
Supports:
- init → initialize environment
- buy → buy shares
- sell → sell shares
- hold → no action
"""
type: str # "init", "buy", "sell", "hold"
# Trading fields
quantity: Optional[int] = 0
task_type: Optional[Literal["easy", "medium", "hard"]] = None
# Initialization fields
stock: Optional[str] = None
market: Optional[StockExchangeMarket] = None
initial_cash: Optional[float] = None
max_steps: Optional[int] = None
class FinenvObservation(Observation):
"""Observation from the Finenv environment - the echoed message."""
stock: Optional[str] = None
market: Optional[StockExchangeMarket] = None
shares: int
cash: float
price: float
reward: str
done: bool
metadata: Optional[Dict[str, Any]] = None
|