Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmoelei committed Mar 4, 2023
1 parent 463567d commit 98e270d
Show file tree
Hide file tree
Showing 15 changed files with 378 additions and 265 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

trainer = dict(
type='PortfolioManagementEIIETrainer',
epochs=10,
epochs=2,
work_dir=work_dir,
if_remove=False )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
if_remove=False ,
configs = {},
work_dir=work_dir,
epochs=2,
)
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def evaualte(self, df):
tr = df["total assets"].values[-1] / (df["total assets"].values[0] + 1e-10) - 1
return_rate_list=self.get_daily_return_rate(df["total assets"].values)

sharpe_ratio = tr*(252)** 0.5 / (np.std(return_rate_list) * (len(df) ** 0.5) + 1e-10)
sharpe_ratio = np.mean(return_rate_list)*(252)** 0.5 / (np.std(return_rate_list)+ 1e-10)
vol = np.std(return_rate_list)
mdd = 0
peak=df["total assets"][0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def step(self, action):
stats = OrderedDict(
{
"Total Return": ["{:04f}%".format(tr * 100)],
"Sharp Ratio": ["{:04f}".format(sharpe_ratio)],
# "Sharp Ratio": ["{:04f}".format(sharpe_ratio)],
"Volatility": ["{:04f}%".format(vol* 100)],
"Max Drawdown": ["{:04f}%".format(mdd* 100)],
# "Calmar Ratio": ["{:04f}".format(cr)],
Expand Down Expand Up @@ -387,7 +387,7 @@ def evaualte(self, df):
tr = df["total assets"].values[-1] / (df["total assets"].values[0] + 1e-10) - 1
return_rate_list=self.get_daily_return_rate(df["total assets"].values)

sharpe_ratio = np.mean(return_rate_list)*(31536000)** 0.5 / (np.std(return_rate_list) * (len(df) ** 0.5) + 1e-10)
sharpe_ratio = np.mean(return_rate_list)*(31536000)** 0.5 / (np.std(return_rate_list)+ 1e-10)
vol = np.std(return_rate_list)
mdd = 0
peak=df["total assets"][0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def evaualte(self, df):
tr = df["total assets"].values[-1] / (df["total assets"].values[0] + 1e-10) - 1
return_rate_list=self.get_daily_return_rate(df["total assets"].values)

sharpe_ratio = tr*(252)** 0.5 / (np.std(return_rate_list) * (len(df) ** 0.5) + 1e-10)
sharpe_ratio = np.mean(return_rate_list)*(252)** 0.5 / (np.std(return_rate_list) + 1e-10)
vol = np.std(return_rate_list)
mdd = 0
peak=df["total assets"][0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def evaualte(self, df):
tr = df["total assets"].values[-1] / (df["total assets"].values[0] + 1e-10) - 1
return_rate_list=self.get_daily_return_rate(df["total assets"].values)

sharpe_ratio = tr*(252)** 0.5 / (np.std(return_rate_list) * (len(df) ** 0.5) + 1e-10)
sharpe_ratio = np.mean(return_rate_list)*(252)** 0.5 / (np.std(return_rate_list) + 1e-10)
vol = np.std(return_rate_list)
mdd = 0
peak=df["total assets"][0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def evaualte(self, df):
tr = df["total assets"].values[-1] / (df["total assets"].values[0] + 1e-10) - 1
return_rate_list=self.get_daily_return_rate(df["total assets"].values)

sharpe_ratio = tr*(252)** 0.5 / (np.std(return_rate_list) * (len(df) ** 0.5) + 1e-10)
sharpe_ratio = np.mean(return_rate_list)*(252)** 0.5 / (np.std(return_rate_list) + 1e-10)
vol = np.std(return_rate_list)
mdd = 0
peak=df["total assets"][0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def evaualte(self, df):
tr = df["total assets"].values[-1] / (df["total assets"].values[0] + 1e-10) - 1
return_rate_list=self.get_daily_return_rate(df["total assets"].values)

sharpe_ratio = tr*(252)** 0.5 / (np.std(return_rate_list) * (len(df) ** 0.5) + 1e-10)
sharpe_ratio = np.mean(return_rate_list)*(252)** 0.5 / (np.std(return_rate_list) + 1e-10)
vol = np.std(return_rate_list)
mdd = 0
peak=df["total assets"][0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def evaualte(self, df):
tr = df["total assets"].values[-1] / (df["total assets"].values[0] + 1e-10) - 1
return_rate_list=self.get_daily_return_rate(df["total assets"].values)

sharpe_ratio = tr*(252)** 0.5 / (np.std(return_rate_list) * (len(df) ** 0.5) + 1e-10)
sharpe_ratio = np.mean(return_rate_list)*(252)** 0.5 / (np.std(return_rate_list) + 1e-10)
vol = np.std(return_rate_list)
mdd = 0
peak=df["total assets"][0]
Expand Down
22 changes: 11 additions & 11 deletions tutorial/Tutorial1_EIIE.ipynb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions tutorial/Tutorial2_DeepScalper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"name": "stderr",
"output_type": "stream",
"text": [
"2023-03-03 02:05:01,150\tINFO services.py:1476 -- View the Ray dashboard at \u001b[1m\u001b[32mhttp://127.0.0.1:8265\u001b[39m\u001b[22m\n",
"2023-03-03 02:05:03,178\tINFO worker.py:973 -- Calling ray.init() again after it has already been called.\n"
"2023-03-04 18:50:27,916\tINFO services.py:1476 -- View the Ray dashboard at \u001b[1m\u001b[32mhttp://127.0.0.1:8266\u001b[39m\u001b[22m\n",
"2023-03-04 18:50:30,042\tINFO worker.py:973 -- Calling ray.init() again after it has already been called.\n"
]
}
],
Expand Down Expand Up @@ -453,25 +453,25 @@
"+--------------+-------------+------------+--------------+\n",
"| Total Return | Sharp Ratio | Volatility | Max Drawdown |\n",
"+--------------+-------------+------------+--------------+\n",
"| 663.053338% | 103.820287 | 3.726925% | 63.966805% |\n",
"| 663.053338% | 1.465309 | 3.726925% | 63.966805% |\n",
"+--------------+-------------+------------+--------------+\n",
"Valid Episode: [1/2]\n",
"+--------------+-------------+------------+--------------+\n",
"| Total Return | Sharp Ratio | Volatility | Max Drawdown |\n",
"+--------------+-------------+------------+--------------+\n",
"| -35.444878% | -0.597242 | 42.560375% | 118.689588% |\n",
"| -35.444878% | 0.430537 | 42.560375% | 118.689588% |\n",
"+--------------+-------------+------------+--------------+\n",
"Train Episode: [2/2]\n",
"+--------------+-------------+------------+--------------+\n",
"| Total Return | Sharp Ratio | Volatility | Max Drawdown |\n",
"+--------------+-------------+------------+--------------+\n",
"| 967.324329% | 145.920481 | 3.868479% | 64.052556% |\n",
"| 967.324329% | 1.621369 | 3.868479% | 64.052556% |\n",
"+--------------+-------------+------------+--------------+\n",
"Valid Episode: [2/2]\n",
"+--------------+-------------+------------+--------------+\n",
"| Total Return | Sharp Ratio | Volatility | Max Drawdown |\n",
"+--------------+-------------+------------+--------------+\n",
"| -199.576611% | -9.537242 | 15.006834% | 289.010033% |\n",
"| -199.576611% | 0.292613 | 15.006834% | 289.010033% |\n",
"+--------------+-------------+------------+--------------+\n"
]
}
Expand Down Expand Up @@ -501,7 +501,7 @@
"+--------------+-------------+------------+--------------+\n",
"| Total Return | Sharp Ratio | Volatility | Max Drawdown |\n",
"+--------------+-------------+------------+--------------+\n",
"| 218.177594% | 74.097753 | 2.131242% | 29.503340% |\n",
"| 218.177594% | 1.966325 | 2.131242% | 29.503340% |\n",
"+--------------+-------------+------------+--------------+\n"
]
}
Expand Down
Loading

0 comments on commit 98e270d

Please sign in to comment.