init
This commit is contained in:
@@ -91,7 +91,7 @@ def calculate_technical_indicators(data):
|
||||
return data
|
||||
|
||||
|
||||
def check_ma_alert(symbol, data):
|
||||
def check_ma_alert(symbol, data, interval=0):
|
||||
"""1시간봉 기준 이동평균선 조건 알림
|
||||
- 5봉 이동평균(MA5) 상승
|
||||
- 20봉 이동평균(MA20) 상승
|
||||
@@ -121,6 +121,7 @@ def check_ma_alert(symbol, data):
|
||||
'price': data['Close'].iloc[-1],
|
||||
'alert': alert,
|
||||
'details': {
|
||||
'interval': interval,
|
||||
'up5': up5,
|
||||
'up20': up20,
|
||||
'ma40_turning': turning
|
||||
@@ -380,7 +381,7 @@ def monitor_us_stocks():
|
||||
if data is not None and not data.empty:
|
||||
try:
|
||||
data = calculate_technical_indicators(data)
|
||||
info = check_ma_alert(symbol, data)
|
||||
info = check_ma_alert(symbol, data, 0)
|
||||
if info is None:
|
||||
continue
|
||||
info['name'] = US_STOCKS[symbol]
|
||||
@@ -414,7 +415,7 @@ def monitor_kr_stocks():
|
||||
if data is not None and not data.empty:
|
||||
try:
|
||||
data = calculate_technical_indicators(data)
|
||||
info = check_ma_alert(symbol, data)
|
||||
info = check_ma_alert(symbol, data, 0)
|
||||
if info is None:
|
||||
continue
|
||||
info['name'] = KR_ETFS[symbol]
|
||||
@@ -449,15 +450,17 @@ 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, interval=60)
|
||||
# 1시간
|
||||
interval = 60
|
||||
data = get_coin_data(symbol, interval=interval)
|
||||
if data is not None and not data.empty:
|
||||
try:
|
||||
data = calculate_technical_indicators(data)
|
||||
info = check_ma_alert(symbol, data)
|
||||
info = check_ma_alert(symbol, data, interval)
|
||||
if info is None:
|
||||
continue
|
||||
info['name'] = KR_COINS[symbol]
|
||||
print(f" - {info['name']} ({symbol}): {info['price']:.2f} -> {info['alert']}")
|
||||
print(f" - {info['name']} ({symbol}): {info['price']:.2f} -> {info['alert']} ({info['interval']})")
|
||||
|
||||
if info['alert']:
|
||||
message_list.append(format_ma_message(info, 'KR'))
|
||||
@@ -467,15 +470,17 @@ def monitor_coins():
|
||||
print(f"Data for {symbol} is empty or None.")
|
||||
time.sleep(0.5)
|
||||
|
||||
data = get_coin_data(symbol, interval=240)
|
||||
# 4시간
|
||||
interval = 240
|
||||
data = get_coin_data(symbol, interval=interval)
|
||||
if data is not None and not data.empty:
|
||||
try:
|
||||
data = calculate_technical_indicators(data)
|
||||
info = check_ma_alert(symbol, data)
|
||||
info = check_ma_alert(symbol, data, interval)
|
||||
if info is None:
|
||||
continue
|
||||
info['name'] = KR_COINS[symbol]
|
||||
print(f" - {info['name']} ({symbol}): {info['price']:.2f} -> {info['alert']}")
|
||||
print(f" - {info['name']} ({symbol}): {info['price']:.2f} -> {info['alert']} ({info['interval']})")
|
||||
|
||||
if info['alert']:
|
||||
message_list.append(format_ma_message(info, 'KR'))
|
||||
|
||||
Reference in New Issue
Block a user