博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
菲阿里四价策略
阅读量:4294 次
发布时间:2019-05-27

本文共 1881 字,大约阅读时间需要 6 分钟。

菲阿里四价策略

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

  上轨=昨日高点;

  下轨=昨日低点;

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

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

  

import talibfrom rqalpha.api import *import numpyimport pandas as pdfrom pandas import Seriesfrom rqalpha import run_funcfrom rqalpha.api import industry, update_universe, order_target_valuefrom rqalpha.utils import schedulerimport numpy as npimport pandas as pdimport loggingimport warningsfrom math import ceilimport numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom rqalpha.api import *import scipy.optimize as scoimport seaborn as snsimport talibfrom sklearn.metrics import mean_squared_errorfrom sklearn.model_selection import TimeSeriesSplitfrom sklearn.preprocessing import StandardScalerdef init(context):    context.feature_id = "IH88"    subscribe(context.feature_id)    context.per_qty = 10def before_trading(context):    passdef 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)

 

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

 

 

参考:

转载地址:http://bhyws.baihongyu.com/

你可能感兴趣的文章
理解socket与tcp/ip编程相关函数
查看>>
BootLoader理解
查看>>
解决VS2010链接错误:LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
查看>>
TCP/IP协议的连接与释放的三次握手过程及Socket套接字
查看>>
Socket建立网络连接方法
查看>>
TCP和UDP的区别
查看>>
Socket编程,实现通信
查看>>
C++虚函数的定义与意义
查看>>
互斥量、临界区、信号量、事件标志组和消息邮箱
查看>>
ucos2 事件 任务的通讯和同步 信号量 互斥量 消息邮箱 消息队列
查看>>
RT-thread任务调度算法
查看>>
Keil调试STM32中解析main开始前的工作
查看>>
extern "C"解释
查看>>
C语言中的const、extern及结构体、联合体的定义
查看>>
RT_Thead 中断
查看>>
cotex m4 汇编指令集
查看>>
功率与dbm关系
查看>>
CC1101调试入门
查看>>
SPI时序分析
查看>>
MSP430FR5969内存分配的问题
查看>>