RqAlpha-Learning-12-1



In [1]:
import numpy as np
import pandas as pd
pd.set_option('display.max_rows', 10)
pd.set_option('display.max_columns', 1000)
import datetime
import matplotlib.pylab as plt
%matplotlib inline
import seaborn as sns
sns.set_style('whitegrid')
import time
import os
import copy

定义获取数据函数


In [2]:
def fix_data(path):
    tmp = pd.read_csv(path, encoding="gbk", engine='python')
    tmp.rename(columns={'Unnamed: 0':'trading_time'}, inplace=True)
    tmp['trading_point'] = pd.to_datetime(tmp.trading_time)
    del tmp['trading_time']
    tmp.set_index(tmp.trading_point, inplace=True)
    return tmp

def High_2_Low(tmp, freq):
    """处理从RiceQuant下载的分钟线数据,
    从分钟线数据合成低频数据
    2017-08-11    
    """
    # 分别处理bar数据
    tmp_open = tmp['open'].resample(freq).ohlc()
    tmp_open = tmp_open['open'].dropna()

    tmp_high = tmp['high'].resample(freq).ohlc()
    tmp_high = tmp_high['high'].dropna()

    tmp_low = tmp['low'].resample(freq).ohlc()
    tmp_low = tmp_low['low'].dropna()

    tmp_close = tmp['close'].resample(freq).ohlc()
    tmp_close = tmp_close['close'].dropna()

    tmp_price = pd.concat([tmp_open, tmp_high, tmp_low, tmp_close], axis=1)
    
    # 处理成交量
    tmp_volume = tmp['volume'].resample(freq).sum()
    tmp_volume.dropna(inplace=True)
    
    return pd.concat([tmp_price, tmp_volume], axis=1)

计算技术分析指标


In [3]:
import talib 

def get_factors(index, 
                Open, 
                Close, 
                High, 
                Low, 
                Volume,
                rolling = 26,
                drop=False, 
                normalization=True):
    
    tmp = pd.DataFrame()
    tmp['tradeTime'] = index
    
    #累积/派发线(Accumulation / Distribution Line,该指标将每日的成交量通过价格加权累计,
    #用以计算成交量的动量。属于趋势型因子
    tmp['AD'] = talib.AD(High, Low, Close, Volume)

    # 佳庆指标(Chaikin Oscillator),该指标基于AD曲线的指数移动均线而计算得到。属于趋势型因子
    tmp['ADOSC'] = talib.ADOSC(High, Low, Close, Volume, fastperiod=3, slowperiod=10)

    # 平均动向指数,DMI因子的构成部分。属于趋势型因子
    tmp['ADX'] = talib.ADX(High, Low, Close,timeperiod=14)

    # 相对平均动向指数,DMI因子的构成部分。属于趋势型因子
    tmp['ADXR'] = talib.ADXR(High, Low, Close,timeperiod=14)

    # 绝对价格振荡指数
    tmp['APO'] = talib.APO(Close, fastperiod=12, slowperiod=26)

    # Aroon通过计算自价格达到近期最高值和最低值以来所经过的期间数,帮助投资者预测证券价格从趋势到区域区域或反转的变化,
    #Aroon指标分为Aroon、AroonUp和AroonDown3个具体指标。属于趋势型因子
    tmp['AROONDown'], tmp['AROONUp'] = talib.AROON(High, Low,timeperiod=14)
    tmp['AROONOSC'] = talib.AROONOSC(High, Low,timeperiod=14)

    # 均幅指标(Average TRUE Ranger),取一定时间周期内的股价波动幅度的移动平均值,
    #是显示市场变化率的指标,主要用于研判买卖时机。属于超买超卖型因子。
    tmp['ATR14']= talib.ATR(High, Low, Close, timeperiod=14)
    tmp['ATR6']= talib.ATR(High, Low, Close, timeperiod=6)

    # 布林带
    tmp['Boll_Up'],tmp['Boll_Mid'],tmp['Boll_Down']= talib.BBANDS(Close, timeperiod=20, nbdevup=2, nbdevdn=2, matype=0)

    # 均势指标
    tmp['BOP'] = talib.BOP(Open, High, Low, Close)

    #5日顺势指标(Commodity Channel Index),专门测量股价是否已超出常态分布范围。属于超买超卖型因子。
    tmp['CCI5'] = talib.CCI(High, Low, Close, timeperiod=5)
    tmp['CCI10'] = talib.CCI(High, Low, Close, timeperiod=10)
    tmp['CCI20'] = talib.CCI(High, Low, Close, timeperiod=20)
    tmp['CCI88'] = talib.CCI(High, Low, Close, timeperiod=88)

    # 钱德动量摆动指标(Chande Momentum Osciliator),与其他动量指标摆动指标如相对强弱指标(RSI)和随机指标(KDJ)不同,
    # 钱德动量指标在计算公式的分子中采用上涨日和下跌日的数据。属于超买超卖型因子
    tmp['CMO_Close'] = talib.CMO(Close,timeperiod=14)
    tmp['CMO_Open'] = talib.CMO(Close,timeperiod=14)

    # DEMA双指数移动平均线
    tmp['DEMA6'] = talib.DEMA(Close, timeperiod=6)
    tmp['DEMA12'] = talib.DEMA(Close, timeperiod=12)
    tmp['DEMA26'] = talib.DEMA(Close, timeperiod=26)

    # DX 动向指数
    tmp['DX'] = talib.DX(High, Low, Close,timeperiod=14)

    # EMA 指数移动平均线
    tmp['EMA6'] = talib.EMA(Close, timeperiod=6)
    tmp['EMA12'] = talib.EMA(Close, timeperiod=12)
    tmp['EMA26'] = talib.EMA(Close, timeperiod=26)

    # KAMA 适应性移动平均线
    tmp['KAMA'] = talib.KAMA(Close, timeperiod=30)

    # MACD
    tmp['MACD_DIF'],tmp['MACD_DEA'],tmp['MACD_bar'] = talib.MACD(Close, fastperiod=12, slowperiod=24, signalperiod=9)

    # 中位数价格 不知道是什么意思
    tmp['MEDPRICE'] = talib.MEDPRICE(High, Low)

    # 负向指标 负向运动
    tmp['MiNUS_DI'] = talib.MINUS_DI(High, Low, Close,timeperiod=14)
    tmp['MiNUS_DM'] = talib.MINUS_DM(High, Low,timeperiod=14)

    # 动量指标(Momentom Index),动量指数以分析股价波动的速度为目的,研究股价在波动过程中各种加速,
    #减速,惯性作用以及股价由静到动或由动转静的现象。属于趋势型因子
    tmp['MOM'] = talib.MOM(Close, timeperiod=10)

    # 归一化平均值范围
    tmp['NATR'] = talib.NATR(High, Low, Close,timeperiod=14)

    # OBV 	能量潮指标(On Balance Volume,OBV),以股市的成交量变化来衡量股市的推动力,
    #从而研判股价的走势。属于成交量型因子
    tmp['OBV'] = talib.OBV(Close, Volume)

    # PLUS_DI 更向指示器
    tmp['PLUS_DI'] = talib.PLUS_DI(High, Low, Close,timeperiod=14)
    tmp['PLUS_DM'] = talib.PLUS_DM(High, Low, timeperiod=14)

    # PPO 价格振荡百分比
    tmp['PPO'] = talib.PPO(Close, fastperiod=6, slowperiod= 26, matype=0)

    # ROC 6日变动速率(Price Rate of Change),以当日的收盘价和N天前的收盘价比较,
    #通过计算股价某一段时间内收盘价变动的比例,应用价格的移动比较来测量价位动量。属于超买超卖型因子。
    tmp['ROC6'] = talib.ROC(Close, timeperiod=6)
    tmp['ROC20'] = talib.ROC(Close, timeperiod=20)
    #12日量变动速率指标(Volume Rate of Change),以今天的成交量和N天前的成交量比较,
    #通过计算某一段时间内成交量变动的幅度,应用成交量的移动比较来测量成交量运动趋向,
    #达到事先探测成交量供需的强弱,进而分析成交量的发展趋势及其将来是否有转势的意愿,
    #属于成交量的反趋向指标。属于成交量型因子
    tmp['VROC6'] = talib.ROC(Volume, timeperiod=6)
    tmp['VROC20'] = talib.ROC(Volume, timeperiod=20)

    # ROC 6日变动速率(Price Rate of Change),以当日的收盘价和N天前的收盘价比较,
    #通过计算股价某一段时间内收盘价变动的比例,应用价格的移动比较来测量价位动量。属于超买超卖型因子。
    tmp['ROCP6'] = talib.ROCP(Close, timeperiod=6)
    tmp['ROCP20'] = talib.ROCP(Close, timeperiod=20)
    #12日量变动速率指标(Volume Rate of Change),以今天的成交量和N天前的成交量比较,
    #通过计算某一段时间内成交量变动的幅度,应用成交量的移动比较来测量成交量运动趋向,
    #达到事先探测成交量供需的强弱,进而分析成交量的发展趋势及其将来是否有转势的意愿,
    #属于成交量的反趋向指标。属于成交量型因子
    tmp['VROCP6'] = talib.ROCP(Volume, timeperiod=6)
    tmp['VROCP20'] = talib.ROCP(Volume, timeperiod=20)

    # RSI
    tmp['RSI'] = talib.RSI(Close, timeperiod=14)

    # SAR 抛物线转向
    tmp['SAR'] = talib.SAR(High, Low, acceleration=0.02, maximum=0.2)

    # TEMA
    tmp['TEMA6'] = talib.TEMA(Close, timeperiod=6)
    tmp['TEMA12'] = talib.TEMA(Close, timeperiod=12)
    tmp['TEMA26'] = talib.TEMA(Close, timeperiod=26)

    # TRANGE 真实范围
    tmp['TRANGE'] = talib.TRANGE(High, Low, Close)

    # TYPPRICE 典型价格
    tmp['TYPPRICE'] = talib.TYPPRICE(High, Low, Close)

    # TSF 时间序列预测
    tmp['TSF'] = talib.TSF(Close, timeperiod=14)

    # ULTOSC 极限振子
    tmp['ULTOSC'] = talib.ULTOSC(High, Low, Close, timeperiod1=7, timeperiod2=14, timeperiod3=28)

    # 威廉指标
    tmp['WILLR'] = talib.WILLR(High, Low, Close, timeperiod=14)
    
    # 标准化
    if normalization:
        factors_list = tmp.columns.tolist()[1:]

        if rolling >= 26:
            for i in factors_list:
                tmp[i] = (tmp[i] - tmp[i].rolling(window=rolling, center=False).mean())\
                /tmp[i].rolling(window=rolling, center=False).std()
        elif rolling < 26 & rolling > 0:
            print ('Recommended rolling range greater than 26')
        elif rolling <=0:
            for i in factors_list:
                tmp[i] = (tmp[i] - tmp[i].mean())/tmp[i].std()
            
    if drop:
        tmp.dropna(inplace=True)
        
    tmp.set_index('tradeTime', inplace=True)
    
    return tmp

