Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ class PortfolioEnv(Env):
|
|
24 |
|
25 |
def step(self, action):
|
26 |
action = np.clip(action, 0, 1)
|
27 |
-
weights = action / np.sum(action)
|
28 |
|
29 |
portfolio_return = np.dot(weights, self.returns.iloc[self.current_step].values)
|
30 |
self.current_balance *= (1 + portfolio_return)
|
|
|
24 |
|
25 |
def step(self, action):
|
26 |
action = np.clip(action, 0, 1)
|
27 |
+
weights = action / (np.sum(action) + 1e-8) # Prevent division by zero
|
28 |
|
29 |
portfolio_return = np.dot(weights, self.returns.iloc[self.current_step].values)
|
30 |
self.current_balance *= (1 + portfolio_return)
|