实盘,记录的行情有问题。ag白天开盘之后记录的行情不完整,而且时间现实的是第二天的夜盘。。。。rb是没有白天的数据,请问该怎么处理。。。。。
青青子荆 wrote:
请问第二张图是改动了代码得到的吗?因为run.py是no_ui下运行的。
可以把非交易段时间的Tick过滤掉试试看能否成功。
你好,没有改动代码。我是一边运行run.py,一边登陆图形界面的vnpy。
我运行了run.py,没有非交易时间的数据,行情录制的结束时间到夜里23:58就停止了,第二天虽然自动连接了,但是没有自动录制行情。。。
run.py也显示正常运行的。
这是实盘提示登陆的时间。。。。。然后我看录制行情,有色贵金属的行情到夜里23:58就自动停止了,第二天数据也没有录制。。。。。请问是哪里出了问题
这是run.py里面的时间
这个是.ipynb文件,打开有运行选项,是我软件的设置有问题吗,这块是小白,不太懂。。。。
这个是data_clean.py文件,打开之后没有运行选项。。。。
青青子荆 wrote:
运行时直接点击run
你好,请问这个使用jupyternotebook打开的吗,我的打开.py文件没有运行选项,打开.ipynb文件有运行选项。。。。。不知道哪里出了问题。。
脏数据也没有清除,最后也没有输出,好像这个脚本没有运行一样。。。。尴尬,
请问是哪边出了问题了嘛。
我按照微信公众号上那个教程试着运行,但是有时候database.db没变化,有时候多出来的和教程里不一样。。。。是什么原因呢
import multiprocessing
import sys
from time import sleep
from datetime import datetime, time
from logging import INFO
from vnpy.event import EventEngine
from vnpy.trader.setting import SETTINGS
from vnpy.trader.engine import MainEngine
from vnpy.gateway.ctp import CtpGateway
from vnpy.app.cta_strategy import CtaStrategyApp
from vnpy.app.cta_strategy.base import EVENT_CTA_LOG
SETTINGS["log.active"] = True
SETTINGS["log.level"] = INFO
SETTINGS["log.console"] = True
ctp_setting = {
"用户名": "**",
"密码": "**",
"经纪商代码": "9999",
"交易服务器": "180.168.146.187:10101",
"行情服务器": "180.168.146.187:10111",
"产品名称": "simnow_client_test",
"授权编码": "0000000000000000",
"产品信息": ""
}
DAY_START = time(8, 45)
DAY_END = time(15, 0)
NIGHT_START = time(20, 45)
NIGHT_END = time(2, 45)
def check_trading_period():
""""""
current_time = datetime.now().time()
trading = False
if (
(current_time >= DAY_START and current_time <= DAY_END)
or (current_time >= NIGHT_START)
or (current_time <= NIGHT_END)
):
trading = True
return trading
def run_child():
"""
Running in the child process.
"""
SETTINGS["log.file"] = True
event_engine = EventEngine()
main_engine = MainEngine(event_engine)
main_engine.add_gateway(CtpGateway)
cta_engine = main_engine.add_app(CtaStrategyApp)
main_engine.write_log("主引擎创建成功")
log_engine = main_engine.get_engine("log")
event_engine.register(EVENT_CTA_LOG, log_engine.process_log_event)
main_engine.write_log("注册日志事件监听")
main_engine.connect(ctp_setting, "CTP")
main_engine.write_log("连接CTP接口")
sleep(10)
cta_engine.init_engine()
main_engine.write_log("CTA策略初始化完成")
cta_engine.init_all_strategies()
sleep(60) # Leave enough time to complete strategy initialization
main_engine.write_log("CTA策略全部初始化")
cta_engine.start_all_strategies()
main_engine.write_log("CTA策略全部启动")
while True:
sleep(10)
trading = check_trading_period()
if not trading:
print("关闭子进程")
main_engine.close()
sys.exit(0)
def run_parent():
"""
Running in the parent process.
"""
print("启动CTA策略守护父进程")
child_process = None
while True:
trading = check_trading_period()
# Start child process in trading period
if trading and child_process is None:
print("启动子进程")
child_process = multiprocessing.Process(target=run_child)
child_process.start()
print("子进程启动成功")
# 非记录时间则退出子进程
if not trading and child_process is not None:
if not child_process.is_alive():
child_process = None
print("子进程关闭成功")
sleep(5)
if name == "main":
run_parent()
你好,我搜了其他的帖子,学着用run.py ,下载了之后用vscode打开却是这样的,请问是什么问题。。。。。
比如贵金属有色这些品种收盘比较迟,不想人工关闭行情记录,有没有什么简单的办法让行情记录在特定的时间自动开启和关闭吗?(一直开启会有无效的数据推送,所以想在特定的时间开启关闭)
正常的交易情况都是如果有仓位,先平仓,然后再开仓。但是这个k线图表上却显示开完多单,又开多单。。。。实际成交记录却不是。