处理数据


In [4]:
tmp = fix_data('期货测试数据/白银88.csv')

# targets 1d 数据合成
tmp_1d = High_2_Low(tmp, '1d')
rolling = 88
targets = tmp_1d
targets['returns'] =  targets['close'].shift(-2) / targets['close'] - 1.0
targets['upper_boundary']= targets.returns.rolling(rolling).mean() + 0.5 * targets.returns.rolling(rolling).std()
targets['lower_boundary']= targets.returns.rolling(rolling).mean() - 0.5 * targets.returns.rolling(rolling).std()
targets.dropna(inplace=True)
targets['labels'] = 1
targets.loc[targets['returns']>=targets['upper_boundary'], 'labels'] = 2
targets.loc[targets['returns']<=targets['lower_boundary'], 'labels'] = 0

# factors 1d 数据合成
tmp_1d = High_2_Low(tmp, '1d')
Index = tmp_1d.index
High = tmp_1d.high.values
Low = tmp_1d.low.values
Close = tmp_1d.close.values
Open = tmp_1d.open.values
Volume = tmp_1d.volume.values
factors = get_factors(Index, Open, Close, High, Low, Volume, rolling = 26, drop=True)

factors = factors.loc[:targets.index[-1]]

tmp_factors_1 = factors.iloc[:12]
targets = targets.loc[tmp_factors_1.index[-1]:]

gather_list = np.arange(factors.shape[0])[11:]

转换数据


In [5]:
inputs = np.array(factors).reshape(-1, 1, factors.shape[1])

def dense_to_one_hot(labels_dense):
    """标签 转换one hot 编码
    输入labels_dense 必须为非负数
    2016-11-21
    """
    num_classes = len(np.unique(labels_dense)) # np.unique 去掉重复函数
    raws_labels = labels_dense.shape[0]
    index_offset = np.arange(raws_labels) * num_classes
    labels_one_hot = np.zeros((raws_labels, num_classes))
    labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
    return labels_one_hot  

targets = dense_to_one_hot(targets['labels'])
targets = np.expand_dims(targets, axis=1)

构建RNN模型


In [6]:
import tensorflow as tf
from FixPonderDNCore import DNCore_L3
from FixPonderDNCore import ResidualACTCore as ACTCore

In [8]:
class Classifier_PonderDNC_BasicLSTM_L3(object):
    
    def __init__(self, 
                 inputs, 
                 targets,
                 gather_list=None,
                 mini_batch_size=1, 
                 hidden_size=10, 
                 memory_size=10, 
                 threshold=0.99,
                 pondering_coefficient = 1e-2,
                 num_reads=3,
                 num_writes=1,
                 learning_rate = 1e-4,
                 optimizer_epsilon = 1e-10,
                 max_gard_norm = 50):
        
        self._tmp_inputs = inputs
        self._tmp_targets = targets
        self._in_length = None
        self._in_width = inputs.shape[2]
        self._out_length = None
        self._out_width = targets.shape[2]
        self._mini_batch_size = mini_batch_size
        self._batch_size = inputs.shape[1]
        
        # 声明计算会话
        self._sess = tf.InteractiveSession()
        
        self._inputs = tf.placeholder(dtype=tf.float32, 
                                      shape=[self._in_length, self._batch_size, self._in_width], 
                                      name='inputs')
        self._targets = tf.placeholder(dtype=tf.float32, 
                                       shape=[self._out_length, self._batch_size, self._out_width],
                                       name='targets')
        
        act_core = DNCore_L3( hidden_size=hidden_size, 
                              memory_size=memory_size, 
                              word_size=self._in_width, 
                              num_read_heads=num_reads, 
                              num_write_heads=num_writes)        
        self._InferenceCell = ACTCore(core=act_core, 
                                              output_size=self._out_width, 
                                              threshold=threshold, 
                                              get_state_for_halting=self._get_hidden_state)
        
        self._initial_state = self._InferenceCell.initial_state(self._batch_size)
        
        tmp, act_final_cumul_state = \
        tf.nn.dynamic_rnn(cell=self._InferenceCell, 
                          inputs=self._inputs, 
                          initial_state=self._initial_state, 
                          time_major=True)
        act_output, (act_final_iteration, act_final_remainder) = tmp
        
        # 测试
        self._final_iteration = tf.reduce_mean(act_final_iteration)
        
        self._act_output = act_output
        if gather_list is not None:
            out_sequences = tf.gather(act_output, gather_list)
        else:
            out_sequences = act_core
        
        # 设置损失函数
        pondering_cost = (act_final_iteration + act_final_remainder) * pondering_coefficient
        rnn_cost = tf.nn.softmax_cross_entropy_with_logits(
            labels=self._targets, logits=out_sequences)
        self._pondering_cost = tf.reduce_mean(pondering_cost)
        self._rnn_cost = tf.reduce_mean(rnn_cost)
        self._cost = self._pondering_cost + self._rnn_cost        
        self._pred = tf.nn.softmax(out_sequences, dim=2)
        correct_pred = tf.equal(tf.argmax(self._pred,2), tf.argmax(self._targets,2))
        self._accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
        
        # 设置优化器
        # Set up optimizer with global norm clipping.
        trainable_variables = tf.trainable_variables()
        grads, _ = tf.clip_by_global_norm(
            tf.gradients(self._cost, trainable_variables), max_gard_norm)
        global_step = tf.get_variable(
            name="global_step",
            shape=[],
            dtype=tf.int64,
            initializer=tf.zeros_initializer(),
            trainable=False,
            collections=[tf.GraphKeys.GLOBAL_VARIABLES, tf.GraphKeys.GLOBAL_STEP])
        
        optimizer = tf.train.RMSPropOptimizer(
            learning_rate=learning_rate, epsilon=optimizer_epsilon)
        self._train_step = optimizer.apply_gradients(
            zip(grads, trainable_variables), global_step=global_step)  
        
        
    # 待处理函数
    def _get_hidden_state(self, state):
        controller_state, access_state, read_vectors = state
        layer_1, layer_2, layer_3 = controller_state
        L1_next_state, L1_next_cell = layer_1
        L2_next_state, L2_next_cell = layer_2
        L3_next_state, L3_next_cell = layer_3
        return tf.concat([L1_next_state, L2_next_state, L3_next_state], axis=-1)
    
    
    def fit(self, 
            training_iters =1e2,             
            display_step = 5, 
            save_path = None,
            restore_path = None):

        self._sess.run(tf.global_variables_initializer())        
        # 保存和恢复
        self._variables_saver = tf.train.Saver()
        if restore_path is not None:
            self._variables_saver.restore(self._sess, restore_path)
        
        if self._batch_size == self._mini_batch_size:        
            for scope in range(np.int(training_iters)):
                _, loss, acc, tp1, tp2, tp3 = \
                self._sess.run([self._train_step, 
                                self._cost, 
                                self._accuracy, 
                                self._pondering_cost, 
                                self._rnn_cost, 
                                self._final_iteration],
                               feed_dict = {self._inputs:self._tmp_inputs, self._targets:self._tmp_targets})
                # 显示优化进程
                if scope % display_step == 0:
                    print (scope, 
                           '  loss--', loss, 
                           '  acc--', acc, 
                           '  pondering_cost--',tp1, 
                           '  rnn_cost--', tp2, 
                           '  final_iteration', tp3)
                    # 保存模型可训练变量
                    if save_path is not None:
                        self._variables_saver.save(self._sess, save_path) 
                    
            print ("Optimization Finished!") 
        else:
            print ('未完待续')
        
            
    def close(self):
        self._sess.close()
        print ('结束进程,清理tensorflow内存/显存占用')
        
        
    def pred(self, inputs, gather_list=None, restore_path=None):
        if restore_path is not None:
            self._sess.run(tf.global_variables_initializer())        
            self._variables_saver = tf.train.Saver()
            self._variables_saver.restore(self._sess, restore_path)
            
        output_pred = self._act_output
        if gather_list is not None:
            output_pred = tf.gather(output_pred, gather_list)
        probability = tf.nn.softmax(output_pred)
        classification = tf.argmax(probability, axis=-1)
        
        return self._sess.run([probability, classification],feed_dict = {self._inputs:inputs})

训练模型


In [8]:
op1 = Classifier_PonderDNC_BasicLSTM_L3(
    inputs= inputs, 
    targets= targets, 
    gather_list= gather_list, 
    hidden_size= 50, 
    memory_size= 50, 
    pondering_coefficient= 1e-2, 
    learning_rate= 1e-2)


WARNING:tensorflow:The `skip_connections` argument will be deprecated. Please use snt.SkipConnectionCore instead.
E:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py:93: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "

