v0.1.7 done

This commit is contained in:
guoyz 2025-06-05 22:39:20 +08:00
parent 0e36cf82a7
commit cbf7f301f5
3 changed files with 59 additions and 15 deletions

15
AutoStartTurtle.py Normal file
View File

@ -0,0 +1,15 @@
import schedule
import time
import os
def run_script():
os.system("/opt/miniconda3/envs/turtle_trade/bin/python3 TurtleOnTime.py")
# 每天上午9点20运行
schedule.every().day.at("09:20").do(run_script)
# schedule.every().day.a
# t("10:00").do(run_script)
while True:
schedule.run_pending()
time.sleep(1)

View File

@ -21,11 +21,13 @@ import requests
'''
todo
1 运行过程框架调整支持多个turtle同时监测 done
2 增加运行状态写入yaml文件读取文件恢复状态 done
3 测试每分钟获取实时信息是否稳定 done
4 etf实时数据使用异步方式获取速度加快了 done
4 获取数据调用clash代理 done
v0.1.1 运行过程框架调整支持多个turtle同时监测 done
v0.1.2 增加运行状态写入yaml文件读取文件恢复状态 done
v0.1.3 测试每分钟获取实时信息是否稳定 done
v0.1.4 etf实时数据使用异步方式获取速度加快了 done
v0.1.5 获取数据调用clash代理 done
v0.1.6 把东方财富网写进规则代理 done
v0.1.7 每天定时启动 done
'''
@dataclass
@ -375,12 +377,14 @@ class TurtleTrading_OnTime(object):
"R2-3|香港-NF|HKT家宽",
"R2-5|香港-NF|HKT家宽",
"R3-1|香港-NF|BGP静态",
"R4-1|台湾-NF|家宽|原生",
"R5-1|日本-NF|GMO|原生IP",
"R5-4|日本-NF|IIJ|精品",
"R6-1|美国-NF|BGP",
"R9-1|狮城-NF|FDC",
"D1-1直连|香港-NF",
"D1-2直连|香港-NF",
"D1-3直连|香港-NF"
]
def load_previous_state(self):
"""Load previous state from YAML file if exists"""
@ -778,6 +782,12 @@ class TurtleTrading_OnTime(object):
# 获取当前时间
now = datetime.now().time()
# 优先判断是否收盘
is_stop_time = (now.hour >= 15 and now.minute > 5) #收盘时间
# is_stop_time = (now.hour >= 18 and now.minute > 32) #收盘时间
if is_stop_time:
break
# 判断当前时间是否在交易时段内9:30-11:30 或 13:00-15:00
is_trading_time = (
(now.hour == 9 and now.minute >= 30) or
@ -795,10 +805,7 @@ class TurtleTrading_OnTime(object):
time.sleep(60)
continue
is_stop_time = (now.hour >= 15 and now.minute > 0) #收盘时间
# is_stop_time = (now.hour >= 18 and now.minute > 32) #收盘时间
if is_stop_time:
break
# 获取股票和ETF数据
self.monitor_all_turtles()
@ -850,8 +857,8 @@ class TurtleTrading_OnTime(object):
if now.hour == 9 and now.minute == 30 and turtle.PriceNow > turtle.prev_heigh:
turtle.is_gap_up = True
fake_price = 1.492
turtle.PriceNow = fake_price
# fake_price = 1.492
# turtle.PriceNow = fake_price
# 判断当前仓位状态并执行相应操作
if turtle.TrigerTime == 0:
if turtle.system1EnterNormal(
@ -934,8 +941,8 @@ class TurtleTrading_OnTime(object):
if __name__ == '__main__':
user_email = "guoyize2209@163.com"
nsdk = TurtleTrading('513870', "etf", 0.0025, 100000, 200000)
cjdl = TurtleTrading('600900', "stock", 0.0025, 100000, 200000)
nsdk = TurtleTrading('513870', "etf", 0.0025, 50000, 200000)
cjdl = TurtleTrading('600900', "stock", 0.0025, 50000, 200000)
# t.get_ready(100)
a = TurtleTrading_OnTime([nsdk, cjdl], user_email)

22
state/2025-06-04.yaml Normal file
View File

@ -0,0 +1,22 @@
main_state:
email_events: {}
turtles:
- BreakOutLog: []
BuyStates: []
Capital: 50000
TradeCode: '513870'
TrigerTime: 0
cash: 200000
riskcoe: 0.0025
tradeslog: []
type: etf
- BreakOutLog: []
BuyStates: []
Capital: 50000
TradeCode: '600900'
TrigerTime: 0
cash: 200000
riskcoe: 0.0025
tradeslog: []
type: stock
user_email: guoyize2209@163.com