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