哈奇计划法(Harch Plan Method),又称10%转换法,属于趋势投资计划。
它是以发明人哈奇的名字命名的股票投资方法。
哈奇计划法的具体操作:投资者将购进的股票在每周末计算周平均值,并在月底再计算出月平均值。若本月的平均数比最后一次的高价下降10%,则股价有可能出现下跌趋势,投资者便卖出全部股票,而不再购进。等到他卖出股票平均市值,由最低点回升到10%,再行买进。这种方法,也就是当市场趋势发生了10%的反向变动时,便改变投资地位。
哈奇实施这种方法不作卖空交易,在实行此种计划的53年中,先后改变了44次地位,所持股票的期限,最短的为3个月,最长的为6年。哈奇在1882年至1936年的54年中,利用这个计划,将其资产由10万元提高到1440万美元。这个计划,直到哈奇逝世后,才被伦敦金融新闻公布。
harch_plan.py
# coding=utf-8
import os, sys
import datetime
import numpy as np
import pandas as pd
# python 按周分组统计:周平均值
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)
# 用pandas读取csv
df = pd.read_csv(file1)
df = df[['date','close']]
df = df[ df['date'] > '2022-01-01']
df.index = pd.to_datetime(df.date)
# 计算周平均值
df_w = df.groupby(df.index.week).mean()
df_w.rename(columns={'close':'w_avg'}, inplace=True)
#print('df_week:', df_w)
# 周平均值
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]
# 四舍五入到所需精度的值
diff = np.around(diff,3)
diff_percentage = np.around(diff_percentage,2)
# DataFrame 新增2列: 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)
# 计算月平均值
df_m = df.groupby(df.index.month).mean()
df_m.rename(columns={'close':'m_avg'}, inplace=True)
#print('df_month:', df_m)
# 月平均值
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]
# 四舍五入到所需精度的值
diff = np.around(diff,3)
diff_percentage = np.around(diff_percentage,2)
# DataFrame 新增2列: 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
本文介绍了哈奇计划法,一种趋势投资策略,通过计算股票周平均值和月平均值来判断买卖时机。具体操作是,当月平均值下降10%时卖出,回升10%时买入。提供的Python代码实现了该策略,展示了如何计算周和月平均值及其变化率,并给出了示例数据。
2786

被折叠的 条评论
为什么被折叠?



