止盈止损单如何传递参数 #55
-
在下单时想直接设置止盈止损价格,如何传递参数? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
WonderTrader的下单接口的逻辑,是参考MultiCharts来实现的,以CTA为例,一共提供了5个下单接口 def stra_set_position(self, stdCode:str, qty:float, usertag:str = "", limitprice:float = 0.0, stopprice:float = 0.0):
'''
设置仓位
@stdCode 合约/股票代码
@qty 目标仓位,正为多仓,负为空仓
@return 设置结果TRUE/FALSE
'''
self.__wrapper__.cta_set_position(self.__id__, stdCode, qty, usertag, limitprice, stopprice)
def stra_enter_long(self, stdCode:str, qty:float, usertag:str = "", limitprice:float = 0.0, stopprice:float = 0.0):
'''
多仓进场,如果有空仓,则平空再开多
@stdCode 品种代码
@qty 数量
@limitprice 限价,默认为0
@stopprice 止价,默认为0
'''
self.__wrapper__.cta_enter_long(self.__id__, stdCode, qty, usertag, limitprice, stopprice)
def stra_exit_long(self, stdCode:str, qty:float, usertag:str = "", limitprice:float = 0.0, stopprice:float = 0.0):
'''
多仓出场,如果剩余多仓不够,则全部平掉即可
@stdCode 品种代码
@qty 数量
@limitprice 限价,默认为0
@stopprice 止价,默认为0
'''
self.__wrapper__.cta_exit_long(self.__id__, stdCode, qty, usertag, limitprice, stopprice)
def stra_enter_short(self, stdCode:str, qty:float, usertag:str = "", limitprice:float = 0.0, stopprice:float = 0.0):
'''
空仓进场,如果有多仓,则平多再开空
@stdCode 品种代码
@qty 数量
@limitprice 限价,默认为0
@stopprice 止价,默认为0
'''
self.__wrapper__.cta_enter_short(self.__id__, stdCode, qty, usertag, limitprice, stopprice)
def stra_exit_short(self, stdCode:str, qty:float, usertag:str = "", limitprice:float = 0.0, stopprice:float = 0.0):
'''
空仓出场,如果剩余空仓不够,则全部平掉即可
@stdCode 品种代码
@qty 数量
@limitprice 限价,默认为0
@stopprice 止价,默认为0
'''
self.__wrapper__.cta_exit_short(self.__id__, stdCode, qty, usertag, limitprice, stopprice) 每个接口都有limitprice和stopprice两个参数
|
Beta Was this translation helpful? Give feedback.
-
会不会加一些百分比的api会更好?比如涨10%止盈,跌20%止损 |
Beta Was this translation helpful? Give feedback.
WonderTrader的下单接口的逻辑,是参考MultiCharts来实现的,以CTA为例,一共提供了5个下单接口