update
This commit is contained in:
parent
a90256307c
commit
dbd90d28d7
Binary file not shown.
@ -232,6 +232,9 @@ class CryptoAgent:
|
||||
|
||||
# 获取并处理数据
|
||||
raw_data = self.fetch_historical_data(symbol, days=self.crypto_config['historical_days'])
|
||||
|
||||
# 数据反转
|
||||
raw_data = raw_data.iloc[::-1]
|
||||
|
||||
if not raw_data.empty:
|
||||
processed_data = self.process_data(symbol, raw_data)
|
||||
@ -251,7 +254,7 @@ class CryptoAgent:
|
||||
"bollinger_upper": float(processed_data['Bollinger_Upper'].iloc[-1]),
|
||||
"bollinger_lower": float(processed_data['Bollinger_Lower'].iloc[-1]),
|
||||
"ma5": float(processed_data['MA5'].iloc[-1]),
|
||||
"ma10": float(processed_data['MA10'].iloc[-1]),
|
||||
"ma100": float(processed_data['MA100'].iloc[-1]),
|
||||
"ma20": float(processed_data['MA20'].iloc[-1]),
|
||||
"ma50": float(processed_data['MA50'].iloc[-1]),
|
||||
"atr": float(processed_data['ATR'].iloc[-1])
|
||||
|
||||
@ -270,7 +270,7 @@ class GoldAgent:
|
||||
"bollinger_upper": float(processed_data['Bollinger_Upper'].iloc[-1]),
|
||||
"bollinger_lower": float(processed_data['Bollinger_Lower'].iloc[-1]),
|
||||
"ma5": float(processed_data['MA5'].iloc[-1]),
|
||||
"ma10": float(processed_data['MA10'].iloc[-1]),
|
||||
"ma100": float(processed_data['MA100'].iloc[-1]),
|
||||
"ma20": float(processed_data['MA20'].iloc[-1]),
|
||||
"ma50": float(processed_data['MA50'].iloc[-1]),
|
||||
"ma200": float(processed_data['MA50'].iloc[-1]) if 'MA200' not in processed_data else float(processed_data['MA200'].iloc[-1]),
|
||||
|
||||
@ -32,12 +32,8 @@ crypto:
|
||||
base_currencies:
|
||||
- "BTC"
|
||||
- "ETH"
|
||||
- "SOL"
|
||||
- "SUI"
|
||||
- "DOGE"
|
||||
- "LTC"
|
||||
quote_currency: "USDT"
|
||||
time_interval: "4h" # 可选: 1m, 5m, 15m, 30m, 1h, 4h, 1d
|
||||
time_interval: "1h" # 可选: 1m, 5m, 15m, 30m, 1h, 4h, 1d
|
||||
historical_days: 90
|
||||
|
||||
# 黄金市场分析配置
|
||||
@ -62,8 +58,8 @@ logging:
|
||||
# 钉钉机器人设置
|
||||
dingtalk:
|
||||
enabled: true # 是否启用钉钉机器人
|
||||
webhook_url: "https://oapi.dingtalk.com/robot/send?access_token=2278b723cd363bb6f85592c743b59b166e70b9e02a275bb5cedbc33b53a5cbdc"
|
||||
secret: "your_secret" # 如果没有设置安全设置,可以为空
|
||||
webhook_url: "https://oapi.dingtalk.com/robot/send?access_token=c0f5188f4b5960c3076d28af111ca4c95b267d8e7340b90561d1cb3566f299ac"
|
||||
secret: "SECc9cb82a674e6da5ea2a6821ebb1e592a848a418cfe15b3073b055639213baebd" # 如果没有设置安全设置,可以为空
|
||||
at_mobiles: [] # 需要@的手机号列表
|
||||
at_all: false # 是否@所有人
|
||||
|
||||
|
||||
@ -8,6 +8,9 @@ from sqlalchemy import Column, Integer, String, DateTime, Index
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.orm import Session
|
||||
from cryptoai.models.base import Base, logger
|
||||
from cryptoai.models.user_subscription import UserSubscriptionManager
|
||||
from datetime import datetime, timedelta
|
||||
import uuid
|
||||
|
||||
# 定义用户数据模型
|
||||
class User(Base):
|
||||
@ -74,6 +77,15 @@ class UserManager:
|
||||
# 添加并提交
|
||||
self.session.add(new_user)
|
||||
self.session.commit()
|
||||
self.session.refresh(new_user)
|
||||
|
||||
# 增加初始订阅信息
|
||||
user_subscription_manager = UserSubscriptionManager(self.session)
|
||||
|
||||
random_order_id = str(uuid.uuid4())
|
||||
expire_time = datetime.now().replace(hour=23, minute=59, second=59) + timedelta(days=7)
|
||||
|
||||
user_subscription_manager.create_subscription(new_user.id, 1, 1, random_order_id, expire_time)
|
||||
|
||||
logger.info(f"成功注册用户: {mail},初始积分: {points}")
|
||||
return True
|
||||
|
||||
38
test.py
38
test.py
@ -1,19 +1,31 @@
|
||||
from cryptoai.agents.crypto_agent import CryptoAgent
|
||||
import cryptoai.tasks.token_selector as token_selector
|
||||
import telegram
|
||||
from cryptoai.agents.crypto_agent import CryptoAgent
|
||||
import cryptoai.tasks.news as news
|
||||
from cryptoai.utils.db_manager import SessionLocal
|
||||
from cryptoai.models.user import User
|
||||
from cryptoai.models.user_subscription import UserSubscriptionManager
|
||||
from datetime import datetime, timedelta
|
||||
import asyncio
|
||||
|
||||
async def main():
|
||||
# token_selector.main()
|
||||
|
||||
#https://t.me/c/2299979359/26
|
||||
|
||||
chat_id = "2299979359"
|
||||
|
||||
bot = telegram.Bot(token="5671996954:AAH5ymtcEPEnjlkI5ah2I8MemScmX3VF3bY")
|
||||
|
||||
await bot.send_message(chat_id=chat_id, text="Hello, world!")
|
||||
import logging
|
||||
import uuid
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
session = SessionLocal()
|
||||
users = session.query(User).all()
|
||||
|
||||
user_subscription_manager = UserSubscriptionManager(session)
|
||||
|
||||
for u in users:
|
||||
# 如果没有用户订阅,则增加订阅信息
|
||||
if not user_subscription_manager.get_subscription_by_user_id(u.id):
|
||||
expire_time = datetime.now().replace(hour=23, minute=59, second=59) + timedelta(days=7)
|
||||
|
||||
random_order_id = str(uuid.uuid4())
|
||||
|
||||
user_subscription_manager.create_subscription(u.id,1, 1, random_order_id, expire_time)
|
||||
logger.info(f"用户 {u.mail} 增加初始订阅信息")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user