- cleaned up
- added GD50 and GD200 git-svn-id: http://moon:8086/svn/projects/Stock@360 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -24,9 +24,7 @@ params = {
|
||||
'plot_range_days' : 0,
|
||||
'btfd' : {'thresh_max' : -7, 'thresh_min' : 1, 'cand_window' : 5},
|
||||
'k_euro' : 1 / 1.11,
|
||||
'ema_alpha' : 0.75,
|
||||
'sma_days' : 10,
|
||||
'q_days' : 10,
|
||||
'q_range_days' : 10,
|
||||
'fetch_on_outdated' : True
|
||||
}
|
||||
|
||||
@@ -36,6 +34,7 @@ parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--symbol', help='Symbol to fetch')
|
||||
parser.add_argument('--analyze-range', type=int, help='Analyze window [days]')
|
||||
parser.add_argument('--plot-range', type=int, help='Plot range [days]')
|
||||
parser.add_argument('--q-range', type=int, help='Q range [days]')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -72,6 +71,9 @@ if args.analyze_range is not None:
|
||||
if args.plot_range is not None:
|
||||
params['plot_range_days'] = args.plot_range
|
||||
|
||||
if args.q_range is not None:
|
||||
params['q_range_days'] = args.q_range
|
||||
|
||||
do_plot = params['plot_range_days'] > 0
|
||||
buy_list = {}
|
||||
def buy_callback(data):
|
||||
|
||||
@@ -90,12 +90,13 @@ class Stock(object):
|
||||
|
||||
def statistics(self):
|
||||
N = len(self.data['index'])
|
||||
self.data['ema'] = exponential_moving_average(self.data['close'], alpha=self.params['ema_alpha'])
|
||||
self.data['sma'] = moving_average(self.data['close'], window_days=self.params['sma_days'])
|
||||
self.data['ema'] = exponential_moving_average(self.data['close'], alpha=0.75)
|
||||
self.data['GD200'] = moving_average(self.data['close'], window_days=200)
|
||||
self.data['GD50'] = moving_average(self.data['close'], window_days=50)
|
||||
self.data['close_n'] = normalize(self.data['close'])
|
||||
self.data['macd'] = macd(self.data['close_n'])
|
||||
self.data['min'] = moving_min(self.data['close_n'], window_days=self.params['q_days'])
|
||||
self.data['max'] = moving_max(self.data['close_n'], window_days=self.params['q_days'])
|
||||
self.data['min'] = moving_min(self.data['close_n'], window_days=self.params['q_range_days'])
|
||||
self.data['max'] = moving_max(self.data['close_n'], window_days=self.params['q_range_days'])
|
||||
|
||||
self.data['Qmin'] = self.data['close_n'] - self.data['min']
|
||||
self.data['Qmax'] = self.data['close_n'] - self.data['max']
|
||||
@@ -172,8 +173,7 @@ class Stock(object):
|
||||
plt.grid()
|
||||
|
||||
subplot_id += 1
|
||||
# self.__plot(self.boll, ['lower', 'mid', 'upper'])
|
||||
self.__plot(subplot_id, self.data, ['Qmin', 'Qmax'])
|
||||
self.__plot(subplot_id, self.data, ['close', 'GD50', 'GD200'])
|
||||
plt.legend()
|
||||
plt.grid()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user