菲阿里四价策略

菲阿里四价策略

  菲阿里四价策略是一种比较简单的趋势型日内交易策略。昨天高点、昨天低点、昨日收盘价、今天开盘价,可并称为菲阿里四价。它由日本期货冠军菲阿里实盘采用的主要突破交易参照系。菲阿里四价是日内突破策略,所以每日收盘之前都需要进行平仓。该策略的上下轨以及用法如下所示:

  上轨=昨日高点;

  下轨=昨日低点;

  当价格突破上轨,买入开仓;

  当价格跌穿下轨,卖出开仓。

  

import talib
from rqalpha.api import *
import numpy
import pandas as pd
from pandas import Series
from rqalpha import run_func
from rqalpha.api import industry, update_universe, order_target_value
from rqalpha.utils import scheduler
import numpy as np
import pandas as pd
import logging
import warnings
from math import ceil

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from rqalpha.api import *
import scipy.optimize as sco
import seaborn as sns
import talib
from sklearn.metrics import mean_squared_error
from sklearn.model_selection import TimeSeriesSplit
from sklearn.preprocessing import StandardScaler


def init(context):
    context.feature_id = "IH88"
    subscribe(context.feature_id)
    context.per_qty = 10


def before_trading(context):
    pass


def handle_bar(context, bar_dict):
    if context.now.strftime('%H:%M') < '14:59':
        yest_high = history_bars(context.feature_id, 1, '1d', 'high')[-1]
        yest_low = history_bars(context.feature_id, 1, '1d', 'low')[-1]
        last_open = history_bars(context.feature_id, 1, '1m', 'open')
        last_close = history_bars(context.feature_id, 1, '1m', 'close')
        if last_open <= yest_high < last_close:
            buy_open(context.feature_id, context.per_qty)
        elif last_open >= yest_low > last_close:
            sell_open(context.feature_id, context.per_qty)
    else:
        buy_qty = context.portfolio.positions[context.feature_id].buy_quantity
        sell_qty = context.portfolio.positions[context.feature_id].sell_quantity
        if buy_qty > 0:
            sell_close(context.feature_id, buy_qty)
        if sell_qty > 0:
            buy_close(context.feature_id, sell_qty)

 

看起来还是不错的,原始裸策略,未做任何优化的,跑出这样的成绩还是意外的.

 

 

参考:https://www.ricequant.com/community/topic/2469/

https://uqer.io/v3/community/share/5a7d31c0efdee6010bb5b4ba

https://blog.csdn.net/u011331731/article/details/88326872

  • 5
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值