init
This commit is contained in:
@@ -120,105 +120,104 @@ class BuySellChecker():
|
||||
df_signal = data_signal.loc[df_tmp]
|
||||
si = len(df_signal) - 1
|
||||
|
||||
"""
|
||||
duration = 5
|
||||
if duration < i:
|
||||
if sum(data['avg20'][i - duration:i])/len(data['avg20'][i - duration:i]) < data['avg20'][i]:
|
||||
min_value1 = min(data['close'][i - 1], data['close'][i - 1])
|
||||
min_value2 = min(data['close'][i - 2], data['close'][i - 2])
|
||||
min_value3 = min(data['close'][i - 3], data['close'][i - 3])
|
||||
min_sum = min_value1 + min_value2 + min_value3
|
||||
if min_sum / 3 < data['close'][i] and data['close'][i] == data['high'][i]:
|
||||
if data['avg60'][i] < data['avg20'][i] and data['avg5'][i-1] < data['avg5'][i]:
|
||||
if data['middle'][i-1] < data['middle'][i]:
|
||||
if 0 < len(BUY_LIST['buy_list']):
|
||||
if BUY_LIST['buy_list'][-1]['buy_price'] < data['close'][i]:
|
||||
buy_price = data['close'][i]
|
||||
buy_type = 'avg20_close_up'
|
||||
buy_ymd = data['ymd'][i]
|
||||
buy_cut = -1
|
||||
if data['slow_k'][si] < 30:
|
||||
buy_count = MAX_BUY_PRICE / (1 * data['close'][i])
|
||||
elif data['slow_k'][si] < 50:
|
||||
buy_count = MAX_BUY_PRICE / (1.5 * data['close'][i])
|
||||
else:
|
||||
buy_count = MAX_BUY_PRICE / (2 * data['close'][i])
|
||||
|
||||
return buy_ymd, buy_price, buy_count, buy_cut, buy_type
|
||||
else:
|
||||
buy_price = data['close'][i]
|
||||
buy_type = 'avg20_close_up'
|
||||
buy_ymd = data['ymd'][i]
|
||||
buy_cut = -1
|
||||
if data['slow_k'][si] < 30:
|
||||
buy_count = MAX_BUY_PRICE / (1 * data['close'][i])
|
||||
elif data['slow_k'][si] < 50:
|
||||
buy_count = MAX_BUY_PRICE / (1.5 * data['close'][i])
|
||||
else:
|
||||
buy_count = MAX_BUY_PRICE / (2 * data['close'][i])
|
||||
|
||||
return buy_ymd, buy_price, buy_count, buy_cut, buy_type
|
||||
"""
|
||||
|
||||
duration = 5
|
||||
check = False
|
||||
duration = 5 + 60
|
||||
if duration < i:
|
||||
if np.average(data['trend_avg'][i - duration:i]) < data['trend_avg'][i]:
|
||||
if self.is_Support(data, i-10, observation_time = 300):
|
||||
if data['open'][i] < data['close'][i]:
|
||||
if np.max(data['high'][i-2:i]) < data['close'][i]:
|
||||
|
||||
buy_price = data['close'][i]
|
||||
buy_type = 'support_300'
|
||||
buy_ymd = data['ymd'][i]
|
||||
buy_cut = data['close'][i] * 0.995
|
||||
BUY_LIST['buy_limit'] = 0
|
||||
if data['slow_k'][si] < 30:
|
||||
buy_count = MAX_BUY_PRICE*5 / (data['close'][i])
|
||||
elif data['slow_k'][si] < 50:
|
||||
buy_count = MAX_BUY_PRICE*4 / (data['close'][i])
|
||||
if np.average(data['avg480'][i - duration:i]) < data['avg480'][i]:
|
||||
if data['avg480'][i] < data['trend_avg'][i]:
|
||||
if data['avg20'][i] < data['avg480'][i] and data['avg20'][i - 1] < data['avg20'][i]:
|
||||
if len(BUY_LIST['buy_list']) == 0:
|
||||
check = True
|
||||
else:
|
||||
buy_count = MAX_BUY_PRICE*3 / (data['close'][i])
|
||||
if BUY_LIST['buy_list'][-1]['buy_price'] < data['close'][i]:
|
||||
check = True
|
||||
|
||||
return buy_ymd, buy_price, buy_count, buy_cut, buy_type
|
||||
if 2800 < len(data['close'][i - 2880:i]) and np.max(data['close'][i - 2880:i]) < data['close'][i]:
|
||||
if np.max(data['rsi'][i - 30:i]) < data['rsi'][i]:
|
||||
if data['disparity_avg1500'][i] < 1.1:
|
||||
if data['close'][i] < data['trend_avg'][i]:
|
||||
buy_type = 'upward'
|
||||
check = True
|
||||
|
||||
if data['slow_k'][i] < 15:
|
||||
if data['slow_k'][i-1] < data['slow_d'][i-1] and data['slow_d'][i] < data['slow_k'][i]:
|
||||
buy_price = data['close'][i]
|
||||
buy_type = 'slow_k'
|
||||
buy_ymd = data['ymd'][i]
|
||||
buy_cut = data['close'][i] * 0.995
|
||||
BUY_LIST['buy_limit'] = 0
|
||||
buy_count = MAX_BUY_PRICE * 2 / (data['close'][i])
|
||||
return buy_ymd, buy_price, buy_count, buy_cut, buy_type
|
||||
if data['disparity_avg20'][i] < BUY_LIST['disparity']['limit_bottom_3']['avg20']:
|
||||
buy_type = 'disparity_avg20'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg60'][i] < BUY_LIST['disparity']['limit_bottom_3']['avg60']:
|
||||
buy_type = 'disparity_avg60'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg480'][i] < BUY_LIST['disparity']['limit_bottom_3']['avg480']:
|
||||
buy_type = 'disparity_avg1500'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg1500'][i] < BUY_LIST['disparity']['limit_bottom_3']['avg1500']:
|
||||
buy_type = 'disparity_avg1500'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg20'][i] < BUY_LIST['disparity']['limit_bottom_1']['avg20']:
|
||||
buy_type = 'disparity_avg20'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg60'][i] < BUY_LIST['disparity']['limit_bottom_1']['avg60']:
|
||||
buy_type = 'disparity_avg60'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg480'][i] < BUY_LIST['disparity']['limit_bottom_1']['avg480']:
|
||||
buy_type = 'disparity_avg1500'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg1500'][i] < BUY_LIST['disparity']['limit_bottom_1']['avg1500']:
|
||||
buy_type = 'disparity_avg1500'
|
||||
check = True
|
||||
|
||||
if check:
|
||||
buy_price = data['close'][i]
|
||||
buy_ymd = data['ymd'][i]
|
||||
if data['slow_k'][si] < 30:
|
||||
buy_count = MAX_BUY_PRICE * 2 / (data['close'][i])
|
||||
elif data['slow_k'][si] < 50:
|
||||
buy_count = MAX_BUY_PRICE * 1.5 / (data['close'][i])
|
||||
else:
|
||||
buy_count = MAX_BUY_PRICE * 1 / (data['close'][i])
|
||||
|
||||
return buy_ymd, buy_price, buy_count, buy_cut, buy_type
|
||||
|
||||
return buy_ymd, buy_price, buy_count, buy_cut, buy_type
|
||||
|
||||
def getSellPriceAndWeight1(self, ticker, i, data, data_signal, BUY_LIST=None):
|
||||
sell_price, sell_count, sell_type = -1, -1, ''
|
||||
|
||||
df_tmp = data_signal['ymd'] <= data['ymd'][i]
|
||||
df_signal = data_signal.loc[df_tmp]
|
||||
si = len(df_signal) - 1
|
||||
|
||||
check = False
|
||||
if 0 < len(BUY_LIST['buy_list']):
|
||||
duration = 5
|
||||
if duration < i:
|
||||
if data['trend_avg'][i] < np.average(data['trend_avg'][i - duration:i]):
|
||||
if self.is_Resistance(data, i - 10, observation_time=300):
|
||||
sell_price = data['close'][i]
|
||||
sell_count = sum([price['buy_count'] for price in BUY_LIST['buy_list']])
|
||||
|
||||
if 75 < np.max(data_signal['rsi'][si-5:si]):
|
||||
if self.is_Resistance(data, i - 10, observation_time=300):
|
||||
sell_price = data['close'][i]
|
||||
sell_count = sum([price['buy_count'] for price in BUY_LIST['buy_list']])
|
||||
"""
|
||||
if 1.05 < data['disparity_avg20'][i]:
|
||||
check = True
|
||||
|
||||
if 1.10 < data['disparity_avg480'][i]:
|
||||
check = True
|
||||
|
||||
if 70 < data['slow_k'][i]:
|
||||
if data['slow_d'][i-1] < data['slow_k'][i-1] and data['slow_k'][i] <= data['slow_d'][i]:
|
||||
sell_price = data['close'][i]
|
||||
sell_count = sum([price['buy_count'] for price in BUY_LIST['buy_list'] if price['buy_type'] == 'slow_k'])
|
||||
sell_type = 'slow_k'
|
||||
if 1.15 < data['disparity_avg1500'][i]:
|
||||
check = True
|
||||
"""
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_1']['avg20'] < data['disparity_avg20'][i]:
|
||||
check = True
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_1']['avg480'] < data['disparity_avg480'][i]:
|
||||
check = True
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_1']['avg1500'] < data['disparity_avg1500'][i]:
|
||||
check = True
|
||||
|
||||
if data['avg1500'][i - 1] < data['trend_avg'][i - 1] and data['trend_avg'][i] <= data['avg1500'][i]:
|
||||
check = True
|
||||
|
||||
if check:
|
||||
sell_price = data['close'][i]
|
||||
sell_count = sum([price['buy_count'] for price in BUY_LIST['buy_list']])
|
||||
|
||||
return sell_price, sell_count, sell_type
|
||||
|
||||
@@ -268,7 +267,7 @@ class BuySellChecker():
|
||||
sell_price, sell_count, sell_type = self.getSellPriceAndWeight1(ticker, last_index, data, data_signal, BUY_LIST)
|
||||
bsLine['sell_price'][last_index] = sell_price
|
||||
bsLine['sell_count'][last_index] = sell_count
|
||||
bsLine['sell_type'] = [sell_type]
|
||||
bsLine['sell_type'][last_index] = sell_type
|
||||
|
||||
if 0 < sell_price:
|
||||
BUY_LIST['buy_limit'] = 0
|
||||
|
||||
Reference in New Issue
Block a user