plotguy 2.1.5__tar.gz → 2.1.7__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.1.5 → plotguy-2.1.7}/PKG-INFO +1 -1
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy/__init__.py +8 -3
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy/components.py +67 -67
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy.egg-info/PKG-INFO +1 -1
- {plotguy-2.1.5 → plotguy-2.1.7}/setup.py +1 -1
- {plotguy-2.1.5 → plotguy-2.1.7}/README.md +0 -0
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy/aggregate.py +0 -0
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy/equity_curves.py +0 -0
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy/signals.py +0 -0
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy.egg-info/SOURCES.txt +0 -0
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy.egg-info/dependency_links.txt +0 -0
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy.egg-info/requires.txt +0 -0
- {plotguy-2.1.5 → plotguy-2.1.7}/plotguy.egg-info/top_level.txt +0 -0
- {plotguy-2.1.5 → plotguy-2.1.7}/setup.cfg +0 -0
|
@@ -60,8 +60,13 @@ def get_all_para_combination(para_dict, backtest_attribute, df_dict, sec_profile
|
|
|
60
60
|
|
|
61
61
|
all_para_combination[ref_code] = para_combination
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
print('5 second countdown before running backtest()')
|
|
64
|
+
for i in range(5):
|
|
65
|
+
print(5 - i)
|
|
66
|
+
time.sleep(1)
|
|
67
|
+
print(0)
|
|
68
|
+
|
|
69
|
+
print(datetime.datetime.now().strftime('%H:%M:%S'), 'start running backtest()')
|
|
65
70
|
|
|
66
71
|
return all_para_combination
|
|
67
72
|
|
|
@@ -223,7 +228,7 @@ def save_backtest_result(df, para_combination_item):
|
|
|
223
228
|
|
|
224
229
|
######## resample to daily #############
|
|
225
230
|
if 'summary_mode' in para_combination:
|
|
226
|
-
if
|
|
231
|
+
if para_combination['summary_mode']:
|
|
227
232
|
eqiuty_curve_non_summary_save_path = os.path.join('', equity_curve_folder, f'{ref_code}_non-summary-intraday.parquet')
|
|
228
233
|
df.to_parquet(eqiuty_curve_non_summary_save_path)
|
|
229
234
|
|
|
@@ -798,73 +798,73 @@ class Components:
|
|
|
798
798
|
saved_strategies_path = os.path.join(str_dir, 'saved_strategies.parquet')
|
|
799
799
|
saved_strategies_df = pd.read_parquet(saved_strategies_path)
|
|
800
800
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
801
|
+
if len(saved_strategies_df) > 1:
|
|
802
|
+
for i, row in saved_strategies_df.iterrows():
|
|
803
|
+
equity_path = os.path.join(str_dir, row["equity_curve_folder"], str(row['ref_code']) + '.parquet')
|
|
804
|
+
|
|
805
|
+
yearly_stats_string = row['yearly_stats_string']
|
|
806
|
+
para_keys_str = row['para_keys_str']
|
|
807
|
+
para_keys_list = para_keys_str.split('|')
|
|
808
|
+
|
|
809
|
+
parameters = {}
|
|
810
|
+
for para_keys in para_keys_list:
|
|
811
|
+
parameters[para_keys] = str(row[para_keys])
|
|
812
|
+
|
|
813
|
+
equity_curve_dict = {}
|
|
814
|
+
|
|
815
|
+
equity_curve_dict['folder'] = str_dir
|
|
816
|
+
equity_curve_dict['backtest_name'] = row['backtest_name']
|
|
817
|
+
equity_curve_dict['equity_path'] = equity_path
|
|
818
|
+
equity_curve_dict['parameters'] = parameters
|
|
819
|
+
|
|
820
|
+
equity_curve_dict['performance'] = {
|
|
821
|
+
'initial_capital': row['initial_capital'],
|
|
822
|
+
'sharpe_ratio': row['equity_annualized_sr'],
|
|
823
|
+
'annualized_return': row['equity_annualized_return'],
|
|
824
|
+
'net_profit_to_mdd': row['equity_net_profit_to_mdd'],
|
|
825
|
+
'net_profit': row['equity_net_profit'],
|
|
826
|
+
'mdd_dollar': row['equity_mdd_dollar'],
|
|
827
|
+
'mdd_pct': row['equity_mdd_pct'],
|
|
828
|
+
'num_of_trade': row['num_of_trade'],
|
|
829
|
+
'num_of_win': row['num_of_win'],
|
|
830
|
+
'return_on_capital': row['equity_return_on_capital'],
|
|
831
|
+
'total_commission': row['total_commission'],
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
ref_code = str(row['ref_code'])
|
|
835
|
+
equity_curve_dict['ref_code'] = ref_code
|
|
836
|
+
|
|
837
|
+
yearly_stats_dict = {}
|
|
838
|
+
years_data = yearly_stats_string.split("|")
|
|
839
|
+
|
|
840
|
+
for year_data in years_data:
|
|
841
|
+
parts = year_data.split(",")
|
|
842
|
+
year = parts[0]
|
|
843
|
+
yearly_stats_dict[year] = {}
|
|
844
|
+
|
|
845
|
+
for item in parts[1:]:
|
|
846
|
+
key, value = item.split(":")
|
|
847
|
+
yearly_stats_dict[year][key] = float(value)
|
|
848
|
+
|
|
849
|
+
for idx, (year, value) in enumerate(yearly_stats_dict.items()):
|
|
850
|
+
year_trade_count = value['year_trade_count']
|
|
851
|
+
year_win_rate = value['year_win_rate']
|
|
852
|
+
year_return = value['year_return']
|
|
853
|
+
|
|
854
|
+
year_win_count = year_trade_count * year_win_rate * 0.01
|
|
855
|
+
|
|
856
|
+
### dont remove ###
|
|
857
|
+
# year_trade_count = "{:d}".format(int(year_trade_count))
|
|
858
|
+
# year_win_count = "{:d}".format(int(year_win_count))
|
|
859
|
+
# year_win_rate = "{:d}%".format(int(year_win_rate))
|
|
860
|
+
# year_return = "{:.2f} %".format(int(year_return))
|
|
861
|
+
|
|
862
|
+
equity_curve_dict['performance'][f'{year} Count'] = year_trade_count
|
|
863
|
+
equity_curve_dict['performance'][f'{year} Win Rate'] = year_win_rate
|
|
864
|
+
equity_curve_dict['performance'][f'{year} Win Count'] = year_win_count
|
|
865
|
+
equity_curve_dict['performance'][f'{year} Return'] = year_return
|
|
866
|
+
|
|
867
|
+
equity_curves_dict_list.append(equity_curve_dict)
|
|
868
868
|
|
|
869
869
|
line_colour = []
|
|
870
870
|
for c in range(len(equity_curves_dict_list)):
|
|
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
|