init
This commit is contained in:
@@ -124,7 +124,8 @@ class BuySellChecker():
|
||||
check = False
|
||||
duration = 5 + 60
|
||||
if duration < i:
|
||||
if np.average(data['trend_avg'][i - duration:i]) < data['trend_avg'][i]:
|
||||
if np.average(data['trend_avg'][i - duration:i]) < data['trend_avg'][i] and data['avg1500'][i] < \
|
||||
data['trend_avg'][i]:
|
||||
|
||||
if np.average(data['avg480'][i - duration:i]) < data['avg480'][i]:
|
||||
if data['avg480'][i] < data['trend_avg'][i]:
|
||||
@@ -142,20 +143,27 @@ class BuySellChecker():
|
||||
buy_type = 'upward'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg20'][i] < BUY_LIST['disparity']['limit_bottom_1']['avg20']:
|
||||
buy_type = 'disparity_avg20'
|
||||
max_value = np.max(data['close'][i - 3000:i])
|
||||
min_value = np.min(data['close'][i - 3000:i])
|
||||
if 0.1 < (max_value - min_value) / max_value:
|
||||
if data['close'][i - 1] < data['trend_avg'][i - 1] and data['trend_avg'][i] < data['close'][i]:
|
||||
buy_type = 'trend_close'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg20'][i] < BUY_LIST['disparity']['limit_bottom_5']['avg20']:
|
||||
buy_type = 'disparity_avg'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg60'][i] < BUY_LIST['disparity']['limit_bottom_1']['avg60']:
|
||||
buy_type = 'disparity_avg60'
|
||||
if data['disparity_avg60'][i] < BUY_LIST['disparity']['limit_bottom_5']['avg60']:
|
||||
buy_type = 'disparity_avg'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg480'][i] < BUY_LIST['disparity']['limit_bottom_3']['avg480']:
|
||||
buy_type = 'disparity_avg1500'
|
||||
if data['disparity_avg480'][i] < BUY_LIST['disparity']['limit_bottom_10']['avg480']:
|
||||
buy_type = 'disparity_avg'
|
||||
check = True
|
||||
|
||||
if data['disparity_avg1500'][i] < BUY_LIST['disparity']['limit_bottom_5']['avg1500']:
|
||||
buy_type = 'disparity_avg1500'
|
||||
if data['disparity_avg1500'][i] < BUY_LIST['disparity']['limit_bottom_20']['avg1500']:
|
||||
buy_type = 'disparity_avg'
|
||||
check = True
|
||||
|
||||
if check:
|
||||
@@ -176,41 +184,65 @@ class BuySellChecker():
|
||||
sell_price, sell_count, sell_type = -1, -1, ''
|
||||
|
||||
check = False
|
||||
sell_count_disparity_avg = 0
|
||||
sell_count_trend_close = 0
|
||||
if 0 < len(BUY_LIST['buy_list']):
|
||||
|
||||
# 매수한지 3시간 이내라면
|
||||
if data['ymd'][i] - timedelta(hours=3) < BUY_LIST['buy_list'][-1]['buy_ymd']:
|
||||
if data['avg480'][i - 1] <= data['avg420'][i] and data['avg420'][i] < data['avg480'][i]:
|
||||
sell_count_trend_close = sum(
|
||||
[price['buy_count'] for price in BUY_LIST['buy_list'] if price['buy_type'] == 'trend_close'])
|
||||
if 0 < sell_count_trend_close:
|
||||
check = True
|
||||
|
||||
# 매수한지 12시간 이내라면
|
||||
if data['ymd'][i] - timedelta(hours=12) < BUY_LIST['buy_list'][-1]['buy_ymd']:
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_3']['avg20'] < data['disparity_avg20'][i]:
|
||||
sell_count_disparity_avg = sum(
|
||||
[price['buy_count'] for price in BUY_LIST['buy_list'] if price['buy_type'] == 'disparity_avg'])
|
||||
check = True
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_3']['avg60'] < data['disparity_avg60'][i]:
|
||||
sell_count_disparity_avg = sum(
|
||||
[price['buy_count'] for price in BUY_LIST['buy_list'] if price['buy_type'] == 'disparity_avg'])
|
||||
check = True
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_5']['avg480'] < data['disparity_avg480'][i]:
|
||||
sell_count_disparity_avg = sum(
|
||||
[price['buy_count'] for price in BUY_LIST['buy_list'] if price['buy_type'] == 'disparity_avg'])
|
||||
check = True
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_10']['avg1500'] < data['disparity_avg1500'][i]:
|
||||
sell_count_disparity_avg = sum(
|
||||
[price['buy_count'] for price in BUY_LIST['buy_list'] if price['buy_type'] == 'disparity_avg'])
|
||||
check = True
|
||||
else:
|
||||
# 매수한지 3시간 이후라면
|
||||
if BUY_LIST['buy_list'][-1]['buy_price'] * 1.002 < data['close'][i]:
|
||||
# 매수한지 12시간 이후라면
|
||||
if BUY_LIST['buy_list'][-1]['buy_price'] * 1.004 < data['close'][i]:
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_99']['avg20'] < data['disparity_avg20'][i]:
|
||||
sell_count_disparity_avg = sum([price['buy_count'] for price in BUY_LIST['buy_list'] if
|
||||
price['buy_type'] == 'disparity_avg'])
|
||||
check = True
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_99']['avg60'] < data['disparity_avg60'][i]:
|
||||
sell_count_disparity_avg = sum([price['buy_count'] for price in BUY_LIST['buy_list'] if
|
||||
price['buy_type'] == 'disparity_avg'])
|
||||
check = True
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_99']['avg480'] < data['disparity_avg480'][i]:
|
||||
sell_count_disparity_avg = sum([price['buy_count'] for price in BUY_LIST['buy_list'] if
|
||||
price['buy_type'] == 'disparity_avg'])
|
||||
check = True
|
||||
|
||||
if BUY_LIST['disparity']['limit_top_99']['avg1500'] < data['disparity_avg1500'][i]:
|
||||
sell_count_disparity_avg = sum([price['buy_count'] for price in BUY_LIST['buy_list'] if
|
||||
price['buy_type'] == 'disparity_avg'])
|
||||
check = True
|
||||
|
||||
if check:
|
||||
sell_price = data['close'][i]
|
||||
sell_count = sum([price['buy_count'] for price in BUY_LIST['buy_list']])
|
||||
sell_count = sell_count_disparity_avg + sell_count_trend_close
|
||||
|
||||
return sell_price, sell_count, sell_type
|
||||
|
||||
@@ -243,7 +275,8 @@ class BuySellChecker():
|
||||
bsLine['buy_type'] = [buy_type]
|
||||
|
||||
if 0 < buy_price:
|
||||
BUY_LIST['buy_list'].append({'buy_ymd': buy_ymd, 'buy_price': buy_price, 'buy_count': buy_count, 'buy_cut': buy_cut, 'buy_type': buy_type})
|
||||
BUY_LIST['buy_list'].append(
|
||||
{'buy_ymd': buy_ymd, 'buy_price': buy_price, 'buy_count': buy_count, 'buy_cut': buy_cut, 'buy_type': buy_type})
|
||||
else:
|
||||
# Type=False, 시뮬레이션 적용
|
||||
bsLine['buy_ymd'] = [-1 for i in range(size)]
|
||||
@@ -273,7 +306,8 @@ class BuySellChecker():
|
||||
bsLine['buy_type'][last_index] = buy_type
|
||||
|
||||
if 0 < buy_price:
|
||||
BUY_LIST['buy_list'].append({'buy_ymd': buy_ymd, 'buy_price': buy_price, 'buy_count': buy_count, 'buy_cut': buy_cut, 'buy_type': buy_type})
|
||||
BUY_LIST['buy_list'].append(
|
||||
{'buy_ymd': buy_ymd, 'buy_price': buy_price, 'buy_count': buy_count, 'buy_cut': buy_cut, 'buy_type': buy_type})
|
||||
|
||||
else:
|
||||
bsLine['buy_price'] = [-1]
|
||||
|
||||
Reference in New Issue
Block a user