VeighNa量化社区
你的开源社区量化交易平台
winsoning's Avatar
Member
离线
9 帖子
声望: 1

熟悉期货市场各种单边套利策咯研发,擅长数据分析,技术指标结合深度学习模型。开发技术熟练掌握c++,python,c#,深度学习框架熟悉tensorflow。可以代开发各种技术指标策略(vnpy)+ 神经网络模型,目前只接受远程工作,有意168580264@qq.com。

vnpy用户群体已经很庞大了,希望开通vnpy招聘求职板块,方便招聘和求职。

tick 级别回测,这个值我下单后,值不会变,为了便于还原此bug,我再 on_tick里键入这个逻辑,结果下了好多单,基本上判断pos废了
if self.pos == 0:,
self.buy(tick.ask_price_1, 1)
elif self > 0:
self.sell(tick.bid_price_1, 1)

from vnpy.app.cta_strategy import (
CtaTemplate,
StopOrder,
TickData,
BarData,
TradeData,
OrderData,
BarGenerator,
ArrayManager
)

class Demo02(CtaTemplate):

author = "" 
止盈点 = 3
止损点 = 3

parameters = ["止盈点", "止损点"]

variables = []

# 持仓成本价
trade_price = 0
# 计划止盈平仓价格
plan_win_price = 0
# 计划止损平仓价格
plan_lost_price = 0

def __init__(self,cta_engine, strategy_name, vt_symbol, setting):

    super().__init__(cta_engine, strategy_name, vt_symbol, setting)

    self.bg = BarGenerator(self.on_bar)

    self.am = ArrayManager()

def on_init(self):

    self.load_tick(1)

def on_start(self):

    print("策略开始")

def on_stop(self):

    print("策略结束")

def on_tick(self, tick: TickData):
    if self.pos == 0:
        if tick.datetime.hour > 14 and tick.datetime.minute > 40:
            return
        # 如果卖1价为整数压力位,则用xxx9价格建仓做空
        if (tick.ask_price_1%10 == 0) and (tick.ask_price_1-tick.bid_price_1)==1:

            self.short(tick.bid_price_1, 1)

            self.plan_win_price = tick.bid_price_1 - self.止盈点

            self.plan_lost_price = tick.bid_price_1 + self.止损点

            self.trade_price = tick.bid_price_1

    elif self.pos < 0:
        # 如果到收盘时间或者至止盈止损价,平仓空单
        if (tick.datetime.hour == 14 and tick.datetime.minute > 58) or (tick.ask_price_1 >= self.plan_lost_price) or (tick.ask_price_1 <= self.plan_win_price):
            self.cover(tick.ask_price_1, 1)

    self.put_event()

def on_bar(self, bar: BarData):

    self.put_event()

def on_trade(self, trade: TradeData):

    self.put_event()

def on_order(self, order: OrderData):

    self.put_event()

def on_stop_order(self, stop_order: StopOrder):

    self.put_event()





就这么简单的一个tick级别的策略,就是逢卖1价整数,做空,结果无论怎么测试,都是很大的盈利,数据乱的。

© 2015-2022 微信 18391752892
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】