Upload folder using huggingface_hub
Browse files- server/finenv_environment.py +14 -2
server/finenv_environment.py
CHANGED
|
@@ -100,7 +100,19 @@ class FinenvEnvironment(Environment):
|
|
| 100 |
raise ValueError("Stock and market required for init")
|
| 101 |
|
| 102 |
self.stock = action.stock
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
|
| 106 |
|
|
@@ -161,7 +173,7 @@ class FinenvEnvironment(Environment):
|
|
| 161 |
# hold → no action
|
| 162 |
|
| 163 |
|
| 164 |
-
index = self._state.step_count
|
| 165 |
self.stock_price = self.price_history[index]
|
| 166 |
|
| 167 |
new_value = self.cash + self.shares * self.stock_price
|
|
|
|
| 100 |
raise ValueError("Stock and market required for init")
|
| 101 |
|
| 102 |
self.stock = action.stock
|
| 103 |
+
market=action.market
|
| 104 |
+
if isinstance(market, str):
|
| 105 |
+
market = market.lower()
|
| 106 |
+
if market == "nse":
|
| 107 |
+
self.market = StockExchangeMarket.NSE
|
| 108 |
+
elif market == "bse":
|
| 109 |
+
self.market = StockExchangeMarket.BSE
|
| 110 |
+
else:
|
| 111 |
+
raise ValueError("Unsupported market. Use 'NSE' or 'BSE'.")
|
| 112 |
+
elif isinstance(market, StockExchangeMarket):
|
| 113 |
+
self.market = market
|
| 114 |
+
else:
|
| 115 |
+
raise ValueError("Invalid market type. Use string or StockExchangeMarket enum.")
|
| 116 |
|
| 117 |
|
| 118 |
|
|
|
|
| 173 |
# hold → no action
|
| 174 |
|
| 175 |
|
| 176 |
+
index = min(self._state.step_count, len(self.price_history) - 1)
|
| 177 |
self.stock_price = self.price_history[index]
|
| 178 |
|
| 179 |
new_value = self.cash + self.shares * self.stock_price
|