a5c17b6ba0
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
"""
|
|
每日交易信号汇总。
|
|
开盘前跑一下,输出当天方向建议。
|
|
"""
|
|
import sqlite3
|
|
from datetime import datetime
|
|
from macro import direction as macro_direction, init as macro_init
|
|
|
|
DB_PATH = "/Users/vipg/Documents/futures-data-warehouse/db/futures.db"
|
|
|
|
def main():
|
|
macro_init()
|
|
|
|
today = datetime.now().strftime("%Y%m%d")
|
|
|
|
# 1. 宏观方向
|
|
dir, reason = macro_direction()
|
|
print(f"日期: {today}")
|
|
print(f"宏观方向: {dir}")
|
|
print(f"依据: {reason}")
|
|
|
|
if dir == "观望":
|
|
print("\n建议: 今天不交易")
|
|
return
|
|
|
|
# 2. 持仓量最大的主力合约
|
|
conn = sqlite3.connect(DB_PATH)
|
|
main_row = conn.execute("""
|
|
SELECT d.ts_code, d.open, d.close, d.high, d.low, d.oi
|
|
FROM daily d
|
|
JOIN contracts c ON d.ts_code = c.ts_code
|
|
WHERE d.trade_date = ? AND c.delist_date > ? AND d.oi > 0
|
|
ORDER BY d.oi DESC LIMIT 1
|
|
""", (today, today)).fetchone()
|
|
conn.close()
|
|
|
|
if main_row:
|
|
ts, open_p, close_p, high, low, oi = main_row
|
|
print(f"\n主力合约: {ts}")
|
|
print(f"昨收: {close_p} 持仓: {int(oi):,}")
|
|
else:
|
|
print("\n注意: 今日行情数据尚未拉取,请先运行 update.py")
|
|
print("或使用历史近似的合约数据")
|
|
|
|
# 3. 交易提醒
|
|
print(f"\n{'='*40}")
|
|
print(f"今日计划: {dir}")
|
|
print(f" 开盘后确认方向后入场")
|
|
print(f" 止损: 5跳")
|
|
print(f" 收盘前5分钟平仓")
|
|
print(f"{'='*40}")
|
|
print(f"\n风控提醒:")
|
|
print(f" - 单笔止损严格执行 5 跳")
|
|
print(f" - 连续亏损 3 天暂停交易")
|
|
print(f" - 累计盈利达标后买入期权做保护")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|