support send btc-usdt isolately

This commit is contained in:
blade 2025-09-15 15:02:49 +08:00
parent ff2c35e1b3
commit 7b132cddb2
4 changed files with 16 additions and 11 deletions

View File

@ -126,6 +126,9 @@ MYSQL_CONFIG = {
"database": "okx", "database": "okx",
} }
WECHAT_CONFIG = {"key": "11e6f7ac-efa9-418a-904c-9325a9f5d324"} WECHAT_CONFIG = {
"general_key": "11e6f7ac-efa9-418a-904c-9325a9f5d324",
"btc_key": "529e135d-843b-43dc-8aca-677a860f4b4b",
}
ITICK_API_KEY = "dfd4bc0caed148d6bc03b960224754ffb5356349e389431f828702b3a27e8a2b" ITICK_API_KEY = "dfd4bc0caed148d6bc03b960224754ffb5356349e389431f828702b3a27e8a2b"

View File

@ -6,15 +6,14 @@
""" """
import core.logger as logging import core.logger as logging
import requests import requests
from config import WECHAT_CONFIG
logger = logging.logger logger = logging.logger
class Wechat: class Wechat:
def __init__(self): def __init__(self, key: str):
# 虽然config在根目录但是取决于调用代码在哪 # 虽然config在根目录但是取决于调用代码在哪
# 只要启动代码文件在根目录config就能找到 # 只要启动代码文件在根目录config就能找到
self.key = WECHAT_CONFIG["key"] self.key = key
self.url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={self.key}" self.url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={self.key}"
def send_text(self, text: str): def send_text(self, text: str):

View File

@ -113,7 +113,7 @@ class HugeVolumeMain:
f"开始处理巨量交易数据: {symbol} {bar} 窗口大小: {window_size}{start}{end}" f"开始处理巨量交易数据: {symbol} {bar} 窗口大小: {window_size}{start}{end}"
) )
data = self.db_market_data.query_market_data_by_symbol_bar( data = self.db_market_data.query_market_data_by_symbol_bar(
symbol, bar, start, end symbol=symbol, bar=bar, start=start, end=end
) )
if data is None: if data is None:
logger.warning( logger.warning(
@ -697,8 +697,8 @@ def test_send_huge_volume_data_to_wechat():
if __name__ == "__main__": if __name__ == "__main__":
# test_import_binance_data_by_csv() # test_import_binance_data_by_csv()
batch_import_binance_data_by_csv() # batch_import_binance_data_by_csv()
# batch_update_volume_spike(threshold=2.0, is_us_stock=True) batch_update_volume_spike(threshold=2.0, is_us_stock=False)
# test_send_huge_volume_data_to_wechat() # test_send_huge_volume_data_to_wechat()
# batch_initial_detect_volume_spike(threshold=2.0) # batch_initial_detect_volume_spike(threshold=2.0)

View File

@ -4,7 +4,7 @@ from huge_volume_main import HugeVolumeMain
from core.biz.market_monitor import create_metrics_report from core.biz.market_monitor import create_metrics_report
from core.db.db_market_monitor import DBMarketMonitor from core.db.db_market_monitor import DBMarketMonitor
from core.wechat import Wechat from core.wechat import Wechat
from config import OKX_MONITOR_CONFIG, MYSQL_CONFIG from config import OKX_MONITOR_CONFIG, MYSQL_CONFIG, WECHAT_CONFIG
from core.utils import timestamp_to_datetime, transform_date_time_to_timestamp from core.utils import timestamp_to_datetime, transform_date_time_to_timestamp
import core.logger as logging import core.logger as logging
@ -20,7 +20,6 @@ class MarketMonitorMain:
def __init__(self): def __init__(self):
self.market_data_main = MarketDataMain() self.market_data_main = MarketDataMain()
self.huge_volume_main = HugeVolumeMain() self.huge_volume_main = HugeVolumeMain()
self.wechat = Wechat()
self.monitor_config = OKX_MONITOR_CONFIG self.monitor_config = OKX_MONITOR_CONFIG
self.window_size = 100 self.window_size = 100
self.start_date = OKX_MONITOR_CONFIG.get("volume_monitor", {}).get( self.start_date = OKX_MONITOR_CONFIG.get("volume_monitor", {}).get(
@ -179,7 +178,11 @@ class MarketMonitorMain:
text_length = len(report.encode("utf-8")) text_length = len(report.encode("utf-8"))
logger.info(f"发送报告到企业微信,字节数: {text_length}") logger.info(f"发送报告到企业微信,字节数: {text_length}")
self.wechat.send_markdown(report) if symbol == "BTC-USDT":
wechat = Wechat(WECHAT_CONFIG["btc_key"])
else:
wechat = Wechat(WECHAT_CONFIG["general_key"])
wechat.send_markdown(report)
# remove punction in latest_reatime_datetime # remove punction in latest_reatime_datetime
file_datetime = re.sub(r"[\:\-\s]", "", latest_reatime_datetime) file_datetime = re.sub(r"[\:\-\s]", "", latest_reatime_datetime)
@ -287,7 +290,7 @@ class MarketMonitorMain:
if __name__ == "__main__": if __name__ == "__main__":
market_monitor_main = MarketMonitorMain() market_monitor_main = MarketMonitorMain()
market_monitor_main.monitor_realtime_market( market_monitor_main.monitor_realtime_market(
symbol="PUMP-USDT", symbol="BTC-USDT",
bar="5m", bar="5m",
only_output_huge_volume=False, only_output_huge_volume=False,
only_output_rise=False, only_output_rise=False,