请问如果是纯自己写的脚本策略(不是no_ui启动),如何开启风控?
请问如果是纯自己写的脚本策略(不是no_ui启动),如何开启风控?
请问有办法开启风控吗?
from vnpy_riskmanger import RiskManagerApp
engine = init_cli_engine(xxx)
engine.main_engine.add_app(RiskManagerApp)
谢谢,已运行上述代码,但是运行以后没有输出,请问在哪里可以设置风控的条件(如委托笔数,报单次数等)?
from vnpy_riskmanager import RiskManagerApp
engine = init_cli_trading([CtpGateway])
engine.main_engine.add_app(RiskManagerApp)
vnpy_riskmanager.engine的update_setting、save_setting
是这样写吗?报错了
from vnpy_riskmanager import RiskManagerApp
engine = init_cli_trading([CtpGateway])
engine.main_engine.add_app(RiskManagerApp)
from vnpy_riskmanager.engine import RiskEngine
setting = {}
setting["active"] = True
setting["order_flow_limit"] = 10
setting["order_flow_clear"] = 100
setting["order_size_limit"] = 10
setting["trade_limit"] = 100
setting["active_order_limit"] = 10
setting["order_cancel_limit"] = 10
engine.update_setting(setting)
报错内容:
PS C:\Users\wp61413_114147317492> & D:/veighna_studio/python.exe c:/Users/wp61413_114147317492/期权交易/终稿/Boxarbitrage.py
找不到数据服务驱动vnpy,使用默认的RQData数据服务
Traceback (most recent call last):
File "c:\Users\wp61413_114147317492\期权交易\终稿\Box_arbitrage.py", line 27, in <module>
engine.update_setting(setting)
AttributeError: 'ScriptEngine' object has no attribute 'update_setting'
这两个函数都是RiskEngine的函数
需要自己创建RishEngine类的对象吗?然后用创建的对象调用update_setting方法?请教对象的参数怎么写?
risk = RiskEngine(main_engine=??, event_engine=??)
您好,可以帮助回答吗?
可以用engine.main_engine.get_engine('RiskManager')访问到已经创建的riskengine
在命令行运行的时候应该先创建一个RiskManager的实例,比如
risk_manager = RiskEngine(main_engine, event_engine)
再调用
risk_manager.update_setting()
谢谢,请问是这样写吗?
'''
from vnpy_riskmanager import RiskManagerApp
from vnpy_ctp import CtpGateway
from vnpy_scripttrader import init_cli_trading
engine = init_cli_trading([CtpGateway])
engine.main_engine.add_app(RiskManagerApp)
a = engine.main_engine.get_engine('RiskManager')
setting = {}
setting["active"] = True
setting["order_flow_limit"] = 10
setting["order_flow_clear"] = 100
setting["order_size_limit"] = 10
setting["trade_limit"] = 100
setting["active_order_limit"] = 10
setting["order_cancel_limit"] = 10
a.update_setting(setting)
a.save_setting()
'''
可以帮助回答吗?这样写,是不是就可以启动风控了?
from vnpy_riskmanager import RiskManagerApp
from vnpy_ctp import CtpGateway
from vnpy_scripttrader import init_cli_trading
engine = init_cli_trading([CtpGateway])
engine.main_engine.add_app(RiskManagerApp)
a = engine.main_engine.get_engine('RiskManager')
setting = {}
setting["active"] = True
setting["order_flow_limit"] = 10
setting["order_flow_clear"] = 100
setting["order_size_limit"] = 10
setting["trade_limit"] = 100
setting["active_order_limit"] = 10
setting["order_cancel_limit"] = 10
a.update_setting(setting)
a.save_setting()
应该可以的,update_setting且active为True的时候应该会输出”交易风控功能启动“的日志
好的,非常感谢!