In [9]:
op1.fit(training_iters = 100,
        display_step = 10,
        save_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt")


0   loss-- 1.1359   acc-- 0.291498   pondering_cost-- 0.0274369   rnn_cost-- 1.10846   final_iteration 2.44415
10   loss-- 1.09858   acc-- 0.462888   pondering_cost-- 0.0273241   rnn_cost-- 1.07125   final_iteration 2.42952
20   loss-- 1.0635   acc-- 0.520918   pondering_cost-- 0.0272065   rnn_cost-- 1.0363   final_iteration 2.41489
30   loss-- 1.03904   acc-- 0.526316   pondering_cost-- 0.0270681   rnn_cost-- 1.01197   final_iteration 2.39495
40   loss-- 1.02417   acc-- 0.527665   pondering_cost-- 0.0270631   rnn_cost-- 0.997111   final_iteration 2.39761
50   loss-- 1.00878   acc-- 0.527665   pondering_cost-- 0.0270222   rnn_cost-- 0.981757   final_iteration 2.39096
60   loss-- 0.986728   acc-- 0.531714   pondering_cost-- 0.0269659   rnn_cost-- 0.959762   final_iteration 2.38165
70   loss-- 0.950577   acc-- 0.560054   pondering_cost-- 0.0270237   rnn_cost-- 0.923554   final_iteration 2.38165
80   loss-- 1.04791   acc-- 0.522267   pondering_cost-- 0.0289592   rnn_cost-- 1.01895   final_iteration 2.6516
90   loss-- 0.929772   acc-- 0.605938   pondering_cost-- 0.0276835   rnn_cost-- 0.902089   final_iteration 2.46676
Optimization Finished!

In [10]:
op1.close()


结束进程,清理tensorflow内存/显存占用

second


In [11]:
tf.reset_default_graph()
op2 = Classifier_PonderDNC_BasicLSTM_L3(
    inputs= inputs, 
    targets= targets, 
    gather_list= gather_list, 
    hidden_size= 50, 
    memory_size= 50, 
    pondering_coefficient= 1e-2, 
    learning_rate= 1e-3)

op2.fit(training_iters = 100,
        display_step = 10,
        save_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt",
        restore_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt")


WARNING:tensorflow:The `skip_connections` argument will be deprecated. Please use snt.SkipConnectionCore instead.
E:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py:93: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
INFO:tensorflow:Restoring parameters from /QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt
0   loss-- 0.924143   acc-- 0.585695   pondering_cost-- 0.0284473   rnn_cost-- 0.895696   final_iteration 2.55319
10   loss-- 0.85397   acc-- 0.647773   pondering_cost-- 0.0283574   rnn_cost-- 0.825613   final_iteration 2.54654
20   loss-- 0.829104   acc-- 0.65857   pondering_cost-- 0.0290101   rnn_cost-- 0.800094   final_iteration 2.62234
30   loss-- 0.79098   acc-- 0.684211   pondering_cost-- 0.03074   rnn_cost-- 0.76024   final_iteration 2.81383
40   loss-- 0.752021   acc-- 0.695007   pondering_cost-- 0.032658   rnn_cost-- 0.719363   final_iteration 3.0266
50   loss-- 0.689885   acc-- 0.740891   pondering_cost-- 0.0377466   rnn_cost-- 0.652138   final_iteration 3.56915
60   loss-- 0.675371   acc-- 0.731444   pondering_cost-- 0.0397278   rnn_cost-- 0.635643   final_iteration 3.78059
70   loss-- 0.575239   acc-- 0.802969   pondering_cost-- 0.049013   rnn_cost-- 0.526226   final_iteration 4.75399
80   loss-- 0.536282   acc-- 0.823212   pondering_cost-- 0.0613976   rnn_cost-- 0.474884   final_iteration 6.01463
90   loss-- 0.481901   acc-- 0.866397   pondering_cost-- 0.0915182   rnn_cost-- 0.390383   final_iteration 9.05851
Optimization Finished!

third


In [12]:
tf.reset_default_graph()
op3 = Classifier_PonderDNC_BasicLSTM_L3(
    inputs= inputs, 
    targets= targets, 
    gather_list= gather_list, 
    hidden_size= 50, 
    memory_size= 50, 
    pondering_coefficient= 1e-2, 
    learning_rate= 1e-3)

op3.fit(training_iters = 100,
        display_step = 10,
        save_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt",
        restore_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt")


WARNING:tensorflow:The `skip_connections` argument will be deprecated. Please use snt.SkipConnectionCore instead.
E:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py:93: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
INFO:tensorflow:Restoring parameters from /QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt
0   loss-- 0.462972   acc-- 0.854251   pondering_cost-- 0.065323   rnn_cost-- 0.39765   final_iteration 6.42021
10   loss-- 0.422676   acc-- 0.881242   pondering_cost-- 0.0903257   rnn_cost-- 0.33235   final_iteration 8.94415
20   loss-- 0.391257   acc-- 0.889339   pondering_cost-- 0.0937862   rnn_cost-- 0.297471   final_iteration 9.29122
30   loss-- 0.406005   acc-- 0.902834   pondering_cost-- 0.131223   rnn_cost-- 0.274781   final_iteration 13.0519
40   loss-- 0.369556   acc-- 0.908232   pondering_cost-- 0.101144   rnn_cost-- 0.268412   final_iteration 10.0306
50   loss-- 0.331032   acc-- 0.940621   pondering_cost-- 0.128366   rnn_cost-- 0.202667   final_iteration 12.7646
60   loss-- 0.300251   acc-- 0.956815   pondering_cost-- 0.148845   rnn_cost-- 0.151406   final_iteration 14.8205
70   loss-- 0.326303   acc-- 0.946019   pondering_cost-- 0.159408   rnn_cost-- 0.166895   final_iteration 15.8803
80   loss-- 0.276531   acc-- 0.977058   pondering_cost-- 0.172115   rnn_cost-- 0.104416   final_iteration 17.1556
90   loss-- 0.272624   acc-- 0.982456   pondering_cost-- 0.170847   rnn_cost-- 0.101778   final_iteration 17.0266
Optimization Finished!

In [13]:
tf.reset_default_graph()
op4 = Classifier_PonderDNC_BasicLSTM_L3(
    inputs= inputs, 
    targets= targets, 
    gather_list= gather_list, 
    hidden_size= 50, 
    memory_size= 50, 
    pondering_coefficient= 1e-2, 
    learning_rate= 1e-3)

op4.fit(training_iters = 50,
        display_step = 10,
        save_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt",
        restore_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt")


WARNING:tensorflow:The `skip_connections` argument will be deprecated. Please use snt.SkipConnectionCore instead.
E:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py:93: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
INFO:tensorflow:Restoring parameters from /QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt
0   loss-- 0.27052   acc-- 0.982456   pondering_cost-- 0.17756   rnn_cost-- 0.0929605   final_iteration 17.7008
10   loss-- 0.321946   acc-- 0.960864   pondering_cost-- 0.176679   rnn_cost-- 0.145267   final_iteration 17.6117
20   loss-- 0.274515   acc-- 0.955466   pondering_cost-- 0.149419   rnn_cost-- 0.125096   final_iteration 14.8777
30   loss-- 0.251235   acc-- 0.986505   pondering_cost-- 0.188465   rnn_cost-- 0.0627701   final_iteration 18.7912
40   loss-- 0.440759   acc-- 0.905533   pondering_cost-- 0.20219   rnn_cost-- 0.238569   final_iteration 20.1676
Optimization Finished!

In [14]:
op4.close()


结束进程,清理tensorflow内存/显存占用

In [15]:
tf.reset_default_graph()
op5 = Classifier_PonderDNC_BasicLSTM_L3(
    inputs= inputs, 
    targets= targets, 
    gather_list= gather_list, 
    hidden_size= 50, 
    memory_size= 50, 
    pondering_coefficient= 1e-1, 
    learning_rate= 1e-3)

op5.fit(training_iters = 50,
        display_step = 10,
        save_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_2.ckpt",
        restore_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt")


WARNING:tensorflow:The `skip_connections` argument will be deprecated. Please use snt.SkipConnectionCore instead.
E:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py:93: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
INFO:tensorflow:Restoring parameters from /QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_1.ckpt
0   loss-- 1.81499   acc-- 0.973009   pondering_cost-- 1.71147   rnn_cost-- 0.10352   final_iteration 17.0585
10   loss-- 1.25422   acc-- 0.987854   pondering_cost-- 1.17059   rnn_cost-- 0.0836344   final_iteration 11.6303
20   loss-- 0.973435   acc-- 0.991903   pondering_cost-- 0.906457   rnn_cost-- 0.0669776   final_iteration 8.97606
30   loss-- 0.904253   acc-- 0.993252   pondering_cost-- 0.840059   rnn_cost-- 0.0641937   final_iteration 8.30585
40   loss-- 0.793794   acc-- 0.975708   pondering_cost-- 0.682381   rnn_cost-- 0.111413   final_iteration 6.70878
Optimization Finished!

In [16]:
op5.close()


结束进程,清理tensorflow内存/显存占用

In [17]:
tf.reset_default_graph()
op6 = Classifier_PonderDNC_BasicLSTM_L3(
    inputs= inputs, 
    targets= targets, 
    gather_list= gather_list, 
    hidden_size= 50, 
    memory_size= 50, 
    pondering_coefficient= 1e-1, 
    learning_rate= 1e-4)

op6.fit(training_iters = 100,
        display_step = 10,
        save_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_3.ckpt",
        restore_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_2.ckpt")


WARNING:tensorflow:The `skip_connections` argument will be deprecated. Please use snt.SkipConnectionCore instead.
E:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py:93: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
INFO:tensorflow:Restoring parameters from /QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_2.ckpt
0   loss-- 0.838057   acc-- 0.995951   pondering_cost-- 0.771468   rnn_cost-- 0.0665885   final_iteration 7.60904
10   loss-- 0.789648   acc-- 0.991903   pondering_cost-- 0.727666   rnn_cost-- 0.0619824   final_iteration 7.16622
20   loss-- 0.759923   acc-- 0.991903   pondering_cost-- 0.700286   rnn_cost-- 0.0596365   final_iteration 6.89096
30   loss-- 0.72831   acc-- 0.990553   pondering_cost-- 0.671155   rnn_cost-- 0.0571554   final_iteration 6.5891
40   loss-- 0.698293   acc-- 0.991903   pondering_cost-- 0.643709   rnn_cost-- 0.0545842   final_iteration 6.30984
50   loss-- 0.666798   acc-- 0.995951   pondering_cost-- 0.615156   rnn_cost-- 0.051642   final_iteration 6.02261
60   loss-- 0.637745   acc-- 0.997301   pondering_cost-- 0.588644   rnn_cost-- 0.0491018   final_iteration 5.75
70   loss-- 0.604989   acc-- 0.994602   pondering_cost-- 0.556566   rnn_cost-- 0.0484231   final_iteration 5.42553
80   loss-- 0.571635   acc-- 0.995951   pondering_cost-- 0.523343   rnn_cost-- 0.0482922   final_iteration 5.08112
90   loss-- 0.552297   acc-- 0.997301   pondering_cost-- 0.506004   rnn_cost-- 0.0462924   final_iteration 4.9016
Optimization Finished!

In [9]:
tf.reset_default_graph()
op7 = Classifier_PonderDNC_BasicLSTM_L3(
    inputs= inputs, 
    targets= targets, 
    gather_list= gather_list, 
    hidden_size= 50, 
    memory_size= 50, 
    pondering_coefficient= 1e-1, 
    learning_rate= 1e-4)

op7.fit(training_iters = 100,
        display_step = 10,
        save_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_4.ckpt",
        restore_path = "/QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_3.ckpt")


WARNING:tensorflow:The `skip_connections` argument will be deprecated. Please use snt.SkipConnectionCore instead.
E:\Anaconda3\lib\site-packages\tensorflow\python\ops\gradients_impl.py:93: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
INFO:tensorflow:Restoring parameters from /QuantPython/RqAlphaMod/Model_Saver/ResidualPonderDNC_3.ckpt
0   loss-- 0.557076   acc-- 0.995951   pondering_cost-- 0.512336   rnn_cost-- 0.04474   final_iteration 4.96543
10   loss-- 0.542246   acc-- 0.99865   pondering_cost-- 0.49976   rnn_cost-- 0.0424863   final_iteration 4.83511
20   loss-- 0.515805   acc-- 0.997301   pondering_cost-- 0.472288   rnn_cost-- 0.043517   final_iteration 4.54388
30   loss-- 0.494251   acc-- 0.997301   pondering_cost-- 0.450699   rnn_cost-- 0.0435524   final_iteration 4.31782
40   loss-- 0.491783   acc-- 0.99865   pondering_cost-- 0.452294   rnn_cost-- 0.0394888   final_iteration 4.33511
50   loss-- 0.479336   acc-- 1.0   pondering_cost-- 0.440716   rnn_cost-- 0.0386203   final_iteration 4.21543
60   loss-- 0.458445   acc-- 1.0   pondering_cost-- 0.418858   rnn_cost-- 0.0395862   final_iteration 3.98803
70   loss-- 0.449   acc-- 0.997301   pondering_cost-- 0.408906   rnn_cost-- 0.0400936   final_iteration 3.88165
80   loss-- 0.44356   acc-- 1.0   pondering_cost-- 0.40746   rnn_cost-- 0.0361004   final_iteration 3.85904
90   loss-- 0.426672   acc-- 1.0   pondering_cost-- 0.389673   rnn_cost-- 0.0369994   final_iteration 3.68218
Optimization Finished!

In [10]:
model = op7

设置回测框架


In [11]:
import rqalpha.api as rqa
from rqalpha import run_func

def init(context):
    context.contract = 'AG88'
    context.BarSpan = 200
    context.TransactionRate = '1d'
    context.DataFields = ['datetime', 'open', 'close','high', 'low', 'volume']
    context.DefineQuantity = 5 
    context.func_get_factors = get_factors
    context.model_classifier = model


WARNING: better_exceptions will only inspect code from the command line
         when using: `python -m better_exceptions'. Otherwise, only code
         loaded from files will be inspected!

In [17]:
def handle_bar(context, bar_dict):
    
    # 合约池代码 
    contract = context.contract
    #rqa.logger.info('------------------------------------')
    #timepoint = rqa.history_bars(contract, 1, '1d', 'datetime')[0]  
    #timepoint = pd.to_datetime(str(timepoint))
    #timepoint = rqa.get_next_trading_date(timepoint)
    #rqa.logger.info (timepoint)    
    
    # 获取合约报价
    Quotes = rqa.history_bars(
        order_book_id= contract, 
        bar_count= context.BarSpan, 
        frequency= context.TransactionRate,
        fields= context.DataFields)
    Quotes = pd.DataFrame(Quotes)

    # 计算技术分析指标
    tmp_factors = context.func_get_factors(
        index= pd.to_datetime(Quotes['datetime']), 
        Open= Quotes['open'].values, 
        Close= Quotes['close'].values, 
        High= Quotes['high'].values, 
        Low= Quotes['low'].values, 
        Volume=Quotes['volume'].values,
        drop=True)   
    inputs = np.expand_dims(np.array(tmp_factors), axis=1)    
    
    # 模型预测
    probability, classification = context.model_classifier.pred(inputs)
    flag = classification[-1][0]
    rqa.logger.info(str(flag))
    #print (flag)
    
    # 绘制估计概率
    rqa.plot("估空概率", probability[-1][0][0])
    rqa.plot("振荡概率", probability[-1][0][1])
    rqa.plot("估多概率", probability[-1][0][2])
    
    
    # 获取仓位
    cur_position = context.portfolio.accounts['FUTURE'].positions
    
    tmp_buy_quantity = 0
    tmp_sell_quantity = 0
    if cur_position:
        tmp_buy_quantity = cur_position[contract].buy_quantity
        tmp_sell_quantity = cur_position[contract].sell_quantity

    # 沽空
    if flag == 0:
        rqa.logger.info ('沽空')
        
        if tmp_buy_quantity > 0:
            rqa.sell_close(contract, tmp_buy_quantity)            
            rqa.sell_open(contract, context.DefineQuantity)
            rqa.logger.info ('平多单  开空单')
            
        elif tmp_sell_quantity >0:
            rqa.logger.info ('持有空头,不调仓')
        else:
            rqa.sell_open(contract, context.DefineQuantity)
            rqa.logger.info ('开空单')

            
    # 沽多
    if flag == 2:
        rqa.logger.info ('沽多')
        if tmp_sell_quantity > 0:
            rqa.buy_close(contract, tmp_sell_quantity)
            rqa.buy_open(contract, context.DefineQuantity)   
            rqa.logger.info ('平空单  开多单')

        elif tmp_buy_quantity > 0:
            rqa.logger.info ('持有多头,不调仓')
            pass
        else:
            rqa.logger.info ('开多单')
            rqa.buy_open(contract, context.DefineQuantity)   
            
    if flag == 1:
        rqa.logger.info ('振荡区间')
        if tmp_sell_quantity > 0:
            rqa.buy_close(contract, tmp_sell_quantity)
            rqa.logger.info ('平空单')
        if tmp_buy_quantity > 0:
            rqa.sell_close(contract, tmp_buy_quantity)
            rqa.logger.info ('平多单')
        else:
            rqa.logger.info ('空仓规避')

In [18]:
start_date = '2016-01-01'
end_date = '2017-01-01'
accounts = {'future':1e5}

config = {
    'base':{'start_date':start_date, 'end_date':end_date, 'accounts':accounts},
    'extra':{'log_level':'info'},
    'mod':{'sys_analyser':{'enabled':True, 'plot':True}}
}

results = run_func(init=init, handle_bar=handle_bar, config=config)


2016-01-04 INFO 0
2016-01-04 INFO 沽空
2016-01-04 INFO 开空单
2016-01-05 INFO 0
2016-01-05 INFO 沽空
2016-01-05 INFO 持有空头,不调仓
2016-01-06 INFO 0
2016-01-06 INFO 沽空
2016-01-06 INFO 持有空头,不调仓
2016-01-07 INFO 0
2016-01-07 INFO 沽空
2016-01-07 INFO 持有空头,不调仓
2016-01-08 INFO 0
2016-01-08 INFO 沽空
2016-01-08 INFO 持有空头,不调仓
2016-01-11 INFO 0
2016-01-11 INFO 沽空
2016-01-11 INFO 持有空头,不调仓
2016-01-12 INFO 1
2016-01-12 INFO 振荡区间
2016-01-12 INFO 平空单
2016-01-12 INFO 空仓规避
2016-01-13 INFO 2
2016-01-13 INFO 沽多
2016-01-13 INFO 开多单
2016-01-14 INFO 1
2016-01-14 INFO 振荡区间
2016-01-14 INFO 平多单
2016-01-15 INFO 1
2016-01-15 INFO 振荡区间
2016-01-15 INFO 空仓规避
2016-01-18 INFO 1
2016-01-18 INFO 振荡区间
2016-01-18 INFO 空仓规避
2016-01-19 INFO 0
2016-01-19 INFO 沽空
2016-01-19 INFO 开空单
2016-01-20 INFO 0
2016-01-20 INFO 沽空
2016-01-20 INFO 持有空头,不调仓
2016-01-21 INFO 2
2016-01-21 INFO 沽多
2016-01-21 INFO 平空单  开多单
2016-01-22 INFO 2
2016-01-22 INFO 沽多
2016-01-22 INFO 持有多头,不调仓
2016-01-25 INFO 2
2016-01-25 INFO 沽多
2016-01-25 INFO 持有多头,不调仓
2016-01-26 INFO 0
2016-01-26 INFO 沽空
2016-01-26 INFO 平多单  开空单
2016-01-27 INFO 0
2016-01-27 INFO 沽空
2016-01-27 INFO 持有空头,不调仓
2016-01-28 INFO 0
2016-01-28 INFO 沽空
2016-01-28 INFO 持有空头,不调仓
2016-01-29 INFO 1
2016-01-29 INFO 振荡区间
2016-01-29 INFO 平空单
2016-01-29 INFO 空仓规避
2016-02-01 INFO 1
2016-02-01 INFO 振荡区间
2016-02-01 INFO 空仓规避
2016-02-02 INFO 2
2016-02-02 INFO 沽多
2016-02-02 INFO 开多单
2016-02-03 INFO 2
2016-02-03 INFO 沽多
2016-02-03 INFO 持有多头,不调仓
2016-02-04 INFO 0
2016-02-04 INFO 沽空
2016-02-04 INFO 平多单  开空单
2016-02-05 INFO 0
2016-02-05 INFO 沽空
2016-02-05 INFO 持有空头,不调仓
2016-02-15 INFO 0
2016-02-15 INFO 沽空
2016-02-15 INFO 持有空头,不调仓
2016-02-16 INFO 0
2016-02-16 INFO 沽空
2016-02-16 INFO 持有空头,不调仓
2016-02-17 INFO 0
2016-02-17 INFO 沽空
2016-02-17 INFO 持有空头,不调仓
2016-02-18 INFO 0
2016-02-18 INFO 沽空
2016-02-18 INFO 持有空头,不调仓
2016-02-19 INFO 0
2016-02-19 INFO 沽空
2016-02-19 INFO 持有空头,不调仓
2016-02-22 INFO 1
2016-02-22 INFO 振荡区间
2016-02-22 INFO 平空单
2016-02-22 INFO 空仓规避
2016-02-23 INFO 0
2016-02-23 INFO 沽空
2016-02-23 INFO 开空单
2016-02-24 INFO 0
2016-02-24 INFO 沽空
2016-02-24 INFO 持有空头,不调仓
2016-02-25 INFO 1
2016-02-25 INFO 振荡区间
2016-02-25 INFO 平空单
2016-02-25 INFO 空仓规避
2016-02-26 INFO 1
2016-02-26 INFO 振荡区间
2016-02-26 INFO 空仓规避
2016-02-29 INFO 1
2016-02-29 INFO 振荡区间
2016-02-29 INFO 空仓规避
2016-03-01 INFO 1
2016-03-01 INFO 振荡区间
2016-03-01 INFO 空仓规避
2016-03-02 INFO 1
2016-03-02 INFO 振荡区间
2016-03-02 INFO 空仓规避
2016-03-03 INFO 1
2016-03-03 INFO 振荡区间
2016-03-03 INFO 空仓规避
2016-03-04 INFO 1
2016-03-04 INFO 振荡区间
2016-03-04 INFO 空仓规避
2016-03-07 INFO 1
2016-03-07 INFO 振荡区间
2016-03-07 INFO 空仓规避
2016-03-08 INFO 2
2016-03-08 INFO 沽多
2016-03-08 INFO 开多单
2016-03-09 INFO 2
2016-03-09 INFO 沽多
2016-03-09 INFO 持有多头,不调仓
2016-03-10 INFO 2
2016-03-10 INFO 沽多
2016-03-10 INFO 持有多头,不调仓
2016-03-11 INFO 1
2016-03-11 INFO 振荡区间
2016-03-11 INFO 平多单
2016-03-14 INFO 1
2016-03-14 INFO 振荡区间
2016-03-14 INFO 空仓规避
2016-03-15 INFO 2
2016-03-15 INFO 沽多
2016-03-15 INFO 开多单
2016-03-16 INFO 2
2016-03-16 INFO 沽多
2016-03-16 INFO 持有多头,不调仓
2016-03-17 INFO 0
2016-03-17 INFO 沽空
2016-03-17 INFO 平多单  开空单
2016-03-18 INFO 0
2016-03-18 INFO 沽空
2016-03-18 INFO 持有空头,不调仓
2016-03-21 INFO 1
2016-03-21 INFO 振荡区间
2016-03-21 INFO 平空单
2016-03-21 INFO 空仓规避
2016-03-22 INFO 1
2016-03-22 INFO 振荡区间
2016-03-22 INFO 空仓规避
2016-03-23 INFO 1
2016-03-23 INFO 振荡区间
2016-03-23 INFO 空仓规避
2016-03-24 INFO 1
2016-03-24 INFO 振荡区间
2016-03-24 INFO 空仓规避
2016-03-25 INFO 2
2016-03-25 INFO 沽多
2016-03-25 INFO 开多单
2016-03-28 INFO 2
2016-03-28 INFO 沽多
2016-03-28 INFO 持有多头,不调仓
2016-03-29 INFO 2
2016-03-29 INFO 沽多
2016-03-29 INFO 持有多头,不调仓
2016-03-30 INFO 0
2016-03-30 INFO 沽空
2016-03-30 INFO 平多单  开空单
2016-03-31 INFO 0
2016-03-31 INFO 沽空
2016-03-31 INFO 持有空头,不调仓
2016-04-01 INFO 0
2016-04-01 INFO 沽空
2016-04-01 INFO 持有空头,不调仓
2016-04-05 INFO 0
2016-04-05 INFO 沽空
2016-04-05 INFO 持有空头,不调仓
2016-04-06 INFO 1
2016-04-06 INFO 振荡区间
2016-04-06 INFO 平空单
2016-04-06 INFO 空仓规避
2016-04-07 INFO 1
2016-04-07 INFO 振荡区间
2016-04-07 INFO 空仓规避
2016-04-08 INFO 1
2016-04-08 INFO 振荡区间
2016-04-08 INFO 空仓规避
2016-04-11 INFO 0
2016-04-11 INFO 沽空
2016-04-11 INFO 开空单
2016-04-12 INFO 0
2016-04-12 INFO 沽空
2016-04-12 INFO 持有空头,不调仓
2016-04-13 INFO 0
2016-04-13 INFO 沽空
2016-04-13 INFO 持有空头,不调仓
2016-04-14 INFO 0
2016-04-14 INFO 沽空
2016-04-14 INFO 持有空头,不调仓
2016-04-15 INFO 0
2016-04-15 INFO 沽空
2016-04-15 INFO 持有空头,不调仓
2016-04-18 INFO 0
2016-04-18 INFO 沽空
2016-04-18 INFO 持有空头,不调仓
2016-04-19 INFO 0
2016-04-19 INFO 沽空
2016-04-19 INFO 持有空头,不调仓
2016-04-20 INFO 1
2016-04-20 INFO 振荡区间
2016-04-20 INFO 平空单
2016-04-20 INFO 空仓规避
2016-04-21 INFO 1
2016-04-21 INFO 振荡区间
2016-04-21 INFO 空仓规避
2016-04-22 INFO 1
2016-04-22 INFO 振荡区间
2016-04-22 INFO 空仓规避
2016-04-25 INFO 1
2016-04-25 INFO 振荡区间
2016-04-25 INFO 空仓规避
2016-04-26 INFO 1
2016-04-26 INFO 振荡区间
2016-04-26 INFO 空仓规避
2016-04-27 INFO 1
2016-04-27 INFO 振荡区间
2016-04-27 INFO 空仓规避
2016-04-28 INFO 1
2016-04-28 INFO 振荡区间
2016-04-28 INFO 空仓规避
2016-04-29 INFO 1
2016-04-29 INFO 振荡区间
2016-04-29 INFO 空仓规避
2016-05-03 INFO 1
2016-05-03 INFO 振荡区间
2016-05-03 INFO 空仓规避
2016-05-04 INFO 1
2016-05-04 INFO 振荡区间
2016-05-04 INFO 空仓规避
2016-05-05 INFO 1
2016-05-05 INFO 振荡区间
2016-05-05 INFO 空仓规避
2016-05-06 INFO 1
2016-05-06 INFO 振荡区间
2016-05-06 INFO 空仓规避
2016-05-09 INFO 1
2016-05-09 INFO 振荡区间
2016-05-09 INFO 空仓规避
2016-05-10 INFO 1
2016-05-10 INFO 振荡区间
2016-05-10 INFO 空仓规避
2016-05-11 INFO 0
2016-05-11 INFO 沽空
2016-05-11 INFO 开空单
2016-05-12 INFO 0
2016-05-12 INFO 沽空
2016-05-12 INFO 持有空头,不调仓
2016-05-13 INFO 1
2016-05-13 INFO 振荡区间
2016-05-13 INFO 平空单
2016-05-13 INFO 空仓规避
2016-05-16 INFO 0
2016-05-16 INFO 沽空
2016-05-16 INFO 开空单
2016-05-17 INFO 0
2016-05-17 INFO 沽空
2016-05-17 INFO 持有空头,不调仓
2016-05-18 INFO 1
2016-05-18 INFO 振荡区间
2016-05-18 INFO 平空单
2016-05-18 INFO 空仓规避
2016-05-19 INFO 1
2016-05-19 INFO 振荡区间
2016-05-19 INFO 空仓规避
2016-05-20 INFO 1
2016-05-20 INFO 振荡区间
2016-05-20 INFO 空仓规避
2016-05-23 INFO 1
2016-05-23 INFO 振荡区间
2016-05-23 INFO 空仓规避
2016-05-24 INFO 1
2016-05-24 INFO 振荡区间
2016-05-24 INFO 空仓规避
2016-05-25 INFO 1
2016-05-25 INFO 振荡区间
2016-05-25 INFO 空仓规避
2016-05-26 INFO 1
2016-05-26 INFO 振荡区间
2016-05-26 INFO 空仓规避
2016-05-27 INFO 1
2016-05-27 INFO 振荡区间
2016-05-27 INFO 空仓规避
2016-05-30 INFO 1
2016-05-30 INFO 振荡区间
2016-05-30 INFO 空仓规避
2016-05-31 INFO 1
2016-05-31 INFO 振荡区间
2016-05-31 INFO 空仓规避
2016-06-01 INFO 1
2016-06-01 INFO 振荡区间
2016-06-01 INFO 空仓规避
2016-06-02 INFO 2
2016-06-02 INFO 沽多
2016-06-02 INFO 开多单
2016-06-03 INFO 2
2016-06-03 INFO 沽多
2016-06-03 INFO 持有多头,不调仓
2016-06-06 INFO 1
2016-06-06 INFO 振荡区间
2016-06-06 INFO 平多单
2016-06-07 INFO 1
2016-06-07 INFO 振荡区间
2016-06-07 INFO 空仓规避
2016-06-08 INFO 1
2016-06-08 INFO 振荡区间
2016-06-08 INFO 空仓规避
2016-06-13 INFO 1
2016-06-13 INFO 振荡区间
2016-06-13 INFO 空仓规避
2016-06-14 INFO 2
2016-06-14 INFO 沽多
2016-06-14 INFO 开多单
2016-06-15 INFO 0
2016-06-15 INFO 沽空
2016-06-15 INFO 平多单  开空单
2016-06-16 INFO 1
2016-06-16 INFO 振荡区间
2016-06-16 INFO 平空单
2016-06-16 INFO 空仓规避
2016-06-17 INFO 1
2016-06-17 INFO 振荡区间
2016-06-17 INFO 空仓规避
2016-06-20 INFO 2
2016-06-20 INFO 沽多
2016-06-20 INFO 开多单
2016-06-21 INFO 2
2016-06-21 INFO 沽多
2016-06-21 INFO 持有多头,不调仓
2016-06-22 INFO 2
2016-06-22 INFO 沽多
2016-06-22 INFO 持有多头,不调仓
2016-06-23 INFO 2
2016-06-23 INFO 沽多
2016-06-23 INFO 持有多头,不调仓
2016-06-24 INFO 1
2016-06-24 INFO 振荡区间
2016-06-24 INFO 平多单
2016-06-27 INFO 1
2016-06-27 INFO 振荡区间
2016-06-27 INFO 空仓规避
2016-06-28 INFO 2
2016-06-28 INFO 沽多
2016-06-28 INFO 开多单
2016-06-29 INFO 1
2016-06-29 INFO 振荡区间
2016-06-29 INFO 平多单
2016-06-30 INFO 1
2016-06-30 INFO 振荡区间
2016-06-30 INFO 空仓规避
2016-07-01 INFO 1
2016-07-01 INFO 振荡区间
2016-07-01 INFO 空仓规避
2016-07-04 INFO 1
2016-07-04 INFO 振荡区间
2016-07-04 INFO 空仓规避
2016-07-05 INFO 1
2016-07-05 INFO 振荡区间
2016-07-05 INFO 空仓规避
2016-07-06 INFO 1
2016-07-06 INFO 振荡区间
2016-07-06 INFO 空仓规避
2016-07-07 INFO 1
2016-07-07 INFO 振荡区间
2016-07-07 INFO 空仓规避
2016-07-08 INFO 2
2016-07-08 INFO 沽多
2016-07-08 INFO 开多单
2016-07-11 INFO 2
2016-07-11 INFO 沽多
2016-07-11 INFO 持有多头,不调仓
2016-07-12 INFO 1
2016-07-12 INFO 振荡区间
2016-07-12 INFO 平多单
2016-07-13 INFO 1
2016-07-13 INFO 振荡区间
2016-07-13 INFO 空仓规避
2016-07-14 INFO 1
2016-07-14 INFO 振荡区间
2016-07-14 INFO 空仓规避
2016-07-15 INFO 0
2016-07-15 INFO 沽空
2016-07-15 INFO 开空单
2016-07-18 INFO 1
2016-07-18 INFO 振荡区间
2016-07-18 INFO 平空单
2016-07-18 INFO 空仓规避
2016-07-19 INFO 0
2016-07-19 INFO 沽空
2016-07-19 INFO 开空单
2016-07-20 INFO 0
2016-07-20 INFO 沽空
2016-07-20 INFO 持有空头,不调仓
2016-07-21 INFO 2
2016-07-21 INFO 沽多
2016-07-21 INFO 平空单  开多单
2016-07-22 INFO 1
2016-07-22 INFO 振荡区间
2016-07-22 INFO 平多单
2016-07-25 INFO 2
2016-07-25 INFO 沽多
2016-07-25 INFO 开多单
2016-07-26 INFO 1
2016-07-26 INFO 振荡区间
2016-07-26 INFO 平多单
2016-07-27 INFO 1
2016-07-27 INFO 振荡区间
2016-07-27 INFO 空仓规避
2016-07-28 INFO 1
2016-07-28 INFO 振荡区间
2016-07-28 INFO 空仓规避
2016-07-29 INFO 0
2016-07-29 INFO 沽空
2016-07-29 INFO 开空单
2016-08-01 INFO 0
2016-08-01 INFO 沽空
2016-08-01 INFO 持有空头,不调仓
2016-08-02 INFO 0
2016-08-02 INFO 沽空
2016-08-02 INFO 持有空头,不调仓
2016-08-03 INFO 0
2016-08-03 INFO 沽空
2016-08-03 INFO 持有空头,不调仓
2016-08-04 INFO 0
2016-08-04 INFO 沽空
2016-08-04 INFO 持有空头,不调仓
2016-08-05 INFO 0
2016-08-05 INFO 沽空
2016-08-05 INFO 持有空头,不调仓
2016-08-08 INFO 2
2016-08-08 INFO 沽多
2016-08-08 INFO 平空单  开多单
2016-08-09 INFO 2
2016-08-09 INFO 沽多
2016-08-09 INFO 持有多头,不调仓
2016-08-10 INFO 2
2016-08-10 INFO 沽多
2016-08-10 INFO 持有多头,不调仓
2016-08-11 INFO 2
2016-08-11 INFO 沽多
2016-08-11 INFO 持有多头,不调仓
2016-08-12 INFO 2
2016-08-12 INFO 沽多
2016-08-12 INFO 持有多头,不调仓
2016-08-15 INFO 2
2016-08-15 INFO 沽多
2016-08-15 INFO 持有多头,不调仓
2016-08-16 INFO 2
2016-08-16 INFO 沽多
2016-08-16 INFO 持有多头,不调仓
2016-08-17 INFO 2
2016-08-17 INFO 沽多
2016-08-17 INFO 持有多头,不调仓
2016-08-18 INFO 1
2016-08-18 INFO 振荡区间
2016-08-18 INFO 平多单
2016-08-19 INFO 1
2016-08-19 INFO 振荡区间
2016-08-19 INFO 空仓规避
2016-08-22 INFO 1
2016-08-22 INFO 振荡区间
2016-08-22 INFO 空仓规避
2016-08-23 INFO 1
2016-08-23 INFO 振荡区间
2016-08-23 INFO 空仓规避
2016-08-24 INFO 1
2016-08-24 INFO 振荡区间
2016-08-24 INFO 空仓规避
2016-08-25 INFO 1
2016-08-25 INFO 振荡区间
2016-08-25 INFO 空仓规避
2016-08-26 INFO 1
2016-08-26 INFO 振荡区间
2016-08-26 INFO 空仓规避
2016-08-29 INFO 1
2016-08-29 INFO 振荡区间
2016-08-29 INFO 空仓规避
2016-08-30 INFO 1
2016-08-30 INFO 振荡区间
2016-08-30 INFO 空仓规避
2016-08-31 INFO 1
2016-08-31 INFO 振荡区间
2016-08-31 INFO 空仓规避
2016-09-01 INFO 1
2016-09-01 INFO 振荡区间
2016-09-01 INFO 空仓规避
2016-09-02 INFO 1
2016-09-02 INFO 振荡区间
2016-09-02 INFO 空仓规避
2016-09-05 INFO 1
2016-09-05 INFO 振荡区间
2016-09-05 INFO 空仓规避
2016-09-06 INFO 1
2016-09-06 INFO 振荡区间
2016-09-06 INFO 空仓规避
2016-09-07 INFO 1
2016-09-07 INFO 振荡区间
2016-09-07 INFO 空仓规避
2016-09-08 INFO 0
2016-09-08 INFO 沽空
2016-09-08 INFO 开空单
2016-09-09 INFO 0
2016-09-09 INFO 沽空
2016-09-09 INFO 持有空头,不调仓
2016-09-12 INFO 1
2016-09-12 INFO 振荡区间
2016-09-12 INFO 平空单
2016-09-12 INFO 空仓规避
2016-09-13 INFO 1
2016-09-13 INFO 振荡区间
2016-09-13 INFO 空仓规避
2016-09-14 INFO 1
2016-09-14 INFO 振荡区间
2016-09-14 INFO 空仓规避
2016-09-19 INFO 2
2016-09-19 INFO 沽多
2016-09-19 INFO 开多单
2016-09-20 INFO 0
2016-09-20 INFO 沽空
2016-09-20 INFO 平多单  开空单
2016-09-21 INFO 0
2016-09-21 INFO 沽空
2016-09-21 INFO 持有空头,不调仓
2016-09-22 INFO 0
2016-09-22 INFO 沽空
2016-09-22 INFO 持有空头,不调仓
2016-09-23 INFO 0
2016-09-23 INFO 沽空
2016-09-23 INFO 持有空头,不调仓
2016-09-26 INFO 0
2016-09-26 INFO 沽空
2016-09-26 INFO 持有空头,不调仓
2016-09-27 INFO 2
2016-09-27 INFO 沽多
2016-09-27 INFO 平空单  开多单
2016-09-28 INFO 2
2016-09-28 INFO 沽多
2016-09-28 INFO 持有多头,不调仓
2016-09-29 INFO 2
2016-09-29 INFO 沽多
2016-09-29 INFO 持有多头,不调仓
2016-09-30 INFO 0
2016-09-30 INFO 沽空
2016-09-30 INFO 平多单  开空单
2016-10-10 INFO 1
2016-10-10 INFO 振荡区间
2016-10-10 INFO 平空单
2016-10-10 INFO 空仓规避
2016-10-11 INFO 1
2016-10-11 INFO 振荡区间
2016-10-11 INFO 空仓规避
2016-10-12 INFO 1
2016-10-12 INFO 振荡区间
2016-10-12 INFO 空仓规避
2016-10-13 INFO 1
2016-10-13 INFO 振荡区间
2016-10-13 INFO 空仓规避
2016-10-14 INFO 1
2016-10-14 INFO 振荡区间
2016-10-14 INFO 空仓规避
2016-10-17 INFO 2
2016-10-17 INFO 沽多
2016-10-17 INFO 开多单
2016-10-18 INFO 1
2016-10-18 INFO 振荡区间
2016-10-18 INFO 平多单
2016-10-19 INFO 0
2016-10-19 INFO 沽空
2016-10-19 INFO 开空单
2016-10-20 INFO 2
2016-10-20 INFO 沽多
2016-10-20 INFO 平空单  开多单
2016-10-21 INFO 2
2016-10-21 INFO 沽多
2016-10-21 INFO 持有多头,不调仓
2016-10-24 INFO 2
2016-10-24 INFO 沽多
2016-10-24 INFO 持有多头,不调仓
2016-10-25 INFO 2
2016-10-25 INFO 沽多
2016-10-25 INFO 持有多头,不调仓
2016-10-26 INFO 1
2016-10-26 INFO 振荡区间
2016-10-26 INFO 平多单
2016-10-27 INFO 2
2016-10-27 INFO 沽多
2016-10-27 INFO 开多单
2016-10-28 INFO 2
2016-10-28 INFO 沽多
2016-10-28 INFO 持有多头,不调仓
2016-10-31 INFO 2
2016-10-31 INFO 沽多
2016-10-31 INFO 持有多头,不调仓
2016-11-01 INFO 2
2016-11-01 INFO 沽多
2016-11-01 INFO 持有多头,不调仓
2016-11-02 INFO 0
2016-11-02 INFO 沽空
2016-11-02 INFO 平多单  开空单
2016-11-03 INFO 1
2016-11-03 INFO 振荡区间
2016-11-03 INFO 平空单
2016-11-03 INFO 空仓规避
2016-11-04 INFO 1
2016-11-04 INFO 振荡区间
2016-11-04 INFO 空仓规避
2016-11-07 INFO 1
2016-11-07 INFO 振荡区间
2016-11-07 INFO 空仓规避
2016-11-08 INFO 2
2016-11-08 INFO 沽多
2016-11-08 INFO 开多单
2016-11-09 INFO 1
2016-11-09 INFO 振荡区间
2016-11-09 INFO 平多单
2016-11-10 INFO 1
2016-11-10 INFO 振荡区间
2016-11-10 INFO 空仓规避
2016-11-11 INFO 0
2016-11-11 INFO 沽空
2016-11-11 INFO 开空单
2016-11-14 INFO 1
2016-11-14 INFO 振荡区间
2016-11-14 INFO 平空单
2016-11-14 INFO 空仓规避
2016-11-15 INFO 1
2016-11-15 INFO 振荡区间
2016-11-15 INFO 空仓规避
2016-11-16 INFO 1
2016-11-16 INFO 振荡区间
2016-11-16 INFO 空仓规避
2016-11-17 INFO 1
2016-11-17 INFO 振荡区间
2016-11-17 INFO 空仓规避
2016-11-18 INFO 2
2016-11-18 INFO 沽多
2016-11-18 INFO 开多单
2016-11-21 INFO 1
2016-11-21 INFO 振荡区间
2016-11-21 INFO 平多单
2016-11-22 INFO 0
2016-11-22 INFO 沽空
2016-11-22 INFO 开空单
2016-11-23 INFO 0
2016-11-23 INFO 沽空
2016-11-23 INFO 持有空头,不调仓
2016-11-24 INFO 0
2016-11-24 INFO 沽空
2016-11-24 INFO 持有空头,不调仓
2016-11-25 INFO 1
2016-11-25 INFO 振荡区间
2016-11-25 INFO 平空单
2016-11-25 INFO 空仓规避
2016-11-28 INFO 1
2016-11-28 INFO 振荡区间
2016-11-28 INFO 空仓规避
2016-11-29 INFO 0
2016-11-29 INFO 沽空
2016-11-29 INFO 开空单
2016-11-30 INFO 0
2016-11-30 INFO 沽空
2016-11-30 INFO 持有空头,不调仓
2016-12-01 INFO 0
2016-12-01 INFO 沽空
2016-12-01 INFO 持有空头,不调仓
2016-12-02 INFO 0
2016-12-02 INFO 沽空
2016-12-02 INFO 持有空头,不调仓
2016-12-05 INFO 0
2016-12-05 INFO 沽空
2016-12-05 INFO 持有空头,不调仓
2016-12-06 INFO 0
2016-12-06 INFO 沽空
2016-12-06 INFO 持有空头,不调仓
2016-12-07 INFO 0
2016-12-07 INFO 沽空
2016-12-07 INFO 持有空头,不调仓
2016-12-08 INFO 0
2016-12-08 INFO 沽空
2016-12-08 INFO 持有空头,不调仓
2016-12-09 INFO 0
2016-12-09 INFO 沽空
2016-12-09 INFO 持有空头,不调仓
2016-12-12 INFO 0
2016-12-12 INFO 沽空
2016-12-12 INFO 持有空头,不调仓
2016-12-13 INFO 0
2016-12-13 INFO 沽空
2016-12-13 INFO 持有空头,不调仓
2016-12-14 INFO 0
2016-12-14 INFO 沽空
2016-12-14 INFO 持有空头,不调仓
2016-12-15 INFO 1
2016-12-15 INFO 振荡区间
2016-12-15 INFO 平空单
2016-12-15 INFO 空仓规避
2016-12-16 INFO 1
2016-12-16 INFO 振荡区间
2016-12-16 INFO 空仓规避
2016-12-19 INFO 1
2016-12-19 INFO 振荡区间
2016-12-19 INFO 空仓规避
2016-12-20 INFO 1
2016-12-20 INFO 振荡区间
2016-12-20 INFO 空仓规避
2016-12-21 INFO 1
2016-12-21 INFO 振荡区间
2016-12-21 INFO 空仓规避
2016-12-22 INFO 1
2016-12-22 INFO 振荡区间
2016-12-22 INFO 空仓规避
2016-12-23 INFO 1
2016-12-23 INFO 振荡区间
2016-12-23 INFO 空仓规避
2016-12-26 INFO 1
2016-12-26 INFO 振荡区间
2016-12-26 INFO 空仓规避
2016-12-27 INFO 1
2016-12-27 INFO 振荡区间
2016-12-27 INFO 空仓规避
2016-12-28 INFO 1
2016-12-28 INFO 振荡区间
2016-12-28 INFO 空仓规避
2016-12-29 INFO 1
2016-12-29 INFO 振荡区间
2016-12-29 INFO 空仓规避
2016-12-30 INFO 1
2016-12-30 INFO 振荡区间
2016-12-30 INFO 空仓规避
E:\Anaconda3\lib\site-packages\rqalpha\utils\risk.py:122: RuntimeWarning: invalid value encountered in double_scalars
  self._beta = cov[0][1] / cov[1][1]

In [19]:
start_date = '2017-01-01'
end_date = '2017-08-01'
accounts = {'future':1e5}

config = {
    'base':{'start_date':start_date, 'end_date':end_date, 'accounts':accounts},
    'extra':{'log_level':'info'},
    'mod':{'sys_analyser':{'enabled':True, 'plot':True}}
}

results = run_func(init=init, handle_bar=handle_bar, config=config)


2017-01-03 INFO 0
2017-01-03 INFO 沽空
2017-01-03 INFO 开空单
2017-01-04 INFO 0
2017-01-04 INFO 沽空
2017-01-04 INFO 持有空头,不调仓
2017-01-05 INFO 0
2017-01-05 INFO 沽空
2017-01-05 INFO 持有空头,不调仓
2017-01-06 INFO 2
2017-01-06 INFO 沽多
2017-01-06 INFO 平空单  开多单
2017-01-09 INFO 2
2017-01-09 INFO 沽多
2017-01-09 INFO 持有多头,不调仓
2017-01-10 INFO 2
2017-01-10 INFO 沽多
2017-01-10 INFO 持有多头,不调仓
2017-01-11 INFO 0
2017-01-11 INFO 沽空
2017-01-11 INFO 平多单  开空单
2017-01-12 INFO 2
2017-01-12 INFO 沽多
2017-01-12 INFO 平空单  开多单
2017-01-13 INFO 2
2017-01-13 INFO 沽多
2017-01-13 INFO 持有多头,不调仓
2017-01-16 INFO 2
2017-01-16 INFO 沽多
2017-01-16 INFO 持有多头,不调仓
2017-01-17 INFO 2
2017-01-17 INFO 沽多
2017-01-17 INFO 持有多头,不调仓
2017-01-18 INFO 2
2017-01-18 INFO 沽多
2017-01-18 INFO 持有多头,不调仓
2017-01-19 INFO 2
2017-01-19 INFO 沽多
2017-01-19 INFO 持有多头,不调仓
2017-01-20 INFO 2
2017-01-20 INFO 沽多
2017-01-20 INFO 持有多头,不调仓
2017-01-23 INFO 2
2017-01-23 INFO 沽多
2017-01-23 INFO 持有多头,不调仓
2017-01-24 INFO 2
2017-01-24 INFO 沽多
2017-01-24 INFO 持有多头,不调仓
2017-01-25 INFO 2
2017-01-25 INFO 沽多
2017-01-25 INFO 持有多头,不调仓
2017-01-26 INFO 2
2017-01-26 INFO 沽多
2017-01-26 INFO 持有多头,不调仓
2017-02-03 INFO 2
2017-02-03 INFO 沽多
2017-02-03 INFO 持有多头,不调仓
2017-02-06 INFO 2
2017-02-06 INFO 沽多
2017-02-06 INFO 持有多头,不调仓
2017-02-07 INFO 0
2017-02-07 INFO 沽空
2017-02-07 INFO 平多单  开空单
2017-02-08 INFO 0
2017-02-08 INFO 沽空
2017-02-08 INFO 持有空头,不调仓
2017-02-09 INFO 0
2017-02-09 INFO 沽空
2017-02-09 INFO 持有空头,不调仓
2017-02-10 INFO 0
2017-02-10 INFO 沽空
2017-02-10 INFO 持有空头,不调仓
2017-02-13 INFO 0
2017-02-13 INFO 沽空
2017-02-13 INFO 持有空头,不调仓
2017-02-14 INFO 0
2017-02-14 INFO 沽空
2017-02-14 INFO 持有空头,不调仓
2017-02-15 INFO 0
2017-02-15 INFO 沽空
2017-02-15 INFO 持有空头,不调仓
2017-02-16 INFO 0
2017-02-16 INFO 沽空
2017-02-16 INFO 持有空头,不调仓
2017-02-17 INFO 0
2017-02-17 INFO 沽空
2017-02-17 INFO 持有空头,不调仓
2017-02-20 INFO 0
2017-02-20 INFO 沽空
2017-02-20 INFO 持有空头,不调仓
2017-02-21 INFO 0
2017-02-21 INFO 沽空
2017-02-21 INFO 持有空头,不调仓
2017-02-22 INFO 0
2017-02-22 INFO 沽空
2017-02-22 INFO 持有空头,不调仓
2017-02-23 INFO 0
2017-02-23 INFO 沽空
2017-02-23 INFO 持有空头,不调仓
2017-02-24 INFO 0
2017-02-24 INFO 沽空
2017-02-24 INFO 持有空头,不调仓
2017-02-27 INFO 0
2017-02-27 INFO 沽空
2017-02-27 INFO 持有空头,不调仓
2017-02-28 INFO 0
2017-02-28 INFO 沽空
2017-02-28 INFO 持有空头,不调仓
2017-03-01 INFO 0
2017-03-01 INFO 沽空
2017-03-01 INFO 持有空头,不调仓
2017-03-02 INFO 0
2017-03-02 INFO 沽空
2017-03-02 INFO 持有空头,不调仓
2017-03-03 INFO 1
2017-03-03 INFO 振荡区间
2017-03-03 INFO 平空单
2017-03-03 INFO 空仓规避
2017-03-06 INFO 0
2017-03-06 INFO 沽空
2017-03-06 INFO 开空单
2017-03-07 INFO 2
2017-03-07 INFO 沽多
2017-03-07 INFO 平空单  开多单
2017-03-08 INFO 2
2017-03-08 INFO 沽多
2017-03-08 INFO 持有多头,不调仓
2017-03-09 INFO 2
2017-03-09 INFO 沽多
2017-03-09 INFO 持有多头,不调仓
2017-03-10 INFO 2
2017-03-10 INFO 沽多
2017-03-10 INFO 持有多头,不调仓
2017-03-13 INFO 2
2017-03-13 INFO 沽多
2017-03-13 INFO 持有多头,不调仓
2017-03-14 INFO 2
2017-03-14 INFO 沽多
2017-03-14 INFO 持有多头,不调仓
2017-03-15 INFO 2
2017-03-15 INFO 沽多
2017-03-15 INFO 持有多头,不调仓
2017-03-16 INFO 2
2017-03-16 INFO 沽多
2017-03-16 INFO 持有多头,不调仓
2017-03-17 INFO 2
2017-03-17 INFO 沽多
2017-03-17 INFO 持有多头,不调仓
2017-03-20 INFO 1
2017-03-20 INFO 振荡区间
2017-03-20 INFO 平多单
2017-03-21 INFO 2
2017-03-21 INFO 沽多
2017-03-21 INFO 开多单
2017-03-22 INFO 1
2017-03-22 INFO 振荡区间
2017-03-22 INFO 平多单
2017-03-23 INFO 1
2017-03-23 INFO 振荡区间
2017-03-23 INFO 空仓规避
2017-03-24 INFO 2
2017-03-24 INFO 沽多
2017-03-24 INFO 开多单
2017-03-27 INFO 0
2017-03-27 INFO 沽空
2017-03-27 INFO 平多单  开空单
2017-03-28 INFO 0
2017-03-28 INFO 沽空
2017-03-28 INFO 持有空头,不调仓
2017-03-29 INFO 0
2017-03-29 INFO 沽空
2017-03-29 INFO 持有空头,不调仓
2017-03-30 INFO 0
2017-03-30 INFO 沽空
2017-03-30 INFO 持有空头,不调仓
2017-03-31 INFO 2
2017-03-31 INFO 沽多
2017-03-31 INFO 平空单  开多单
2017-04-05 INFO 2
2017-04-05 INFO 沽多
2017-04-05 INFO 持有多头,不调仓
2017-04-06 INFO 2
2017-04-06 INFO 沽多
2017-04-06 INFO 持有多头,不调仓
2017-04-07 INFO 0
2017-04-07 INFO 沽空
2017-04-07 INFO 平多单  开空单
2017-04-10 INFO 1
2017-04-10 INFO 振荡区间
2017-04-10 INFO 平空单
2017-04-10 INFO 空仓规避
2017-04-11 INFO 1
2017-04-11 INFO 振荡区间
2017-04-11 INFO 空仓规避
2017-04-12 INFO 1
2017-04-12 INFO 振荡区间
2017-04-12 INFO 空仓规避
2017-04-13 INFO 1
2017-04-13 INFO 振荡区间
2017-04-13 INFO 空仓规避
2017-04-14 INFO 1
2017-04-14 INFO 振荡区间
2017-04-14 INFO 空仓规避
2017-04-17 INFO 1
2017-04-17 INFO 振荡区间
2017-04-17 INFO 空仓规避
2017-04-18 INFO 1
2017-04-18 INFO 振荡区间
2017-04-18 INFO 空仓规避
2017-04-19 INFO 1
2017-04-19 INFO 振荡区间
2017-04-19 INFO 空仓规避
2017-04-20 INFO 1
2017-04-20 INFO 振荡区间
2017-04-20 INFO 空仓规避
2017-04-21 INFO 1
2017-04-21 INFO 振荡区间
2017-04-21 INFO 空仓规避
2017-04-24 INFO 1
2017-04-24 INFO 振荡区间
2017-04-24 INFO 空仓规避
2017-04-25 INFO 1
2017-04-25 INFO 振荡区间
2017-04-25 INFO 空仓规避
2017-04-26 INFO 1
2017-04-26 INFO 振荡区间
2017-04-26 INFO 空仓规避
2017-04-27 INFO 1
2017-04-27 INFO 振荡区间
2017-04-27 INFO 空仓规避
2017-04-28 INFO 1
2017-04-28 INFO 振荡区间
2017-04-28 INFO 空仓规避
2017-05-02 INFO 2
2017-05-02 INFO 沽多
2017-05-02 INFO 开多单
2017-05-03 INFO 2
2017-05-03 INFO 沽多
2017-05-03 INFO 持有多头,不调仓
2017-05-04 INFO 2
2017-05-04 INFO 沽多
2017-05-04 INFO 持有多头,不调仓
2017-05-05 INFO 2
2017-05-05 INFO 沽多
2017-05-05 INFO 持有多头,不调仓
2017-05-08 INFO 2
2017-05-08 INFO 沽多
2017-05-08 INFO 持有多头,不调仓
2017-05-09 INFO 2
2017-05-09 INFO 沽多
2017-05-09 INFO 持有多头,不调仓
2017-05-10 INFO 2
2017-05-10 INFO 沽多
2017-05-10 INFO 持有多头,不调仓
2017-05-11 INFO 2
2017-05-11 INFO 沽多
2017-05-11 INFO 持有多头,不调仓
2017-05-12 INFO 1
2017-05-12 INFO 振荡区间
2017-05-12 INFO 平多单
2017-05-15 INFO 1
2017-05-15 INFO 振荡区间
2017-05-15 INFO 空仓规避
2017-05-16 INFO 0
2017-05-16 INFO 沽空
2017-05-16 INFO 开空单
2017-05-17 INFO 0
2017-05-17 INFO 沽空
2017-05-17 INFO 持有空头,不调仓
2017-05-18 INFO 1
2017-05-18 INFO 振荡区间
2017-05-18 INFO 平空单
2017-05-18 INFO 空仓规避
2017-05-19 INFO 1
2017-05-19 INFO 振荡区间
2017-05-19 INFO 空仓规避
2017-05-22 INFO 1
2017-05-22 INFO 振荡区间
2017-05-22 INFO 空仓规避
2017-05-23 INFO 1
2017-05-23 INFO 振荡区间
2017-05-23 INFO 空仓规避
2017-05-24 INFO 1
2017-05-24 INFO 振荡区间
2017-05-24 INFO 空仓规避
2017-05-25 INFO 1
2017-05-25 INFO 振荡区间
2017-05-25 INFO 空仓规避
2017-05-26 INFO 0
2017-05-26 INFO 沽空
2017-05-26 INFO 开空单
2017-05-31 INFO 0
2017-05-31 INFO 沽空
2017-05-31 INFO 持有空头,不调仓
2017-06-01 INFO 2
2017-06-01 INFO 沽多
2017-06-01 INFO 平空单  开多单
2017-06-02 INFO 2
2017-06-02 INFO 沽多
2017-06-02 INFO 持有多头,不调仓
2017-06-05 INFO 2
2017-06-05 INFO 沽多
2017-06-05 INFO 持有多头,不调仓
2017-06-06 INFO 2
2017-06-06 INFO 沽多
2017-06-06 INFO 持有多头,不调仓
2017-06-07 INFO 0
2017-06-07 INFO 沽空
2017-06-07 INFO 平多单  开空单
2017-06-08 INFO 0
2017-06-08 INFO 沽空
2017-06-08 INFO 持有空头,不调仓
2017-06-09 INFO 1
2017-06-09 INFO 振荡区间
2017-06-09 INFO 平空单
2017-06-09 INFO 空仓规避
2017-06-12 INFO 2
2017-06-12 INFO 沽多
2017-06-12 INFO 开多单
2017-06-13 INFO 2
2017-06-13 INFO 沽多
2017-06-13 INFO 持有多头,不调仓
2017-06-14 INFO 1
2017-06-14 INFO 振荡区间
2017-06-14 INFO 平多单
2017-06-15 INFO 1
2017-06-15 INFO 振荡区间
2017-06-15 INFO 空仓规避
2017-06-16 INFO 1
2017-06-16 INFO 振荡区间
2017-06-16 INFO 空仓规避
2017-06-19 INFO 1
2017-06-19 INFO 振荡区间
2017-06-19 INFO 空仓规避
2017-06-20 INFO 1
2017-06-20 INFO 振荡区间
2017-06-20 INFO 空仓规避
2017-06-21 INFO 1
2017-06-21 INFO 振荡区间
2017-06-21 INFO 空仓规避
2017-06-22 INFO 1
2017-06-22 INFO 振荡区间
2017-06-22 INFO 空仓规避
2017-06-23 INFO 1
2017-06-23 INFO 振荡区间
2017-06-23 INFO 空仓规避
2017-06-26 INFO 0
2017-06-26 INFO 沽空
2017-06-26 INFO 开空单
2017-06-27 INFO 2
2017-06-27 INFO 沽多
2017-06-27 INFO 平空单  开多单
2017-06-28 INFO 2
2017-06-28 INFO 沽多
2017-06-28 INFO 持有多头,不调仓
2017-06-29 INFO 0
2017-06-29 INFO 沽空
2017-06-29 INFO 平多单  开空单
2017-06-30 INFO 2
2017-06-30 INFO 沽多
2017-06-30 INFO 平空单  开多单
2017-07-03 INFO 2
2017-07-03 INFO 沽多
2017-07-03 INFO 持有多头,不调仓
2017-07-04 INFO 2
2017-07-04 INFO 沽多
2017-07-04 INFO 持有多头,不调仓
2017-07-05 INFO 2
2017-07-05 INFO 沽多
2017-07-05 INFO 持有多头,不调仓
2017-07-06 INFO 1
2017-07-06 INFO 振荡区间
2017-07-06 INFO 平多单
2017-07-07 INFO 1
2017-07-07 INFO 振荡区间
2017-07-07 INFO 空仓规避
2017-07-10 INFO 2
2017-07-10 INFO 沽多
2017-07-10 INFO 开多单
2017-07-11 INFO 2
2017-07-11 INFO 沽多
2017-07-11 INFO 持有多头,不调仓
2017-07-12 INFO 2
2017-07-12 INFO 沽多
2017-07-12 INFO 持有多头,不调仓
2017-07-13 INFO 2
2017-07-13 INFO 沽多
2017-07-13 INFO 持有多头,不调仓
2017-07-14 INFO 2
2017-07-14 INFO 沽多
2017-07-14 INFO 持有多头,不调仓
2017-07-17 INFO 1
2017-07-17 INFO 振荡区间
2017-07-17 INFO 平多单
2017-07-18 INFO 1
2017-07-18 INFO 振荡区间
2017-07-18 INFO 空仓规避
2017-07-19 INFO 1
2017-07-19 INFO 振荡区间
2017-07-19 INFO 空仓规避
2017-07-20 INFO 2
2017-07-20 INFO 沽多
2017-07-20 INFO 开多单
2017-07-21 INFO 1
2017-07-21 INFO 振荡区间
2017-07-21 INFO 平多单
2017-07-24 INFO 1
2017-07-24 INFO 振荡区间
2017-07-24 INFO 空仓规避
2017-07-25 INFO 1
2017-07-25 INFO 振荡区间
2017-07-25 INFO 空仓规避
2017-07-26 INFO 1
2017-07-26 INFO 振荡区间
2017-07-26 INFO 空仓规避
2017-07-27 INFO 1
2017-07-27 INFO 振荡区间
2017-07-27 INFO 空仓规避
2017-07-28 INFO 1
2017-07-28 INFO 振荡区间
2017-07-28 INFO 空仓规避
2017-07-31 INFO 0
2017-07-31 INFO 沽空
2017-07-31 INFO 开空单
2017-08-01 INFO 0
2017-08-01 INFO 沽空
2017-08-01 INFO 持有空头,不调仓
E:\Anaconda3\lib\site-packages\rqalpha\utils\risk.py:122: RuntimeWarning: invalid value encountered in double_scalars
  self._beta = cov[0][1] / cov[1][1]

In [ ]: