init
This commit is contained in:
@@ -159,8 +159,13 @@ def calculate_technical_indicators(data):
|
||||
|
||||
def buy_ticker(symbol, data):
|
||||
try:
|
||||
# 매수 금지 시간 확인 (20분)
|
||||
current_time = datetime.now()
|
||||
|
||||
if data['buy_signal'].iloc[-1] != 'fall_5p':
|
||||
# 5%이상 급락일 때는 10분마다 매수
|
||||
BUY_AMOUNT = 100000
|
||||
else:
|
||||
# 매수 금지 시간 확인 (20분)
|
||||
if symbol in buy_cooldown:
|
||||
time_diff = current_time - buy_cooldown[symbol]
|
||||
if time_diff.total_seconds() < 1200: # 20분 = 1200초
|
||||
@@ -289,6 +294,26 @@ def check_buy_point(symbol, data, simulation=None):
|
||||
data.at[data.index[-1], 'buy_signal'] = 'deviation1440'
|
||||
data.at[data.index[-1], 'buy_point'] = 1
|
||||
|
||||
# 하락 5% 조건: 현재가 또는 현재 봉의 저가가 지난 봉 고가/현재 봉 고가 대비 5% 이상 하락
|
||||
try:
|
||||
prev_high = data['High'].iloc[i - 1]
|
||||
curr_high = data['High'].iloc[i]
|
||||
curr_close = data['Close'].iloc[i]
|
||||
curr_low = data['Low'].iloc[i]
|
||||
|
||||
cond_close_drop = (curr_close <= prev_high * 0.95) or (curr_close <= curr_high * 0.95)
|
||||
cond_low_drop = (curr_low <= prev_high * 0.95) or (curr_low <= curr_high * 0.95)
|
||||
|
||||
if cond_close_drop or cond_low_drop:
|
||||
data.at[data.index[i], 'buy_signal'] = 'fall_5p'
|
||||
data.at[data.index[i], 'buy_point'] = 1
|
||||
if not simulation:
|
||||
if data['buy_point'][-3:].sum() > 0:
|
||||
data.at[data.index[-1], 'buy_signal'] = 'fall_5p'
|
||||
data.at[data.index[-1], 'buy_point'] = 1
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return data
|
||||
|
||||
def format_message(market_type, symbol, symbol_name, close, buy_signal):
|
||||
|
||||
Reference in New Issue
Block a user