plotguy 2.2.1__tar.gz → 2.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {plotguy-2.2.1 → plotguy-2.2.4}/PKG-INFO +1 -1
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy/__init__.py +19 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy/components.py +2 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy.egg-info/PKG-INFO +1 -1
- {plotguy-2.2.1 → plotguy-2.2.4}/setup.py +1 -1
- {plotguy-2.2.1 → plotguy-2.2.4}/README.md +0 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy/aggregate.py +0 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy/equity_curves.py +0 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy/signals.py +0 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy.egg-info/SOURCES.txt +0 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy.egg-info/dependency_links.txt +0 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy.egg-info/requires.txt +0 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/plotguy.egg-info/top_level.txt +0 -0
- {plotguy-2.2.1 → plotguy-2.2.4}/setup.cfg +0 -0
|
@@ -200,6 +200,8 @@ def save_backtest_result(df, para_combination_item):
|
|
|
200
200
|
elif len(df_count) > 0:
|
|
201
201
|
|
|
202
202
|
########### by year count, win rate and return ###############
|
|
203
|
+
start_year = df.index[0].year
|
|
204
|
+
end_year = df.index[-1].year
|
|
203
205
|
|
|
204
206
|
num_of_trade = len(df_count)
|
|
205
207
|
df_count = pd.concat([df_count, df[df['trd_side'] != ''].tail(1)])
|
|
@@ -217,6 +219,23 @@ def save_backtest_result(df, para_combination_item):
|
|
|
217
219
|
yearly_stats['year_return'] = 100 * (yearly_stats['year_pnl'] / yearly_stats['year_start_equity_value'])
|
|
218
220
|
yearly_stats['year_win_rate'] = 100 * (yearly_stats['year_win_count'] / yearly_stats['year_trade_count'])
|
|
219
221
|
|
|
222
|
+
all_years = range(start_year, end_year + 1)
|
|
223
|
+
current_years = yearly_stats.index
|
|
224
|
+
missing_years = [year for year in all_years if year not in current_years]
|
|
225
|
+
|
|
226
|
+
#if year_start_equity_value = df.at[df.index[0], 'equity_value'
|
|
227
|
+
missing_rows = pd.DataFrame(
|
|
228
|
+
{ "year_pnl": 0,
|
|
229
|
+
"year_win_count": 0,
|
|
230
|
+
"year_trade_count": 0,
|
|
231
|
+
"year_start_equity_value": 0,
|
|
232
|
+
"year_return": 0,
|
|
233
|
+
"year_win_rate": 0,
|
|
234
|
+
}, index=missing_years)
|
|
235
|
+
missing_rows.index.name = "datetime"
|
|
236
|
+
|
|
237
|
+
yearly_stats = pd.concat([yearly_stats, missing_rows]).sort_index()
|
|
238
|
+
|
|
220
239
|
cov_return = yearly_stats['year_return'].std() / yearly_stats['year_return'].mean() if yearly_stats['year_return'].mean() != 0 else 0
|
|
221
240
|
cov_count = yearly_stats['year_trade_count'].std() / yearly_stats['year_trade_count'].mean() if yearly_stats['year_trade_count'].mean() != 0 else 0
|
|
222
241
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|