This commit is contained in:
dsyoon
2025-08-09 14:00:06 +09:00
parent 60ef3cd299
commit 5350984215

View File

@@ -159,27 +159,32 @@ def calculate_technical_indicators(data):
def buy_ticker(symbol, data):
try:
# 매수 금지 시간 확인 (20분)
current_time = datetime.now()
if symbol in buy_cooldown:
time_diff = current_time - buy_cooldown[symbol]
if time_diff.total_seconds() < 1200: # 20분 = 1200초
print(f"{symbol}: 매수 금지 중 (남은 시간: {1200 - time_diff.total_seconds():.0f}초)")
return False
BUY_AMOUNT = 6000
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초
print(f"{symbol}: 매수 금지 중 (남은 시간: {1200 - time_diff.total_seconds():.0f}초)")
return False
if data['buy_signal'].iloc[-1] == 'movingaverage':
BUY_AMOUNT = 10000
elif data['buy_signal'].iloc[-1] == 'deviation40':
BUY_AMOUNT = 15000
elif data['buy_signal'].iloc[-1] == 'deviation240':
BUY_AMOUNT = 6000
elif data['buy_signal'].iloc[-1] == 'deviation1440':
if symbol in ['BONK', 'PEPE', 'TON']:
BUY_AMOUNT = 30000
else:
BUY_AMOUNT = 50000
if data['buy_signal'].iloc[-1] == 'movingaverage':
BUY_AMOUNT = 10000
elif data['buy_signal'].iloc[-1] == 'deviation40':
BUY_AMOUNT = 15000
elif data['buy_signal'].iloc[-1] == 'deviation240':
BUY_AMOUNT = 6000
elif data['buy_signal'].iloc[-1] == 'deviation1440':
if symbol in ['BONK', 'PEPE', 'TON']:
BUY_AMOUNT = 30000
else:
BUY_AMOUNT = 50000
_ = hts.buyCoinMarket(symbol, BUY_AMOUNT)
@@ -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):