Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -25,10 +25,21 @@ def send_stock_msg(text):
|
|||||||
asyncio.run(stock_client.send_message(chat_id=STOCK_TELEGRAM_CHAT_ID, text=text))
|
asyncio.run(stock_client.send_message(chat_id=STOCK_TELEGRAM_CHAT_ID, text=text))
|
||||||
return
|
return
|
||||||
|
|
||||||
def send_stock_telegram_message(message):
|
def send_stock_telegram_message(message_list, header):
|
||||||
pool = Pool(12)
|
pStr = header+"/n"
|
||||||
pool.map(send_stock_msg, [message])
|
for i, message in enumerate(message_list):
|
||||||
|
pStr += message
|
||||||
|
|
||||||
|
if i+1 % 20 == 0:
|
||||||
|
pool = Pool(12)
|
||||||
|
pool.map(send_stock_msg, [pStr])
|
||||||
|
pStr = ''
|
||||||
|
|
||||||
|
if len(message_list) % 20 != 0:
|
||||||
|
pool = Pool(12)
|
||||||
|
pool.map(send_stock_msg, [pStr])
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
def calculate_bollinger_bands(data):
|
def calculate_bollinger_bands(data):
|
||||||
data['MA'] = data['Close'].rolling(window=BOLLINGER_PERIOD).mean()
|
data['MA'] = data['Close'].rolling(window=BOLLINGER_PERIOD).mean()
|
||||||
@@ -254,7 +265,7 @@ def get_stock_data(symbol, retries=3):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def monitor_us_stocks():
|
def monitor_us_stocks():
|
||||||
message = ""
|
message_list = []
|
||||||
print("US Stocks {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
print("US Stocks {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||||
|
|
||||||
for symbol in US_STOCKS:
|
for symbol in US_STOCKS:
|
||||||
@@ -268,17 +279,14 @@ def monitor_us_stocks():
|
|||||||
|
|
||||||
if info['buy']:
|
if info['buy']:
|
||||||
#if info['buy'] or any(info['buy_signals'].values()):
|
#if info['buy'] or any(info['buy_signals'].values()):
|
||||||
if message == "":
|
message_list.append(format_message(info, 'US'))
|
||||||
message = "[US-STOCK]\n"
|
|
||||||
|
|
||||||
message += format_message(info, 'US')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error processing data for {symbol}: {str(e)}")
|
print(f"Error processing data for {symbol}: {str(e)}")
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
if message:
|
if len(message_list) > 0:
|
||||||
try:
|
try:
|
||||||
send_stock_telegram_message(message)
|
send_stock_telegram_message(message_list, header="[US-STOCK]")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error sending Telegram message: {str(e)}")
|
print(f"Error sending Telegram message: {str(e)}")
|
||||||
|
|
||||||
@@ -286,10 +294,9 @@ def monitor_us_stocks():
|
|||||||
|
|
||||||
|
|
||||||
def monitor_kr_stocks():
|
def monitor_kr_stocks():
|
||||||
message = ""
|
message_list = []
|
||||||
|
|
||||||
# 한국 ETF 모니터링
|
|
||||||
print("KR ETFs {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
print("KR ETFs {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||||
|
|
||||||
for symbol in KR_ETFS:
|
for symbol in KR_ETFS:
|
||||||
data = get_stock_data(symbol)
|
data = get_stock_data(symbol)
|
||||||
if data is not None and not data.empty:
|
if data is not None and not data.empty:
|
||||||
@@ -301,9 +308,7 @@ def monitor_kr_stocks():
|
|||||||
|
|
||||||
if info['buy']:
|
if info['buy']:
|
||||||
#if info['buy'] or any(info['buy_signals'].values()):
|
#if info['buy'] or any(info['buy_signals'].values()):
|
||||||
if message == "":
|
message_list.append(format_message(info, 'KR'))
|
||||||
message = "[KR-STOCK]\n"
|
|
||||||
message += format_message(info, 'KR')
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error processing data for {symbol}: {str(e)}")
|
print(f"Error processing data for {symbol}: {str(e)}")
|
||||||
@@ -311,19 +316,19 @@ def monitor_kr_stocks():
|
|||||||
print(f"Data for {symbol} is empty or None.")
|
print(f"Data for {symbol} is empty or None.")
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
try:
|
if len(message_list) > 0:
|
||||||
send_stock_telegram_message(message)
|
try:
|
||||||
except Exception as e:
|
send_stock_telegram_message(message_list, header="[KR-STOCK]")
|
||||||
print(f"Error sending Telegram message: {str(e)}")
|
except Exception as e:
|
||||||
|
print(f"Error sending Telegram message: {str(e)}")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def monitor_coins():
|
def monitor_coins():
|
||||||
message = ""
|
message_list = []
|
||||||
|
print("KRW COINs {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||||
|
|
||||||
# 코인 모니터링
|
|
||||||
print("KRW Coins {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
|
||||||
for symbol in KR_COINS:
|
for symbol in KR_COINS:
|
||||||
data = get_coin_data(symbol)
|
data = get_coin_data(symbol)
|
||||||
if data is not None and not data.empty:
|
if data is not None and not data.empty:
|
||||||
@@ -335,23 +340,21 @@ def monitor_coins():
|
|||||||
|
|
||||||
if info['buy']:
|
if info['buy']:
|
||||||
#if info['buy'] or any(info['buy_signals'].values()):
|
#if info['buy'] or any(info['buy_signals'].values()):
|
||||||
if message == "":
|
message_list.append(format_message(info, 'KR'))
|
||||||
message = "[KRW-Coin]\n"
|
|
||||||
message += format_message(info, 'KR')
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error processing data for {symbol}: {str(e)}")
|
print(f"Error processing data for {symbol}: {str(e)}")
|
||||||
else:
|
else:
|
||||||
print(f"Data for {symbol} is empty or None.")
|
print(f"Data for {symbol} is empty or None.")
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
try:
|
if len(message_list) > 0:
|
||||||
send_coin_telegram_message(message)
|
try:
|
||||||
except Exception as e:
|
send_stock_telegram_message(message_list, header="[KRW-COIN]")
|
||||||
print(f"Error sending Telegram message: {str(e)}")
|
except Exception as e:
|
||||||
|
print(f"Error sending Telegram message: {str(e)}")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def run_schedule():
|
def run_schedule():
|
||||||
|
|
||||||
# 코인 모니터링 스케줄 (매시간 1분, 11분, 21분, 31분, 41분, 51분)
|
# 코인 모니터링 스케줄 (매시간 1분, 11분, 21분, 31분, 41분, 51분)
|
||||||
|
|||||||
Reference in New Issue
Block a user