plotguy 2.1.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotguy
3
- Version: 2.1.6
3
+ Version: 2.1.7
4
4
  Summary: Plotguy
5
5
  Home-page: https://pypi.org/project/plotguy/
6
6
  Author: Plotguy Team
@@ -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
- for i, row in saved_strategies_df.iterrows():
802
- equity_path = os.path.join(str_dir, row["equity_curve_folder"], str(row['ref_code']) + '.parquet')
803
- #df_equity = pd.read_parquet(equity_path)
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)
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)):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plotguy
3
- Version: 2.1.6
3
+ Version: 2.1.7
4
4
  Summary: Plotguy
5
5
  Home-page: https://pypi.org/project/plotguy/
6
6
  Author: Plotguy Team
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="plotguy",
8
- version="2.1.6",
8
+ version="2.1.7",
9
9
  author="Plotguy Team",
10
10
  author_email="plotguy.info@gmail.com",
11
11
  description="Plotguy",
File without changes
File without changes
File without changes
File without changes
File without changes