This commit is contained in:
dsyoon
2025-08-04 09:09:27 +09:00
parent f7784bb5bc
commit c304eaeac8

View File

@@ -304,10 +304,10 @@ def format_ma_message(info, market_type):
message += f"현재가: {'$' if market_type == 'US' else ''}{info['price']:.2f} \n"
return message
def get_coin_data(symbol, retries=3):
def get_coin_data(symbol, interval=240, retries=3):
for attempt in range(retries):
try:
url = "https://api.bithumb.com/v1/candles/minutes/{}?market=KRW-{}&count=3000".format(240, symbol)
url = "https://api.bithumb.com/v1/candles/minutes/{}?market=KRW-{}&count=3000".format(interval, symbol)
headers = {"accept": "application/json"}
response = requests.get(url, headers=headers)
json_data = json.loads(response.text)
@@ -449,7 +449,25 @@ def monitor_coins():
print("KRW COINs {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
for symbol in KR_COINS:
data = get_coin_data(symbol)
data = get_coin_data(symbol, interval=60)
if data is not None and not data.empty:
try:
data = calculate_technical_indicators(data)
info = check_ma_alert(symbol, data)
if info is None:
continue
info['name'] = KR_COINS[symbol]
print(f" - {info['name']} ({symbol}): {info['price']:.2f} -> {info['alert']}")
if info['alert']:
message_list.append(format_ma_message(info, 'KR'))
except Exception as e:
print(f"Error processing data for {symbol}: {str(e)}")
else:
print(f"Data for {symbol} is empty or None.")
time.sleep(0.5)
data = get_coin_data(symbol, interval=240)
if data is not None and not data.empty:
try:
data = calculate_technical_indicators(data)
@@ -478,7 +496,7 @@ def monitor_coins():
def run_schedule():
# 코인 모니터링 스케줄 (매시간 1분, 11분, 21분, 31분, 41분, 51분)
for minute in [4, 34]:
for minute in [4, 14, 24, 34, 44, 54]:
schedule.every().hour.at(f":{minute:02d}").do(monitor_coins)
# 미국 주식 모니터링 스케줄 (매일 저녁 5시 20분)