Hatch plan (Harch Plan Method), also called 10% Conversion , It belongs to the trend investment plan .
It is a stock investment method named after the inventor hatch .
The specific operation of hatch plan method : Investors will buy stocks at the end of each week to calculate the weekly average , And calculate the monthly average value at the end of the month . If the average of this month is lower than the last high price 10%, Then the share price may show a downward trend , Investors sell all their shares , Instead of buying . Wait until he sells the average market value of the stock , From the lowest point to 10%, Buy again . This method , That is, when the market trend occurs 10% When the reverse change of , Change the investment position .
Hatch implemented this method without short selling , In the implementation of such a plan 53 Mid year , Has changed 44 Secondary status , The duration of the shares held , The shortest is 3 Months , The longest one is 6 year . Hatch is 1882 - 1936 Year of 54 Mid year , Use this plan , Transfer its assets from 10 Ten thousand yuan increase to 1440 Thousands of dollars . This plan , Until after hatch's death , Just released by London financial news .
harch_plan.py
# coding=utf-8
import os, sys
import datetime
import numpy as np
import pandas as pd
# python Statistics by week : Weekly average
if len(sys.argv) ==2:
scode = sys.argv[1]
else:
print('usage: python harch_plan.py stockcode ')
sys.exit(1)
if len(scode) !=6:
print(' scode is char(6)')
sys.exit(2)
file1 = "./" +scode +'.csv'
if not os.path.exists(file1):
print(file1 +' is not exists.')
sys.exit(3)
# use pandas Read csv
df = pd.read_csv(file1)
df = df[['date','close']]
df = df[ df['date'] > '2022-01-01']
df.index = pd.to_datetime(df.date)
# Calculate the weekly average
df_w = df.groupby(df.index.week).mean()
df_w.rename(columns={'close':'w_avg'}, inplace=True)
#print('df_week:', df_w)
# Weekly average
w_avg = np.array(df_w['w_avg'].values)
# Take diff of net values and computing rate of change
diff = np.diff(w_avg)
diff_percentage = 100.0 * np.diff(w_avg) / w_avg[:-1]
# Value rounded to the desired precision
diff = np.around(diff,3)
diff_percentage = np.around(diff_percentage,2)
# DataFrame newly added 2 Column : diff,percent
df_w['diff'] = np.insert(diff,0,[0.0])
df_w['percent'] = np.insert(diff_percentage,0,[0.0])
print('df_week:\n', df_w)
# Calculate monthly average
df_m = df.groupby(df.index.month).mean()
df_m.rename(columns={'close':'m_avg'}, inplace=True)
#print('df_month:', df_m)
# Monthly average
m_avg = np.array(df_m['m_avg'].values)
# Take diff of net values and computing rate of change
diff = np.diff(m_avg)
diff_percentage = 100.0 * np.diff(m_avg) / m_avg[:-1]
# Value rounded to the desired precision
diff = np.around(diff,3)
diff_percentage = np.around(diff_percentage,2)
# DataFrame newly added 2 Column : diff,percent
df_m['diff'] = np.insert(diff,0,[0.0])
df_m['percent'] = np.insert(diff_percentage,0,[0.0])
print('df_month:\n', df_m)
python harch_plan.py 000661
df_week:
w_avg diff percent
date
1 265.955000 0.000 0.00
2 262.621000 -3.334 -1.25
3 224.447000 -38.174 -14.54
4 168.785000 -55.662 -24.80
6 164.493000 -4.292 -2.54
7 170.169000 5.676 3.45
8 183.481000 13.312 7.82
9 180.243000 -3.238 -1.76
10 172.103000 -8.140 -4.52
11 175.933000 3.830 2.23
12 172.027000 -3.906 -2.22
13 166.303000 -5.724 -3.33
14 162.608333 -3.695 -2.22
15 158.823000 -3.785 -2.33
16 150.435000 -8.388 -5.28
17 145.051000 -5.384 -3.58
18 154.610000 9.559 6.59
19 155.139000 0.529 0.34
20 151.685000 -3.454 -2.23
21 152.951000 1.266 0.83
22 165.557500 12.607 8.24
23 172.257000 6.700 4.05
24 188.012000 15.755 9.15
25 211.330000 23.318 12.40
df_month:
m_avg diff percent
date
1 228.583421 0.000 0.00
2 173.248125 -55.335 -24.21
3 173.236304 -0.012 -0.01
4 154.038158 -19.198 -11.08
5 154.295000 0.257 0.17
6 188.042059 33.747 21.87