From 9192022bf78d62dcbea64e5a4e60a794005c6125 Mon Sep 17 00:00:00 2001 From: king-yellow <33049781+king-yellow@users.noreply.github.com> Date: Thu, 19 Dec 2019 13:55:19 +0800 Subject: [PATCH] Add files via upload --- BTC_LSTM.html | 15136 +++++++++++++++++++++++++++++++++++++++++++++++ ETH_LSTM.html | 15267 ++++++++++++++++++++++++++++++++++++++++++++++++ LTC_LSTM.html | 14761 ++++++++++++++++++++++++++++++++++++++++++++++ XRP_LSTM.html | 14961 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60125 insertions(+) create mode 100644 BTC_LSTM.html create mode 100644 ETH_LSTM.html create mode 100644 LTC_LSTM.html create mode 100644 XRP_LSTM.html diff --git a/BTC_LSTM.html b/BTC_LSTM.html new file mode 100644 index 0000000..6da337b --- /dev/null +++ b/BTC_LSTM.html @@ -0,0 +1,15136 @@ + + + + +BTC_LSTM + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
In [1]:
+
+
+
from __future__ import absolute_import, division, print_function, unicode_literals
+try:
+  # %tensorflow_version only exists in Colab.
+  %tensorflow_version 2.x
+except Exception:
+  pass
+import tensorflow as tf
+
+import matplotlib as mpl
+import matplotlib.pyplot as plt
+import numpy as np
+import os
+import pandas as pd
+
+mpl.rcParams['figure.figsize'] = (8, 6)     #初始化设置,应该是展示图片大小
+
+mpl.rcParams['axes.grid'] = False
+
+ +
+
+
+ +
+
+
+
In [2]:
+
+
+
import pandas as pd 
+import numpy as np
+df= pd.read_excel("data_summary.xlsx", sheet_name=0)
+df=df[960:]
+
+ +
+
+
+ +
+
+
+
In [3]:
+
+
+
df=np.array(df)
+df=pd.DataFrame(df)
+close_price=df[4]
+
+
+CLOSE=[0]
+
+frequency=1200     #1440min合成1条k线
+
+for i in range(len(close_price)):
+    if (i+1) %frequency==0:
+        CLOSE=np.vstack((CLOSE,close_price[i]))
+
+CLOSE=CLOSE[1:]    
+
+
+#open_price=df['open']
+
+open_price=df[1]
+
+
+
+OPEN=[0]
+
+for i in range(len(close_price)):
+    if (i+1) %frequency==0:
+        OPEN=np.vstack((OPEN,open_price[i-(frequency-1)]))
+
+OPEN=OPEN[1:]    
+
+
+#high_price=df['high']
+high_price=df[2]
+
+
+HIGH=[0]
+
+for i in range(len(high_price)):
+    if (i+1) %frequency==0:
+        HIGH=np.vstack((HIGH,max(high_price[i-(frequency-1):i+1])))
+
+HIGH=HIGH[1:]  
+
+#low_price=df['low']
+low_price=df[3]
+
+LOW=[0]
+
+for i in range(len(low_price)):
+    if (i+1) %frequency==0:
+        LOW=np.vstack((LOW,min(low_price[i-(frequency-1):i+1])))
+
+LOW=LOW[1:]
+
+#time=df['time']
+time=df[0]
+
+TIME=[0]
+
+for i in range(len(time)):
+    if (i+1) %frequency==0:
+        TIME=np.vstack((TIME,time[i]))
+
+TIME=TIME[1:] 
+
+ +
+
+
+ +
+
+
+
In [4]:
+
+
+
data=np.hstack((TIME,CLOSE,HIGH,LOW,OPEN))
+data=pd.DataFrame(data)
+data.columns = ["TIME", "C","H","L","O"]
+df=data
+
+ +
+
+
+ +
+
+
+
In [5]:
+
+
+
zero=np.array([0])
+rt=np.diff(np.array(df['C']))
+rt=np.hstack((zero,rt))
+df.insert(5, 'Diff_C', rt) 
+
+moving_avg = df['Diff_C'].rolling(window=5).mean(center=True)
+MV=moving_avg[2:len(rt)-2]
+zeros=np.zeros((4))
+MV=np.hstack((zeros,MV))
+df.insert(6, 'MV_C', MV) 
+df[0:10]
+
+ +
+
+
+ +
+
+ + +
+ +
Out[5]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TIMECHLODiff_CMV_C
02018-04-23 19:59:008861.529020.678727.68887500.000
12018-04-24 15:59:008934.0189858800.68861.5272.490.000
22018-04-25 11:59:009449.9945589228934515.890.000
32018-04-26 07:59:008972.099759.8287309452-477.810.000
42018-04-27 03:59:008857.019185.018651.628972.09-115.08-0.902
52018-04-27 23:59:009240.979307.488740.018858.51383.9675.890
62018-04-28 19:59:009155939588709240.97-85.9744.198
72018-04-29 15:59:0093489427.489081.029155.01193-20.380
82018-04-30 11:59:009320.079570.519163.749348-27.9369.596
92018-05-01 07:59:009318.069458.649124.999326.99-2.0192.210
+
+
+ +
+ +
+
+ +
+
+
+
In [6]:
+
+
+
features_considered=['MV_C']
+
+features = df[features_considered]                       
+features.index = df['TIME']        #在前面加一列时间
+
+dataset = features.values
+TRAIN_SPLIT = (len(df)*7)//10      #first 70% of the rows in dataset will be the training dataset
+tf.random.set_seed(13)     # 保持random selection每次都一样
+EVALUATION_INTERVAL = 2400       #原来是200
+EPOCHS = 10       #1个epoch等于使用训练集中的全部样本训练一次,通俗的讲epoch的值就是整个数据集被轮几次。
+BATCH_SIZE = 256           #训练的小批次, iteration=TRAIN_SPLIT/256
+BUFFER_SIZE = 10000       #缓存容量 
+def multivariate_data(dataset, target, start_index, end_index, history_size,
+                      target_size, step, single_step=False):         
+    data = []
+    labels = []
+
+    start_index = start_index + history_size
+    if end_index is None:
+        end_index = len(dataset) - target_size
+
+    for i in range(start_index, end_index):
+        indices = range(i-history_size, i, step)             #就是在取过去天数的样本时,是间隔着几天取的,这样可以减少训练时间
+        data.append(dataset[indices])
+
+        if single_step:
+            labels.append(target[i+target_size])                #就是说,这里可以规定只预测后面某一天或者是后面好几天
+        else:
+            labels.append(target[i:i+target_size])               
+
+    return np.array(data), np.array(labels)        #output 出numpy格式的数据
+
+past_history = 35         # 用过去50天的数据,本来是720
+future_target = 0            #本来是72  预测12天后的数据,或者是下一天到12天后的数据   72/6=12
+STEP = 1                    #本来是6,取过去天数的样本时,是间隔着6天取的,这样可以减少训练时间
+
+#future_target = 1          # 预测12天后的数据,或者是下一天到12天后的数据   72/6=12
+#STEP = 1                     #取过去天数的样本时,是间隔着6天取的,这样可以减少训练时间
+
+
+x_train_single, y_train_single = multivariate_data(dataset, dataset[:, 0], 0,
+                                                   TRAIN_SPLIT, past_history,
+                                                   future_target, STEP,
+                                                   single_step=True)
+x_val_single, y_val_single = multivariate_data(dataset, dataset[:, 0],
+                                               TRAIN_SPLIT, None, past_history,
+                                               future_target, STEP,
+                                               single_step=True)
+
+train_data_single = tf.data.Dataset.from_tensor_slices((x_train_single, y_train_single))              
+train_data_single = train_data_single.cache().shuffle(BUFFER_SIZE).batch(BATCH_SIZE).repeat()      #traning data 
+
+val_data_single = tf.data.Dataset.from_tensor_slices((x_val_single, y_val_single))
+val_data_single = val_data_single.batch(BATCH_SIZE).repeat()                        #validation data 
+
+
+single_step_model = tf.keras.models.Sequential()
+single_step_model.add(tf.keras.layers.LSTM(6,
+                                           input_shape=x_train_single.shape[-2:]))    #应该是这一层有32 个神经元
+single_step_model.add(tf.keras.layers.Dense(1))                         #output layer, 因为预测未来1 期的data, 所以是1个神经元
+
+single_step_model.compile(optimizer=tf.keras.optimizers.RMSprop(), loss='mae')    #这里优化算法用RMSprop而不是Adam 或 Momentum
+
+single_step_history = single_step_model.fit(train_data_single, epochs=EPOCHS,      #EPOCHS = 10  轮10次
+                                            steps_per_epoch=EVALUATION_INTERVAL,    #每轮test 200次 data
+                                            validation_data=val_data_single, 
+                                            validation_steps=50)      #设置验证多少次数据后取平均值作为此epoch训练后的效果 
+
+def plot_train_history(history, title):             #把training lost 和validation loss 表示出来
+  loss = history.history['loss']             
+  val_loss = history.history['val_loss']
+
+  epochs = range(len(loss))
+
+  plt.figure()
+
+  plt.plot(epochs, loss, 'b', label='Training loss')
+  plt.plot(epochs, val_loss, 'r', label='Validation loss')
+  plt.title(title)
+  plt.legend()
+
+  plt.show()
+
+plot_train_history(single_step_history,
+                   'Single Step Training and validation loss')
+
+single_step_model.save('BTC_1200.h5') 
+model = tf.keras.models.load_model('BTC_1200.h5')
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
Train for 2400 steps, validate for 50 steps
+Epoch 1/10
+2400/2400 [==============================] - 83s 35ms/step - loss: 50.6852 - val_loss: 121.4187
+Epoch 2/10
+2400/2400 [==============================] - 73s 30ms/step - loss: 47.2670 - val_loss: 117.7336
+Epoch 3/10
+2400/2400 [==============================] - 75s 31ms/step - loss: 44.4204 - val_loss: 115.0552
+Epoch 4/10
+2400/2400 [==============================] - 74s 31ms/step - loss: 41.8872 - val_loss: 112.2282
+Epoch 5/10
+2400/2400 [==============================] - 74s 31ms/step - loss: 40.1423 - val_loss: 110.1467
+Epoch 6/10
+2400/2400 [==============================] - 74s 31ms/step - loss: 39.0767 - val_loss: 109.7285
+Epoch 7/10
+2400/2400 [==============================] - 75s 31ms/step - loss: 38.3035 - val_loss: 107.2883
+Epoch 8/10
+2400/2400 [==============================] - 78s 32ms/step - loss: 37.6985 - val_loss: 106.8553
+Epoch 9/10
+2400/2400 [==============================] - 79s 33ms/step - loss: 37.2131 - val_loss: 105.2949
+Epoch 10/10
+2400/2400 [==============================] - 78s 32ms/step - loss: 36.6460 - val_loss: 103.4797
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [29]:
+
+
+
df['TIME']#
+
+R1=[0]
+R2=[0]
+
+
+past_history = 35 
+TC=100000       #总资金10万
+
+C=1             #每次交易1手
+
+
+leverage=1
+
+cost_rate=0.0005
+
+
+price_per_point=1       #1点300元
+
+last_day=len(df['TIME'])
+
+
+m=0
+n=0
+p=0
+r=0
+R=0
+s=0
+
+I=0
+B=0
+RR=[0]
+II=[0]
+BB=[0]
+tt=0
+t=0
+d=0
+d2=0
+
+rr=[0]
+maximum_markdown_final=[0]
+CR=1
+CRR=[0]
+TCC=[0]
+
+day=500
+k=day
+#for k in range(3000):
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        #print(data2)
+
+        #j=[0,0,0,0,0]
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        #trend=x[0][0]-MV[-1-k]-MV[-2-k]                #预测正负
+        
+        #trend_real=MV[-k]-MV[-1-k]-MV[-2-k]           #实际正负
+        
+        #P0=np.array(df['C'])[-7-k]
+        #P1=np.array(df['C'])[-6-k]
+        #P2=np.array(df['C'])[-5-k]
+        #P5=np.array(df['C'])[-2-k]
+        #P6=np.array(df['C'])[-1-k]
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        P0=np.array(df['C'])[-6-k]
+        P1=np.array(df['C'])[-5-k]
+        P5=np.array(df['C'])[-1-k]
+        
+        
+        
+        
+        
+        #line=P6+P5+P2-P1-P0
+        
+        line=P5+P1-P0
+        
+        L=np.array(df['L'])[-k]
+        H=np.array(df['H'])[-k]
+        
+        if trend<0:
+            if P5-d2>line and (np.array(df['O'])[-k])-d2>line:
+                r1=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+               
+                
+                
+            else:
+                if L<line<H:
+                    r1=((np.array(df['C'])[-k])-(line))/(line)                      #r1必须小于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                   
+                else:
+                    r1=0
+                    maximum_markdown=0
+                       
+            
+            if r1!=0:
+                m+=1
+                R1=np.vstack((R1,r1))
+                
+            
+            if r1<0:
+                n+=1
+            r=r+r1
+            R=R-r1
+            
+        else:
+            r1=0
+            r=r
+            R=R
+            maximum_markdown=0
+           
+        
+        if trend>0:
+            
+            
+            if P5<line-d and (np.array(df['O'])[-k])<line-d:
+                r2=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+               
+            else:
+                if L<line<H:
+                    r2=((np.array(df['C'])[-k])-(line))/(line)    #r2必须大于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                   
+                else:
+                    r2=0
+                    maximum_markdown=0
+                    profit2=0
+                    
+                   
+            
+            if r2!=0:
+                m+=1
+                s+=1
+                
+                R2=np.vstack((R2,r2))
+            
+            if r2>0:
+                p+=1
+            R=R+r2
+        else:
+            R=R
+            r2=0
+            maximum_markdown=0
+            profit2=0
+            
+            
+        
+        
+        i=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+        I=I+i
+        
+        b=((np.array(df['C'])[-k])-(np.array(df['C'])[-k-1]))/(np.array(df['C'])[-k-1])
+        B=B+b
+        
+        
+        BB=np.vstack((BB,B))
+        RR=np.vstack((RR,R))  
+        II=np.vstack((II,I))
+        
+        maximum_markdown_final=np.vstack((maximum_markdown_final,maximum_markdown))
+        rr=np.vstack((rr,r2))
+        
+        if r1!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        if r2!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        
+        CRR=np.vstack((CRR,(CR-1)*10))
+    k=k-1
+    
+    
+
+    
+    
+    
+RR=RR[1:]
+II=II[1:]
+tt=tt[1:]
+
+R1=R1[1:]
+R2=R2[1:]
+
+
+plt.plot(tt,RR)               
+#plt.plot(tt,II) 
+BB=BB[1:]
+plt.plot(tt,BB)
+
+
+  
+maximum_markdown_final=maximum_markdown_final[1:]        
+#plt.plot(tt,maximum_markdown_final)  
+final_maximum=min(maximum_markdown_final)
+rr=rr[1:]
+maximum_loss=min(rr) 
+
+     
+print("trading dates=",m)
+print("success to sell=",n)
+print("success to buy=",p)
+print('return from short=',-r)
+print('total return of long and short=',R)
+print('Time of long',s)      
+print('maximum markdown=',final_maximum)
+print('maximum loss=',maximum_loss)
+
+print('compound interest=',CR-1)
+
+import numpy as np, scipy.stats as st
+CI_R1=st.t.interval(0.9, len(R1)-1, loc=np.mean(R1), scale=st.sem(R1))      #90% Confidence interval of short
+CI_R2=st.t.interval(0.9, len(R2)-1, loc=np.mean(R2), scale=st.sem(R2))      #90% Confidence interval of long
+
+print("confidence interval of short=",CI_R1)
+print("confidence interval of long=",CI_R2)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
trading dates= 332
+success to sell= 91
+success to buy= 99
+return from short= 0.388198533804498
+total return of long and short= 1.2875382200197902
+Time of long 162
+maximum markdown= [-0.14392047]
+maximum loss= [-0.10965397]
+compound interest= -0.37235013441928044
+confidence interval of short= (array([-0.00609658]), array([0.00152954]))
+confidence interval of long= (array([0.00087558]), array([0.01022738]))
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [27]:
+
+
+
#
+
+TC=100000       #总资金10万
+
+C=1             #每次交易1手
+
+
+leverage=1
+
+cost_rate=0.0005
+
+
+price_per_point=1       #1点300元
+
+last_day=len(df['TIME'])
+
+
+m=0
+n=0
+p=0
+r=0
+R=0
+s=0
+
+I=0
+B=100000
+RR=[0]
+II=[0]
+BB=[0]
+tt=0
+t=0
+d=0
+d2=0
+
+rr=[0]
+maximum_markdown_final=[0]
+CR=1
+CRR=[0]
+TCC=[0]
+
+day=500
+k=day
+#for k in range(3000):
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        #print(data2)
+
+        #j=[0,0,0,0,0]
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        #trend=x[0][0]-MV[-1-k]-MV[-2-k]                #预测正负
+        
+        #trend_real=MV[-k]-MV[-1-k]-MV[-2-k]           #实际正负
+        
+        #P0=np.array(df['C'])[-7-k]
+        #P1=np.array(df['C'])[-6-k]
+        #P2=np.array(df['C'])[-5-k]
+        #P5=np.array(df['C'])[-2-k]
+        #P6=np.array(df['C'])[-1-k]
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        P0=np.array(df['C'])[-6-k]
+        P1=np.array(df['C'])[-5-k]
+        P5=np.array(df['C'])[-1-k]
+        
+        
+        
+        
+        
+        #line=P6+P5+P2-P1-P0
+        
+        line=P5+P1-P0
+        
+        L=np.array(df['L'])[-k]
+        H=np.array(df['H'])[-k]
+        
+        if trend<0:
+            if P5-d2>line and (np.array(df['O'])[-k])-d2>line:
+                r1=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+                profit1=C*(((np.array(df['O'])[-k])*price_per_point-np.array(df['C'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(np.array(df['O'])[-k])*price_per_point*cost_rate)
+                
+                print('date:',df['TIME'][last_day-k],'buy price=',(np.array(df['O'])[-k]),"sell price=",(np.array(df['C'])[-k]),'short profit=',profit1)
+                
+                
+            else:
+                if L<line<H:
+                    r1=((np.array(df['C'])[-k])-(line))/(line)                      #r1必须小于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                    profit1=C*(((line)*price_per_point-np.array(df['C'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(line)*price_per_point*cost_rate)
+                    print('date:',df['TIME'][last_day-k],'buy price=',(line),"sell price=",(np.array(df['C'])[-k]),'short profit=',profit1)
+                    
+                else:
+                    r1=0
+                    maximum_markdown=0
+                    profit1=0
+                    
+                    print('date:',df['TIME'][last_day-k],'No transaction','profit=',0)
+            
+            
+            if r1!=0:
+                m+=1
+                
+            
+            if r1<0:
+                n+=1
+            r=r+r1
+            R=R-r1
+            
+        else:
+            r1=0
+            r=r
+            R=R
+            maximum_markdown=0
+            profit1=0
+            
+        
+        if trend>0:
+            
+            
+            if P5<line-d and (np.array(df['O'])[-k])<line-d:
+                r2=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+                profit2=C*((np.array(df['C'])[-k])*price_per_point-(np.array(df['O'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(np.array(df['O'])[-k])*price_per_point*cost_rate)
+                
+                print('date:',df['TIME'][last_day-k],'buy price=',(np.array(df['O'])[-k]),"sell price=",(np.array(df['C'])[-k]),'long profit=',profit2)
+                
+                
+            else:
+                if L<line<H:
+                    r2=((np.array(df['C'])[-k])-(line))/(line)    #r2必须大于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                    profit2=(np.array(df['C'])[-k])*price_per_point-(line)*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(line)*price_per_point*cost_rate
+                    
+                    print('date:',df['TIME'][last_day-k],'buy price=',(line),"sell price=",(np.array(df['C'])[-k]),'long profit=',profit2)
+                    
+                else:
+                    r2=0
+                    maximum_markdown=0
+                    profit2=0
+                    
+                    print('date:',df['TIME'][last_day-k],'No transaction','profit=',0)
+            
+            
+            if r2!=0:
+                m+=1
+                s+=1
+            
+            if r2>0:
+                p+=1
+            R=R+r2
+        else:
+            R=R
+            r2=0
+            maximum_markdown=0
+            profit2=0
+            
+            
+        TC=TC+profit1+profit2
+        TCC=np.vstack((TCC,TC))
+        
+        i=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+        I=I+i
+        
+        b=((np.array(df['C'])[-k])-(np.array(df['C'])[-k-1]))
+        B=B+b
+        
+        
+        BB=np.vstack((BB,B))
+        RR=np.vstack((RR,R))  
+        II=np.vstack((II,I))
+        
+        maximum_markdown_final=np.vstack((maximum_markdown_final,maximum_markdown))
+        rr=np.vstack((rr,r2))
+        
+        if r1!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        if r2!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        
+        CRR=np.vstack((CRR,(CR-1)*10))
+    k=k-1
+    
+    
+
+    
+    
+    
+RR=RR[1:]
+II=II[1:]
+tt=tt[1:]
+
+TCC=TCC[1:]
+
+
+
+#plt.plot(tt,RR)               
+#plt.plot(tt,II) 
+plt.plot(tt,TCC) 
+BB=BB[1:]
+plt.plot(tt,BB)
+
+
+  
+maximum_markdown_final=maximum_markdown_final[1:]        
+#plt.plot(tt,maximum_markdown_final)  
+final_maximum=min(maximum_markdown_final)
+rr=rr[1:]
+maximum_loss=min(rr) 
+
+     
+
+
+print("Final total capital=",TC)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
date: 2018-08-03 11:18:00 buy price= 7586.45 sell price= 7510.99 long profit= -83.00872000000004
+date: 2018-08-04 07:18:00 buy price= 7412.32 sell price= 7467.47 long profit= 47.710105000000546
+date: 2018-08-05 03:18:00 buy price= 7464.49 sell price= 7388.29 long profit= -83.62638999999983
+date: 2018-08-05 23:18:00 No transaction profit= 0
+date: 2018-08-06 19:18:00 buy price= 6975.6 sell price= 7110.63 long profit= 127.98688499999973
+date: 2018-08-07 15:18:00 buy price= 7031.059999999999 sell price= 6924.0 long profit= -114.03752999999858
+date: 2018-08-08 11:18:00 No transaction profit= 0
+date: 2018-08-09 07:18:00 buy price= 7016.78 sell price= 6478.64 long profit= -544.8877099999994
+date: 2018-08-10 03:18:00 No transaction profit= 0
+date: 2018-08-10 23:18:00 buy price= 6311.25 sell price= 6460.01 long profit= 142.37437000000023
+date: 2018-08-11 19:18:00 buy price= 6273.38 sell price= 6121.16 long profit= -158.41727000000023
+date: 2018-08-12 15:18:00 buy price= 6121.16 sell price= 6394.13 long profit= 266.71235500000023
+date: 2018-08-13 11:18:00 No transaction profit= 0
+date: 2018-08-14 07:18:00 No transaction profit= 0
+date: 2018-08-15 03:18:00 No transaction profit= 0
+date: 2018-08-15 23:18:00 No transaction profit= 0
+date: 2018-08-16 19:18:00 buy price= 6608.0 sell price= 6306.0 short profit= 295.543
+date: 2018-08-17 15:18:00 No transaction profit= 0
+date: 2018-08-18 11:18:00 buy price= 6273.93 sell price= 6505.52 long profit= 225.20027500000015
+date: 2018-08-19 07:18:00 No transaction profit= 0
+date: 2018-08-20 03:18:00 No transaction profit= 0
+date: 2018-08-20 23:18:00 buy price= 6375.9800000000005 sell price= 6436.21 long profit= 53.82390499999956
+date: 2018-08-21 19:18:00 buy price= 6436.5 sell price= 6306.93 short profit= 123.19828499999971
+date: 2018-08-22 15:18:00 buy price= 6307.2 sell price= 6469.53 long profit= 155.9416349999999
+date: 2018-08-23 11:18:00 buy price= 6466.01 sell price= 6418.77 short profit= 40.797609999999786
+date: 2018-08-24 07:18:00 No transaction profit= 0
+date: 2018-08-25 03:18:00 buy price= 6440.62 sell price= 6553.0 long profit= 105.88319000000011
+date: 2018-08-25 23:18:00 buy price= 6555.0 sell price= 6668.01 short profit= -119.62150500000023
+date: 2018-08-26 19:18:00 No transaction profit= 0
+date: 2018-08-27 15:18:00 No transaction profit= 0
+date: 2018-08-28 11:18:00 buy price= 6678.7 sell price= 6738.16 long profit= 52.75157000000004
+date: 2018-08-29 07:18:00 buy price= 6738.41 sell price= 7045.67 long profit= 300.3679600000002
+date: 2018-08-30 03:18:00 No transaction profit= 0
+date: 2018-08-30 23:18:00 buy price= 7064.6 sell price= 6993.94 short profit= 63.63073000000076
+date: 2018-08-31 19:18:00 No transaction profit= 0
+date: 2018-09-01 15:18:00 buy price= 6952.87 sell price= 7050.09 long profit= 90.21852000000025
+date: 2018-09-02 11:18:00 buy price= 7050.55 sell price= 7228.76 long profit= 171.07034500000003
+date: 2018-09-03 07:18:00 buy price= 7228.99 sell price= 7244.73 long profit= 8.503139999999782
+date: 2018-09-04 03:18:00 No transaction profit= 0
+date: 2018-09-04 23:18:00 No transaction profit= 0
+date: 2018-09-05 19:18:00 buy price= 7389.510000000001 sell price= 7364.99 short profit= 17.142750000001346
+date: 2018-09-06 15:18:00 No transaction profit= 0
+date: 2018-09-07 11:18:00 buy price= 6914.99 sell price= 6440.02 long profit= -481.64750499999934
+date: 2018-09-08 07:18:00 buy price= 6431.27 sell price= 6427.8 long profit= -9.899535000000256
+date: 2018-09-09 03:18:00 buy price= 6425.31 sell price= 6442.51 long profit= 10.766089999999819
+date: 2018-09-09 23:18:00 buy price= 6443.73 sell price= 6187.97 long profit= -262.07584999999926
+date: 2018-09-10 19:18:00 No transaction profit= 0
+date: 2018-09-11 15:18:00 No transaction profit= 0
+date: 2018-09-12 11:18:00 buy price= 6298.03 sell price= 6243.64 short profit= 48.11916499999942
+date: 2018-09-13 07:18:00 buy price= 6258.350000000001 sell price= 6270.32 short profit= -18.234334999998435
+date: 2018-09-14 03:18:00 No transaction profit= 0
+date: 2018-09-14 23:18:00 buy price= 6430.82 sell price= 6576.02 long profit= 138.69658000000072
+date: 2018-09-15 19:18:00 buy price= 6576.06 sell price= 6496.0 short profit= 73.52397000000039
+date: 2018-09-16 15:18:00 No transaction profit= 0
+date: 2018-09-17 11:18:00 buy price= 6522.13 sell price= 6493.0 long profit= -35.63756500000011
+date: 2018-09-18 07:18:00 No transaction profit= 0
+date: 2018-09-19 03:18:00 No transaction profit= 0
+date: 2018-09-19 23:18:00 No transaction profit= 0
+date: 2018-09-20 19:18:00 buy price= 6358.92 sell price= 6384.0 short profit= -31.451459999999926
+date: 2018-09-21 15:18:00 buy price= 6356.86 sell price= 6509.41 long profit= 146.1168650000002
+date: 2018-09-22 11:18:00 No transaction profit= 0
+date: 2018-09-23 07:18:00 buy price= 6760.62 sell price= 6667.06 short profit= 86.8461599999995
+date: 2018-09-24 03:18:00 buy price= 6749.47 sell price= 6765.63 short profit= -22.917549999999856
+date: 2018-09-24 23:18:00 No transaction profit= 0
+date: 2018-09-25 19:18:00 buy price= 6676.63 sell price= 6474.9 long profit= -208.30576500000046
+date: 2018-09-26 15:18:00 No transaction profit= 0
+date: 2018-09-27 11:18:00 No transaction profit= 0
+date: 2018-09-28 07:18:00 No transaction profit= 0
+date: 2018-09-29 03:18:00 No transaction profit= 0
+date: 2018-09-29 23:18:00 buy price= 6666.01 sell price= 6514.1 short profit= 145.31994499999985
+date: 2018-09-30 19:18:00 No transaction profit= 0
+date: 2018-10-01 15:18:00 No transaction profit= 0
+date: 2018-10-02 11:18:00 buy price= 6637.15 sell price= 6592.0 short profit= 38.535424999999634
+date: 2018-10-03 07:18:00 No transaction profit= 0
+date: 2018-10-04 03:18:00 buy price= 6547.37 sell price= 6482.05 short profit= 58.80528999999971
+date: 2018-10-04 23:18:00 buy price= 6548.59 sell price= 6583.52 short profit= -41.4960550000003
+date: 2018-10-05 19:18:00 buy price= 6583.01 sell price= 6579.36 long profit= -10.231185000000545
+date: 2018-10-06 15:18:00 buy price= 6576.33 sell price= 6629.24 short profit= -59.51278499999985
+date: 2018-10-07 11:18:00 buy price= 6584.610000000001 sell price= 6591.89 long profit= 0.691749999999745
+date: 2018-10-08 07:18:00 buy price= 6526.570000000001 sell price= 6576.62 long profit= 43.498404999999266
+date: 2018-10-09 03:18:00 No transaction profit= 0
+date: 2018-10-09 23:18:00 buy price= 6646.03 sell price= 6656.89 short profit= -17.511460000000582
+date: 2018-10-10 19:18:00 No transaction profit= 0
+date: 2018-10-11 15:18:00 buy price= 6627.5 sell price= 6629.98 short profit= -9.108739999999564
+date: 2018-10-12 11:18:00 buy price= 6630.01 sell price= 6301.05 short profit= 322.49447000000004
+date: 2018-10-13 07:18:00 buy price= 6301.05 sell price= 6332.91 long profit= 25.54301999999967
+date: 2018-10-14 03:18:00 buy price= 6332.9 sell price= 6334.02 long profit= -5.2134599999992
+date: 2018-10-14 23:18:00 buy price= 6304.63 sell price= 6382.01 long profit= 71.0366800000001
+date: 2018-10-15 19:18:00 buy price= 6382.01 sell price= 6369.82 long profit= -18.56591500000051
+date: 2018-10-16 15:18:00 No transaction profit= 0
+date: 2018-10-17 11:18:00 buy price= 6773.22 sell price= 6724.99 short profit= 41.48089500000047
+date: 2018-10-18 07:18:00 buy price= 6726.1 sell price= 6739.09 short profit= -19.72259499999978
+date: 2018-10-19 03:18:00 buy price= 6787.08 sell price= 6727.74 short profit= 52.582590000000145
+date: 2018-10-20 02:48:00 buy price= 6727.03 sell price= 6604.0 short profit= 116.36448499999973
+date: 2018-10-20 22:47:00 buy price= 6605.24 sell price= 6594.86 long profit= -16.98005000000011
+date: 2018-10-21 18:47:00 buy price= 6594.86 sell price= 6627.8 short profit= -39.55133000000051
+date: 2018-10-22 14:47:00 buy price= 6641.9 sell price= 6599.99 short profit= 35.28905499999985
+date: 2018-10-23 10:47:00 buy price= 6599.99 sell price= 6566.82 short profit= 26.586595000000074
+date: 2018-10-24 06:47:00 buy price= 6566.82 sell price= 6561.62 short profit= -1.364220000000182
+date: 2018-10-25 02:47:00 buy price= 6552.48 sell price= 6610.93 long profit= 51.86829500000073
+date: 2018-10-25 22:47:00 buy price= 6610.15 sell price= 6544.0 long profit= -72.72707499999964
+date: 2018-10-26 18:47:00 buy price= 6544.02 sell price= 6530.05 short profit= 7.432965000000255
+date: 2018-10-27 14:47:00 buy price= 6531.48 sell price= 6542.15 short profit= -17.206815000000073
+date: 2018-10-28 10:47:00 buy price= 6542.45 sell price= 6491.14 short profit= 44.79320499999949
+date: 2018-10-29 06:47:00 No transaction profit= 0
+date: 2018-10-30 02:47:00 buy price= 6506.62 sell price= 6491.9 short profit= 8.220740000000255
+date: 2018-10-30 22:47:00 buy price= 6491.9 sell price= 6376.0 short profit= 109.46604999999964
+date: 2018-10-31 18:47:00 No transaction profit= 0
+date: 2018-11-01 14:47:00 buy price= 6338.3 sell price= 6379.7 short profit= -47.75899999999964
+date: 2018-11-02 10:47:00 buy price= 6395.179999999999 sell price= 6374.24 short profit= 14.5552899999996
+date: 2018-11-03 06:47:00 buy price= 6375.6 sell price= 6433.3 short profit= -64.10444999999982
+date: 2018-11-04 02:47:00 No transaction profit= 0
+date: 2018-11-04 22:47:00 No transaction profit= 0
+date: 2018-11-05 18:47:00 buy price= 6393.04 sell price= 6470.14 long profit= 70.66841000000035
+date: 2018-11-06 14:47:00 buy price= 6464.680000000001 sell price= 6457.81 long profit= -13.331245000000802
+date: 2018-11-07 10:47:00 No transaction profit= 0
+date: 2018-11-08 06:47:00 buy price= 6490.07 sell price= 6550.75 short profit= -67.20041000000029
+date: 2018-11-09 02:47:00 buy price= 6577.720000000001 sell price= 6541.56 short profit= 29.600360000000762
+date: 2018-11-09 22:47:00 No transaction profit= 0
+date: 2018-11-10 18:47:00 buy price= 6498.08 sell price= 6433.76 short profit= 57.854079999999705
+date: 2018-11-11 14:47:00 buy price= 6466.0199999999995 sell price= 6448.5 short profit= 11.062739999999527
+date: 2018-11-12 10:47:00 No transaction profit= 0
+date: 2018-11-13 06:47:00 buy price= 6410.26 sell price= 6467.42 short profit= -63.59883999999985
+date: 2018-11-14 02:47:00 buy price= 6467.42 sell price= 6447.02 short profit= 13.942779999999635
+date: 2018-11-15 05:47:00 buy price= 6446.67 sell price= 6365.93 short profit= 74.33369999999978
+date: 2018-11-16 01:46:00 No transaction profit= 0
+date: 2018-11-16 21:46:00 buy price= 5721.34 sell price= 5694.06 long profit= -32.98769999999975
+date: 2018-11-17 17:46:00 buy price= 5694.89 sell price= 5620.92 long profit= -79.62790500000025
+date: 2018-11-18 13:46:00 buy price= 5600.52 sell price= 5620.76 long profit= 14.62935999999978
+date: 2018-11-19 09:46:00 No transaction profit= 0
+date: 2018-11-20 05:46:00 No transaction profit= 0
+date: 2018-11-21 01:46:00 buy price= 5145.550000000001 sell price= 4581.32 long profit= -569.0934350000014
+date: 2018-11-21 21:46:00 buy price= 4508.179999999999 sell price= 4571.55 long profit= 58.8301350000008
+date: 2018-11-22 17:46:00 buy price= 4571.390000000001 sell price= 4687.5 long profit= 111.48055499999876
+date: 2018-11-23 13:46:00 buy price= 4687.5 sell price= 4535.81 long profit= -156.3016549999996
+date: 2018-11-24 09:46:00 No transaction profit= 0
+date: 2018-11-25 05:46:00 No transaction profit= 0
+date: 2018-11-26 01:46:00 buy price= 4386.81 sell price= 3782.0 short profit= 600.7255950000005
+date: 2018-11-26 21:46:00 buy price= 3779.96 sell price= 4104.49 long profit= 320.58777499999974
+date: 2018-11-27 17:46:00 buy price= 3952.7999999999993 sell price= 3788.51 long profit= -168.16065499999905
+date: 2018-11-28 13:46:00 No transaction profit= 0
+date: 2018-11-29 09:46:00 buy price= 3847.71 sell price= 4230.0 long profit= 378.25114499999995
+date: 2018-11-30 05:46:00 buy price= 4230.01 sell price= 4294.46 short profit= -68.71223499999981
+date: 2018-12-01 01:46:00 No transaction profit= 0
+date: 2018-12-01 21:46:00 No transaction profit= 0
+date: 2018-12-02 17:46:00 buy price= 3978.45 sell price= 4289.54 long profit= 306.9560050000002
+date: 2018-12-03 13:46:00 No transaction profit= 0
+date: 2018-12-04 09:46:00 No transaction profit= 0
+date: 2018-12-05 05:46:00 buy price= 3822.46 sell price= 3993.09 long profit= 166.72222500000012
+date: 2018-12-06 01:46:00 No transaction profit= 0
+date: 2018-12-06 21:46:00 No transaction profit= 0
+date: 2018-12-07 17:46:00 buy price= 3777.4700000000003 sell price= 3397.01 long profit= -384.04724000000004
+date: 2018-12-08 13:46:00 No transaction profit= 0
+date: 2018-12-09 09:46:00 buy price= 3385.04 sell price= 3386.55 long profit= -1.8757949999997818
+date: 2018-12-10 05:46:00 No transaction profit= 0
+date: 2018-12-11 01:46:00 buy price= 3474.03 sell price= 3486.47 long profit= 8.9597499999996
+date: 2018-12-11 21:46:00 No transaction profit= 0
+date: 2018-12-12 17:46:00 buy price= 3449.21 sell price= 3373.24 short profit= 72.55877500000025
+date: 2018-12-13 13:46:00 buy price= 3372.01 sell price= 3465.94 long profit= 90.51102499999985
+date: 2018-12-14 09:46:00 No transaction profit= 0
+date: 2018-12-15 05:46:00 buy price= 3396.46 sell price= 3289.02 short profit= 104.09726000000006
+date: 2018-12-16 01:46:00 buy price= 3287.75 sell price= 3201.31 short profit= 83.19547000000006
+date: 2018-12-16 21:46:00 No transaction profit= 0
+date: 2018-12-17 17:46:00 No transaction profit= 0
+date: 2018-12-18 13:46:00 buy price= 3237.81 sell price= 3490.84 short profit= -256.3943250000002
+date: 2018-12-19 09:46:00 No transaction profit= 0
+date: 2018-12-20 05:46:00 No transaction profit= 0
+date: 2018-12-21 01:46:00 buy price= 3942.48 sell price= 3978.35 short profit= -39.830414999999896
+date: 2018-12-21 21:46:00 buy price= 3978.34 sell price= 3885.1 short profit= 89.30828000000024
+date: 2018-12-22 17:46:00 No transaction profit= 0
+date: 2018-12-23 13:46:00 buy price= 3843.9699999999993 sell price= 3882.98 short profit= -42.873475000000674
+date: 2018-12-24 09:46:00 No transaction profit= 0
+date: 2018-12-25 05:46:00 buy price= 3937.24 sell price= 4122.0 long profit= 180.73038000000022
+date: 2018-12-26 01:46:00 buy price= 4122.0 sell price= 3745.74 short profit= 372.32613000000026
+date: 2018-12-26 21:46:00 buy price= 3673.98 sell price= 3802.99 long profit= 125.27151499999977
+date: 2018-12-27 17:46:00 No transaction profit= 0
+date: 2018-12-28 13:46:00 No transaction profit= 0
+date: 2018-12-29 09:46:00 buy price= 3569.63 sell price= 3805.34 long profit= 232.02251500000003
+date: 2018-12-30 05:46:00 No transaction profit= 0
+date: 2018-12-31 01:46:00 No transaction profit= 0
+date: 2018-12-31 21:46:00 buy price= 3802.9 sell price= 3742.14 short profit= 56.98748000000022
+date: 2019-01-01 17:46:00 buy price= 3741.28 sell price= 3689.17 short profit= 48.394775000000124
+date: 2019-01-02 13:46:00 No transaction profit= 0
+date: 2019-01-03 09:46:00 buy price= 3729.24 sell price= 3829.2 short profit= -103.73922000000003
+date: 2019-01-04 05:46:00 buy price= 3804.5899999999997 sell price= 3813.78 long profit= 5.380815000000509
+date: 2019-01-05 01:46:00 buy price= 3813.5 sell price= 3766.91 short profit= 42.799795000000145
+date: 2019-01-05 21:46:00 buy price= 3766.91 sell price= 3834.86 short profit= -71.75088500000027
+date: 2019-01-06 17:46:00 No transaction profit= 0
+date: 2019-01-07 13:46:00 buy price= 3778.98 sell price= 3969.3 long profit= 186.44586000000018
+date: 2019-01-08 09:46:00 buy price= 3953.88 sell price= 3974.3 long profit= 16.455910000000074
+date: 2019-01-09 05:46:00 buy price= 3927.43 sell price= 4019.0 long profit= 87.59678500000017
+date: 2019-01-10 01:46:00 No transaction profit= 0
+date: 2019-01-10 21:46:00 buy price= 3985.89 sell price= 3990.32 short profit= -8.418105000000292
+date: 2019-01-11 17:46:00 No transaction profit= 0
+date: 2019-01-12 13:46:00 buy price= 3591.45 sell price= 3604.85 long profit= 9.80185000000009
+date: 2019-01-13 09:46:00 buy price= 3604.85 sell price= 3593.88 long profit= -14.569364999999799
+date: 2019-01-14 05:46:00 buy price= 3560.58 sell price= 3586.54 long profit= 22.386440000000036
+date: 2019-01-15 01:46:00 buy price= 3586.54 sell price= 3510.01 long profit= -80.07827499999975
+date: 2019-01-15 21:46:00 No transaction profit= 0
+date: 2019-01-16 17:46:00 buy price= 3625.03 sell price= 3565.6 long profit= -63.02531500000029
+date: 2019-01-17 13:46:00 buy price= 3565.59 sell price= 3584.51 short profit= -22.495050000000074
+date: 2019-01-18 09:46:00 buy price= 3577.17 sell price= 3585.68 long profit= 4.928574999999763
+date: 2019-01-19 05:46:00 No transaction profit= 0
+date: 2019-01-20 01:46:00 No transaction profit= 0
+date: 2019-01-20 21:46:00 buy price= 3613.38 sell price= 3674.54 short profit= -64.80395999999985
+date: 2019-01-21 17:46:00 buy price= 3693.4500000000003 sell price= 3532.37 short profit= 157.46709000000038
+date: 2019-01-22 13:46:00 buy price= 3533.539999999999 sell price= 3512.46 short profit= 17.556999999999018
+date: 2019-01-23 09:46:00 buy price= 3515.4300000000007 sell price= 3578.1 short profit= -66.21676499999917
+date: 2019-01-24 05:46:00 buy price= 3578.41 sell price= 3583.77 long profit= 1.7789100000001277
+date: 2019-01-25 01:46:00 No transaction profit= 0
+date: 2019-01-25 21:46:00 buy price= 3545.26 sell price= 3568.2 short profit= -26.496729999999598
+date: 2019-01-26 17:46:00 buy price= 3548.29 sell price= 3566.51 long profit= 14.662600000000253
+date: 2019-01-27 13:46:00 buy price= 3566.78 sell price= 3567.7 long profit= -2.647240000000382
+date: 2019-01-28 09:46:00 buy price= 3573.3699999999994 sell price= 3562.76 short profit= 7.041934999999217
+date: 2019-01-29 05:46:00 buy price= 3562.76 sell price= 3430.54 short profit= 128.72335000000024
+date: 2019-01-30 01:46:00 No transaction profit= 0
+date: 2019-01-30 21:46:00 buy price= 3390.09 sell price= 3439.32 short profit= -52.644705000000016
+date: 2019-01-31 17:46:00 buy price= 3440.51 sell price= 3476.52 short profit= -39.46851499999976
+date: 2019-02-01 13:46:00 buy price= 3476.48 sell price= 3437.04 short profit= 35.98324000000006
+date: 2019-02-02 09:46:00 No transaction profit= 0
+date: 2019-02-03 05:46:00 No transaction profit= 0
+date: 2019-02-04 01:46:00 buy price= 3467.26 sell price= 3456.15 long profit= -14.571705000000128
+date: 2019-02-04 21:46:00 No transaction profit= 0
+date: 2019-02-05 17:46:00 No transaction profit= 0
+date: 2019-02-06 13:46:00 buy price= 3478.84 sell price= 3462.94 short profit= 12.42911000000009
+date: 2019-02-07 09:46:00 buy price= 3468.21 sell price= 3401.94 short profit= 62.834924999999984
+date: 2019-02-08 05:46:00 buy price= 3401.73 sell price= 3408.98 short profit= -10.655355
+date: 2019-02-09 01:46:00 buy price= 3408.03 sell price= 3433.39 long profit= 21.939289999999673
+date: 2019-02-09 21:46:00 buy price= 3429.9999999999995 sell price= 3648.98 long profit= 215.44051000000047
+date: 2019-02-10 17:46:00 buy price= 3648.98 sell price= 3656.94 long profit= 4.307040000000036
+date: 2019-02-11 13:46:00 No transaction profit= 0
+date: 2019-02-12 09:46:00 buy price= 3642.0 sell price= 3634.38 long profit= -11.25818999999989
+date: 2019-02-13 05:46:00 buy price= 3634.5 sell price= 3621.47 long profit= -16.6579850000002
+date: 2019-02-14 01:46:00 buy price= 3620.46 sell price= 3622.93 long profit= -1.1516950000002
+date: 2019-02-14 21:46:00 No transaction profit= 0
+date: 2019-02-15 17:46:00 buy price= 3614.28 sell price= 3607.11 short profit= 3.559305000000072
+date: 2019-02-16 13:46:00 buy price= 3607.11 sell price= 3600.39 short profit= 3.116250000000254
+date: 2019-02-17 09:46:00 buy price= 3601.42 sell price= 3623.26 short profit= -25.452340000000145
+date: 2019-02-18 05:46:00 buy price= 3623.26 sell price= 3610.07 long profit= -16.806665000000056
+date: 2019-02-19 01:46:00 No transaction profit= 0
+date: 2019-02-19 21:46:00 buy price= 3738.2999999999997 sell price= 3879.34 long profit= 137.23118000000042
+date: 2019-02-20 17:46:00 buy price= 3872.6199999999994 sell price= 3903.13 long profit= 26.622125000000675
+date: 2019-02-21 13:46:00 buy price= 3903.59 sell price= 3950.39 long profit= 42.87300999999973
+date: 2019-02-22 09:46:00 buy price= 3937.2 sell price= 3932.94 long profit= -8.195069999999763
+date: 2019-02-23 05:46:00 buy price= 3932.94 sell price= 3978.52 long profit= 41.624269999999925
+date: 2019-02-24 01:46:00 buy price= 3978.52 sell price= 3942.53 long profit= -39.950524999999786
+date: 2019-02-24 21:46:00 buy price= 3941.8 sell price= 4168.53 long profit= 222.67483499999958
+date: 2019-02-25 17:46:00 buy price= 4168.02 sell price= 3781.29 long profit= -390.70465500000046
+date: 2019-02-26 13:46:00 buy price= 3780.95 sell price= 3832.97 short profit= -55.826959999999985
+date: 2019-02-27 09:46:00 No transaction profit= 0
+date: 2019-02-28 05:46:00 buy price= 3802.35 sell price= 3828.58 short profit= -30.045465000000018
+date: 2019-03-01 01:46:00 No transaction profit= 0
+date: 2019-03-01 21:46:00 No transaction profit= 0
+date: 2019-03-02 17:46:00 buy price= 3825.13 sell price= 3834.0 long profit= 5.040434999999891
+date: 2019-03-03 13:46:00 buy price= 3834.0 sell price= 3822.49 short profit= 7.681755000000219
+date: 2019-03-04 09:46:00 No transaction profit= 0
+date: 2019-03-05 05:46:00 buy price= 3822.6499999999996 sell price= 3714.0 short profit= 104.88167499999963
+date: 2019-03-06 01:46:00 buy price= 3714.9 sell price= 3738.76 short profit= -27.586830000000127
+date: 2019-03-06 21:46:00 buy price= 3747.63 sell price= 3836.23 short profit= -92.3919299999999
+date: 2019-03-07 17:46:00 No transaction profit= 0
+date: 2019-03-08 13:46:00 buy price= 3871.870000000001 sell price= 3882.16 long profit= 6.412984999999054
+date: 2019-03-09 09:46:00 buy price= 3882.31 sell price= 3915.2 short profit= -36.788754999999874
+date: 2019-03-10 05:46:00 buy price= 3939.96 sell price= 3925.79 short profit= 10.237125000000074
+date: 2019-03-11 01:46:00 buy price= 3925.63 sell price= 3899.6 long profit= -29.9426150000002
+date: 2019-03-11 21:46:00 buy price= 3899.91 sell price= 3900.7 long profit= -3.1103050000000363
+date: 2019-03-12 17:46:00 buy price= 3900.73 sell price= 3840.14 short profit= 56.719565000000145
+date: 2019-03-13 19:45:00 buy price= 3873.1800000000003 sell price= 3888.1 short profit= -18.800639999999618
+date: 2019-03-14 15:45:00 No transaction profit= 0
+date: 2019-03-15 11:45:00 buy price= 3866.88 sell price= 3877.03 short profit= -14.02195500000009
+date: 2019-03-16 07:45:00 buy price= 3878.1299999999997 sell price= 3926.04 short profit= -51.81208500000031
+date: 2019-03-17 03:45:00 No transaction profit= 0
+date: 2019-03-17 23:45:00 buy price= 4018.93 sell price= 3970.85 long profit= -52.074889999999925
+date: 2019-03-18 19:45:00 No transaction profit= 0
+date: 2019-03-19 15:45:00 buy price= 4012.8 sell price= 3988.0 long profit= -28.80040000000018
+date: 2019-03-20 11:45:00 No transaction profit= 0
+date: 2019-03-21 07:45:00 No transaction profit= 0
+date: 2019-03-22 03:45:00 No transaction profit= 0
+date: 2019-03-22 23:45:00 No transaction profit= 0
+date: 2019-03-23 19:45:00 buy price= 3972.98 sell price= 4000.62 short profit= -31.62679999999987
+date: 2019-03-24 15:45:00 buy price= 4001.64 sell price= 4003.7 long profit= -1.9426700000000547
+date: 2019-03-25 11:45:00 No transaction profit= 0
+date: 2019-03-26 07:45:00 No transaction profit= 0
+date: 2019-03-27 03:45:00 buy price= 3976.96 sell price= 3917.0 short profit= 56.01302000000003
+date: 2019-03-27 23:45:00 buy price= 3944.08 sell price= 3995.29 short profit= -55.179685000000035
+date: 2019-03-28 19:45:00 buy price= 3995.66 sell price= 4015.05 long profit= 15.384645000000326
+date: 2019-03-29 15:45:00 No transaction profit= 0
+date: 2019-03-30 11:45:00 No transaction profit= 0
+date: 2019-03-31 07:45:00 buy price= 4099.34 sell price= 4081.75 short profit= 13.499455000000145
+date: 2019-04-01 03:45:00 buy price= 4081.77 sell price= 4109.22 long profit= 23.354505000000273
+date: 2019-04-01 23:45:00 buy price= 4109.24 sell price= 4131.65 long profit= 18.289554999999854
+date: 2019-04-02 19:45:00 buy price= 4130.89 sell price= 4178.66 long profit= 43.615224999999526
+date: 2019-04-03 15:45:00 buy price= 4177.9 sell price= 4887.94 long profit= 705.50708
+date: 2019-04-04 11:45:00 buy price= 4887.94 sell price= 5110.59 short profit= -227.64926500000055
+date: 2019-04-05 07:45:00 buy price= 5138.060000000001 sell price= 4965.99 short profit= 167.01797500000154
+date: 2019-04-06 03:45:00 buy price= 4988.419999999999 sell price= 4987.37 short profit= -3.9378950000007276
+date: 2019-04-06 23:45:00 No transaction profit= 0
+date: 2019-04-07 19:45:00 No transaction profit= 0
+date: 2019-04-08 15:45:00 No transaction profit= 0
+date: 2019-04-09 11:45:00 No transaction profit= 0
+date: 2019-04-10 07:45:00 buy price= 5181.379999999999 sell price= 5166.42 short profit= 9.786099999999127
+date: 2019-04-11 03:45:00 buy price= 5166.42 sell price= 5201.43 long profit= 29.826075000000216
+date: 2019-04-11 23:45:00 buy price= 5339.68 sell price= 5171.65 short profit= 162.77433500000066
+date: 2019-04-12 19:45:00 No transaction profit= 0
+date: 2019-04-13 15:45:00 buy price= 4949.03 sell price= 5055.18 long profit= 101.14789500000055
+date: 2019-04-14 11:45:00 buy price= 5061.6 sell price= 5052.67 short profit= 3.8728650000002913
+date: 2019-04-15 07:45:00 No transaction profit= 0
+date: 2019-04-16 03:45:00 No transaction profit= 0
+date: 2019-04-16 23:45:00 No transaction profit= 0
+date: 2019-04-17 19:45:00 buy price= 5064.6 sell price= 5185.0 long profit= 115.27519999999963
+date: 2019-04-18 15:45:00 buy price= 5182.49 sell price= 5207.15 long profit= 19.465179999999854
+date: 2019-04-19 11:45:00 buy price= 5201.299999999999 sell price= 5264.62 long profit= 58.08704000000062
+date: 2019-04-20 07:45:00 buy price= 5263.95 sell price= 5246.53 long profit= -22.675240000000073
+date: 2019-04-21 03:45:00 No transaction profit= 0
+date: 2019-04-21 23:45:00 No transaction profit= 0
+date: 2019-04-22 19:45:00 No transaction profit= 0
+date: 2019-04-23 15:45:00 buy price= 5283.75 sell price= 5355.14 short profit= -76.70944500000033
+date: 2019-04-24 11:45:00 buy price= 5355.15 sell price= 5565.0 short profit= -215.31007500000035
+date: 2019-04-25 07:45:00 No transaction profit= 0
+date: 2019-04-26 03:45:00 buy price= 5431.27 sell price= 5423.0 long profit= -13.697135000000438
+date: 2019-04-26 23:45:00 buy price= 5355.879999999999 sell price= 5294.63 long profit= -66.57525499999909
+date: 2019-04-27 19:45:00 No transaction profit= 0
+date: 2019-04-28 15:45:00 No transaction profit= 0
+date: 2019-04-29 11:45:00 No transaction profit= 0
+date: 2019-04-30 07:45:00 buy price= 5287.01 sell price= 5240.64 short profit= 41.106174999999894
+date: 2019-05-01 03:45:00 buy price= 5239.51 sell price= 5267.26 short profit= -33.003385
+date: 2019-05-01 23:45:00 buy price= 5276.650000000001 sell price= 5348.64 short profit= -77.30264499999977
+date: 2019-05-02 19:45:00 buy price= 5337.77 sell price= 5383.83 long profit= 40.699199999999486
+date: 2019-05-03 15:45:00 buy price= 5383.83 sell price= 5501.0 short profit= -122.61241500000007
+date: 2019-05-04 11:45:00 No transaction profit= 0
+date: 2019-05-05 07:45:00 buy price= 5790.81 sell price= 5647.84 short profit= 137.25067500000026
+date: 2019-05-06 03:45:00 buy price= 5729.219999999999 sell price= 5773.32 short profit= -49.85127000000036
+date: 2019-05-06 23:45:00 buy price= 5808.509999999999 sell price= 5662.83 short profit= 139.94432999999938
+date: 2019-05-07 19:45:00 buy price= 5780.0 sell price= 5968.94 short profit= -194.81446999999957
+date: 2019-05-08 15:45:00 No transaction profit= 0
+date: 2019-05-09 11:45:00 buy price= 5789.22 sell price= 5958.88 long profit= 163.78594999999984
+date: 2019-05-10 07:45:00 buy price= 6084.360000000001 sell price= 6063.25 short profit= 15.036195000000584
+date: 2019-05-11 03:45:00 buy price= 6065.15 sell price= 6302.0 short profit= -243.03357500000038
+date: 2019-05-11 23:45:00 buy price= 6608.109999999999 sell price= 6816.98 short profit= -215.5825450000008
+date: 2019-05-12 19:45:00 buy price= 6817.0 sell price= 7136.65 short profit= -326.62682499999966
+date: 2019-05-13 15:45:00 buy price= 7189.959999999999 sell price= 6941.88 short profit= 241.014079999999
+date: 2019-05-14 11:45:00 buy price= 7046.250000000001 sell price= 7868.32 short profit= -829.5272849999989
+date: 2019-05-15 07:45:00 buy price= 8107.07 sell price= 8028.52 short profit= 70.48220499999927
+date: 2019-05-16 13:44:00 No transaction profit= 0
+date: 2019-05-17 09:44:00 No transaction profit= 0
+date: 2019-05-18 05:44:00 buy price= 7882.25 sell price= 7170.37 short profit= 704.35369
+date: 2019-05-19 01:44:00 buy price= 7171.83 sell price= 7245.82 long profit= 66.78117499999978
+date: 2019-05-19 21:44:00 buy price= 7248.44 sell price= 7896.68 long profit= 640.6674400000006
+date: 2019-05-20 17:44:00 buy price= 8021.07 sell price= 7939.32 short profit= 73.76980499999999
+date: 2019-05-21 13:44:00 buy price= 7940.92 sell price= 7998.32 short profit= -65.36961999999964
+date: 2019-05-22 09:44:00 No transaction profit= 0
+date: 2019-05-23 05:44:00 buy price= 7999.830000000001 sell price= 7838.6 short profit= 153.3107850000005
+date: 2019-05-24 01:44:00 No transaction profit= 0
+date: 2019-05-24 21:44:00 buy price= 7544.46 sell price= 7794.46 long profit= 242.33053999999998
+date: 2019-05-25 17:44:00 buy price= 7853.459999999999 sell price= 7993.16 short profit= -147.6233100000007
+date: 2019-05-26 13:44:00 buy price= 7919.220000000001 sell price= 8033.0 long profit= 105.80388999999884
+date: 2019-05-27 09:44:00 buy price= 7947.22 sell price= 7972.65 long profit= 17.47006499999938
+date: 2019-05-28 05:44:00 No transaction profit= 0
+date: 2019-05-29 01:44:00 No transaction profit= 0
+date: 2019-05-29 21:44:00 No transaction profit= 0
+date: 2019-05-30 17:44:00 buy price= 8505.73 sell price= 8615.85 short profit= -118.6807900000008
+date: 2019-05-31 13:44:00 buy price= 8616.98 sell price= 8226.2 short profit= 382.35840999999886
+date: 2019-06-01 09:44:00 buy price= 8226.2 sell price= 8417.77 long profit= 183.2480149999997
+date: 2019-06-02 05:44:00 No transaction profit= 0
+date: 2019-06-03 01:44:00 buy price= 8530.79 sell price= 8709.26 short profit= -187.09002499999934
+date: 2019-06-03 21:44:00 buy price= 8711.05 sell price= 8579.24 long profit= -140.4551449999995
+date: 2019-06-04 17:44:00 buy price= 8580.25 sell price= 7983.27 short profit= 588.6982399999996
+date: 2019-06-05 13:44:00 buy price= 7980.36 sell price= 7580.31 long profit= -407.8303349999993
+date: 2019-06-06 09:44:00 buy price= 7580.33 sell price= 7818.47 long profit= 230.44060000000033
+date: 2019-06-07 05:44:00 buy price= 7819.45 sell price= 7700.0 long profit= -127.2097249999998
+date: 2019-06-08 01:44:00 buy price= 7569.98 sell price= 7937.88 long profit= 360.1460700000006
+date: 2019-06-08 22:44:00 No transaction profit= 0
+date: 2019-06-09 18:44:00 buy price= 7907.7 sell price= 7864.29 short profit= 35.52400499999985
+date: 2019-06-10 14:44:00 buy price= 7862.76 sell price= 7568.55 long profit= -301.925655
+date: 2019-06-11 10:44:00 No transaction profit= 0
+date: 2019-06-12 06:44:00 buy price= 7917.3 sell price= 7771.64 long profit= -153.50446999999986
+date: 2019-06-13 02:44:00 buy price= 7771.04 sell price= 7947.42 short profit= -184.23923000000013
+date: 2019-06-13 22:44:00 No transaction profit= 0
+date: 2019-06-14 18:44:00 No transaction profit= 0
+date: 2019-06-15 14:44:00 buy price= 8536.82 sell price= 8612.64 short profit= -84.39472999999971
+date: 2019-06-16 10:44:00 buy price= 8612.86 sell price= 8790.0 short profit= -185.84142999999943
+date: 2019-06-17 06:44:00 buy price= 8965.779999999999 sell price= 9257.14 short profit= -300.4714600000006
+date: 2019-06-18 02:44:00 No transaction profit= 0
+date: 2019-06-18 22:44:00 buy price= 9256.820000000002 sell price= 9099.33 short profit= 148.3119250000016
+date: 2019-06-19 18:44:00 No transaction profit= 0
+date: 2019-06-20 14:44:00 No transaction profit= 0
+date: 2019-06-21 10:44:00 No transaction profit= 0
+date: 2019-06-22 06:44:00 No transaction profit= 0
+date: 2019-06-23 02:44:00 buy price= 9796.82 sell price= 10907.09 short profit= -1120.6219550000005
+date: 2019-06-23 22:44:00 buy price= 10932.540000000003 sell price= 10811.82 short profit= 109.84782000000297
+date: 2019-06-24 18:44:00 buy price= 10936.199999999999 sell price= 10721.76 short profit= 203.6110199999987
+date: 2019-06-25 14:44:00 buy price= 10870.920000000002 sell price= 11036.67 short profit= -176.7037949999982
+date: 2019-06-26 10:44:00 buy price= 11435.169999999998 sell price= 11429.87 short profit= -6.132520000002546
+date: 2019-06-27 06:44:00 buy price= 12540.14 sell price= 12894.79 short profit= -367.36746500000146
+date: 2019-06-28 02:44:00 buy price= 12894.79 sell price= 12070.03 short profit= 812.2775900000001
+date: 2019-06-28 22:44:00 buy price= 12070.03 sell price= 11506.05 short profit= 552.1919600000014
+date: 2019-06-29 18:44:00 buy price= 11820.960000000001 sell price= 11822.03 short profit= -12.891494999999711
+date: 2019-06-30 14:44:00 buy price= 12215.230000000001 sell price= 12052.83 short profit= 150.26597000000146
+date: 2019-07-01 10:44:00 No transaction profit= 0
+date: 2019-07-02 06:44:00 buy price= 10501.21 sell price= 10500.0 long profit= -11.710604999999127
+date: 2019-07-03 02:44:00 buy price= 9936.019999999999 sell price= 10038.23 long profit= 92.22287500000095
+date: 2019-07-03 22:44:00 buy price= 10038.23 sell price= 11440.75 long profit= 1391.7805100000003
+date: 2019-07-04 18:44:00 buy price= 11440.72 sell price= 11895.02 long profit= 442.6321300000011
+date: 2019-07-05 14:44:00 buy price= 11895.96 sell price= 11621.01 short profit= 263.19151499999896
+date: 2019-07-06 10:44:00 buy price= 11617.4 sell price= 11186.98 short profit= 419.0178100000001
+date: 2019-07-07 06:44:00 buy price= 11186.55 sell price= 11366.28 short profit= -191.0064150000014
+date: 2019-07-08 02:44:00 No transaction profit= 0
+date: 2019-07-08 22:44:00 No transaction profit= 0
+date: 2019-07-09 18:44:00 No transaction profit= 0
+date: 2019-07-10 14:44:00 buy price= 12608.16 sell price= 12509.39 short profit= 86.21122500000044
+date: 2019-07-11 10:44:00 buy price= 12688.689999999999 sell price= 12233.11 short profit= 443.1190999999981
+date: 2019-07-12 06:44:00 buy price= 12228.45 sell price= 11741.18 short profit= 475.28518500000047
+date: 2019-07-13 02:44:00 No transaction profit= 0
+date: 2019-07-13 22:44:00 buy price= 11618.65 sell price= 11575.83 long profit= -54.41723999999971
+date: 2019-07-14 18:44:00 buy price= 11477.060000000001 sell price= 11339.93 long profit= -148.538495000001
+date: 2019-07-15 14:44:00 buy price= 11063.650000000001 sell price= 10575.32 long profit= -499.1494850000018
+date: 2019-07-16 10:44:00 buy price= 10083.39 sell price= 10841.78 long profit= 747.9274150000012
+date: 2019-07-17 06:44:00 buy price= 10718.870000000003 sell price= 10456.9 long profit= -272.557885000003
+date: 2019-07-18 02:44:00 buy price= 10414.46 sell price= 9301.25 long profit= -1123.067854999999
+date: 2019-07-18 22:44:00 buy price= 9065.35 sell price= 9879.2 long profit= 804.3777250000003
+date: 2019-07-19 18:44:00 No transaction profit= 0
+date: 2019-07-20 14:44:00 buy price= 10593.65 sell price= 10474.62 long profit= -129.56413499999886
+date: 2019-07-21 10:44:00 No transaction profit= 0
+date: 2019-07-22 06:44:00 buy price= 10920.43 sell price= 10405.14 short profit= 504.6272150000009
+date: 2019-07-23 02:44:00 No transaction profit= 0
+date: 2019-07-23 22:44:00 No transaction profit= 0
+date: 2019-07-24 18:44:00 buy price= 9935.33 sell price= 9695.94 long profit= -249.20563499999943
+date: 2019-07-25 14:44:00 buy price= 9695.94 sell price= 9773.75 long profit= 68.07515499999948
+date: 2019-07-26 10:44:00 No transaction profit= 0
+date: 2019-07-27 06:44:00 buy price= 9990.0 sell price= 9735.68 long profit= -264.1828399999997
+date: 2019-07-28 02:44:00 No transaction profit= 0
+date: 2019-07-28 22:44:00 No transaction profit= 0
+date: 2019-07-29 18:44:00 buy price= 9580.49 sell price= 9646.27 short profit= -75.39338000000066
+date: 2019-07-30 14:44:00 No transaction profit= 0
+date: 2019-07-31 10:44:00 No transaction profit= 0
+date: 2019-08-01 06:44:00 buy price= 9626.12 sell price= 9949.11 short profit= -332.7776149999998
+date: 2019-08-02 02:44:00 buy price= 9949.11 sell price= 9928.69 short profit= 10.48110000000007
+date: 2019-08-02 22:44:00 buy price= 10072.279999999999 sell price= 10474.7 short profit= -412.6934900000019
+date: 2019-08-03 18:44:00 buy price= 10474.88 sell price= 10765.0 short profit= -300.7399400000008
+date: 2019-08-04 14:44:00 buy price= 10869.36 sell price= 10820.46 short profit= 38.05509000000146
+date: 2019-08-05 10:44:00 No transaction profit= 0
+date: 2019-08-06 06:44:00 buy price= 10928.99 sell price= 11763.25 short profit= -845.6061200000003
+date: 2019-08-07 02:44:00 buy price= 12309.26 sell price= 11849.2 short profit= 447.9807699999995
+date: 2019-08-07 22:44:00 No transaction profit= 0
+date: 2019-08-08 18:44:00 buy price= 11695.369999999999 sell price= 11930.35 short profit= -246.79286000000138
+date: 2019-08-09 14:44:00 No transaction profit= 0
+date: 2019-08-10 10:44:00 No transaction profit= 0
+date: 2019-08-11 06:44:00 buy price= 11825.18 sell price= 11400.0 long profit= -436.7925900000003
+date: 2019-08-12 02:44:00 buy price= 11190.71 sell price= 11344.85 long profit= 142.87222000000122
+date: 2019-08-12 22:44:00 buy price= 11344.83 sell price= 11395.36 long profit= 39.159905000000656
+date: 2019-08-13 18:44:00 buy price= 11261.929999999998 sell price= 11401.13 long profit= 127.86847000000071
+date: 2019-08-14 14:44:00 buy price= 11400.88 sell price= 10887.37 long profit= -524.6541249999983
+date: 2019-08-15 10:44:00 buy price= 10462.010000000002 sell price= 10197.69 long profit= -274.6498500000015
+date: 2019-08-16 14:43:00 buy price= 10142.54 sell price= 10360.0 long profit= 207.20872999999912
+date: 2019-08-17 10:43:00 buy price= 10360.0 sell price= 10416.27 long profit= 45.88186500000044
+date: 2019-08-18 06:43:00 buy price= 10416.54 sell price= 10331.62 long profit= -95.29408000000006
+date: 2019-08-19 02:43:00 No transaction profit= 0
+date: 2019-08-19 22:43:00 No transaction profit= 0
+date: 2019-08-20 18:43:00 buy price= 10576.189999999997 sell price= 10863.0 short profit= -297.52959500000316
+date: 2019-08-21 14:43:00 No transaction profit= 0
+date: 2019-08-22 10:43:00 buy price= 10813.94 sell price= 10092.03 short profit= 711.4570149999998
+date: 2019-08-23 06:43:00 buy price= 10093.51 sell price= 10062.07 long profit= -41.51779000000051
+date: 2019-08-24 02:43:00 buy price= 10062.6 sell price= 10122.03 long profit= 49.33768500000029
+date: 2019-08-24 22:43:00 buy price= 10122.05 sell price= 10316.26 long profit= 183.99084500000095
+date: 2019-08-25 18:43:00 buy price= 10264.45 sell price= 10120.02 long profit= -154.6222350000003
+date: 2019-08-26 14:43:00 No transaction profit= 0
+date: 2019-08-27 10:43:00 No transaction profit= 0
+date: 2019-08-28 06:43:00 buy price= 10302.3 sell price= 10168.67 long profit= -143.8654849999992
+date: 2019-08-29 02:43:00 buy price= 10167.83 sell price= 10133.0 long profit= -44.98041499999992
+date: 2019-08-29 22:43:00 buy price= 10133.02 sell price= 9536.87 short profit= 586.3150549999997
+date: 2019-08-30 18:43:00 buy price= 9456.850000000002 sell price= 9427.7 long profit= -38.59227500000146
+date: 2019-08-31 14:43:00 buy price= 9427.7 sell price= 9582.9 long profit= 145.6946999999989
+date: 2019-09-01 10:43:00 No transaction profit= 0
+date: 2019-09-02 06:43:00 buy price= 9537.020000000002 sell price= 9579.47 long profit= 32.89175499999709
+date: 2019-09-03 02:43:00 No transaction profit= 0
+date: 2019-09-03 22:43:00 buy price= 9786.64 sell price= 10379.77 short profit= -603.213205000001
+date: 2019-09-04 18:43:00 buy price= 10534.969999999998 sell price= 10538.49 short profit= -14.056730000002254
+date: 2019-09-05 14:43:00 buy price= 10538.0 sell price= 10547.35 short profit= -19.892675000000366
+date: 2019-09-06 10:43:00 buy price= 10554.13 sell price= 10527.64 short profit= 15.949114999999782
+date: 2019-09-07 06:43:00 buy price= 10734.769999999999 sell price= 10844.79 short profit= -120.80978000000225
+date: 2019-09-08 02:43:00 No transaction profit= 0
+date: 2019-09-08 22:43:00 buy price= 10358.27 sell price= 10527.96 long profit= 159.24688499999868
+date: 2019-09-09 18:43:00 buy price= 10529.53 sell price= 10339.5 long profit= -200.46451500000066
+date: 2019-09-10 14:43:00 buy price= 10338.45 sell price= 10332.32 short profit= -4.205384999998982
+date: 2019-09-11 10:43:00 No transaction profit= 0
+date: 2019-09-12 06:43:00 No transaction profit= 0
+date: 2019-09-13 02:43:00 buy price= 10012.3 sell price= 10146.35 long profit= 123.9706750000011
+date: 2019-09-13 22:43:00 No transaction profit= 0
+date: 2019-09-14 18:43:00 buy price= 10292.809999999998 sell price= 10295.0 long profit= -8.10390499999767
+date: 2019-09-15 14:43:00 buy price= 10295.02 sell price= 10338.82 short profit= -54.11691999999927
+date: 2019-09-16 10:43:00 No transaction profit= 0
+date: 2019-09-17 06:43:00 buy price= 10288.72 sell price= 10147.03 long profit= -151.90787499999868
+date: 2019-09-18 02:43:00 buy price= 10147.94 sell price= 10176.88 long profit= 18.777589999998693
+date: 2019-09-18 22:43:00 buy price= 10176.88 sell price= 10198.0 short profit= -31.3074400000008
+date: 2019-09-19 18:43:00 No transaction profit= 0
+date: 2019-09-20 14:43:00 buy price= 10106.5 sell price= 10237.8 short profit= -141.47214999999926
+date: 2019-09-21 10:43:00 buy price= 10095.850000000002 sell price= 10150.11 long profit= 44.1370199999984
+date: 2019-09-22 06:43:00 buy price= 10150.11 sell price= 10000.4 long profit= -159.78525500000094
+date: 2019-09-23 02:43:00 buy price= 10021.520000000002 sell price= 10005.39 short profit= 6.116545000002837
+date: 2019-09-23 22:43:00 buy price= 10005.39 sell price= 9908.8 short profit= 86.63290500000015
+date: 2019-09-24 18:43:00 No transaction profit= 0
+Final total capital= 104761.20254500002
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [15]:
+
+
+
past_history = 35 
+
+
+
+last_day=len(df['TIME'])
+
+
+
+
+day=500
+k=day
+#for k in range(3000):
+
+h=0
+y=0
+z=0
+u=0
+
+
+
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        if trend>0 and trend_real>0:
+            h+=1
+            y+=1
+            
+        if trend>0 and trend_real<0:
+            h=h
+            y+=1
+        if trend<0 and trend_real<0:
+            z+=1
+            u+=1
+        if trend<0 and trend_real>0:
+            z=z
+            u+=1
+        
+        
+        
+        
+        
+        
+    k=k-1
+    
+print('accuracy of buy=',h/y)   
+    
+print('accuracy of sell=',z/u) 
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
accuracy of buy= 0.6378600823045267
+accuracy of sell= 0.6108949416342413
+
+
+
+ +
+
+ +
+
+
+
In [30]:
+
+
+
past_history = 35 
+
+
+
+last_day=len(df['TIME'])
+
+
+
+
+day=500
+k=day
+#for k in range(3000):
+
+h=0
+y=0
+z=0
+u=0
+
+H=[0]
+Z=[0]
+
+a=0
+
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        if trend>0 and trend_real>0:
+            h+=1
+            y+=1
+            
+        if trend>0 and trend_real<0:
+            h=h
+            y+=1
+        if trend<0 and trend_real<0:
+            z+=1
+            u+=1
+        if trend<0 and trend_real>0:
+            z=z
+            u+=1
+        
+        a+=1
+        
+        if a%15==0:
+            #print("counter=",a)
+            
+            H=np.vstack((H,h/y))
+            h=0
+            y=0
+            Z=np.vstack((Z,z/u))
+            z=0
+            u=0
+        
+        
+    k=k-1
+    
+H=H[1:]
+Z=Z[1:]
+
+print('success rate of buying in every 15 units',H)
+print('success rate of selling in every 15 units',Z)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
success rate of buying in every 15 units [[0.64285714]
+ [0.875     ]
+ [0.5       ]
+ [0.77777778]
+ [0.8       ]
+ [0.5       ]
+ [0.33333333]
+ [0.75      ]
+ [0.55555556]
+ [0.9       ]
+ [0.75      ]
+ [1.        ]
+ [1.        ]
+ [0.5       ]
+ [0.66666667]
+ [0.44444444]
+ [0.5       ]
+ [0.5       ]
+ [0.57142857]
+ [0.85714286]
+ [0.88888889]
+ [0.6       ]
+ [1.        ]
+ [0.85714286]
+ [0.45454545]
+ [1.        ]
+ [0.75      ]
+ [0.44444444]
+ [0.55555556]
+ [0.5       ]
+ [0.41666667]
+ [0.5       ]
+ [0.55555556]]
+success rate of selling in every 15 units [[1.        ]
+ [0.71428571]
+ [1.        ]
+ [0.66666667]
+ [0.7       ]
+ [0.42857143]
+ [0.58333333]
+ [0.63636364]
+ [0.66666667]
+ [0.8       ]
+ [0.85714286]
+ [0.77777778]
+ [0.5       ]
+ [0.57142857]
+ [0.66666667]
+ [0.33333333]
+ [0.4       ]
+ [0.45454545]
+ [0.625     ]
+ [0.75      ]
+ [1.        ]
+ [0.5       ]
+ [0.57142857]
+ [0.625     ]
+ [0.5       ]
+ [0.58333333]
+ [0.45454545]
+ [0.83333333]
+ [0.5       ]
+ [0.54545455]
+ [0.66666667]
+ [0.42857143]
+ [0.33333333]]
+
+
+
+ +
+
+ +
+
+
+
In [20]:
+
+
+
from scipy import stats
+stats.ttest_1samp(H,0.5)               #t test of buying success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[20]:
+ + + + +
+
Ttest_1sampResult(statistic=array([4.74463751]), pvalue=array([4.16818035e-05]))
+
+ +
+ +
+
+ +
+
+
+
In [21]:
+
+
+
stats.ttest_1samp(Z,0.5)               #t test of selling success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[21]:
+ + + + +
+
Ttest_1sampResult(statistic=array([4.02327216]), pvalue=array([0.00032805]))
+
+ +
+ +
+
+ +
+
+
+
In [24]:
+
+
+
import numpy as np, scipy.stats as st
+st.t.interval(0.95, len(H)-1, loc=np.mean(H), scale=st.sem(H))      #95% Confidence interval of buying success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[24]:
+ + + + +
+
(array([0.59419808]), array([0.73592348]))
+
+ +
+ +
+
+ +
+
+
+
In [25]:
+
+
+
import numpy as np, scipy.stats as st
+st.t.interval(0.95, len(Z)-1, loc=np.mean(Z), scale=st.sem(Z))       #95% Confidence interval of selling success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[25]:
+ + + + +
+
(array([0.56243887]), array([0.69049741]))
+
+ +
+ +
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+ + + + + + diff --git a/ETH_LSTM.html b/ETH_LSTM.html new file mode 100644 index 0000000..4d0b200 --- /dev/null +++ b/ETH_LSTM.html @@ -0,0 +1,15267 @@ + + + + +ETH_LSTM + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
In [1]:
+
+
+
from __future__ import absolute_import, division, print_function, unicode_literals
+try:
+  # %tensorflow_version only exists in Colab.
+  %tensorflow_version 2.x
+except Exception:
+  pass
+import tensorflow as tf
+
+import matplotlib as mpl
+import matplotlib.pyplot as plt
+import numpy as np
+import os
+import pandas as pd
+
+mpl.rcParams['figure.figsize'] = (8, 6)     #初始化设置,应该是展示图片大小
+
+mpl.rcParams['axes.grid'] = False
+
+ +
+
+
+ +
+
+
+
In [2]:
+
+
+
import pandas as pd 
+import numpy as np
+df= pd.read_excel("data_summary.xlsx", sheet_name=1)
+
+ +
+
+
+ +
+
+
+
In [3]:
+
+
+
df=np.array(df)
+df=pd.DataFrame(df)
+close_price=df[4]
+
+
+CLOSE=[0]
+
+frequency=1200     #1440min合成1条k线
+
+for i in range(len(close_price)):
+    if (i+1) %frequency==0:
+        CLOSE=np.vstack((CLOSE,close_price[i]))
+
+CLOSE=CLOSE[1:]    
+
+
+#open_price=df['open']
+
+open_price=df[1]
+
+
+
+OPEN=[0]
+
+for i in range(len(close_price)):
+    if (i+1) %frequency==0:
+        OPEN=np.vstack((OPEN,open_price[i-(frequency-1)]))
+
+OPEN=OPEN[1:]    
+
+
+#high_price=df['high']
+high_price=df[2]
+
+
+HIGH=[0]
+
+for i in range(len(high_price)):
+    if (i+1) %frequency==0:
+        HIGH=np.vstack((HIGH,max(high_price[i-(frequency-1):i+1])))
+
+HIGH=HIGH[1:]  
+
+#low_price=df['low']
+low_price=df[3]
+
+LOW=[0]
+
+for i in range(len(low_price)):
+    if (i+1) %frequency==0:
+        LOW=np.vstack((LOW,min(low_price[i-(frequency-1):i+1])))
+
+LOW=LOW[1:]
+
+#time=df['time']
+time=df[0]
+
+TIME=[0]
+
+for i in range(len(time)):
+    if (i+1) %frequency==0:
+        TIME=np.vstack((TIME,time[i]))
+
+TIME=TIME[1:] 
+
+ +
+
+
+ +
+
+
+
In [4]:
+
+
+
data=np.hstack((TIME,CLOSE,HIGH,LOW,OPEN))
+data=pd.DataFrame(data)
+data.columns = ["TIME", "C","H","L","O"]
+df=data
+
+ +
+
+
+ +
+
+
+
In [5]:
+
+
+
zero=np.array([0])
+rt=np.diff(np.array(df['C']))
+rt=np.hstack((zero,rt))
+df.insert(5, 'Diff_C', rt) 
+
+moving_avg = df['Diff_C'].rolling(window=5).mean(center=True)
+MV=moving_avg[2:len(rt)-2]
+zeros=np.zeros((4))
+MV=np.hstack((zeros,MV))
+df.insert(6, 'MV_C', MV) 
+df[0:10]
+
+ +
+
+
+ +
+
+ + +
+ +
Out[5]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TIMECHLODiff_CMV_C
02018-02-10 21:59:00893.14900781.66781.6600.000
12018-02-11 18:12:00818.91911.2800893.15-74.230.000
22018-02-12 14:45:00832.82857768.28818.4113.910.000
32018-02-13 10:45:00857.98874805832.8225.160.000
42018-02-14 06:45:00849.43877.56820857.95-8.55-8.742
52018-02-15 02:45:00861.81870.17833.64849.4312.38-6.266
62018-02-15 22:45:00933.6935.31860.03861.9471.7922.938
72018-02-16 18:45:00946.63948.48895.59933.913.0322.762
82018-02-17 14:45:00940.45947.29901.36946.64-6.1816.494
92018-02-18 10:45:00962.32974933.48940.4721.8722.578
+
+
+ +
+ +
+
+ +
+
+
+
In [6]:
+
+
+
features_considered=['MV_C']
+
+features = df[features_considered]                       
+features.index = df['TIME']        #在前面加一列时间
+
+dataset = features.values
+TRAIN_SPLIT = (len(df)*7)//10      #first 70% of the rows in dataset will be the training dataset
+tf.random.set_seed(13)     # 保持random selection每次都一样
+EVALUATION_INTERVAL = 2400       #原来是200
+EPOCHS = 10       #1个epoch等于使用训练集中的全部样本训练一次,通俗的讲epoch的值就是整个数据集被轮几次。
+BATCH_SIZE = 256           #训练的小批次, iteration=TRAIN_SPLIT/256
+BUFFER_SIZE = 10000       #缓存容量 
+def multivariate_data(dataset, target, start_index, end_index, history_size,
+                      target_size, step, single_step=False):         
+    data = []
+    labels = []
+
+    start_index = start_index + history_size
+    if end_index is None:
+        end_index = len(dataset) - target_size
+
+    for i in range(start_index, end_index):
+        indices = range(i-history_size, i, step)             #就是在取过去天数的样本时,是间隔着几天取的,这样可以减少训练时间
+        data.append(dataset[indices])
+
+        if single_step:
+            labels.append(target[i+target_size])                #就是说,这里可以规定只预测后面某一天或者是后面好几天
+        else:
+            labels.append(target[i:i+target_size])               
+
+    return np.array(data), np.array(labels)        #output 出numpy格式的数据
+
+past_history = 35         # 用过去50天的数据,本来是720
+future_target = 0            #本来是72  预测12天后的数据,或者是下一天到12天后的数据   72/6=12
+STEP = 1                    #本来是6,取过去天数的样本时,是间隔着6天取的,这样可以减少训练时间
+
+#future_target = 1          # 预测12天后的数据,或者是下一天到12天后的数据   72/6=12
+#STEP = 1                     #取过去天数的样本时,是间隔着6天取的,这样可以减少训练时间
+
+
+x_train_single, y_train_single = multivariate_data(dataset, dataset[:, 0], 0,
+                                                   TRAIN_SPLIT, past_history,
+                                                   future_target, STEP,
+                                                   single_step=True)
+x_val_single, y_val_single = multivariate_data(dataset, dataset[:, 0],
+                                               TRAIN_SPLIT, None, past_history,
+                                               future_target, STEP,
+                                               single_step=True)
+
+train_data_single = tf.data.Dataset.from_tensor_slices((x_train_single, y_train_single))              
+train_data_single = train_data_single.cache().shuffle(BUFFER_SIZE).batch(BATCH_SIZE).repeat()      #traning data 
+
+val_data_single = tf.data.Dataset.from_tensor_slices((x_val_single, y_val_single))
+val_data_single = val_data_single.batch(BATCH_SIZE).repeat()                        #validation data 
+
+
+single_step_model = tf.keras.models.Sequential()
+single_step_model.add(tf.keras.layers.LSTM(6,
+                                           input_shape=x_train_single.shape[-2:]))    #应该是这一层有32 个神经元
+single_step_model.add(tf.keras.layers.Dense(1))                         #output layer, 因为预测未来1 期的data, 所以是1个神经元
+
+single_step_model.compile(optimizer=tf.keras.optimizers.RMSprop(), loss='mae')    #这里优化算法用RMSprop而不是Adam 或 Momentum
+
+single_step_history = single_step_model.fit(train_data_single, epochs=EPOCHS,      #EPOCHS = 10  轮10次
+                                            steps_per_epoch=EVALUATION_INTERVAL,    #每轮test 200次 data
+                                            validation_data=val_data_single, 
+                                            validation_steps=50)      #设置验证多少次数据后取平均值作为此epoch训练后的效果 
+
+def plot_train_history(history, title):             #把training lost 和validation loss 表示出来
+  loss = history.history['loss']             
+  val_loss = history.history['val_loss']
+
+  epochs = range(len(loss))
+
+  plt.figure()
+
+  plt.plot(epochs, loss, 'b', label='Training loss')
+  plt.plot(epochs, val_loss, 'r', label='Validation loss')
+  plt.title(title)
+  plt.legend()
+
+  plt.show()
+
+plot_train_history(single_step_history,
+                   'Single Step Training and validation loss')
+
+single_step_model.save('ETH_1200.h5') 
+model = tf.keras.models.load_model('ETH_1200.h5')
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
Train for 2400 steps, validate for 50 steps
+Epoch 1/10
+2400/2400 [==============================] - 74s 31ms/step - loss: 3.7916 - val_loss: 1.7344
+Epoch 2/10
+2400/2400 [==============================] - 82s 34ms/step - loss: 2.9100 - val_loss: 1.7483
+Epoch 3/10
+2400/2400 [==============================] - 86s 36ms/step - loss: 2.7351 - val_loss: 1.7777
+Epoch 4/10
+2400/2400 [==============================] - 66s 27ms/step - loss: 2.6562 - val_loss: 1.7890
+Epoch 5/10
+2400/2400 [==============================] - 79s 33ms/step - loss: 2.6003 - val_loss: 1.8241
+Epoch 6/10
+2400/2400 [==============================] - 71s 30ms/step - loss: 2.5469 - val_loss: 1.8386
+Epoch 7/10
+2400/2400 [==============================] - 51s 21ms/step - loss: 2.4999 - val_loss: 1.8333
+Epoch 8/10
+2400/2400 [==============================] - 45s 19ms/step - loss: 2.4756 - val_loss: 1.8101
+Epoch 9/10
+2400/2400 [==============================] - 51s 21ms/step - loss: 2.4548 - val_loss: 1.8069
+Epoch 10/10
+2400/2400 [==============================] - 81s 34ms/step - loss: 2.4328 - val_loss: 1.8056
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [11]:
+
+
+
df['TIME']#
+
+R1=[0]
+R2=[0]
+
+
+past_history = 35 
+TC=100000       #总资金10万
+
+C=1             #每次交易1手
+
+
+leverage=1
+
+cost_rate=0.0005
+
+
+price_per_point=1       #1点300元
+
+last_day=len(df['TIME'])
+
+
+m=0
+n=0
+p=0
+r=0
+R=0
+s=0
+
+I=0
+B=0
+RR=[0]
+II=[0]
+BB=[0]
+tt=0
+t=0
+d=3
+d2=3
+
+rr=[0]
+maximum_markdown_final=[0]
+CR=1
+CRR=[0]
+TCC=[0]
+
+day=600
+k=day
+#for k in range(3000):
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        #print(data2)
+
+        #j=[0,0,0,0,0]
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        #trend=x[0][0]-MV[-1-k]-MV[-2-k]                #预测正负
+        
+        #trend_real=MV[-k]-MV[-1-k]-MV[-2-k]           #实际正负
+        
+        #P0=np.array(df['C'])[-7-k]
+        #P1=np.array(df['C'])[-6-k]
+        #P2=np.array(df['C'])[-5-k]
+        #P5=np.array(df['C'])[-2-k]
+        #P6=np.array(df['C'])[-1-k]
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        P0=np.array(df['C'])[-6-k]
+        P1=np.array(df['C'])[-5-k]
+        P5=np.array(df['C'])[-1-k]
+        
+        
+        
+        
+        
+        #line=P6+P5+P2-P1-P0
+        
+        line=P5+P1-P0
+        
+        L=np.array(df['L'])[-k]
+        H=np.array(df['H'])[-k]
+        
+        if trend<0:
+            if P5-d2>line and (np.array(df['O'])[-k])-d2>line:
+                r1=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+               
+                
+                
+            else:
+                if L<line<H:
+                    r1=((np.array(df['C'])[-k])-(line))/(line)                      #r1必须小于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                   
+                else:
+                    r1=0
+                    maximum_markdown=0
+                       
+            
+            if r1!=0:
+                m+=1
+                R1=np.vstack((R1,r1))
+                
+            
+            if r1<0:
+                n+=1
+            r=r+r1
+            R=R-r1
+            
+        else:
+            r1=0
+            r=r
+            R=R
+            maximum_markdown=0
+           
+        
+        if trend>0:
+            
+            
+            if P5<line-d and (np.array(df['O'])[-k])<line-d:
+                r2=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+               
+            else:
+                if L<line<H:
+                    r2=((np.array(df['C'])[-k])-(line))/(line)    #r2必须大于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                   
+                else:
+                    r2=0
+                    maximum_markdown=0
+                    profit2=0
+                    
+                   
+            
+            if r2!=0:
+                m+=1
+                s+=1
+                
+                R2=np.vstack((R2,r2))
+            
+            if r2>0:
+                p+=1
+            R=R+r2
+        else:
+            R=R
+            r2=0
+            maximum_markdown=0
+            profit2=0
+            
+            
+        
+        
+        i=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+        I=I+i
+        
+        b=((np.array(df['C'])[-k])-(np.array(df['C'])[-k-1]))/(np.array(df['C'])[-k-1])
+        B=B+b
+        
+        
+        BB=np.vstack((BB,B))
+        RR=np.vstack((RR,R))  
+        II=np.vstack((II,I))
+        
+        maximum_markdown_final=np.vstack((maximum_markdown_final,maximum_markdown))
+        rr=np.vstack((rr,r2))
+        
+        if r1!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        if r2!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        
+        CRR=np.vstack((CRR,(CR-1)*10))
+    k=k-1
+    
+    
+
+    
+    
+    
+RR=RR[1:]
+II=II[1:]
+tt=tt[1:]
+
+R1=R1[1:]
+R2=R2[1:]
+
+
+plt.plot(tt,RR)               
+#plt.plot(tt,II) 
+BB=BB[1:]
+plt.plot(tt,BB)
+
+
+  
+maximum_markdown_final=maximum_markdown_final[1:]        
+#plt.plot(tt,maximum_markdown_final)  
+final_maximum=min(maximum_markdown_final)
+rr=rr[1:]
+maximum_loss=min(rr) 
+
+     
+print("trading dates=",m)
+print("success to sell=",n)
+print("success to buy=",p)
+print('return from short=',-r)
+print('total return of long and short=',R)
+print('Time of long',s)      
+print('maximum markdown=',final_maximum)
+print('maximum loss=',maximum_loss)
+
+print('compound interest=',CR-1)
+
+import numpy as np, scipy.stats as st
+CI_R1=st.t.interval(0.9, len(R1)-1, loc=np.mean(R1), scale=st.sem(R1))      #90% Confidence interval of short
+CI_R2=st.t.interval(0.9, len(R2)-1, loc=np.mean(R2), scale=st.sem(R2))      #90% Confidence interval of long
+
+print("confidence interval of short=",CI_R1)
+print("confidence interval of long=",CI_R2)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
trading dates= 362
+success to sell= 95
+success to buy= 108
+return from short= 0.2565772858739267
+total return of long and short= 0.5318179674927612
+Time of long 189
+maximum markdown= [-0.2172579]
+maximum loss= [-0.17849651]
+compound interest= -0.37606075964991137
+confidence interval of short= (array([-0.00773758]), array([0.00477137]))
+confidence interval of long= (array([-0.00324313]), array([0.00615573]))
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [12]:
+
+
+
#
+
+TC=100000       #总资金10万
+
+C=1             #每次交易1手
+
+
+leverage=1
+
+cost_rate=0.0005
+
+
+price_per_point=1       #1点300元
+
+last_day=len(df['TIME'])
+
+
+m=0
+n=0
+p=0
+r=0
+R=0
+s=0
+
+I=0
+B=100000
+RR=[0]
+II=[0]
+BB=[0]
+tt=0
+t=0
+d=3
+d2=3
+
+rr=[0]
+maximum_markdown_final=[0]
+CR=1
+CRR=[0]
+TCC=[0]
+
+day=600
+k=day
+#for k in range(3000):
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        #print(data2)
+
+        #j=[0,0,0,0,0]
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        #trend=x[0][0]-MV[-1-k]-MV[-2-k]                #预测正负
+        
+        #trend_real=MV[-k]-MV[-1-k]-MV[-2-k]           #实际正负
+        
+        #P0=np.array(df['C'])[-7-k]
+        #P1=np.array(df['C'])[-6-k]
+        #P2=np.array(df['C'])[-5-k]
+        #P5=np.array(df['C'])[-2-k]
+        #P6=np.array(df['C'])[-1-k]
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        P0=np.array(df['C'])[-6-k]
+        P1=np.array(df['C'])[-5-k]
+        P5=np.array(df['C'])[-1-k]
+        
+        
+        
+        
+        
+        #line=P6+P5+P2-P1-P0
+        
+        line=P5+P1-P0
+        
+        L=np.array(df['L'])[-k]
+        H=np.array(df['H'])[-k]
+        
+        if trend<0:
+            if P5-d2>line and (np.array(df['O'])[-k])-d2>line:
+                r1=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+                profit1=C*(((np.array(df['O'])[-k])*price_per_point-np.array(df['C'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(np.array(df['O'])[-k])*price_per_point*cost_rate)
+                
+                print('date:',df['TIME'][last_day-k],'buy price=',(np.array(df['O'])[-k]),"sell price=",(np.array(df['C'])[-k]),'short profit=',profit1)
+                
+                
+            else:
+                if L<line<H:
+                    r1=((np.array(df['C'])[-k])-(line))/(line)                      #r1必须小于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                    profit1=C*(((line)*price_per_point-np.array(df['C'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(line)*price_per_point*cost_rate)
+                    print('date:',df['TIME'][last_day-k],'buy price=',(line),"sell price=",(np.array(df['C'])[-k]),'short profit=',profit1)
+                    
+                else:
+                    r1=0
+                    maximum_markdown=0
+                    profit1=0
+                    
+                    print('date:',df['TIME'][last_day-k],'No transaction','profit=',0)
+            
+            
+            if r1!=0:
+                m+=1
+                
+            
+            if r1<0:
+                n+=1
+            r=r+r1
+            R=R-r1
+            
+        else:
+            r1=0
+            r=r
+            R=R
+            maximum_markdown=0
+            profit1=0
+            
+        
+        if trend>0:
+            
+            
+            if P5<line-d and (np.array(df['O'])[-k])<line-d:
+                r2=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+                profit2=C*((np.array(df['C'])[-k])*price_per_point-(np.array(df['O'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(np.array(df['O'])[-k])*price_per_point*cost_rate)
+                
+                print('date:',df['TIME'][last_day-k],'buy price=',(np.array(df['O'])[-k]),"sell price=",(np.array(df['C'])[-k]),'long profit=',profit2)
+                
+                
+            else:
+                if L<line<H:
+                    r2=((np.array(df['C'])[-k])-(line))/(line)    #r2必须大于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                    profit2=(np.array(df['C'])[-k])*price_per_point-(line)*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(line)*price_per_point*cost_rate
+                    
+                    print('date:',df['TIME'][last_day-k],'buy price=',(line),"sell price=",(np.array(df['C'])[-k]),'long profit=',profit2)
+                    
+                else:
+                    r2=0
+                    maximum_markdown=0
+                    profit2=0
+                    
+                    print('date:',df['TIME'][last_day-k],'No transaction','profit=',0)
+            
+            
+            if r2!=0:
+                m+=1
+                s+=1
+            
+            if r2>0:
+                p+=1
+            R=R+r2
+        else:
+            R=R
+            r2=0
+            maximum_markdown=0
+            profit2=0
+            
+            
+        TC=TC+profit1+profit2
+        TCC=np.vstack((TCC,TC))
+        
+        i=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+        I=I+i
+        
+        b=((np.array(df['C'])[-k])-(np.array(df['C'])[-k-1]))
+        B=B+b
+        
+        
+        BB=np.vstack((BB,B))
+        RR=np.vstack((RR,R))  
+        II=np.vstack((II,I))
+        
+        maximum_markdown_final=np.vstack((maximum_markdown_final,maximum_markdown))
+        rr=np.vstack((rr,r2))
+        
+        if r1!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        if r2!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        
+        CRR=np.vstack((CRR,(CR-1)*10))
+    k=k-1
+    
+    
+
+    
+    
+    
+RR=RR[1:]
+II=II[1:]
+tt=tt[1:]
+
+TCC=TCC[1:]
+
+
+
+#plt.plot(tt,RR)               
+#plt.plot(tt,II) 
+plt.plot(tt,TCC) 
+BB=BB[1:]
+plt.plot(tt,BB)
+
+
+  
+maximum_markdown_final=maximum_markdown_final[1:]        
+#plt.plot(tt,maximum_markdown_final)  
+final_maximum=min(maximum_markdown_final)
+rr=rr[1:]
+maximum_loss=min(rr) 
+
+     
+
+
+print("Final total capital=",TC)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
date: 2018-05-11 02:45:00 buy price= 747.31 sell price= 764.5 short profit= -17.945905000000053
+date: 2018-05-11 22:45:00 buy price= 722.1899999999999 sell price= 721.59 long profit= -1.321889999999909
+date: 2018-05-12 18:45:00 buy price= 713.26 sell price= 682.51 long profit= -31.447885
+date: 2018-05-13 14:45:00 buy price= 684.07 sell price= 683.83 long profit= -0.9239500000000092
+date: 2018-05-14 10:45:00 buy price= 686.1499999999999 sell price= 734.06 short profit= -48.62010500000008
+date: 2018-05-15 06:45:00 No transaction profit= 0
+date: 2018-05-16 02:45:00 No transaction profit= 0
+date: 2018-05-16 22:45:00 buy price= 736.1 sell price= 685.01 short profit= 50.37944500000003
+date: 2018-05-17 18:45:00 buy price= 686.3300000000002 sell price= 713.76 long profit= 26.729954999999837
+date: 2018-05-18 14:45:00 No transaction profit= 0
+date: 2018-05-19 10:45:00 buy price= 673.8700000000001 sell price= 681.19 long profit= 6.6424699999999355
+date: 2018-05-20 06:45:00 buy price= 681.36 sell price= 706.65 short profit= -25.984004999999964
+date: 2018-05-21 02:45:00 No transaction profit= 0
+date: 2018-05-21 22:45:00 buy price= 714.65 sell price= 715.82 long profit= 0.4547650000000728
+date: 2018-05-22 18:45:00 No transaction profit= 0
+date: 2018-05-23 14:45:00 No transaction profit= 0
+date: 2018-05-24 10:45:00 buy price= 666.02 sell price= 585.3 short profit= 80.09434000000003
+date: 2018-05-25 06:45:00 buy price= 585.3 sell price= 587.33 long profit= 1.4436850000000865
+date: 2018-05-26 02:45:00 buy price= 588.3600000000001 sell price= 592.05 long profit= 3.099794999999827
+date: 2018-05-26 22:45:00 No transaction profit= 0
+date: 2018-05-27 18:45:00 No transaction profit= 0
+date: 2018-05-28 14:45:00 No transaction profit= 0
+date: 2018-05-29 10:45:00 buy price= 569.74 sell price= 525.29 long profit= -44.99751500000004
+date: 2018-05-30 06:45:00 buy price= 525.34 sell price= 557.81 long profit= 31.928424999999912
+date: 2018-05-31 02:45:00 buy price= 553.4399999999998 sell price= 570.89 long profit= 16.88783500000016
+date: 2018-05-31 22:45:00 buy price= 566.57 sell price= 577.4 long profit= 10.258014999999927
+date: 2018-06-01 18:45:00 No transaction profit= 0
+date: 2018-06-02 14:45:00 No transaction profit= 0
+date: 2018-06-03 10:45:00 No transaction profit= 0
+date: 2018-06-04 06:45:00 buy price= 590.92 sell price= 621.8 long profit= 30.273639999999997
+date: 2018-06-05 02:45:00 No transaction profit= 0
+date: 2018-06-05 22:45:00 buy price= 602.0499999999998 sell price= 586.08 long profit= -16.5640649999998
+date: 2018-06-06 18:45:00 buy price= 586.08 sell price= 606.39 long profit= 19.713764999999945
+date: 2018-06-07 14:45:00 No transaction profit= 0
+date: 2018-06-08 10:45:00 No transaction profit= 0
+date: 2018-06-09 06:45:00 No transaction profit= 0
+date: 2018-06-10 02:45:00 No transaction profit= 0
+date: 2018-06-10 22:45:00 No transaction profit= 0
+date: 2018-06-11 18:45:00 buy price= 571.63 sell price= 529.01 short profit= 42.069680000000005
+date: 2018-06-12 14:45:00 buy price= 531.42 sell price= 522.05 short profit= 8.843265000000004
+date: 2018-06-13 10:45:00 buy price= 522.24 sell price= 509.34 short profit= 12.384210000000033
+date: 2018-06-14 06:45:00 buy price= 509.34 sell price= 471.21 long profit= -38.62027499999999
+date: 2018-06-15 02:45:00 No transaction profit= 0
+date: 2018-06-15 22:45:00 No transaction profit= 0
+date: 2018-06-16 18:45:00 buy price= 500.5899999999999 sell price= 493.94 long profit= -7.147264999999921
+date: 2018-06-17 14:45:00 No transaction profit= 0
+date: 2018-06-18 10:45:00 No transaction profit= 0
+date: 2018-06-19 06:45:00 buy price= 500.54 sell price= 496.01 long profit= -5.028275000000029
+date: 2018-06-20 02:45:00 buy price= 496.05 sell price= 524.07 long profit= 27.50994000000004
+date: 2018-06-20 22:45:00 buy price= 524.55 sell price= 521.13 short profit= 2.897159999999959
+date: 2018-06-21 18:45:00 buy price= 521.5 sell price= 542.95 long profit= 20.917775000000045
+date: 2018-06-22 14:45:00 buy price= 543.84 sell price= 526.37 short profit= 16.934895000000026
+date: 2018-06-23 10:45:00 buy price= 526.37 sell price= 473.78 short profit= 52.08992500000003
+date: 2018-06-24 06:45:00 No transaction profit= 0
+date: 2018-06-25 02:45:00 buy price= 468.05999999999995 sell price= 441.8 short profit= 25.805069999999933
+date: 2018-06-25 22:45:00 No transaction profit= 0
+date: 2018-06-27 04:45:00 No transaction profit= 0
+date: 2018-06-28 00:44:00 No transaction profit= 0
+date: 2018-06-28 22:28:00 buy price= 431.53999999999996 sell price= 432.28 long profit= 0.3080900000000091
+date: 2018-06-29 18:28:00 No transaction profit= 0
+date: 2018-06-30 14:28:00 buy price= 421.28 sell price= 424.18 long profit= 2.477270000000034
+date: 2018-07-01 10:28:00 No transaction profit= 0
+date: 2018-07-02 06:28:00 No transaction profit= 0
+date: 2018-07-03 02:28:00 buy price= 446.5399999999999 sell price= 449.97 long profit= 2.9817450000001204
+date: 2018-07-03 22:28:00 buy price= 449.97 sell price= 479.4 short profit= -29.89468499999995
+date: 2018-07-05 02:05:00 No transaction profit= 0
+date: 2018-07-05 22:04:00 buy price= 467.0 sell price= 471.66 long profit= 4.190670000000025
+date: 2018-07-06 18:04:00 buy price= 474.81 sell price= 466.74 short profit= 7.5992249999999935
+date: 2018-07-07 14:04:00 buy price= 468.13000000000005 sell price= 469.51 short profit= -1.8488199999999386
+date: 2018-07-08 10:04:00 No transaction profit= 0
+date: 2018-07-09 06:04:00 No transaction profit= 0
+date: 2018-07-10 02:04:00 buy price= 492.46000000000004 sell price= 480.21 short profit= 11.763665000000056
+date: 2018-07-10 22:04:00 buy price= 480.41 sell price= 457.16 short profit= 22.781215
+date: 2018-07-11 18:04:00 No transaction profit= 0
+date: 2018-07-12 14:04:00 buy price= 438.44 sell price= 439.4 short profit= -1.3989199999999795
+date: 2018-07-13 10:04:00 buy price= 439.39 sell price= 430.0 long profit= -9.824694999999986
+date: 2018-07-14 06:04:00 buy price= 422.41 sell price= 436.6 long profit= 13.760494999999999
+date: 2018-07-15 02:04:00 No transaction profit= 0
+date: 2018-07-15 22:04:00 No transaction profit= 0
+date: 2018-07-16 18:04:00 buy price= 438.33000000000004 sell price= 445.0 long profit= 6.228334999999959
+date: 2018-07-17 14:04:00 No transaction profit= 0
+date: 2018-07-18 10:04:00 buy price= 482.68000000000006 sell price= 509.07 short profit= -26.88587499999993
+date: 2018-07-19 06:04:00 buy price= 502.86 sell price= 494.03 long profit= -9.32844500000004
+date: 2018-07-20 02:04:00 No transaction profit= 0
+date: 2018-07-20 22:04:00 No transaction profit= 0
+date: 2018-07-21 18:04:00 No transaction profit= 0
+date: 2018-07-22 14:04:00 No transaction profit= 0
+date: 2018-07-23 10:04:00 No transaction profit= 0
+date: 2018-07-24 06:04:00 buy price= 464.86 sell price= 462.5 short profit= 1.8963200000000136
+date: 2018-07-25 02:04:00 No transaction profit= 0
+date: 2018-07-25 22:04:00 buy price= 470.36 sell price= 482.5 short profit= -12.616429999999987
+date: 2018-07-26 18:04:00 No transaction profit= 0
+date: 2018-07-27 14:04:00 buy price= 475.10999999999996 sell price= 466.62 long profit= -8.960864999999952
+date: 2018-07-28 10:04:00 buy price= 464.16 sell price= 467.19 short profit= -3.4956749999999728
+date: 2018-07-29 06:04:00 No transaction profit= 0
+date: 2018-07-30 02:04:00 buy price= 464.75 sell price= 464.24 long profit= -0.9744949999999909
+date: 2018-07-30 22:04:00 No transaction profit= 0
+date: 2018-07-31 18:04:00 buy price= 455.25 sell price= 453.49 long profit= -2.214369999999991
+date: 2018-08-01 14:04:00 buy price= 454.06000000000006 sell price= 431.34 long profit= -23.162700000000083
+date: 2018-08-02 10:04:00 buy price= 428.52000000000004 sell price= 418.3 short profit= 9.796590000000029
+date: 2018-08-03 06:04:00 buy price= 418.16999999999996 sell price= 409.49 short profit= 8.26616999999995
+date: 2018-08-04 02:04:00 buy price= 409.49 sell price= 408.21 long profit= -1.6888500000000295
+date: 2018-08-04 22:04:00 No transaction profit= 0
+date: 2018-08-05 18:04:00 No transaction profit= 0
+date: 2018-08-06 14:04:00 No transaction profit= 0
+date: 2018-08-07 10:04:00 buy price= 403.12000000000006 sell price= 403.86 long profit= 0.33650999999995224
+date: 2018-08-08 06:04:00 buy price= 402.5799999999999 sell price= 408.08 long profit= 5.094670000000057
+date: 2018-08-09 02:04:00 buy price= 408.08 sell price= 368.05 long profit= -40.41806499999997
+date: 2018-08-09 22:04:00 buy price= 368.42 sell price= 361.33 short profit= 6.725125000000031
+date: 2018-08-10 18:04:00 No transaction profit= 0
+date: 2018-08-11 14:04:00 buy price= 361.65 sell price= 327.43 short profit= 33.87545999999997
+date: 2018-08-12 10:04:00 buy price= 331.65 sell price= 325.44 short profit= 5.8814549999999794
+date: 2018-08-13 06:04:00 buy price= 325.44 sell price= 320.49 short profit= 4.627034999999989
+date: 2018-08-14 02:04:00 buy price= 313.7699999999999 sell price= 319.08 long profit= 4.993575000000059
+date: 2018-08-14 22:04:00 buy price= 319.39000000000004 sell price= 262.38 long profit= -57.300885000000044
+date: 2018-08-15 18:04:00 No transaction profit= 0
+date: 2018-08-16 14:04:00 buy price= 280.71999999999997 sell price= 291.18 long profit= 10.174050000000037
+date: 2018-08-17 10:04:00 buy price= 286.2300000000001 sell price= 291.07 long profit= 4.5513499999999185
+date: 2018-08-18 06:04:00 buy price= 289.65999999999997 sell price= 297.42 long profit= 7.466460000000048
+date: 2018-08-19 02:04:00 No transaction profit= 0
+date: 2018-08-19 22:04:00 No transaction profit= 0
+date: 2018-08-20 18:04:00 buy price= 293.2 sell price= 302.74 long profit= 9.242030000000021
+date: 2018-08-21 14:04:00 buy price= 302.62999999999994 sell price= 283.84 short profit= 18.496764999999964
+date: 2018-08-22 10:04:00 No transaction profit= 0
+date: 2018-08-23 06:04:00 buy price= 285.7300000000001 sell price= 285.11 short profit= 0.3345800000000614
+date: 2018-08-24 02:04:00 buy price= 285.03 sell price= 271.72 short profit= 13.031624999999947
+date: 2018-08-24 22:04:00 buy price= 271.81 sell price= 275.44 long profit= 3.3563749999999954
+date: 2018-08-25 18:04:00 No transaction profit= 0
+date: 2018-08-26 14:04:00 No transaction profit= 0
+date: 2018-08-27 10:04:00 buy price= 277.62 sell price= 272.1 long profit= -5.794859999999982
+date: 2018-08-28 06:04:00 No transaction profit= 0
+date: 2018-08-29 02:04:00 buy price= 279.69000000000005 sell price= 285.5 short profit= -6.092594999999946
+date: 2018-08-29 22:04:00 buy price= 291.34999999999997 sell price= 292.4 short profit= -1.3418750000000113
+date: 2018-08-30 18:04:00 buy price= 292.4 sell price= 288.58 short profit= 3.5295099999999935
+date: 2018-08-31 14:04:00 buy price= 288.57 sell price= 283.97 short profit= 4.313729999999966
+date: 2018-09-01 10:04:00 buy price= 287.84000000000003 sell price= 283.23 short profit= 4.324465000000014
+date: 2018-09-02 06:04:00 No transaction profit= 0
+date: 2018-09-03 02:04:00 buy price= 293.19000000000005 sell price= 296.75 short profit= -3.8549699999999456
+date: 2018-09-03 22:04:00 buy price= 296.65 sell price= 289.53 short profit= 6.826910000000005
+date: 2018-09-04 18:04:00 buy price= 289.53 sell price= 290.87 short profit= -1.6302000000000318
+date: 2018-09-05 14:04:00 buy price= 290.13 sell price= 285.57 short profit= 4.272150000000003
+date: 2018-09-06 10:04:00 No transaction profit= 0
+date: 2018-09-07 06:04:00 No transaction profit= 0
+date: 2018-09-08 02:04:00 buy price= 230.45 sell price= 224.28 short profit= 5.942634999999988
+date: 2018-09-08 22:04:00 No transaction profit= 0
+date: 2018-09-09 18:04:00 buy price= 217.26 sell price= 193.83 short profit= 23.224454999999978
+date: 2018-09-10 14:04:00 No transaction profit= 0
+date: 2018-09-11 10:04:00 No transaction profit= 0
+date: 2018-09-12 06:04:00 No transaction profit= 0
+date: 2018-09-13 02:04:00 buy price= 183.92 sell price= 172.83 long profit= -11.268374999999976
+date: 2018-09-13 22:04:00 No transaction profit= 0
+date: 2018-09-14 18:04:00 buy price= 189.53 sell price= 214.89 long profit= 25.157789999999988
+date: 2018-09-15 14:04:00 buy price= 208.57999999999998 sell price= 213.68 long profit= 4.888870000000023
+date: 2018-09-16 10:04:00 buy price= 215.11 sell price= 225.99 long profit= 10.659449999999996
+date: 2018-09-17 06:04:00 buy price= 225.91 sell price= 216.25 short profit= 9.438919999999998
+date: 2018-09-18 02:04:00 No transaction profit= 0
+date: 2018-09-18 22:04:00 No transaction profit= 0
+date: 2018-09-19 18:04:00 buy price= 195.65000000000003 sell price= 211.67 short profit= -16.223659999999953
+date: 2018-09-20 14:04:00 buy price= 211.64 sell price= 209.6 long profit= -2.250619999999992
+date: 2018-09-21 10:04:00 No transaction profit= 0
+date: 2018-09-22 06:04:00 buy price= 208.46 sell price= 227.32 long profit= 18.642109999999985
+date: 2018-09-23 02:04:00 buy price= 227.39 sell price= 239.1 short profit= -11.943245000000008
+date: 2018-09-23 22:04:00 No transaction profit= 0
+date: 2018-09-24 18:04:00 No transaction profit= 0
+date: 2018-09-25 14:04:00 buy price= 243.45000000000002 sell price= 232.69 short profit= 10.521930000000019
+date: 2018-09-26 10:04:00 No transaction profit= 0
+date: 2018-09-27 06:04:00 buy price= 209.37 sell price= 213.89 long profit= 4.308369999999982
+date: 2018-09-28 02:04:00 buy price= 215.23999999999998 sell price= 212.38 short profit= 2.6461899999999856
+date: 2018-09-28 22:04:00 buy price= 212.37 sell price= 230.65 long profit= 18.058490000000003
+date: 2018-09-29 18:04:00 buy price= 218.73000000000002 sell price= 217.39 long profit= -1.5580600000000318
+date: 2018-09-30 14:04:00 No transaction profit= 0
+date: 2018-10-01 10:04:00 buy price= 236.92000000000002 sell price= 234.22 short profit= 2.464430000000017
+date: 2018-10-02 06:04:00 buy price= 232.71000000000004 sell price= 227.61 long profit= -5.330160000000023
+date: 2018-10-03 02:04:00 No transaction profit= 0
+date: 2018-10-03 22:04:00 buy price= 228.84 sell price= 219.24 short profit= 9.375959999999994
+date: 2018-10-04 18:04:00 No transaction profit= 0
+date: 2018-10-05 14:04:00 No transaction profit= 0
+date: 2018-10-06 10:04:00 No transaction profit= 0
+date: 2018-10-07 06:04:00 buy price= 224.29999999999995 sell price= 224.0 long profit= -0.5241499999999545
+date: 2018-10-08 02:04:00 No transaction profit= 0
+date: 2018-10-08 22:04:00 No transaction profit= 0
+date: 2018-10-09 18:04:00 No transaction profit= 0
+date: 2018-10-10 14:04:00 buy price= 230.07000000000002 sell price= 228.53 short profit= 1.3107000000000204
+date: 2018-10-11 10:04:00 No transaction profit= 0
+date: 2018-10-12 06:04:00 buy price= 225.75 sell price= 202.63 short profit= 22.905810000000006
+date: 2018-10-13 02:04:00 buy price= 204.05999999999997 sell price= 197.24 long profit= -7.020649999999965
+date: 2018-10-13 22:04:00 buy price= 197.26 sell price= 199.71 long profit= 2.2515150000000173
+date: 2018-10-14 18:04:00 No transaction profit= 0
+date: 2018-10-15 14:04:00 buy price= 198.93000000000004 sell price= 199.42 long profit= 0.29082499999995226
+date: 2018-10-16 10:04:00 No transaction profit= 0
+date: 2018-10-17 06:04:00 buy price= 210.79000000000002 sell price= 214.3 long profit= 3.297454999999991
+date: 2018-10-18 02:04:00 buy price= 216.76999999999998 sell price= 213.69 long profit= -3.295229999999984
+date: 2018-10-18 22:04:00 buy price= 214.91 sell price= 213.14 short profit= 1.55597500000001
+date: 2018-10-19 18:04:00 buy price= 211.62999999999994 sell price= 205.77 short profit= 5.651299999999929
+date: 2018-10-20 17:33:00 No transaction profit= 0
+date: 2018-10-21 13:33:00 No transaction profit= 0
+date: 2018-10-22 09:33:00 No transaction profit= 0
+date: 2018-10-23 05:33:00 buy price= 207.73999999999995 sell price= 205.6 long profit= -2.3466699999999583
+date: 2018-10-24 01:33:00 No transaction profit= 0
+date: 2018-10-24 21:33:00 buy price= 202.55999999999997 sell price= 207.57 short profit= -5.21506500000002
+date: 2018-10-25 17:33:00 No transaction profit= 0
+date: 2018-10-26 13:33:00 buy price= 205.52999999999997 sell price= 204.21 long profit= -1.5248699999999646
+date: 2018-10-27 09:33:00 No transaction profit= 0
+date: 2018-10-28 05:33:00 No transaction profit= 0
+date: 2018-10-29 01:33:00 No transaction profit= 0
+date: 2018-10-29 21:33:00 No transaction profit= 0
+date: 2018-10-30 17:33:00 buy price= 203.50000000000003 sell price= 196.93 long profit= -6.770215000000022
+date: 2018-10-31 13:33:00 buy price= 197.29999999999998 sell price= 196.72 long profit= -0.7770099999999841
+date: 2018-11-01 09:33:00 buy price= 197.16 sell price= 198.61 long profit= 1.2521150000000172
+date: 2018-11-02 05:33:00 buy price= 197.97 sell price= 198.44 long profit= 0.2717949999999989
+date: 2018-11-03 01:33:00 buy price= 198.95 sell price= 200.16 long profit= 1.010445000000008
+date: 2018-11-03 21:33:00 No transaction profit= 0
+date: 2018-11-04 17:33:00 buy price= 201.0 sell price= 200.01 short profit= 0.789495000000009
+date: 2018-11-05 13:33:00 buy price= 201.9 sell price= 212.65 short profit= -10.957275
+date: 2018-11-06 09:33:00 buy price= 212.48000000000002 sell price= 209.38 short profit= 2.8890700000000225
+date: 2018-11-07 05:33:00 buy price= 211.09999999999997 sell price= 215.51 short profit= -4.623305000000025
+date: 2018-11-08 01:33:00 buy price= 216.56000000000003 sell price= 222.14 short profit= -5.799349999999955
+date: 2018-11-08 21:33:00 buy price= 220.93999999999997 sell price= 215.67 short profit= 5.051694999999982
+date: 2018-11-09 17:33:00 No transaction profit= 0
+date: 2018-11-10 13:33:00 buy price= 213.17 sell price= 210.49 short profit= 2.4681699999999784
+date: 2018-11-11 09:33:00 No transaction profit= 0
+date: 2018-11-12 05:33:00 No transaction profit= 0
+date: 2018-11-13 01:33:00 No transaction profit= 0
+date: 2018-11-13 21:33:00 buy price= 209.83 sell price= 212.01 long profit= 1.9690799999999782
+date: 2018-11-14 17:33:00 buy price= 209.29 sell price= 209.98 short profit= -0.8996349999999977
+date: 2018-11-15 20:32:00 No transaction profit= 0
+date: 2018-11-16 16:32:00 buy price= 175.93 sell price= 183.66 short profit= -7.909794999999989
+date: 2018-11-17 12:32:00 buy price= 183.32999999999998 sell price= 177.37 long profit= -6.140349999999979
+date: 2018-11-18 08:32:00 buy price= 177.09 sell price= 175.12 long profit= -2.1461049999999986
+date: 2018-11-19 04:32:00 No transaction profit= 0
+date: 2018-11-20 00:32:00 No transaction profit= 0
+date: 2018-11-20 20:32:00 buy price= 156.05 sell price= 151.08 long profit= -5.123564999999999
+date: 2018-11-21 16:32:00 buy price= 144.79000000000005 sell price= 132.19 long profit= -12.738490000000052
+date: 2018-11-22 12:32:00 buy price= 129.94 sell price= 135.43 long profit= 5.35731500000001
+date: 2018-11-23 08:32:00 buy price= 137.87 sell price= 132.02 long profit= -5.984944999999994
+date: 2018-11-24 04:32:00 No transaction profit= 0
+date: 2018-11-25 00:32:00 No transaction profit= 0
+date: 2018-11-25 20:32:00 buy price= 124.99 sell price= 108.61 short profit= 16.263199999999998
+date: 2018-11-26 16:32:00 buy price= 111.85000000000002 sell price= 121.32 short profit= -9.586584999999971
+date: 2018-11-27 12:32:00 buy price= 117.91 sell price= 111.54 long profit= -6.48472499999999
+date: 2018-11-28 08:32:00 buy price= 103.91999999999999 sell price= 105.9 long profit= 1.8750900000000181
+date: 2018-11-29 04:32:00 buy price= 106.48999999999998 sell price= 115.07 long profit= 8.469220000000012
+date: 2018-11-30 00:32:00 No transaction profit= 0
+date: 2018-11-30 20:32:00 No transaction profit= 0
+date: 2018-12-01 16:32:00 No transaction profit= 0
+date: 2018-12-02 12:32:00 buy price= 113.38 sell price= 118.73 short profit= -5.466055000000008
+date: 2018-12-03 08:32:00 No transaction profit= 0
+date: 2018-12-04 04:32:00 buy price= 117.15 sell price= 113.83 long profit= -3.4354900000000073
+date: 2018-12-05 00:32:00 buy price= 110.53 sell price= 111.57 long profit= 0.9289499999999921
+date: 2018-12-05 20:32:00 buy price= 106.87999999999998 sell price= 107.53 long profit= 0.5427950000000199
+date: 2018-12-06 16:32:00 buy price= 107.53 sell price= 102.97 long profit= -4.665250000000002
+date: 2018-12-07 12:32:00 buy price= 101.39999999999999 sell price= 97.32 long profit= -4.179359999999998
+date: 2018-12-08 08:32:00 buy price= 93.98999999999998 sell price= 83.35 long profit= -10.728669999999987
+date: 2018-12-09 04:32:00 No transaction profit= 0
+date: 2018-12-10 00:32:00 buy price= 87.45 sell price= 90.69 short profit= -3.329069999999995
+date: 2018-12-10 20:32:00 No transaction profit= 0
+date: 2018-12-11 16:32:00 No transaction profit= 0
+date: 2018-12-12 12:32:00 No transaction profit= 0
+date: 2018-12-13 08:32:00 No transaction profit= 0
+date: 2018-12-14 04:32:00 No transaction profit= 0
+date: 2018-12-15 00:32:00 No transaction profit= 0
+date: 2018-12-15 20:32:00 buy price= 84.0 sell price= 84.84 long profit= 0.7555800000000034
+date: 2018-12-16 16:32:00 buy price= 82.15999999999998 sell price= 84.1 long profit= 1.856870000000012
+date: 2018-12-17 12:32:00 buy price= 84.07 sell price= 86.32 long profit= 2.1648050000000003
+date: 2018-12-18 08:32:00 buy price= 85.94 sell price= 91.86 long profit= 5.831100000000001
+date: 2018-12-19 04:32:00 buy price= 91.86 sell price= 92.76 short profit= -0.9923100000000057
+date: 2018-12-20 00:32:00 No transaction profit= 0
+date: 2018-12-20 20:32:00 buy price= 99.77000000000001 sell price= 100.69 short profit= -1.0202299999999875
+date: 2018-12-21 16:32:00 buy price= 102.91 sell price= 110.99 short profit= -8.18695
+date: 2018-12-22 12:32:00 buy price= 116.53 sell price= 107.13 short profit= 9.288170000000004
+date: 2018-12-23 08:32:00 buy price= 108.02999999999999 sell price= 108.62 short profit= -0.6983250000000176
+date: 2018-12-24 04:32:00 buy price= 116.36999999999999 sell price= 127.6 short profit= -11.351985000000004
+date: 2018-12-25 00:32:00 buy price= 127.77999999999999 sell price= 146.7 short profit= -19.057240000000004
+date: 2018-12-25 20:32:00 buy price= 157.0 sell price= 125.41 short profit= 31.448795000000004
+date: 2018-12-26 16:32:00 buy price= 121.55 sell price= 127.27 long profit= 5.59559
+date: 2018-12-27 12:32:00 buy price= 128.76 sell price= 128.25 short profit= 0.3814949999999909
+date: 2018-12-28 08:32:00 No transaction profit= 0
+date: 2018-12-29 04:32:00 buy price= 123.14 sell price= 115.15 long profit= -8.109144999999994
+date: 2018-12-30 00:32:00 buy price= 115.15 sell price= 135.75 short profit= -20.725449999999995
+date: 2018-12-30 20:32:00 buy price= 137.60999999999999 sell price= 132.4 short profit= 5.074994999999979
+date: 2018-12-31 16:32:00 buy price= 133.38 sell price= 137.0 short profit= -3.7551900000000047
+date: 2019-01-01 12:32:00 buy price= 137.0 sell price= 130.76 short profit= 6.106120000000009
+date: 2019-01-02 08:32:00 buy price= 130.76 sell price= 133.16 short profit= -2.531960000000006
+date: 2019-01-03 04:32:00 No transaction profit= 0
+date: 2019-01-04 00:32:00 buy price= 147.43 sell price= 150.91 short profit= -3.6291699999999896
+date: 2019-01-04 20:32:00 No transaction profit= 0
+date: 2019-01-05 16:32:00 buy price= 149.97 sell price= 156.92 short profit= -7.103444999999988
+date: 2019-01-06 12:32:00 No transaction profit= 0
+date: 2019-01-07 08:32:00 No transaction profit= 0
+date: 2019-01-08 04:32:00 buy price= 154.60999999999999 sell price= 150.85 short profit= 3.607269999999991
+date: 2019-01-09 00:32:00 buy price= 149.91 sell price= 146.95 short profit= 2.8115700000000077
+date: 2019-01-09 20:32:00 No transaction profit= 0
+date: 2019-01-10 16:32:00 buy price= 149.04000000000005 sell price= 148.2 long profit= -0.9886200000000603
+date: 2019-01-11 12:32:00 buy price= 144.01 sell price= 126.36 long profit= -17.78518499999999
+date: 2019-01-12 08:32:00 buy price= 126.09999999999997 sell price= 125.06 short profit= 0.9144199999999637
+date: 2019-01-13 04:32:00 No transaction profit= 0
+date: 2019-01-14 00:32:00 buy price= 124.89 sell price= 123.22 long profit= -1.7940550000000017
+date: 2019-01-14 20:32:00 buy price= 120.75999999999996 sell price= 116.4 long profit= -4.478579999999957
+date: 2019-01-15 16:32:00 No transaction profit= 0
+date: 2019-01-16 12:32:00 buy price= 126.31000000000002 sell price= 120.1 long profit= -6.333205000000023
+date: 2019-01-17 08:32:00 buy price= 119.93 sell price= 120.84 long profit= 0.7896149999999965
+date: 2019-01-18 04:32:00 buy price= 119.17 sell price= 119.66 long profit= 0.3705849999999949
+date: 2019-01-19 00:32:00 No transaction profit= 0
+date: 2019-01-19 20:32:00 No transaction profit= 0
+date: 2019-01-20 16:32:00 No transaction profit= 0
+date: 2019-01-21 12:32:00 buy price= 123.12 sell price= 117.0 short profit= 5.999940000000004
+date: 2019-01-22 08:32:00 buy price= 115.82 sell price= 116.37 long profit= 0.43390500000001136
+date: 2019-01-23 04:32:00 No transaction profit= 0
+date: 2019-01-24 00:32:00 No transaction profit= 0
+date: 2019-01-24 20:32:00 No transaction profit= 0
+date: 2019-01-25 16:32:00 No transaction profit= 0
+date: 2019-01-26 12:32:00 buy price= 115.9 sell price= 114.96 short profit= 0.824570000000012
+date: 2019-01-27 08:32:00 No transaction profit= 0
+date: 2019-01-28 04:32:00 No transaction profit= 0
+date: 2019-01-29 00:32:00 buy price= 112.00999999999999 sell price= 106.29 long profit= -5.829149999999984
+date: 2019-01-29 20:32:00 No transaction profit= 0
+date: 2019-01-30 16:32:00 buy price= 102.78 sell price= 104.04 long profit= 1.1565900000000051
+date: 2019-01-31 12:32:00 buy price= 104.62000000000002 sell price= 108.4 long profit= 3.6734899999999873
+date: 2019-02-01 08:32:00 buy price= 106.83 sell price= 106.02 long profit= -0.9164250000000023
+date: 2019-02-02 04:32:00 No transaction profit= 0
+date: 2019-02-03 00:32:00 No transaction profit= 0
+date: 2019-02-03 20:32:00 No transaction profit= 0
+date: 2019-02-04 16:32:00 No transaction profit= 0
+date: 2019-02-05 12:32:00 No transaction profit= 0
+date: 2019-02-06 08:32:00 No transaction profit= 0
+date: 2019-02-07 04:32:00 buy price= 105.56 sell price= 103.19 long profit= -2.474375000000004
+date: 2019-02-08 00:32:00 buy price= 103.16 sell price= 105.28 long profit= 2.015780000000005
+date: 2019-02-08 20:32:00 No transaction profit= 0
+date: 2019-02-09 16:32:00 buy price= 105.60000000000001 sell price= 118.91 long profit= 13.197744999999989
+date: 2019-02-10 12:32:00 No transaction profit= 0
+date: 2019-02-11 08:32:00 buy price= 118.78 sell price= 117.49 short profit= 1.1718650000000062
+date: 2019-02-12 04:32:00 buy price= 119.57999999999998 sell price= 121.3 short profit= -1.8404400000000132
+date: 2019-02-13 00:32:00 buy price= 120.69 sell price= 120.58 short profit= -0.010635000000000575
+date: 2019-02-13 20:32:00 No transaction profit= 0
+date: 2019-02-14 16:32:00 buy price= 122.87 sell price= 122.96 short profit= -0.2129149999999892
+date: 2019-02-15 12:32:00 buy price= 121.66999999999999 sell price= 120.86 short profit= 0.6887349999999881
+date: 2019-02-16 08:32:00 No transaction profit= 0
+date: 2019-02-17 04:32:00 No transaction profit= 0
+date: 2019-02-18 00:32:00 No transaction profit= 0
+date: 2019-02-18 20:32:00 buy price= 124.13 sell price= 137.16 short profit= -13.160645000000002
+date: 2019-02-19 16:32:00 No transaction profit= 0
+date: 2019-02-20 12:32:00 buy price= 148.7 sell price= 146.04 short profit= 2.5126299999999966
+date: 2019-02-21 08:32:00 buy price= 147.32999999999998 sell price= 147.32 long profit= -0.1573249999999909
+date: 2019-02-22 04:32:00 buy price= 148.77 sell price= 144.49 short profit= 4.133370000000001
+date: 2019-02-23 00:32:00 No transaction profit= 0
+date: 2019-02-23 20:32:00 No transaction profit= 0
+date: 2019-02-24 16:32:00 No transaction profit= 0
+date: 2019-02-25 12:32:00 buy price= 160.11999999999998 sell price= 139.11 short profit= 20.86038499999996
+date: 2019-02-26 08:32:00 buy price= 136.28000000000003 sell price= 137.77 long profit= 1.3529749999999805
+date: 2019-02-27 04:32:00 buy price= 139.39 sell price= 135.68 long profit= -3.8475349999999793
+date: 2019-02-28 00:32:00 buy price= 136.45999999999998 sell price= 138.53 long profit= 1.9325050000000215
+date: 2019-02-28 20:32:00 buy price= 138.53 sell price= 136.67 long profit= -1.9976000000000136
+date: 2019-03-01 16:32:00 No transaction profit= 0
+date: 2019-03-02 12:32:00 No transaction profit= 0
+date: 2019-03-03 08:32:00 buy price= 134.54 sell price= 132.57 long profit= -2.103554999999999
+date: 2019-03-04 04:32:00 No transaction profit= 0
+date: 2019-03-05 00:32:00 buy price= 131.69000000000003 sell price= 126.41 long profit= -5.40905000000003
+date: 2019-03-05 20:32:00 buy price= 125.61999999999998 sell price= 126.07 long profit= 0.32415500000001707
+date: 2019-03-06 16:32:00 buy price= 126.82 sell price= 135.62 long profit= 8.668780000000012
+date: 2019-03-07 12:32:00 buy price= 135.65 sell price= 136.7 short profit= -1.1861749999999829
+date: 2019-03-08 08:32:00 buy price= 137.68 sell price= 137.02 short profit= 0.5226499999999966
+date: 2019-03-09 04:32:00 buy price= 137.04 sell price= 136.28 short profit= 0.6233399999999909
+date: 2019-03-10 00:32:00 buy price= 135.94000000000003 sell price= 136.97 short profit= -1.1664549999999727
+date: 2019-03-10 20:32:00 No transaction profit= 0
+date: 2019-03-11 16:32:00 No transaction profit= 0
+date: 2019-03-12 12:32:00 buy price= 135.98000000000002 sell price= 132.4 long profit= -3.7141900000000123
+date: 2019-03-13 14:31:00 buy price= 131.66 sell price= 133.61 long profit= 1.817365000000017
+date: 2019-03-14 10:31:00 No transaction profit= 0
+date: 2019-03-15 06:31:00 buy price= 130.94999999999996 sell price= 131.23 long profit= 0.1489100000000296
+date: 2019-03-16 02:31:00 No transaction profit= 0
+date: 2019-03-16 22:31:00 No transaction profit= 0
+date: 2019-03-17 18:31:00 No transaction profit= 0
+date: 2019-03-18 14:31:00 No transaction profit= 0
+date: 2019-03-19 10:31:00 buy price= 138.68999999999997 sell price= 137.82 short profit= 0.7317449999999761
+date: 2019-03-20 06:31:00 No transaction profit= 0
+date: 2019-03-21 02:31:00 No transaction profit= 0
+date: 2019-03-21 22:31:00 No transaction profit= 0
+date: 2019-03-22 18:31:00 No transaction profit= 0
+date: 2019-03-23 14:31:00 No transaction profit= 0
+date: 2019-03-24 10:31:00 buy price= 136.82 sell price= 136.7 long profit= -0.25676000000000454
+date: 2019-03-25 06:31:00 buy price= 136.14 sell price= 136.37 long profit= 0.0937450000000182
+date: 2019-03-26 02:31:00 No transaction profit= 0
+date: 2019-03-26 22:31:00 buy price= 131.82000000000002 sell price= 133.93 long profit= 1.9771249999999851
+date: 2019-03-27 18:31:00 buy price= 135.12 sell price= 136.75 long profit= 1.4940649999999953
+date: 2019-03-28 14:31:00 buy price= 137.26 sell price= 138.33 short profit= -1.2077950000000215
+date: 2019-03-29 10:31:00 buy price= 138.00000000000006 sell price= 137.98 short profit= -0.11798999999993295
+date: 2019-03-30 06:31:00 buy price= 137.33999999999997 sell price= 140.69 short profit= -3.489015000000023
+date: 2019-03-31 02:31:00 No transaction profit= 0
+date: 2019-03-31 22:31:00 No transaction profit= 0
+date: 2019-04-01 18:31:00 buy price= 142.48000000000002 sell price= 142.31 short profit= 0.02760500000001591
+date: 2019-04-02 14:31:00 buy price= 141.95999999999995 sell price= 141.52 short profit= 0.2982599999999409
+date: 2019-04-03 10:31:00 buy price= 144.23000000000005 sell price= 156.68 short profit= -12.600454999999961
+date: 2019-04-04 06:31:00 buy price= 157.98000000000002 sell price= 166.0 short profit= -8.181989999999981
+date: 2019-04-05 02:31:00 buy price= 164.90999999999997 sell price= 160.27 short profit= 4.477409999999957
+date: 2019-04-05 22:31:00 buy price= 161.68000000000004 sell price= 163.78 short profit= -2.2627299999999657
+date: 2019-04-06 18:31:00 buy price= 162.99 sell price= 163.38 short profit= -0.5531849999999864
+date: 2019-04-07 14:31:00 No transaction profit= 0
+date: 2019-04-08 10:31:00 No transaction profit= 0
+date: 2019-04-09 06:31:00 buy price= 166.83 sell price= 176.84 short profit= -10.18183499999999
+date: 2019-04-10 02:31:00 buy price= 180.35 sell price= 174.15 short profit= 6.022749999999989
+date: 2019-04-10 22:31:00 No transaction profit= 0
+date: 2019-04-11 18:31:00 buy price= 182.39999999999998 sell price= 173.95 short profit= 8.271824999999987
+date: 2019-04-12 14:31:00 No transaction profit= 0
+date: 2019-04-13 10:31:00 buy price= 163.46 sell price= 163.98 long profit= 0.3562799999999818
+date: 2019-04-14 06:31:00 buy price= 161.29 sell price= 163.65 long profit= 2.1975300000000138
+date: 2019-04-15 02:31:00 buy price= 163.65 sell price= 162.83 long profit= -0.9832399999999932
+date: 2019-04-15 22:31:00 No transaction profit= 0
+date: 2019-04-16 18:31:00 buy price= 157.02000000000004 sell price= 161.35 long profit= 4.170814999999956
+date: 2019-04-17 14:31:00 buy price= 161.88 sell price= 164.48 long profit= 2.436819999999994
+date: 2019-04-18 10:31:00 buy price= 164.15 sell price= 164.54 short profit= -0.5543449999999863
+date: 2019-04-19 06:31:00 No transaction profit= 0
+date: 2019-04-20 02:31:00 No transaction profit= 0
+date: 2019-04-20 22:31:00 buy price= 172.16 sell price= 173.88 short profit= -1.8930199999999988
+date: 2019-04-21 18:31:00 No transaction profit= 0
+date: 2019-04-22 14:31:00 buy price= 172.61000000000004 sell price= 168.64 short profit= 3.799375000000056
+date: 2019-04-23 10:31:00 No transaction profit= 0
+date: 2019-04-24 06:31:00 buy price= 171.07999999999998 sell price= 173.54 long profit= 2.287690000000008
+date: 2019-04-25 02:31:00 No transaction profit= 0
+date: 2019-04-25 22:31:00 buy price= 162.53000000000003 sell price= 162.13 long profit= -0.5623300000000341
+date: 2019-04-26 18:31:00 buy price= 158.21999999999997 sell price= 159.62 long profit= 1.2410800000000342
+date: 2019-04-27 14:31:00 buy price= 161.14 sell price= 157.81 long profit= -3.4894749999999837
+date: 2019-04-28 10:31:00 buy price= 157.8 sell price= 160.24 long profit= 2.280979999999998
+date: 2019-04-29 06:31:00 No transaction profit= 0
+date: 2019-04-30 02:31:00 buy price= 156.79999999999995 sell price= 156.44 long profit= -0.5166199999999568
+date: 2019-04-30 22:31:00 buy price= 153.93 sell price= 156.69 long profit= 2.604689999999991
+date: 2019-05-01 18:31:00 No transaction profit= 0
+date: 2019-05-02 14:31:00 No transaction profit= 0
+date: 2019-05-03 10:31:00 No transaction profit= 0
+date: 2019-05-04 06:31:00 No transaction profit= 0
+date: 2019-05-05 02:31:00 buy price= 169.13 sell price= 164.17 short profit= 4.793350000000007
+date: 2019-05-05 22:31:00 No transaction profit= 0
+date: 2019-05-06 18:31:00 buy price= 164.47 sell price= 161.41 short profit= 2.8970600000000024
+date: 2019-05-07 14:31:00 buy price= 163.2 sell price= 175.45 short profit= -12.419325
+date: 2019-05-08 10:31:00 No transaction profit= 0
+date: 2019-05-09 06:31:00 buy price= 168.01999999999998 sell price= 169.44 long profit= 1.251270000000016
+date: 2019-05-10 02:31:00 buy price= 169.73999999999998 sell price= 171.36 short profit= -1.790550000000033
+date: 2019-05-10 22:31:00 buy price= 171.35 sell price= 174.68 short profit= -3.503015000000013
+date: 2019-05-11 18:31:00 No transaction profit= 0
+date: 2019-05-12 14:31:00 No transaction profit= 0
+date: 2019-05-13 10:31:00 buy price= 200.62 sell price= 187.5 short profit= 12.925940000000004
+date: 2019-05-14 06:31:00 buy price= 189.42000000000002 sell price= 192.41 long profit= 2.7990849999999807
+date: 2019-05-15 02:31:00 buy price= 195.73000000000002 sell price= 204.11 short profit= -8.579919999999996
+date: 2019-05-16 08:30:00 buy price= 204.06 sell price= 239.11 short profit= -35.27158500000001
+date: 2019-05-17 04:30:00 buy price= 265.17 sell price= 251.07 short profit= 13.841880000000023
+date: 2019-05-18 00:30:00 buy price= 237.88 sell price= 237.2 long profit= -0.9175400000000069
+date: 2019-05-18 20:30:00 buy price= 242.11 sell price= 240.7 short profit= 1.1685950000000251
+date: 2019-05-19 16:30:00 No transaction profit= 0
+date: 2019-05-20 12:30:00 No transaction profit= 0
+date: 2019-05-21 08:30:00 No transaction profit= 0
+date: 2019-05-22 04:30:00 No transaction profit= 0
+date: 2019-05-23 00:30:00 buy price= 253.89 sell price= 256.56 short profit= -2.925225000000016
+date: 2019-05-23 20:30:00 buy price= 256.53 sell price= 242.61 short profit= 13.670429999999959
+date: 2019-05-24 16:30:00 No transaction profit= 0
+date: 2019-05-25 12:30:00 No transaction profit= 0
+date: 2019-05-26 08:30:00 buy price= 254.10999999999996 sell price= 249.71 short profit= 4.148089999999948
+date: 2019-05-27 04:30:00 buy price= 249.61 sell price= 246.92 long profit= -2.938265000000026
+date: 2019-05-28 00:30:00 No transaction profit= 0
+date: 2019-05-28 20:30:00 buy price= 267.5 sell price= 271.35 short profit= -4.119425000000023
+date: 2019-05-29 16:30:00 buy price= 271.32 sell price= 267.93 long profit= -3.6596249999999864
+date: 2019-05-30 12:30:00 buy price= 266.23 sell price= 271.27 short profit= -5.308749999999963
+date: 2019-05-31 08:30:00 buy price= 268.4799999999999 sell price= 276.07 short profit= -7.862275000000089
+date: 2019-06-01 04:30:00 No transaction profit= 0
+date: 2019-06-02 00:30:00 buy price= 256.41 sell price= 268.59 long profit= 11.91749999999995
+date: 2019-06-02 20:30:00 buy price= 265.16999999999996 sell price= 265.45 long profit= 0.014690000000029568
+date: 2019-06-03 16:30:00 buy price= 268.79 sell price= 267.39 short profit= 1.1319100000000342
+date: 2019-06-04 12:30:00 buy price= 267.39 sell price= 261.79 long profit= -5.864589999999966
+date: 2019-06-05 08:30:00 buy price= 242.12000000000006 sell price= 249.22 long profit= 6.854329999999938
+date: 2019-06-06 04:30:00 buy price= 249.26 sell price= 245.38 long profit= -4.127319999999996
+date: 2019-06-07 00:30:00 buy price= 242.24 sell price= 244.95 long profit= 2.4664049999999795
+date: 2019-06-07 20:30:00 buy price= 246.88999999999993 sell price= 246.92 long profit= -0.216904999999942
+date: 2019-06-08 17:31:00 No transaction profit= 0
+date: 2019-06-09 13:30:00 No transaction profit= 0
+date: 2019-06-10 09:30:00 buy price= 239.35 sell price= 231.67 long profit= -7.9155100000000065
+date: 2019-06-11 05:30:00 buy price= 231.24 sell price= 241.12 long profit= 9.643819999999996
+date: 2019-06-12 01:30:00 buy price= 243.08999999999997 sell price= 244.72 long profit= 1.3860950000000238
+date: 2019-06-12 21:30:00 buy price= 247.48999999999998 sell price= 246.73 long profit= -1.0071099999999908
+date: 2019-06-13 17:30:00 No transaction profit= 0
+date: 2019-06-14 13:30:00 buy price= 259.95 sell price= 259.46 short profit= 0.23029500000000908
+date: 2019-06-15 09:30:00 buy price= 259.46 sell price= 255.23 long profit= -4.48734499999999
+date: 2019-06-16 05:30:00 buy price= 255.23 sell price= 261.28 long profit= 5.791744999999984
+date: 2019-06-17 01:30:00 buy price= 263.28999999999996 sell price= 268.18 short profit= -5.155735000000043
+date: 2019-06-17 21:30:00 No transaction profit= 0
+date: 2019-06-18 17:30:00 No transaction profit= 0
+date: 2019-06-19 13:30:00 buy price= 271.14 sell price= 263.02 short profit= 7.852920000000005
+date: 2019-06-20 09:30:00 buy price= 269.06999999999994 sell price= 266.73 short profit= 2.072099999999918
+date: 2019-06-21 05:30:00 No transaction profit= 0
+date: 2019-06-22 01:30:00 buy price= 267.02000000000004 sell price= 286.13 long profit= 18.833424999999956
+date: 2019-06-22 21:30:00 buy price= 289.83 sell price= 306.08 short profit= -16.547955
+date: 2019-06-23 17:30:00 buy price= 298.06999999999994 sell price= 317.63 long profit= 19.252150000000057
+date: 2019-06-24 13:30:00 buy price= 317.63 sell price= 320.2 long profit= 2.251084999999993
+date: 2019-06-25 09:30:00 buy price= 321.3399999999999 sell price= 311.74 short profit= 9.28345999999991
+date: 2019-06-26 05:30:00 No transaction profit= 0
+date: 2019-06-27 01:30:00 buy price= 329.0 sell price= 336.57 short profit= -7.9027849999999935
+date: 2019-06-27 21:30:00 buy price= 348.12000000000006 sell price= 335.58 short profit= 12.198150000000076
+date: 2019-06-28 17:30:00 No transaction profit= 0
+date: 2019-06-29 13:30:00 buy price= 297.2200000000001 sell price= 309.08 long profit= 11.5568499999999
+date: 2019-06-30 09:30:00 buy price= 306.39 sell price= 307.91 long profit= 1.2128500000000386
+date: 2019-07-01 05:30:00 buy price= 307.91 sell price= 304.65 long profit= -3.5662800000000474
+date: 2019-07-02 01:30:00 buy price= 303.66 sell price= 298.0 short profit= 5.359170000000025
+date: 2019-07-02 21:30:00 No transaction profit= 0
+date: 2019-07-03 17:30:00 buy price= 278.56 sell price= 296.63 long profit= 17.782404999999994
+date: 2019-07-04 13:30:00 buy price= 295.46 sell price= 292.32 long profit= -3.4338899999999866
+date: 2019-07-05 09:30:00 No transaction profit= 0
+date: 2019-07-06 05:30:00 buy price= 287.91999999999996 sell price= 292.11 long profit= 3.899985000000055
+date: 2019-07-07 01:30:00 No transaction profit= 0
+date: 2019-07-07 21:30:00 No transaction profit= 0
+date: 2019-07-08 17:30:00 No transaction profit= 0
+date: 2019-07-09 13:30:00 buy price= 306.15000000000003 sell price= 309.19 short profit= -3.3476699999999635
+date: 2019-07-10 09:30:00 buy price= 306.72999999999996 sell price= 309.11 short profit= -2.6879200000000525
+date: 2019-07-11 05:30:00 buy price= 306.98 sell price= 309.09 short profit= -2.418034999999957
+date: 2019-07-12 01:30:00 buy price= 307.28 sell price= 270.8 short profit= 36.19095999999996
+date: 2019-07-12 21:30:00 buy price= 270.8 sell price= 270.75 long profit= -0.32077500000001136
+date: 2019-07-13 17:30:00 buy price= 270.8 sell price= 272.99 long profit= 1.9181049999999977
+date: 2019-07-14 13:30:00 buy price= 272.91 sell price= 262.77 long profit= -10.407840000000043
+date: 2019-07-15 09:30:00 buy price= 262.7499999999999 sell price= 238.84 long profit= -24.160794999999883
+date: 2019-07-16 05:30:00 No transaction profit= 0
+date: 2019-07-17 01:30:00 buy price= 222.32 sell price= 226.16 short profit= -4.064240000000003
+date: 2019-07-17 21:30:00 No transaction profit= 0
+date: 2019-07-18 17:30:00 buy price= 199.2 sell price= 212.97 short profit= -13.97608500000001
+date: 2019-07-19 13:30:00 buy price= 212.97 sell price= 223.9 short profit= -11.148435000000006
+date: 2019-07-20 09:30:00 buy price= 223.83 sell price= 219.39 short profit= 4.218390000000026
+date: 2019-07-21 05:30:00 buy price= 219.27 sell price= 224.82 long profit= 5.327954999999983
+date: 2019-07-22 01:30:00 No transaction profit= 0
+date: 2019-07-22 21:30:00 No transaction profit= 0
+date: 2019-07-23 17:30:00 buy price= 224.93 sell price= 215.6 long profit= -9.550265000000012
+date: 2019-07-24 13:30:00 buy price= 211.09 sell price= 216.83 long profit= 5.526040000000009
+date: 2019-07-25 09:30:00 No transaction profit= 0
+date: 2019-07-26 05:30:00 buy price= 211.72 sell price= 219.83 long profit= 7.894225000000013
+date: 2019-07-27 01:30:00 buy price= 216.46 sell price= 216.34 long profit= -0.33640000000000453
+date: 2019-07-27 21:30:00 No transaction profit= 0
+date: 2019-07-28 17:30:00 No transaction profit= 0
+date: 2019-07-29 13:30:00 No transaction profit= 0
+date: 2019-07-30 09:30:00 buy price= 208.02 sell price= 210.77 long profit= 2.540605
+date: 2019-07-31 05:30:00 buy price= 207.28 sell price= 208.77 long profit= 1.2819750000000092
+date: 2019-08-01 01:30:00 buy price= 208.77 sell price= 212.08 long profit= 3.099575000000002
+date: 2019-08-01 21:30:00 No transaction profit= 0
+date: 2019-08-02 17:30:00 buy price= 213.99 sell price= 216.29 short profit= -2.515139999999983
+date: 2019-08-03 13:30:00 buy price= 218.99 sell price= 215.8 short profit= 2.972604999999998
+date: 2019-08-04 09:30:00 No transaction profit= 0
+date: 2019-08-05 05:30:00 No transaction profit= 0
+date: 2019-08-06 01:30:00 buy price= 220.35 sell price= 228.85 short profit= -8.7246
+date: 2019-08-06 21:30:00 buy price= 231.83999999999997 sell price= 229.42 short profit= 2.1893699999999874
+date: 2019-08-07 17:30:00 buy price= 228.93000000000004 sell price= 225.86 short profit= 2.8426050000000216
+date: 2019-08-08 13:30:00 No transaction profit= 0
+date: 2019-08-09 09:30:00 buy price= 221.30999999999995 sell price= 219.09 short profit= 1.9997999999999423
+date: 2019-08-10 05:30:00 No transaction profit= 0
+date: 2019-08-11 01:30:00 buy price= 212.27 sell price= 212.99 long profit= 0.5073699999999989
+date: 2019-08-11 21:30:00 buy price= 209.43000000000004 sell price= 209.94 long profit= 0.3003149999999625
+date: 2019-08-12 17:30:00 buy price= 208.12 sell price= 214.32 long profit= 5.988779999999989
+date: 2019-08-13 13:30:00 No transaction profit= 0
+date: 2019-08-14 09:30:00 buy price= 204.92 sell price= 208.8 long profit= 3.673140000000024
+date: 2019-08-15 05:30:00 buy price= 210.09000000000003 sell price= 207.18 long profit= -3.118635000000025
+date: 2019-08-16 09:30:00 buy price= 204.13 sell price= 184.0 long profit= -20.324064999999994
+date: 2019-08-17 05:29:00 buy price= 188.38 sell price= 183.46 short profit= 4.734079999999987
+date: 2019-08-18 01:29:00 No transaction profit= 0
+date: 2019-08-18 21:29:00 buy price= 182.39000000000004 sell price= 183.96 long profit= 1.386824999999965
+date: 2019-08-19 17:29:00 No transaction profit= 0
+date: 2019-08-20 13:29:00 No transaction profit= 0
+date: 2019-08-21 09:29:00 buy price= 197.94 sell price= 196.88 long profit= -1.2574100000000024
+date: 2019-08-22 05:29:00 No transaction profit= 0
+date: 2019-08-23 01:29:00 buy price= 181.94000000000003 sell price= 186.28 long profit= 4.1558899999999745
+date: 2019-08-23 21:29:00 No transaction profit= 0
+date: 2019-08-24 17:29:00 buy price= 191.5 sell price= 192.12 long profit= 0.4281900000000045
+date: 2019-08-25 13:29:00 buy price= 190.52 sell price= 189.24 long profit= -1.4698800000000012
+date: 2019-08-26 09:29:00 No transaction profit= 0
+date: 2019-08-27 05:29:00 buy price= 190.07 sell price= 189.3 short profit= 0.5803149999999818
+date: 2019-08-28 01:29:00 No transaction profit= 0
+date: 2019-08-28 21:29:00 buy price= 186.82000000000005 sell price= 185.44 long profit= -1.5661300000000522
+date: 2019-08-29 17:29:00 buy price= 182.56 sell price= 172.8 long profit= -9.93767999999999
+date: 2019-08-30 13:29:00 buy price= 171.23000000000002 sell price= 169.73 long profit= -1.6704800000000284
+date: 2019-08-31 09:29:00 No transaction profit= 0
+date: 2019-09-01 05:29:00 No transaction profit= 0
+date: 2019-09-02 01:29:00 buy price= 167.48999999999998 sell price= 170.03 long profit= 2.3712400000000207
+date: 2019-09-02 21:29:00 No transaction profit= 0
+date: 2019-09-03 17:29:00 buy price= 170.98 sell price= 177.31 short profit= -6.504145000000013
+date: 2019-09-04 13:29:00 buy price= 175.85000000000005 sell price= 180.82 short profit= -5.148334999999943
+date: 2019-09-05 09:29:00 buy price= 180.80999999999997 sell price= 177.37 short profit= 3.2609099999999693
+date: 2019-09-06 05:29:00 No transaction profit= 0
+date: 2019-09-07 01:29:00 buy price= 172.45000000000002 sell price= 174.85 long profit= 2.226349999999977
+date: 2019-09-07 21:29:00 No transaction profit= 0
+date: 2019-09-08 17:29:00 buy price= 169.38 sell price= 178.43 long profit= 8.876095000000012
+date: 2019-09-09 13:29:00 No transaction profit= 0
+date: 2019-09-10 09:29:00 buy price= 179.53 sell price= 180.62 short profit= -1.2700750000000036
+date: 2019-09-11 05:29:00 buy price= 183.98000000000002 sell price= 180.13 short profit= 3.6679450000000227
+date: 2019-09-12 01:29:00 buy price= 180.1 sell price= 178.19 short profit= 1.7308549999999967
+date: 2019-09-12 21:29:00 No transaction profit= 0
+date: 2019-09-13 17:29:00 buy price= 179.05 sell price= 180.59 long profit= 1.360179999999992
+date: 2019-09-14 13:29:00 No transaction profit= 0
+date: 2019-09-15 09:29:00 buy price= 180.20999999999998 sell price= 188.08 short profit= -8.054145000000032
+date: 2019-09-16 05:29:00 buy price= 186.14 sell price= 188.24 short profit= -2.287190000000023
+date: 2019-09-17 01:29:00 buy price= 188.0 sell price= 193.76 short profit= -5.950879999999991
+date: 2019-09-17 21:29:00 buy price= 196.40000000000003 sell price= 196.82 short profit= -0.6166099999999591
+date: 2019-09-18 17:29:00 buy price= 196.92999999999998 sell price= 212.22 short profit= -15.494575000000019
+date: 2019-09-19 13:29:00 No transaction profit= 0
+date: 2019-09-20 09:29:00 buy price= 212.17 sell price= 222.11 short profit= -10.157140000000027
+date: 2019-09-21 05:29:00 No transaction profit= 0
+date: 2019-09-22 01:29:00 No transaction profit= 0
+date: 2019-09-22 21:29:00 No transaction profit= 0
+date: 2019-09-23 17:29:00 buy price= 209.12000000000003 sell price= 208.92 short profit= -0.009019999999954537
+date: 2019-09-24 13:29:00 No transaction profit= 0
+Final total capital= 100267.14824499997
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [9]:
+
+
+
past_history = 35 
+
+
+
+last_day=len(df['TIME'])
+
+
+
+
+day=600
+k=day
+#for k in range(3000):
+
+h=0
+y=0
+z=0
+u=0
+
+
+
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        if trend>0 and trend_real>0:
+            h+=1
+            y+=1
+            
+        if trend>0 and trend_real<0:
+            h=h
+            y+=1
+        if trend<0 and trend_real<0:
+            z+=1
+            u+=1
+        if trend<0 and trend_real>0:
+            z=z
+            u+=1
+        
+        
+        
+        
+        
+        
+    k=k-1
+    
+print('accuracy of buy=',h/y)   
+    
+print('accuracy of sell=',z/u) 
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
accuracy of buy= 0.6440129449838188
+accuracy of sell= 0.6219931271477663
+
+
+
+ +
+
+ +
+
+
+
In [15]:
+
+
+
past_history = 35 
+
+
+
+last_day=len(df['TIME'])
+
+
+
+
+day=500
+k=day
+#for k in range(3000):
+
+h=0
+y=0
+z=0
+u=0
+
+H=[0]
+Z=[0]
+
+a=0
+
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        if trend>0 and trend_real>0:
+            h+=1
+            y+=1
+            
+        if trend>0 and trend_real<0:
+            h=h
+            y+=1
+        if trend<0 and trend_real<0:
+            z+=1
+            u+=1
+        if trend<0 and trend_real>0:
+            z=z
+            u+=1
+        
+        a+=1
+        
+        if a%15==0:
+            #print("counter=",a)
+            if y==0:
+                H=np.vstack((H,0.6440129449838188))
+            else:
+                H=np.vstack((H,h/y))
+            
+            
+            h=0
+            y=0
+            Z=np.vstack((Z,z/u))
+            
+            
+            z=0
+            u=0
+        
+        
+    k=k-1
+    
+H=H[1:]
+Z=Z[1:]
+
+print('success rate of buying in every 15 units',H)
+print('success rate of selling in every 15 units',Z)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
success rate of buying in every 15 units [[0.66666667]
+ [0.8       ]
+ [1.        ]
+ [0.8       ]
+ [0.57142857]
+ [0.6       ]
+ [0.66666667]
+ [0.71428571]
+ [0.5       ]
+ [0.8       ]
+ [0.54545455]
+ [0.5       ]
+ [0.        ]
+ [0.61538462]
+ [0.6       ]
+ [0.5       ]
+ [0.5       ]
+ [0.5       ]
+ [0.75      ]
+ [0.64401294]
+ [0.66666667]
+ [0.6       ]
+ [0.75      ]
+ [0.6       ]
+ [0.75      ]
+ [0.57142857]
+ [0.77777778]
+ [0.28571429]
+ [0.63636364]
+ [1.        ]
+ [0.53846154]
+ [0.5       ]
+ [1.        ]]
+success rate of selling in every 15 units [[0.66666667]
+ [0.8       ]
+ [0.57142857]
+ [0.6       ]
+ [0.75      ]
+ [1.        ]
+ [0.83333333]
+ [0.5       ]
+ [0.6       ]
+ [0.4       ]
+ [0.5       ]
+ [0.38461538]
+ [0.69230769]
+ [1.        ]
+ [0.6       ]
+ [0.45454545]
+ [0.71428571]
+ [0.4       ]
+ [0.71428571]
+ [0.53333333]
+ [0.55555556]
+ [0.8       ]
+ [0.45454545]
+ [0.7       ]
+ [0.66666667]
+ [0.5       ]
+ [0.83333333]
+ [0.25      ]
+ [0.75      ]
+ [0.7       ]
+ [1.        ]
+ [0.71428571]
+ [0.33333333]]
+
+
+
+ +
+
+ +
+
+
+
In [16]:
+
+
+
from scipy import stats
+stats.ttest_1samp(H,0.5)               #t test of buying success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[16]:
+ + + + +
+
Ttest_1sampResult(statistic=array([3.97401484]), pvalue=array([0.00037674]))
+
+ +
+ +
+
+ +
+
+
+
In [17]:
+
+
+
stats.ttest_1samp(Z,0.5)               #t test of selling success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[17]:
+ + + + +
+
Ttest_1sampResult(statistic=array([4.10987859]), pvalue=array([0.00025695]))
+
+ +
+ +
+
+ +
+
+
+
In [18]:
+
+
+
import numpy as np, scipy.stats as st
+st.t.interval(0.95, len(H)-1, loc=np.mean(H), scale=st.sem(H))      #95% Confidence interval of buying success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[18]:
+ + + + +
+
(array([0.56573474]), array([0.70398115]))
+
+ +
+ +
+
+ +
+
+
+
In [19]:
+
+
+
import numpy as np, scipy.stats as st
+st.t.interval(0.95, len(Z)-1, loc=np.mean(Z), scale=st.sem(Z))       #95% Confidence interval of selling success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[19]:
+ + + + +
+
(array([0.56835926]), array([0.70270267]))
+
+ +
+ +
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+ + + + + + diff --git a/LTC_LSTM.html b/LTC_LSTM.html new file mode 100644 index 0000000..18a8319 --- /dev/null +++ b/LTC_LSTM.html @@ -0,0 +1,14761 @@ + + + + +LTC_LSTM + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
In [1]:
+
+
+
from __future__ import absolute_import, division, print_function, unicode_literals
+try:
+  # %tensorflow_version only exists in Colab.
+  %tensorflow_version 2.x
+except Exception:
+  pass
+import tensorflow as tf
+
+import matplotlib as mpl
+import matplotlib.pyplot as plt
+import numpy as np
+import os
+import pandas as pd
+
+mpl.rcParams['figure.figsize'] = (8, 6)     #初始化设置,应该是展示图片大小
+
+mpl.rcParams['axes.grid'] = False
+
+df= pd.read_excel("data_summary.xlsx", sheet_name=2)
+
+ +
+
+
+ +
+
+
+
In [2]:
+
+
+
df=np.array(df)
+df=pd.DataFrame(df)
+close_price=df[4]
+
+
+CLOSE=[0]
+
+frequency=1200     #1440min合成1条k线
+
+for i in range(len(close_price)):
+    if (i+1) %frequency==0:
+        CLOSE=np.vstack((CLOSE,close_price[i]))
+
+CLOSE=CLOSE[1:]    
+
+
+#open_price=df['open']
+
+open_price=df[1]
+
+
+
+OPEN=[0]
+
+for i in range(len(close_price)):
+    if (i+1) %frequency==0:
+        OPEN=np.vstack((OPEN,open_price[i-(frequency-1)]))
+
+OPEN=OPEN[1:]    
+
+
+#high_price=df['high']
+high_price=df[2]
+
+
+HIGH=[0]
+
+for i in range(len(high_price)):
+    if (i+1) %frequency==0:
+        HIGH=np.vstack((HIGH,max(high_price[i-(frequency-1):i+1])))
+
+HIGH=HIGH[1:]  
+
+#low_price=df['low']
+low_price=df[3]
+
+LOW=[0]
+
+for i in range(len(low_price)):
+    if (i+1) %frequency==0:
+        LOW=np.vstack((LOW,min(low_price[i-(frequency-1):i+1])))
+
+LOW=LOW[1:]
+
+#time=df['time']
+time=df[0]
+
+TIME=[0]
+
+for i in range(len(time)):
+    if (i+1) %frequency==0:
+        TIME=np.vstack((TIME,time[i]))
+
+TIME=TIME[1:] 
+
+data=np.hstack((TIME,CLOSE,HIGH,LOW,OPEN))
+data=pd.DataFrame(data)
+data.columns = ["TIME", "C","H","L","O"]
+df=data
+zero=np.array([0])
+rt=np.diff(np.array(df['C']))
+rt=np.hstack((zero,rt))
+df.insert(5, 'Diff_C', rt) 
+
+moving_avg = df['Diff_C'].rolling(window=5).mean(center=True)
+MV=moving_avg[2:len(rt)-2]
+zeros=np.zeros((4))
+MV=np.hstack((zeros,MV))
+df.insert(6, 'MV_C', MV) 
+
+ +
+
+
+ +
+
+
+
In [3]:
+
+
+
features_considered=['MV_C']
+
+features = df[features_considered]                       
+features.index = df['TIME']        #在前面加一列时间
+
+dataset = features.values
+TRAIN_SPLIT = (len(df)*7)//10      #first 70% of the rows in dataset will be the training dataset
+tf.random.set_seed(13)     # 保持random selection每次都一样
+EVALUATION_INTERVAL = 600       #原来是200
+EPOCHS = 10       #1个epoch等于使用训练集中的全部样本训练一次,通俗的讲epoch的值就是整个数据集被轮几次。
+BATCH_SIZE = 256           #训练的小批次, iteration=TRAIN_SPLIT/256
+BUFFER_SIZE = 10000       #缓存容量 
+def multivariate_data(dataset, target, start_index, end_index, history_size,
+                      target_size, step, single_step=False):         
+    data = []
+    labels = []
+
+    start_index = start_index + history_size
+    if end_index is None:
+        end_index = len(dataset) - target_size
+
+    for i in range(start_index, end_index):
+        indices = range(i-history_size, i, step)             #就是在取过去天数的样本时,是间隔着几天取的,这样可以减少训练时间
+        data.append(dataset[indices])
+
+        if single_step:
+            labels.append(target[i+target_size])                #就是说,这里可以规定只预测后面某一天或者是后面好几天
+        else:
+            labels.append(target[i:i+target_size])               
+
+    return np.array(data), np.array(labels)        #output 出numpy格式的数据
+
+past_history = 35         # 用过去50天的数据,本来是720
+future_target = 0            #本来是72  预测12天后的数据,或者是下一天到12天后的数据   72/6=12
+STEP = 1                    #本来是6,取过去天数的样本时,是间隔着6天取的,这样可以减少训练时间
+
+#future_target = 1          # 预测12天后的数据,或者是下一天到12天后的数据   72/6=12
+#STEP = 1                     #取过去天数的样本时,是间隔着6天取的,这样可以减少训练时间
+
+
+x_train_single, y_train_single = multivariate_data(dataset, dataset[:, 0], 0,
+                                                   TRAIN_SPLIT, past_history,
+                                                   future_target, STEP,
+                                                   single_step=True)
+x_val_single, y_val_single = multivariate_data(dataset, dataset[:, 0],
+                                               TRAIN_SPLIT, None, past_history,
+                                               future_target, STEP,
+                                               single_step=True)
+
+train_data_single = tf.data.Dataset.from_tensor_slices((x_train_single, y_train_single))              
+train_data_single = train_data_single.cache().shuffle(BUFFER_SIZE).batch(BATCH_SIZE).repeat()      #traning data 
+
+val_data_single = tf.data.Dataset.from_tensor_slices((x_val_single, y_val_single))
+val_data_single = val_data_single.batch(BATCH_SIZE).repeat()                        #validation data 
+
+
+single_step_model = tf.keras.models.Sequential()
+single_step_model.add(tf.keras.layers.LSTM(3,
+                                           input_shape=x_train_single.shape[-2:]))    #应该是这一层有32 个神经元
+single_step_model.add(tf.keras.layers.Dense(1))                         #output layer, 因为预测未来1 期的data, 所以是1个神经元
+
+single_step_model.compile(optimizer=tf.keras.optimizers.RMSprop(), loss='mae')    #这里优化算法用RMSprop而不是Adam 或 Momentum
+
+single_step_history = single_step_model.fit(train_data_single, epochs=EPOCHS,      #EPOCHS = 10  轮10次
+                                            steps_per_epoch=EVALUATION_INTERVAL,    #每轮test 200次 data
+                                            validation_data=val_data_single, 
+                                            validation_steps=50)      #设置验证多少次数据后取平均值作为此epoch训练后的效果 
+
+def plot_train_history(history, title):             #把training lost 和validation loss 表示出来
+  loss = history.history['loss']             
+  val_loss = history.history['val_loss']
+
+  epochs = range(len(loss))
+
+  plt.figure()
+
+  plt.plot(epochs, loss, 'b', label='Training loss')
+  plt.plot(epochs, val_loss, 'r', label='Validation loss')
+  plt.title(title)
+  plt.legend()
+
+  plt.show()
+
+plot_train_history(single_step_history,
+                   'Single Step Training and validation loss')
+single_step_model.save('LTC_1200.h5') 
+model = tf.keras.models.load_model('LTC_1200.h5')
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
Train for 600 steps, validate for 50 steps
+Epoch 1/10
+600/600 [==============================] - 31s 52ms/step - loss: 0.9085 - val_loss: 0.6943
+Epoch 2/10
+600/600 [==============================] - 21s 36ms/step - loss: 0.6313 - val_loss: 0.6038
+Epoch 3/10
+600/600 [==============================] - 18s 31ms/step - loss: 0.5577 - val_loss: 0.5932
+Epoch 4/10
+600/600 [==============================] - 22s 37ms/step - loss: 0.5229 - val_loss: 0.5948
+Epoch 5/10
+600/600 [==============================] - 21s 36ms/step - loss: 0.5101 - val_loss: 0.6256
+Epoch 6/10
+600/600 [==============================] - 23s 38ms/step - loss: 0.5020 - val_loss: 0.6540
+Epoch 7/10
+600/600 [==============================] - 24s 40ms/step - loss: 0.4970 - val_loss: 0.6602
+Epoch 8/10
+600/600 [==============================] - 28s 47ms/step - loss: 0.4944 - val_loss: 0.6602
+Epoch 9/10
+600/600 [==============================] - 25s 41ms/step - loss: 0.4929 - val_loss: 0.6625
+Epoch 10/10
+600/600 [==============================] - 20s 34ms/step - loss: 0.4915 - val_loss: 0.6655
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [4]:
+
+
+
df['TIME']#
+
+R1=[0]
+R2=[0]
+
+
+past_history = 35 
+TC=100000       #总资金10万
+
+C=1             #每次交易1手
+
+
+leverage=1
+
+cost_rate=0.0005
+
+
+price_per_point=1       #1点300元
+
+last_day=len(df['TIME'])
+
+
+m=0
+n=0
+p=0
+r=0
+R=0
+s=0
+
+I=0
+B=0
+RR=[0]
+II=[0]
+BB=[0]
+tt=0
+t=0
+d=0
+d2=0
+
+rr=[0]
+maximum_markdown_final=[0]
+CR=1
+CRR=[0]
+TCC=[0]
+
+day=300
+k=day
+#for k in range(3000):
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        #print(data2)
+
+        #j=[0,0,0,0,0]
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        #trend=x[0][0]-MV[-1-k]-MV[-2-k]                #预测正负
+        
+        #trend_real=MV[-k]-MV[-1-k]-MV[-2-k]           #实际正负
+        
+        #P0=np.array(df['C'])[-7-k]
+        #P1=np.array(df['C'])[-6-k]
+        #P2=np.array(df['C'])[-5-k]
+        #P5=np.array(df['C'])[-2-k]
+        #P6=np.array(df['C'])[-1-k]
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        P0=np.array(df['C'])[-6-k]
+        P1=np.array(df['C'])[-5-k]
+        P5=np.array(df['C'])[-1-k]
+        
+        
+        
+        
+        
+        #line=P6+P5+P2-P1-P0
+        
+        line=P5+P1-P0
+        
+        L=np.array(df['L'])[-k]
+        H=np.array(df['H'])[-k]
+        
+        if trend<0:
+            if P5-d2>line and (np.array(df['O'])[-k])-d2>line:
+                r1=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+               
+                
+                
+            else:
+                if L<line<H:
+                    r1=((np.array(df['C'])[-k])-(line))/(line)                      #r1必须小于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                   
+                else:
+                    r1=0
+                    maximum_markdown=0
+                       
+            
+            if r1!=0:
+                m+=1
+                R1=np.vstack((R1,r1))
+                
+            
+            if r1<0:
+                n+=1
+            r=r+r1
+            R=R-r1
+            
+        else:
+            r1=0
+            r=r
+            R=R
+            maximum_markdown=0
+           
+        
+        if trend>0:
+            
+            
+            if P5<line-d and (np.array(df['O'])[-k])<line-d:
+                r2=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+               
+            else:
+                if L<line<H:
+                    r2=((np.array(df['C'])[-k])-(line))/(line)    #r2必须大于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                   
+                else:
+                    r2=0
+                    maximum_markdown=0
+                    profit2=0
+                    
+                   
+            
+            if r2!=0:
+                m+=1
+                s+=1
+                
+                R2=np.vstack((R2,r2))
+            
+            if r2>0:
+                p+=1
+            R=R+r2
+        else:
+            R=R
+            r2=0
+            maximum_markdown=0
+            profit2=0
+            
+            
+        
+        
+        i=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+        I=I+i
+        
+        b=((np.array(df['C'])[-k])-(np.array(df['C'])[-k-1]))/(np.array(df['C'])[-k-1])
+        B=B+b
+        
+        
+        BB=np.vstack((BB,B))
+        RR=np.vstack((RR,R))  
+        II=np.vstack((II,I))
+        
+        maximum_markdown_final=np.vstack((maximum_markdown_final,maximum_markdown))
+        rr=np.vstack((rr,r2))
+        
+        if r1!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        if r2!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        
+        CRR=np.vstack((CRR,(CR-1)*10))
+    k=k-1
+    
+    
+
+    
+    
+    
+RR=RR[1:]
+II=II[1:]
+tt=tt[1:]
+
+R1=R1[1:]
+R2=R2[1:]
+
+
+plt.plot(tt,RR)               
+#plt.plot(tt,II) 
+BB=BB[1:]
+plt.plot(tt,BB)
+
+
+  
+maximum_markdown_final=maximum_markdown_final[1:]        
+#plt.plot(tt,maximum_markdown_final)  
+final_maximum=min(maximum_markdown_final)
+rr=rr[1:]
+maximum_loss=min(rr) 
+
+     
+print("trading dates=",m)
+print("success to sell=",n)
+print("success to buy=",p)
+print('return from short=',-r)
+print('total return of long and short=',R)
+print('Time of long',s)      
+print('maximum markdown=',final_maximum)
+print('maximum loss=',maximum_loss)
+
+print('compound interest=',CR-1)
+
+import numpy as np, scipy.stats as st
+CI_R1=st.t.interval(0.9, len(R1)-1, loc=np.mean(R1), scale=st.sem(R1))      #90% Confidence interval of short
+CI_R2=st.t.interval(0.9, len(R2)-1, loc=np.mean(R2), scale=st.sem(R2))      #90% Confidence interval of long
+
+print("confidence interval of short=",CI_R1)
+print("confidence interval of long=",CI_R2)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
trading dates= 199
+success to sell= 52
+success to buy= 72
+return from short= 0.50258374470029
+total return of long and short= 1.8350320569758791
+Time of long 123
+maximum markdown= [-0.14451642]
+maximum loss= [-0.10752181]
+compound interest= -0.4263461739202258
+confidence interval of short= (array([-0.01371319]), array([0.0004873]))
+confidence interval of long= (array([0.00354272]), array([0.0181231]))
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [5]:
+
+
+
#
+
+TC=100000       #总资金10万
+
+C=1             #每次交易1手
+
+
+leverage=1
+
+cost_rate=0.0005
+
+
+price_per_point=1       #1点300元
+
+last_day=len(df['TIME'])
+
+
+m=0
+n=0
+p=0
+r=0
+R=0
+s=0
+
+I=0
+B=100000
+RR=[0]
+II=[0]
+BB=[0]
+tt=0
+t=0
+d=0
+d2=0
+
+rr=[0]
+maximum_markdown_final=[0]
+CR=1
+CRR=[0]
+TCC=[0]
+
+day=300
+k=day
+#for k in range(3000):
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        #print(data2)
+
+        #j=[0,0,0,0,0]
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        #trend=x[0][0]-MV[-1-k]-MV[-2-k]                #预测正负
+        
+        #trend_real=MV[-k]-MV[-1-k]-MV[-2-k]           #实际正负
+        
+        #P0=np.array(df['C'])[-7-k]
+        #P1=np.array(df['C'])[-6-k]
+        #P2=np.array(df['C'])[-5-k]
+        #P5=np.array(df['C'])[-2-k]
+        #P6=np.array(df['C'])[-1-k]
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        P0=np.array(df['C'])[-6-k]
+        P1=np.array(df['C'])[-5-k]
+        P5=np.array(df['C'])[-1-k]
+        
+        
+        
+        
+        
+        #line=P6+P5+P2-P1-P0
+        
+        line=P5+P1-P0
+        
+        L=np.array(df['L'])[-k]
+        H=np.array(df['H'])[-k]
+        
+        if trend<0:
+            if P5-d2>line and (np.array(df['O'])[-k])-d2>line:
+                r1=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+                profit1=C*(((np.array(df['O'])[-k])*price_per_point-np.array(df['C'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(np.array(df['O'])[-k])*price_per_point*cost_rate)
+                
+                print('date:',df['TIME'][last_day-k],'buy price=',(np.array(df['O'])[-k]),"sell price=",(np.array(df['C'])[-k]),'short profit=',profit1)
+                
+                
+            else:
+                if L<line<H:
+                    r1=((np.array(df['C'])[-k])-(line))/(line)                      #r1必须小于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                    profit1=C*(((line)*price_per_point-np.array(df['C'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(line)*price_per_point*cost_rate)
+                    print('date:',df['TIME'][last_day-k],'buy price=',(line),"sell price=",(np.array(df['C'])[-k]),'short profit=',profit1)
+                    
+                else:
+                    r1=0
+                    maximum_markdown=0
+                    profit1=0
+                    
+                    print('date:',df['TIME'][last_day-k],'No transaction','profit=',0)
+            
+            
+            if r1!=0:
+                m+=1
+                
+            
+            if r1<0:
+                n+=1
+            r=r+r1
+            R=R-r1
+            
+        else:
+            r1=0
+            r=r
+            R=R
+            maximum_markdown=0
+            profit1=0
+            
+        
+        if trend>0:
+            
+            
+            if P5<line-d and (np.array(df['O'])[-k])<line-d:
+                r2=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+                profit2=C*((np.array(df['C'])[-k])*price_per_point-(np.array(df['O'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(np.array(df['O'])[-k])*price_per_point*cost_rate)
+                
+                print('date:',df['TIME'][last_day-k],'buy price=',(np.array(df['O'])[-k]),"sell price=",(np.array(df['C'])[-k]),'long profit=',profit2)
+                
+                
+            else:
+                if L<line<H:
+                    r2=((np.array(df['C'])[-k])-(line))/(line)    #r2必须大于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                    profit2=(np.array(df['C'])[-k])*price_per_point-(line)*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(line)*price_per_point*cost_rate
+                    
+                    print('date:',df['TIME'][last_day-k],'buy price=',(line),"sell price=",(np.array(df['C'])[-k]),'long profit=',profit2)
+                    
+                else:
+                    r2=0
+                    maximum_markdown=0
+                    profit2=0
+                    
+                    print('date:',df['TIME'][last_day-k],'No transaction','profit=',0)
+            
+            
+            if r2!=0:
+                m+=1
+                s+=1
+            
+            if r2>0:
+                p+=1
+            R=R+r2
+        else:
+            R=R
+            r2=0
+            maximum_markdown=0
+            profit2=0
+            
+            
+        TC=TC+profit1+profit2
+        TCC=np.vstack((TCC,TC))
+        
+        i=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+        I=I+i
+        
+        b=((np.array(df['C'])[-k])-(np.array(df['C'])[-k-1]))
+        B=B+b
+        
+        
+        BB=np.vstack((BB,B))
+        RR=np.vstack((RR,R))  
+        II=np.vstack((II,I))
+        
+        maximum_markdown_final=np.vstack((maximum_markdown_final,maximum_markdown))
+        rr=np.vstack((rr,r2))
+        
+        if r1!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        if r2!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        
+        CRR=np.vstack((CRR,(CR-1)*10))
+    k=k-1
+    
+    
+
+    
+    
+    
+RR=RR[1:]
+II=II[1:]
+tt=tt[1:]
+
+TCC=TCC[1:]
+
+
+
+#plt.plot(tt,RR)               
+#plt.plot(tt,II) 
+plt.plot(tt,TCC) 
+BB=BB[1:]
+plt.plot(tt,BB)
+
+
+  
+maximum_markdown_final=maximum_markdown_final[1:]        
+#plt.plot(tt,maximum_markdown_final)  
+final_maximum=min(maximum_markdown_final)
+rr=rr[1:]
+maximum_loss=min(rr) 
+
+     
+
+
+print("Final total capital=",TC)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
date: 2019-01-17 21:19:00 buy price= 30.6 sell price= 30.8 long profit= 0.16929999999999928
+date: 2019-01-18 17:19:00 No transaction profit= 0
+date: 2019-01-19 13:19:00 buy price= 31.25 sell price= 30.74 long profit= -0.5409950000000016
+date: 2019-01-20 09:19:00 No transaction profit= 0
+date: 2019-01-21 05:19:00 buy price= 32.019999999999996 sell price= 30.69 long profit= -1.3613549999999948
+date: 2019-01-22 01:19:00 buy price= 30.540000000000003 sell price= 30.57 long profit= -0.0005550000000024181
+date: 2019-01-22 21:19:00 buy price= 30.58 sell price= 30.64 long profit= 0.029390000000002275
+date: 2019-01-23 17:19:00 buy price= 30.129999999999995 sell price= 31.54 long profit= 1.3791650000000035
+date: 2019-01-24 13:19:00 buy price= 31.55 sell price= 31.41 long profit= -0.17148000000000058
+date: 2019-01-25 09:19:00 No transaction profit= 0
+date: 2019-01-26 05:19:00 buy price= 31.87 sell price= 32.28 long profit= 0.3779250000000002
+date: 2019-01-27 01:19:00 buy price= 32.29 sell price= 33.42 long profit= 1.0971450000000025
+date: 2019-01-27 21:19:00 buy price= 33.38 sell price= 32.66 long profit= -0.7530200000000059
+date: 2019-01-28 17:19:00 buy price= 32.529999999999994 sell price= 32.28 long profit= -0.28240499999999286
+date: 2019-01-29 13:19:00 No transaction profit= 0
+date: 2019-01-30 09:19:00 buy price= 30.42 sell price= 30.96 long profit= 0.509309999999999
+date: 2019-01-31 05:19:00 buy price= 30.96 sell price= 31.43 long profit= 0.4388049999999989
+date: 2019-02-01 01:19:00 No transaction profit= 0
+date: 2019-02-01 21:19:00 buy price= 30.930000000000007 sell price= 31.01 long profit= 0.04902999999999473
+date: 2019-02-02 17:19:00 No transaction profit= 0
+date: 2019-02-03 13:19:00 buy price= 32.72 sell price= 33.09 long profit= 0.3370950000000046
+date: 2019-02-04 09:19:00 buy price= 33.09 sell price= 33.62 long profit= 0.49664499999999406
+date: 2019-02-05 05:19:00 buy price= 33.49999999999999 sell price= 34.01 long profit= 0.47624500000000514
+date: 2019-02-06 01:19:00 buy price= 33.709999999999994 sell price= 34.34 long profit= 0.5959750000000097
+date: 2019-02-06 21:19:00 No transaction profit= 0
+date: 2019-02-07 17:19:00 buy price= 33.190000000000005 sell price= 33.07 short profit= 0.08687000000000455
+date: 2019-02-08 13:19:00 buy price= 33.599999999999994 sell price= 33.2 short profit= 0.3665999999999915
+date: 2019-02-09 09:19:00 buy price= 33.22 sell price= 42.63 long profit= 9.372075000000004
+date: 2019-02-10 05:19:00 buy price= 42.63 sell price= 44.07 long profit= 1.3966499999999977
+date: 2019-02-11 01:19:00 buy price= 44.08 sell price= 43.25 short profit= 0.7863349999999983
+date: 2019-02-11 21:19:00 buy price= 43.489999999999995 sell price= 43.81 short profit= -0.3636500000000074
+date: 2019-02-12 17:19:00 buy price= 43.940000000000005 sell price= 42.96 short profit= 0.9365500000000039
+date: 2019-02-13 13:19:00 No transaction profit= 0
+date: 2019-02-14 09:19:00 No transaction profit= 0
+date: 2019-02-15 05:19:00 buy price= 41.78 sell price= 41.19 short profit= 0.5485150000000034
+date: 2019-02-16 01:19:00 buy price= 41.75 sell price= 42.24 short profit= -0.531995000000002
+date: 2019-02-16 21:19:00 buy price= 41.39 sell price= 43.63 long profit= 2.197490000000002
+date: 2019-02-17 17:19:00 buy price= 43.64 sell price= 43.44 long profit= -0.24354000000000284
+date: 2019-02-18 13:19:00 No transaction profit= 0
+date: 2019-02-19 09:19:00 No transaction profit= 0
+date: 2019-02-20 05:19:00 buy price= 47.91 sell price= 48.42 long profit= 0.4618350000000051
+date: 2019-02-21 01:19:00 No transaction profit= 0
+date: 2019-02-21 21:19:00 buy price= 48.45 sell price= 50.77 short profit= -2.36961
+date: 2019-02-22 17:19:00 buy price= 50.76 sell price= 49.02 short profit= 1.690109999999995
+date: 2019-02-23 13:19:00 No transaction profit= 0
+date: 2019-02-24 09:19:00 buy price= 49.57000000000001 sell price= 50.34 short profit= -0.8199549999999961
+date: 2019-02-25 05:19:00 buy price= 50.38000000000001 sell price= 52.27 short profit= -1.9413249999999935
+date: 2019-02-26 01:19:00 No transaction profit= 0
+date: 2019-02-26 21:19:00 No transaction profit= 0
+date: 2019-02-27 17:19:00 buy price= 44.940000000000005 sell price= 44.52 short profit= 0.3752700000000017
+date: 2019-02-28 13:19:00 buy price= 44.52 sell price= 44.12 long profit= -0.4443200000000057
+date: 2019-03-01 09:19:00 buy price= 44.13 sell price= 45.74 long profit= 1.5650649999999995
+date: 2019-03-02 05:19:00 No transaction profit= 0
+date: 2019-03-03 01:19:00 buy price= 47.39000000000001 sell price= 47.39 short profit= -0.047389999999992896
+date: 2019-03-03 21:19:00 No transaction profit= 0
+date: 2019-03-04 17:19:00 buy price= 48.399999999999984 sell price= 48.08 long profit= -0.3682399999999861
+date: 2019-03-05 13:19:00 No transaction profit= 0
+date: 2019-03-06 09:19:00 buy price= 47.01 sell price= 52.25 short profit= -5.2896300000000025
+date: 2019-03-07 05:19:00 buy price= 52.6 sell price= 54.53 short profit= -1.9835649999999998
+date: 2019-03-08 01:19:00 buy price= 55.94 sell price= 54.62 short profit= 1.2647200000000003
+date: 2019-03-08 21:19:00 buy price= 54.63 sell price= 56.67 short profit= -2.0956499999999996
+date: 2019-03-09 17:19:00 buy price= 56.7 sell price= 57.11 short profit= -0.4669049999999966
+date: 2019-03-10 13:19:00 No transaction profit= 0
+date: 2019-03-11 09:19:00 No transaction profit= 0
+date: 2019-03-12 05:19:00 buy price= 56.739999999999995 sell price= 54.85 short profit= 1.8342049999999934
+date: 2019-03-13 07:19:00 buy price= 56.90000000000001 sell price= 56.17 short profit= 0.6734650000000111
+date: 2019-03-14 03:18:00 buy price= 56.61 sell price= 55.07 short profit= 1.484159999999999
+date: 2019-03-14 23:18:00 buy price= 54.92999999999999 sell price= 55.48 long profit= 0.49479500000000426
+date: 2019-03-15 19:18:00 buy price= 55.16 sell price= 56.18 long profit= 0.9643300000000031
+date: 2019-03-16 15:18:00 No transaction profit= 0
+date: 2019-03-17 11:18:00 buy price= 58.22 sell price= 60.82 long profit= 2.5404800000000014
+date: 2019-03-18 07:18:00 buy price= 59.72 sell price= 60.69 long profit= 0.9097949999999989
+date: 2019-03-19 03:18:00 buy price= 61.09999999999999 sell price= 58.5 short profit= 2.540199999999987
+date: 2019-03-19 23:18:00 buy price= 59.20000000000001 sell price= 58.82 short profit= 0.32099000000000966
+date: 2019-03-20 19:18:00 No transaction profit= 0
+date: 2019-03-21 15:18:00 No transaction profit= 0
+date: 2019-03-22 11:18:00 buy price= 59.919999999999995 sell price= 58.5 long profit= -1.4792099999999946
+date: 2019-03-23 07:18:00 No transaction profit= 0
+date: 2019-03-24 03:18:00 buy price= 59.66 sell price= 60.43 short profit= -0.8300450000000031
+date: 2019-03-24 23:18:00 buy price= 60.43 sell price= 59.58 long profit= -0.9100050000000014
+date: 2019-03-25 19:18:00 buy price= 59.6 sell price= 60.15 long profit= 0.4901249999999972
+date: 2019-03-26 15:18:00 buy price= 58.60000000000001 sell price= 59.16 long profit= 0.501119999999988
+date: 2019-03-27 11:18:00 buy price= 59.16 sell price= 58.11 long profit= -1.1086349999999972
+date: 2019-03-28 07:18:00 buy price= 58.11 sell price= 60.51 long profit= 2.3406899999999986
+date: 2019-03-29 03:18:00 No transaction profit= 0
+date: 2019-03-29 23:18:00 buy price= 60.44 sell price= 60.34 long profit= -0.16038999999999431
+date: 2019-03-30 19:18:00 No transaction profit= 0
+date: 2019-03-31 15:18:00 No transaction profit= 0
+date: 2019-04-01 11:18:00 buy price= 60.39 sell price= 60.38 long profit= -0.070384999999998
+date: 2019-04-02 07:18:00 buy price= 60.300000000000004 sell price= 60.36 long profit= -0.00033000000000483684
+date: 2019-04-03 03:18:00 buy price= 60.27 sell price= 67.55 long profit= 7.216089999999994
+date: 2019-04-03 23:18:00 buy price= 67.55 sell price= 81.38 long profit= 13.755534999999998
+date: 2019-04-04 19:18:00 buy price= 81.22999999999999 sell price= 84.89 long profit= 3.576940000000011
+date: 2019-04-05 15:18:00 buy price= 84.88000000000001 sell price= 84.8 long profit= -0.1648400000000125
+date: 2019-04-06 11:18:00 buy price= 84.78 sell price= 87.37 long profit= 2.5039250000000033
+date: 2019-04-07 07:18:00 No transaction profit= 0
+date: 2019-04-08 03:18:00 No transaction profit= 0
+date: 2019-04-08 23:18:00 No transaction profit= 0
+date: 2019-04-09 19:18:00 buy price= 87.82 sell price= 86.6 short profit= 1.132789999999999
+date: 2019-04-10 15:18:00 No transaction profit= 0
+date: 2019-04-11 11:18:00 buy price= 88.82999999999998 sell price= 89.69 short profit= -0.9492600000000136
+date: 2019-04-12 07:18:00 No transaction profit= 0
+date: 2019-04-13 03:18:00 No transaction profit= 0
+date: 2019-04-13 23:18:00 buy price= 78.66999999999997 sell price= 79.48 long profit= 0.7309250000000307
+date: 2019-04-14 19:18:00 buy price= 78.96000000000001 sell price= 77.13 long profit= -1.9080450000000124
+date: 2019-04-15 15:18:00 buy price= 77.14 sell price= 81.76 long profit= 4.540550000000005
+date: 2019-04-16 11:18:00 No transaction profit= 0
+date: 2019-04-17 07:18:00 buy price= 77.11 sell price= 78.6 long profit= 1.412144999999995
+date: 2019-04-18 03:18:00 No transaction profit= 0
+date: 2019-04-18 23:18:00 No transaction profit= 0
+date: 2019-04-19 19:18:00 buy price= 80.6 sell price= 80.46 long profit= -0.22053000000000056
+date: 2019-04-20 15:18:00 No transaction profit= 0
+date: 2019-04-21 11:18:00 No transaction profit= 0
+date: 2019-04-22 07:18:00 buy price= 81.31 sell price= 75.22 short profit= 6.011735000000003
+date: 2019-04-23 03:18:00 buy price= 75.21 sell price= 76.92 long profit= 1.6339350000000081
+date: 2019-04-23 23:18:00 buy price= 76.78 sell price= 78.19 long profit= 1.3325149999999966
+date: 2019-04-24 19:18:00 No transaction profit= 0
+date: 2019-04-25 15:18:00 buy price= 72.19999999999999 sell price= 72.39 long profit= 0.11770500000001194
+date: 2019-04-26 11:18:00 No transaction profit= 0
+date: 2019-04-27 07:18:00 buy price= 75.41999999999999 sell price= 72.71 short profit= 2.6359349999999937
+date: 2019-04-28 03:18:00 buy price= 72.7 sell price= 72.97 long profit= 0.19716499999999604
+date: 2019-04-28 23:18:00 No transaction profit= 0
+date: 2019-04-29 19:18:00 buy price= 70.79000000000002 sell price= 70.02 long profit= -0.8404050000000245
+date: 2019-04-30 15:18:00 buy price= 70.02 sell price= 67.52 long profit= -2.56877
+date: 2019-05-01 11:18:00 No transaction profit= 0
+date: 2019-05-02 07:18:00 buy price= 73.55999999999999 sell price= 72.92 short profit= 0.5667599999999863
+date: 2019-05-03 03:18:00 No transaction profit= 0
+date: 2019-05-03 23:18:00 No transaction profit= 0
+date: 2019-05-04 19:18:00 No transaction profit= 0
+date: 2019-05-05 15:18:00 No transaction profit= 0
+date: 2019-05-06 11:18:00 buy price= 77.7 sell price= 75.98 short profit= 1.6431599999999988
+date: 2019-05-07 07:18:00 buy price= 76.83999999999999 sell price= 74.7 short profit= 2.0642299999999865
+date: 2019-05-08 03:18:00 buy price= 76.07000000000002 sell price= 76.77 short profit= -0.7764199999999745
+date: 2019-05-08 23:18:00 No transaction profit= 0
+date: 2019-05-09 19:18:00 No transaction profit= 0
+date: 2019-05-10 15:18:00 buy price= 75.43 sell price= 73.81 short profit= 1.5453800000000046
+date: 2019-05-11 11:18:00 buy price= 73.81 sell price= 76.88 short profit= -3.145344999999993
+date: 2019-05-12 07:18:00 buy price= 76.88 sell price= 87.24 long profit= 10.27794
+date: 2019-05-13 03:18:00 buy price= 84.56999999999998 sell price= 88.64 long profit= 3.9833950000000216
+date: 2019-05-13 23:18:00 No transaction profit= 0
+date: 2019-05-14 19:18:00 buy price= 85.79 sell price= 90.7 short profit= -4.998244999999996
+date: 2019-05-15 15:18:00 No transaction profit= 0
+date: 2019-05-16 21:17:00 buy price= 101.56 sell price= 100.59 short profit= 0.8689249999999988
+date: 2019-05-17 17:17:00 buy price= 101.99000000000002 sell price= 94.97 short profit= 6.921520000000024
+date: 2019-05-18 13:17:00 buy price= 94.95 sell price= 87.91 short profit= 6.9485700000000055
+date: 2019-05-19 09:17:00 No transaction profit= 0
+date: 2019-05-20 05:17:00 buy price= 87.95 sell price= 92.77 short profit= -4.910359999999993
+date: 2019-05-21 01:17:00 No transaction profit= 0
+date: 2019-05-21 21:17:00 No transaction profit= 0
+date: 2019-05-22 17:17:00 No transaction profit= 0
+date: 2019-05-23 13:17:00 buy price= 91.35 sell price= 88.65 short profit= 2.6099999999999883
+date: 2019-05-24 09:17:00 buy price= 88.68 sell price= 87.71 long profit= -1.058195000000013
+date: 2019-05-25 05:17:00 No transaction profit= 0
+date: 2019-05-26 01:17:00 No transaction profit= 0
+date: 2019-05-26 21:17:00 No transaction profit= 0
+date: 2019-05-27 17:17:00 buy price= 101.5 sell price= 112.14 short profit= -10.746820000000001
+date: 2019-05-28 13:17:00 buy price= 111.19999999999999 sell price= 113.77 long profit= 2.4575150000000074
+date: 2019-05-29 09:17:00 No transaction profit= 0
+date: 2019-05-30 05:17:00 buy price= 113.91 sell price= 115.53 long profit= 1.5052800000000044
+date: 2019-05-31 01:17:00 buy price= 115.55 sell price= 116.42 short profit= -0.9859850000000046
+date: 2019-05-31 21:17:00 No transaction profit= 0
+date: 2019-06-01 17:17:00 buy price= 106.05 sell price= 115.52 long profit= 9.359214999999999
+date: 2019-06-02 13:17:00 buy price= 115.67 sell price= 113.09 short profit= 2.4656199999999986
+date: 2019-06-03 09:17:00 buy price= 114.7 sell price= 114.1 short profit= 0.48560000000000847
+date: 2019-06-04 05:17:00 buy price= 114.98999999999998 sell price= 112.35 short profit= 2.5263299999999864
+date: 2019-06-05 01:17:00 buy price= 112.35 sell price= 103.12 short profit= 9.12226499999999
+date: 2019-06-05 21:17:00 No transaction profit= 0
+date: 2019-06-06 17:17:00 No transaction profit= 0
+date: 2019-06-07 13:17:00 buy price= 104.08 sell price= 107.53 long profit= 3.344195000000003
+date: 2019-06-08 09:17:00 No transaction profit= 0
+date: 2019-06-09 06:17:00 No transaction profit= 0
+date: 2019-06-10 02:17:00 buy price= 114.78 sell price= 117.11 long profit= 2.2140549999999983
+date: 2019-06-10 22:17:00 No transaction profit= 0
+date: 2019-06-11 18:17:00 buy price= 120.17 sell price= 128.01 short profit= -7.964089999999989
+date: 2019-06-12 14:17:00 buy price= 128.01 sell price= 135.78 long profit= 7.63810500000001
+date: 2019-06-13 10:17:00 No transaction profit= 0
+date: 2019-06-14 06:17:00 buy price= 136.73 sell price= 134.68 long profit= -2.185704999999983
+date: 2019-06-15 02:17:00 buy price= 134.68 sell price= 132.03 short profit= 2.5166450000000053
+date: 2019-06-15 22:17:00 No transaction profit= 0
+date: 2019-06-16 18:17:00 No transaction profit= 0
+date: 2019-06-17 14:17:00 buy price= 137.48999999999998 sell price= 135.98 short profit= 1.3732649999999909
+date: 2019-06-18 10:17:00 buy price= 135.98 sell price= 133.6 short profit= 2.2452099999999953
+date: 2019-06-19 06:17:00 buy price= 133.61 sell price= 134.82 short profit= -1.3442149999999795
+date: 2019-06-20 02:17:00 buy price= 137.92999999999998 sell price= 136.87 short profit= 0.9225999999999739
+date: 2019-06-20 22:17:00 buy price= 138.28000000000003 sell price= 136.23 short profit= 1.9127450000000399
+date: 2019-06-21 18:17:00 buy price= 136.23 sell price= 137.21 short profit= -1.1167200000000181
+date: 2019-06-22 14:17:00 buy price= 134.83 sell price= 136.57 long profit= 1.6042999999999807
+date: 2019-06-23 10:17:00 buy price= 136.58 sell price= 143.17 long profit= 6.450124999999975
+date: 2019-06-24 06:17:00 buy price= 143.23 sell price= 140.61 long profit= -2.761919999999976
+date: 2019-06-25 02:17:00 buy price= 139.97000000000003 sell price= 136.44 long profit= -3.6682050000000297
+date: 2019-06-25 22:17:00 buy price= 136.47 sell price= 136.37 long profit= -0.2364199999999943
+date: 2019-06-26 18:17:00 buy price= 135.73 sell price= 134.34 long profit= -1.5250349999999864
+date: 2019-06-27 14:17:00 buy price= 134.4 sell price= 131.57 long profit= -2.9629850000000126
+date: 2019-06-28 10:17:00 buy price= 129.01000000000002 sell price= 117.89 long profit= -11.243450000000019
+date: 2019-06-29 06:17:00 buy price= 113.71999999999997 sell price= 119.35 long profit= 5.513465000000023
+date: 2019-06-30 02:17:00 buy price= 119.28 sell price= 121.88 long profit= 2.4794199999999944
+date: 2019-06-30 22:17:00 No transaction profit= 0
+date: 2019-07-01 18:17:00 buy price= 131.43 sell price= 125.5 short profit= 5.8015350000000065
+date: 2019-07-02 14:17:00 No transaction profit= 0
+date: 2019-07-03 10:17:00 buy price= 121.89999999999999 sell price= 118.45 short profit= 3.3298249999999885
+date: 2019-07-04 06:17:00 buy price= 118.45 sell price= 119.17 long profit= 0.6011899999999989
+date: 2019-07-05 02:17:00 buy price= 119.18 sell price= 122.41 long profit= 3.1092049999999896
+date: 2019-07-05 22:17:00 No transaction profit= 0
+date: 2019-07-06 18:17:00 No transaction profit= 0
+date: 2019-07-07 14:17:00 buy price= 119.65 sell price= 117.94 short profit= 1.591205000000008
+date: 2019-07-08 10:17:00 buy price= 117.97 sell price= 118.61 long profit= 0.5217100000000006
+date: 2019-07-09 06:17:00 buy price= 118.61 sell price= 119.85 long profit= 1.120769999999995
+date: 2019-07-10 02:17:00 No transaction profit= 0
+date: 2019-07-10 22:17:00 buy price= 118.91 sell price= 118.38 long profit= -0.6486450000000011
+date: 2019-07-11 18:17:00 buy price= 116.66 sell price= 106.15 long profit= -10.62140499999999
+date: 2019-07-12 14:17:00 buy price= 106.15 sell price= 104.09 long profit= -2.1651200000000026
+date: 2019-07-13 10:17:00 buy price= 104.11 sell price= 105.05 long profit= 0.8354199999999977
+date: 2019-07-14 06:17:00 buy price= 104.22999999999999 sell price= 103.16 long profit= -1.173694999999993
+date: 2019-07-15 02:17:00 buy price= 102.50999999999999 sell price= 94.57 long profit= -8.038539999999998
+date: 2019-07-15 22:17:00 No transaction profit= 0
+date: 2019-07-16 18:17:00 No transaction profit= 0
+date: 2019-07-17 14:17:00 buy price= 89.54 sell price= 80.1 long profit= -9.524820000000012
+date: 2019-07-18 10:17:00 buy price= 78.21 sell price= 91.7 long profit= 13.40504500000001
+date: 2019-07-19 06:17:00 No transaction profit= 0
+date: 2019-07-20 02:17:00 buy price= 89.35 sell price= 97.43 short profit= -8.173390000000012
+date: 2019-07-20 22:17:00 buy price= 97.43 sell price= 99.51 long profit= 1.981529999999998
+date: 2019-07-21 18:17:00 No transaction profit= 0
+date: 2019-07-22 14:17:00 buy price= 100.5 sell price= 99.51 long profit= -1.0900049999999948
+date: 2019-07-23 10:17:00 buy price= 99.53 sell price= 93.81 short profit= 5.623329999999999
+date: 2019-07-24 06:17:00 No transaction profit= 0
+date: 2019-07-25 02:17:00 buy price= 89.38 sell price= 90.42 long profit= 0.9501000000000063
+date: 2019-07-25 22:17:00 buy price= 90.41 sell price= 93.87 long profit= 3.367860000000008
+date: 2019-07-26 18:17:00 buy price= 92.94 sell price= 91.57 long profit= -1.4622550000000045
+date: 2019-07-27 14:17:00 No transaction profit= 0
+date: 2019-07-28 10:17:00 buy price= 93.83 sell price= 88.43 short profit= 5.308869999999991
+date: 2019-07-29 06:17:00 buy price= 88.42 sell price= 89.15 long profit= 0.641215000000004
+date: 2019-07-30 02:17:00 buy price= 89.13 sell price= 89.36 long profit= 0.140755000000004
+date: 2019-07-30 22:17:00 No transaction profit= 0
+date: 2019-07-31 18:17:00 buy price= 89.64 sell price= 91.06 long profit= 1.3296500000000016
+date: 2019-08-01 14:17:00 No transaction profit= 0
+date: 2019-08-02 10:17:00 buy price= 98.94 sell price= 98.74 long profit= -0.2988400000000028
+date: 2019-08-03 06:17:00 buy price= 98.94999999999999 sell price= 97.01 short profit= 1.8420199999999836
+date: 2019-08-04 02:17:00 buy price= 97.29 sell price= 94.7 short profit= 2.4940050000000036
+date: 2019-08-04 22:17:00 No transaction profit= 0
+date: 2019-08-05 18:17:00 No transaction profit= 0
+date: 2019-08-06 14:17:00 buy price= 94.43999999999998 sell price= 98.02 long profit= 3.4837700000000127
+date: 2019-08-07 10:17:00 buy price= 98.01 sell price= 94.11 short profit= 3.8039400000000057
+date: 2019-08-08 06:17:00 buy price= 91.8 sell price= 92.97 long profit= 1.0776150000000015
+date: 2019-08-09 02:17:00 buy price= 89.53000000000002 sell price= 89.8 long profit= 0.18033499999998182
+date: 2019-08-09 22:17:00 buy price= 89.8 sell price= 88.86 long profit= -1.0293299999999976
+date: 2019-08-10 18:17:00 buy price= 88.86 sell price= 85.31 long profit= -3.6370849999999972
+date: 2019-08-11 14:17:00 No transaction profit= 0
+date: 2019-08-12 10:17:00 No transaction profit= 0
+date: 2019-08-13 06:17:00 buy price= 91.09 sell price= 87.27 short profit= 3.730820000000007
+date: 2019-08-14 02:17:00 buy price= 87.27 sell price= 85.61 short profit= 1.5735599999999965
+date: 2019-08-14 22:17:00 No transaction profit= 0
+date: 2019-08-16 02:17:00 buy price= 84.82 sell price= 75.7 long profit= -9.200259999999991
+date: 2019-08-16 22:16:00 buy price= 75.91 sell price= 74.2 long profit= -1.7850549999999936
+date: 2019-08-17 18:16:00 No transaction profit= 0
+date: 2019-08-18 14:16:00 buy price= 73.34000000000002 sell price= 72.24 long profit= -1.1727900000000226
+date: 2019-08-19 10:16:00 buy price= 71.45 sell price= 77.4 long profit= 5.875575000000002
+date: 2019-08-20 06:16:00 No transaction profit= 0
+date: 2019-08-21 02:16:00 buy price= 77.72 sell price= 75.69 short profit= 1.9532950000000013
+date: 2019-08-21 22:16:00 buy price= 75.63 sell price= 73.86 long profit= -1.8447449999999959
+date: 2019-08-22 18:16:00 buy price= 71.1 sell price= 71.91 long profit= 0.7384950000000023
+date: 2019-08-23 14:16:00 buy price= 71.96 sell price= 73.84 long profit= 1.8071000000000097
+date: 2019-08-24 10:16:00 buy price= 73.87 sell price= 75.19 long profit= 1.2454699999999932
+date: 2019-08-25 06:16:00 buy price= 73.19 sell price= 72.47 long profit= -0.7928299999999989
+date: 2019-08-26 02:16:00 No transaction profit= 0
+date: 2019-08-26 22:16:00 buy price= 71.90999999999998 sell price= 74.31 long profit= 2.32689000000002
+date: 2019-08-27 18:16:00 buy price= 74.29 sell price= 72.94 long profit= -1.4236150000000085
+date: 2019-08-28 14:16:00 buy price= 72.94 sell price= 72.45 long profit= -0.5626949999999948
+date: 2019-08-29 10:16:00 buy price= 69.73000000000002 sell price= 65.88 long profit= -3.9178050000000226
+date: 2019-08-30 06:16:00 buy price= 65.98 sell price= 64.94 long profit= -1.1054600000000063
+date: 2019-08-31 02:16:00 buy price= 64.89 sell price= 64.3 long profit= -0.6545950000000034
+date: 2019-08-31 22:16:00 No transaction profit= 0
+date: 2019-09-01 18:16:00 buy price= 63.44999999999999 sell price= 64.7 long profit= 1.185925000000014
+date: 2019-09-02 14:16:00 No transaction profit= 0
+date: 2019-09-03 10:16:00 buy price= 66.58 sell price= 66.72 short profit= -0.20665000000000056
+date: 2019-09-04 06:16:00 No transaction profit= 0
+date: 2019-09-05 02:16:00 buy price= 68.71999999999998 sell price= 67.38 long profit= -1.4080499999999891
+date: 2019-09-05 22:16:00 buy price= 67.39 sell price= 66.97 long profit= -0.4871800000000017
+date: 2019-09-06 18:16:00 No transaction profit= 0
+date: 2019-09-07 14:16:00 buy price= 65.28 sell price= 65.07 long profit= -0.27517500000000794
+date: 2019-09-08 10:16:00 buy price= 67.42999999999998 sell price= 69.43 short profit= -2.068430000000028
+date: 2019-09-09 06:16:00 buy price= 69.42 sell price= 69.37 short profit= -0.019395000000002847
+date: 2019-09-10 02:16:00 buy price= 68.96000000000001 sell price= 69.84 long profit= 0.8105999999999955
+date: 2019-09-10 22:16:00 No transaction profit= 0
+date: 2019-09-11 18:16:00 buy price= 71.47 sell price= 70.41 short profit= 0.9890600000000024
+date: 2019-09-12 14:16:00 No transaction profit= 0
+date: 2019-09-13 10:16:00 buy price= 69.41 sell price= 69.09 short profit= 0.2507499999999932
+date: 2019-09-14 06:16:00 buy price= 69.56 sell price= 68.49 short profit= 1.0009750000000073
+date: 2019-09-15 02:16:00 No transaction profit= 0
+date: 2019-09-15 22:16:00 No transaction profit= 0
+date: 2019-09-16 18:16:00 No transaction profit= 0
+date: 2019-09-17 14:16:00 buy price= 71.09 sell price= 72.68 long profit= 1.5181150000000034
+date: 2019-09-18 10:16:00 No transaction profit= 0
+date: 2019-09-19 06:16:00 buy price= 75.01 sell price= 76.36 short profit= -1.4256849999999943
+date: 2019-09-20 02:16:00 buy price= 78.26999999999998 sell price= 74.25 short profit= 3.943739999999982
+date: 2019-09-20 22:16:00 buy price= 75.41 sell price= 74.92 short profit= 0.4148349999999949
+date: 2019-09-21 18:16:00 buy price= 76.16000000000003 sell price= 75.02 short profit= 1.064410000000029
+date: 2019-09-22 14:16:00 No transaction profit= 0
+date: 2019-09-23 10:16:00 buy price= 72.8 sell price= 71.71 long profit= -1.1622550000000034
+date: 2019-09-24 06:16:00 No transaction profit= 0
+date: 2019-09-25 02:16:00 No transaction profit= 0
+Final total capital= 100115.14036000003
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [6]:
+
+
+
past_history = 35 
+
+
+
+last_day=len(df['TIME'])
+
+
+
+
+day=300
+k=day
+#for k in range(3000):
+
+h=0
+y=0
+z=0
+u=0
+
+
+
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        if trend>0 and trend_real>0:
+            h+=1
+            y+=1
+            
+        if trend>0 and trend_real<0:
+            h=h
+            y+=1
+        if trend<0 and trend_real<0:
+            z+=1
+            u+=1
+        if trend<0 and trend_real>0:
+            z=z
+            u+=1
+        
+        
+        
+        
+        
+        
+    k=k-1
+    
+print('accuracy of buy=',h/y)   
+    
+print('accuracy of sell=',z/u) 
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
accuracy of buy= 0.6141304347826086
+accuracy of sell= 0.7391304347826086
+
+
+
+ +
+
+ +
+
+
+
In [7]:
+
+
+
past_history = 35 
+
+
+
+last_day=len(df['TIME'])
+
+
+
+
+day=300
+k=day
+#for k in range(3000):
+
+h=0
+y=0
+z=0
+u=0
+
+H=[0]
+Z=[0]
+
+a=0
+
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        if trend>0 and trend_real>0:
+            h+=1
+            y+=1
+            
+        if trend>0 and trend_real<0:
+            h=h
+            y+=1
+        if trend<0 and trend_real<0:
+            z+=1
+            u+=1
+        if trend<0 and trend_real>0:
+            z=z
+            u+=1
+        
+        a+=1
+        
+        if a%15==0:
+            #print("counter=",a)
+            
+            H=np.vstack((H,h/y))
+            h=0
+            y=0
+            Z=np.vstack((Z,z/u))
+            z=0
+            u=0
+        
+        
+    k=k-1
+    
+H=H[1:]
+Z=Z[1:]
+
+print('success rate of buying in every 15 units',H)
+print('success rate of selling in every 15 units',Z)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
success rate of buying in every 15 units [[0.57142857]
+ [0.81818182]
+ [0.6       ]
+ [0.5       ]
+ [1.        ]
+ [0.53846154]
+ [0.75      ]
+ [0.90909091]
+ [0.66666667]
+ [1.        ]
+ [0.66666667]
+ [0.75      ]
+ [0.33333333]
+ [0.5       ]
+ [0.41666667]
+ [0.4       ]
+ [0.58333333]
+ [0.42857143]
+ [0.66666667]
+ [0.83333333]]
+success rate of selling in every 15 units [[1.        ]
+ [0.75      ]
+ [0.6       ]
+ [0.5       ]
+ [0.8       ]
+ [0.5       ]
+ [0.85714286]
+ [1.        ]
+ [0.83333333]
+ [0.63636364]
+ [0.77777778]
+ [0.71428571]
+ [0.66666667]
+ [0.66666667]
+ [0.66666667]
+ [1.        ]
+ [1.        ]
+ [1.        ]
+ [0.5       ]
+ [0.88888889]]
+
+
+
+ +
+
+ +
+
+
+
In [8]:
+
+
+
from scipy import stats
+stats.ttest_1samp(H,0.5)               #t test of buying success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[8]:
+ + + + +
+
Ttest_1sampResult(statistic=array([3.34191632]), pvalue=array([0.00342579]))
+
+ +
+ +
+
+ +
+
+
+
In [9]:
+
+
+
stats.ttest_1samp(Z,0.5)               #t test of selling success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[9]:
+ + + + +
+
Ttest_1sampResult(statistic=array([6.78652645]), pvalue=array([1.760099e-06]))
+
+ +
+ +
+
+ +
+
+
+
In [10]:
+
+
+
import numpy as np, scipy.stats as st
+st.t.interval(0.95, len(H)-1, loc=np.mean(H), scale=st.sem(H))      #95% Confidence interval of buying success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[10]:
+ + + + +
+
(array([0.55479271]), array([0.73844739]))
+
+ +
+ +
+
+ +
+
+
+
In [11]:
+
+
+
import numpy as np, scipy.stats as st
+st.t.interval(0.95, len(Z)-1, loc=np.mean(Z), scale=st.sem(Z))       #95% Confidence interval of selling success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[11]:
+ + + + +
+
(array([0.68527011]), array([0.85050911]))
+
+ +
+ +
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+ + + + + + diff --git a/XRP_LSTM.html b/XRP_LSTM.html new file mode 100644 index 0000000..9656d97 --- /dev/null +++ b/XRP_LSTM.html @@ -0,0 +1,14961 @@ + + + + +XRP_LSTM + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
In [1]:
+
+
+
from __future__ import absolute_import, division, print_function, unicode_literals
+try:
+  # %tensorflow_version only exists in Colab.
+  %tensorflow_version 2.x
+except Exception:
+  pass
+import tensorflow as tf
+
+import matplotlib as mpl
+import matplotlib.pyplot as plt
+import numpy as np
+import os
+import pandas as pd
+
+df= pd.read_excel("data_summary.xlsx", sheet_name=3)
+
+
+df=np.array(df)
+df=pd.DataFrame(df)
+close_price=df[4]
+
+
+CLOSE=[0]
+
+frequency=1200     #1440min合成1条k线
+
+for i in range(len(close_price)):
+    if (i+1) %frequency==0:
+        CLOSE=np.vstack((CLOSE,close_price[i]))
+
+CLOSE=CLOSE[1:]    
+
+
+#open_price=df['open']
+
+open_price=df[1]
+
+
+
+OPEN=[0]
+
+for i in range(len(close_price)):
+    if (i+1) %frequency==0:
+        OPEN=np.vstack((OPEN,open_price[i-(frequency-1)]))
+
+OPEN=OPEN[1:]    
+
+
+#high_price=df['high']
+high_price=df[2]
+
+
+HIGH=[0]
+
+for i in range(len(high_price)):
+    if (i+1) %frequency==0:
+        HIGH=np.vstack((HIGH,max(high_price[i-(frequency-1):i+1])))
+
+HIGH=HIGH[1:]  
+
+#low_price=df['low']
+low_price=df[3]
+
+LOW=[0]
+
+for i in range(len(low_price)):
+    if (i+1) %frequency==0:
+        LOW=np.vstack((LOW,min(low_price[i-(frequency-1):i+1])))
+
+LOW=LOW[1:]
+
+#time=df['time']
+time=df[0]
+
+TIME=[0]
+
+for i in range(len(time)):
+    if (i+1) %frequency==0:
+        TIME=np.vstack((TIME,time[i]))
+
+TIME=TIME[1:] 
+
+data=np.hstack((TIME,CLOSE,HIGH,LOW,OPEN))
+data=pd.DataFrame(data)
+data.columns = ["TIME", "C","H","L","O"]
+df=data
+zero=np.array([0])
+rt=np.diff(np.array(df['C']))
+rt=np.hstack((zero,rt))
+df.insert(5, 'Diff_C', rt) 
+
+moving_avg = df['Diff_C'].rolling(window=5).mean(center=True)
+MV=moving_avg[2:len(rt)-2]
+zeros=np.zeros((4))
+MV=np.hstack((zeros,MV))
+df.insert(6, 'MV_C', MV) 
+
+ +
+
+
+ +
+
+
+
In [2]:
+
+
+
features_considered=['MV_C']
+
+features = df[features_considered]                       
+features.index = df['TIME']        #在前面加一列时间
+
+dataset = features.values
+TRAIN_SPLIT = (len(df)*7)//10      #first 70% of the rows in dataset will be the training dataset
+tf.random.set_seed(13)     # 保持random selection每次都一样
+EVALUATION_INTERVAL = 400       #原来是200
+EPOCHS = 10       #1个epoch等于使用训练集中的全部样本训练一次,通俗的讲epoch的值就是整个数据集被轮几次。
+BATCH_SIZE = 256           #训练的小批次, iteration=TRAIN_SPLIT/256
+BUFFER_SIZE = 10000       #缓存容量 
+def multivariate_data(dataset, target, start_index, end_index, history_size,
+                      target_size, step, single_step=False):         
+    data = []
+    labels = []
+
+    start_index = start_index + history_size
+    if end_index is None:
+        end_index = len(dataset) - target_size
+
+    for i in range(start_index, end_index):
+        indices = range(i-history_size, i, step)             #就是在取过去天数的样本时,是间隔着几天取的,这样可以减少训练时间
+        data.append(dataset[indices])
+
+        if single_step:
+            labels.append(target[i+target_size])                #就是说,这里可以规定只预测后面某一天或者是后面好几天
+        else:
+            labels.append(target[i:i+target_size])               
+
+    return np.array(data), np.array(labels)        #output 出numpy格式的数据
+
+past_history = 35         # 用过去50天的数据,本来是720
+future_target = 0            #本来是72  预测12天后的数据,或者是下一天到12天后的数据   72/6=12
+STEP = 1                    #本来是6,取过去天数的样本时,是间隔着6天取的,这样可以减少训练时间
+
+#future_target = 1          # 预测12天后的数据,或者是下一天到12天后的数据   72/6=12
+#STEP = 1                     #取过去天数的样本时,是间隔着6天取的,这样可以减少训练时间
+
+
+x_train_single, y_train_single = multivariate_data(dataset, dataset[:, 0], 0,
+                                                   TRAIN_SPLIT, past_history,
+                                                   future_target, STEP,
+                                                   single_step=True)
+x_val_single, y_val_single = multivariate_data(dataset, dataset[:, 0],
+                                               TRAIN_SPLIT, None, past_history,
+                                               future_target, STEP,
+                                               single_step=True)
+
+train_data_single = tf.data.Dataset.from_tensor_slices((x_train_single, y_train_single))              
+train_data_single = train_data_single.cache().shuffle(BUFFER_SIZE).batch(BATCH_SIZE).repeat()      #traning data 
+
+val_data_single = tf.data.Dataset.from_tensor_slices((x_val_single, y_val_single))
+val_data_single = val_data_single.batch(BATCH_SIZE).repeat()                        #validation data 
+
+
+single_step_model = tf.keras.models.Sequential()
+single_step_model.add(tf.keras.layers.LSTM(3,
+                                           input_shape=x_train_single.shape[-2:]))    #应该是这一层有32 个神经元
+single_step_model.add(tf.keras.layers.Dense(1))                         #output layer, 因为预测未来1 期的data, 所以是1个神经元
+
+single_step_model.compile(optimizer=tf.keras.optimizers.RMSprop(), loss='mae')    #这里优化算法用RMSprop而不是Adam 或 Momentum
+
+single_step_history = single_step_model.fit(train_data_single, epochs=EPOCHS,      #EPOCHS = 10  轮10次
+                                            steps_per_epoch=EVALUATION_INTERVAL,    #每轮test 200次 data
+                                            validation_data=val_data_single, 
+                                            validation_steps=50)      #设置验证多少次数据后取平均值作为此epoch训练后的效果 
+
+def plot_train_history(history, title):             #把training lost 和validation loss 表示出来
+  loss = history.history['loss']             
+  val_loss = history.history['val_loss']
+
+  epochs = range(len(loss))
+
+  plt.figure()
+
+  plt.plot(epochs, loss, 'b', label='Training loss')
+  plt.plot(epochs, val_loss, 'r', label='Validation loss')
+  plt.title(title)
+  plt.legend()
+
+  plt.show()
+
+plot_train_history(single_step_history,
+                   'Single Step Training and validation loss')
+
+single_step_model.save('XRP_1200.h5') 
+model = tf.keras.models.load_model('XRP_1200.h5')
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
Train for 400 steps, validate for 50 steps
+Epoch 1/10
+400/400 [==============================] - 14s 35ms/step - loss: 0.0058 - val_loss: 0.0037
+Epoch 2/10
+400/400 [==============================] - 10s 25ms/step - loss: 0.0045 - val_loss: 0.0030
+Epoch 3/10
+400/400 [==============================] - 9s 22ms/step - loss: 0.0037 - val_loss: 0.0029
+Epoch 4/10
+400/400 [==============================] - 9s 24ms/step - loss: 0.0034 - val_loss: 0.0023
+Epoch 5/10
+400/400 [==============================] - 7s 17ms/step - loss: 0.0034 - val_loss: 0.0025
+Epoch 6/10
+400/400 [==============================] - 7s 18ms/step - loss: 0.0034 - val_loss: 0.0023
+Epoch 7/10
+400/400 [==============================] - 7s 18ms/step - loss: 0.0033 - val_loss: 0.0023
+Epoch 8/10
+400/400 [==============================] - 7s 17ms/step - loss: 0.0033 - val_loss: 0.0024
+Epoch 9/10
+400/400 [==============================] - 9s 22ms/step - loss: 0.0032 - val_loss: 0.0024
+Epoch 10/10
+400/400 [==============================] - 9s 22ms/step - loss: 0.0032 - val_loss: 0.0024
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [3]:
+
+
+
df['TIME']#
+
+R1=[0]
+R2=[0]
+
+
+past_history = 35 
+TC=100000       #总资金10万
+
+C=1             #每次交易1手
+
+
+leverage=1
+
+cost_rate=0.0005
+
+
+price_per_point=1       #1点300元
+
+last_day=len(df['TIME'])
+
+
+m=0
+n=0
+p=0
+r=0
+R=0
+s=0
+
+I=0
+B=0
+RR=[0]
+II=[0]
+BB=[0]
+tt=0
+t=0
+d=0
+d2=0
+
+rr=[0]
+maximum_markdown_final=[0]
+CR=1
+CRR=[0]
+TCC=[0]
+
+day=500
+k=day
+#for k in range(3000):
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        #print(data2)
+
+        #j=[0,0,0,0,0]
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        #trend=x[0][0]-MV[-1-k]-MV[-2-k]                #预测正负
+        
+        #trend_real=MV[-k]-MV[-1-k]-MV[-2-k]           #实际正负
+        
+        #P0=np.array(df['C'])[-7-k]
+        #P1=np.array(df['C'])[-6-k]
+        #P2=np.array(df['C'])[-5-k]
+        #P5=np.array(df['C'])[-2-k]
+        #P6=np.array(df['C'])[-1-k]
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        P0=np.array(df['C'])[-6-k]
+        P1=np.array(df['C'])[-5-k]
+        P5=np.array(df['C'])[-1-k]
+        
+        
+        
+        
+        
+        #line=P6+P5+P2-P1-P0
+        
+        line=P5+P1-P0
+        
+        L=np.array(df['L'])[-k]
+        H=np.array(df['H'])[-k]
+        
+        if trend<0:
+            if P5-d2>line and (np.array(df['O'])[-k])-d2>line:
+                r1=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+               
+                
+                
+            else:
+                if L<line<H:
+                    r1=((np.array(df['C'])[-k])-(line))/(line)                      #r1必须小于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                   
+                else:
+                    r1=0
+                    maximum_markdown=0
+                       
+            
+            if r1!=0:
+                m+=1
+                R1=np.vstack((R1,r1))
+                
+            
+            if r1<0:
+                n+=1
+            r=r+r1
+            R=R-r1
+            
+        else:
+            r1=0
+            r=r
+            R=R
+            maximum_markdown=0
+           
+        
+        if trend>0:
+            
+            
+            if P5<line-d and (np.array(df['O'])[-k])<line-d:
+                r2=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+               
+            else:
+                if L<line<H:
+                    r2=((np.array(df['C'])[-k])-(line))/(line)    #r2必须大于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                   
+                else:
+                    r2=0
+                    maximum_markdown=0
+                    profit2=0
+                    
+                   
+            
+            if r2!=0:
+                m+=1
+                s+=1
+                
+                R2=np.vstack((R2,r2))
+            
+            if r2>0:
+                p+=1
+            R=R+r2
+        else:
+            R=R
+            r2=0
+            maximum_markdown=0
+            profit2=0
+            
+            
+        
+        
+        i=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+        I=I+i
+        
+        b=((np.array(df['C'])[-k])-(np.array(df['C'])[-k-1]))/(np.array(df['C'])[-k-1])
+        B=B+b
+        
+        
+        BB=np.vstack((BB,B))
+        RR=np.vstack((RR,R))  
+        II=np.vstack((II,I))
+        
+        maximum_markdown_final=np.vstack((maximum_markdown_final,maximum_markdown))
+        rr=np.vstack((rr,r2))
+        
+        if r1!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        if r2!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        
+        CRR=np.vstack((CRR,(CR-1)*10))
+    k=k-1
+    
+    
+
+    
+    
+    
+RR=RR[1:]
+II=II[1:]
+tt=tt[1:]
+
+R1=R1[1:]
+R2=R2[1:]
+
+
+plt.plot(tt,RR)               
+#plt.plot(tt,II) 
+BB=BB[1:]
+plt.plot(tt,BB)
+
+
+  
+maximum_markdown_final=maximum_markdown_final[1:]        
+#plt.plot(tt,maximum_markdown_final)  
+final_maximum=min(maximum_markdown_final)
+rr=rr[1:]
+maximum_loss=min(rr) 
+
+     
+print("trading dates=",m)
+print("success to sell=",n)
+print("success to buy=",p)
+print('return from short=',-r)
+print('total return of long and short=',R)
+print('Time of long',s)      
+print('maximum markdown=',final_maximum)
+print('maximum loss=',maximum_loss)
+
+print('compound interest=',CR-1)
+
+import numpy as np, scipy.stats as st
+CI_R1=st.t.interval(0.9, len(R1)-1, loc=np.mean(R1), scale=st.sem(R1))      #90% Confidence interval of short
+CI_R2=st.t.interval(0.9, len(R2)-1, loc=np.mean(R2), scale=st.sem(R2))      #90% Confidence interval of long
+
+print("confidence interval of short=",CI_R1)
+print("confidence interval of long=",CI_R2)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
trading dates= 316
+success to sell= 54
+success to buy= 106
+return from short= -0.42473599960484154
+total return of long and short= -0.7495352485129669
+Time of long 221
+maximum markdown= [-0.19243723]
+maximum loss= [-0.12346882]
+compound interest= 0.3675221437091192
+confidence interval of short= (array([-0.00410155]), array([0.01304336]))
+confidence interval of long= (array([-0.00577547]), array([0.00283611]))
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [4]:
+
+
+
#
+
+TC=100000       #总资金10万
+
+C=1             #每次交易1手
+
+
+leverage=1
+
+cost_rate=0.0005
+
+
+price_per_point=1       #1点300元
+
+last_day=len(df['TIME'])
+
+
+m=0
+n=0
+p=0
+r=0
+R=0
+s=0
+
+I=0
+B=100000
+RR=[0]
+II=[0]
+BB=[0]
+tt=0
+t=0
+d=0
+d2=0
+
+rr=[0]
+maximum_markdown_final=[0]
+CR=1
+CRR=[0]
+TCC=[0]
+
+day=500
+k=day
+#for k in range(3000):
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        #print(data2)
+
+        #j=[0,0,0,0,0]
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        #trend=x[0][0]-MV[-1-k]-MV[-2-k]                #预测正负
+        
+        #trend_real=MV[-k]-MV[-1-k]-MV[-2-k]           #实际正负
+        
+        #P0=np.array(df['C'])[-7-k]
+        #P1=np.array(df['C'])[-6-k]
+        #P2=np.array(df['C'])[-5-k]
+        #P5=np.array(df['C'])[-2-k]
+        #P6=np.array(df['C'])[-1-k]
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        P0=np.array(df['C'])[-6-k]
+        P1=np.array(df['C'])[-5-k]
+        P5=np.array(df['C'])[-1-k]
+        
+        
+        
+        
+        
+        #line=P6+P5+P2-P1-P0
+        
+        line=P5+P1-P0
+        
+        L=np.array(df['L'])[-k]
+        H=np.array(df['H'])[-k]
+        
+        if trend<0:
+            if P5-d2>line and (np.array(df['O'])[-k])-d2>line:
+                r1=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+                profit1=C*(((np.array(df['O'])[-k])*price_per_point-np.array(df['C'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(np.array(df['O'])[-k])*price_per_point*cost_rate)
+                
+                print('date:',df['TIME'][last_day-k],'buy price=',(np.array(df['O'])[-k]),"sell price=",(np.array(df['C'])[-k]),'short profit=',profit1)
+                
+                
+            else:
+                if L<line<H:
+                    r1=((np.array(df['C'])[-k])-(line))/(line)                      #r1必须小于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                    profit1=C*(((line)*price_per_point-np.array(df['C'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(line)*price_per_point*cost_rate)
+                    print('date:',df['TIME'][last_day-k],'buy price=',(line),"sell price=",(np.array(df['C'])[-k]),'short profit=',profit1)
+                    
+                else:
+                    r1=0
+                    maximum_markdown=0
+                    profit1=0
+                    
+                    print('date:',df['TIME'][last_day-k],'No transaction','profit=',0)
+            
+            
+            if r1!=0:
+                m+=1
+                
+            
+            if r1<0:
+                n+=1
+            r=r+r1
+            R=R-r1
+            
+        else:
+            r1=0
+            r=r
+            R=R
+            maximum_markdown=0
+            profit1=0
+            
+        
+        if trend>0:
+            
+            
+            if P5<line-d and (np.array(df['O'])[-k])<line-d:
+                r2=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                maximum_markdown=((np.array(df['L'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+                
+                profit2=C*((np.array(df['C'])[-k])*price_per_point-(np.array(df['O'])[-k])*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(np.array(df['O'])[-k])*price_per_point*cost_rate)
+                
+                print('date:',df['TIME'][last_day-k],'buy price=',(np.array(df['O'])[-k]),"sell price=",(np.array(df['C'])[-k]),'long profit=',profit2)
+                
+                
+            else:
+                if L<line<H:
+                    r2=((np.array(df['C'])[-k])-(line))/(line)    #r2必须大于0 
+                    maximum_markdown=((np.array(df['L'])[-k])-(line))/(line)
+                    
+                    profit2=(np.array(df['C'])[-k])*price_per_point-(line)*price_per_point-(np.array(df['C'])[-k])*price_per_point*cost_rate-(line)*price_per_point*cost_rate
+                    
+                    print('date:',df['TIME'][last_day-k],'buy price=',(line),"sell price=",(np.array(df['C'])[-k]),'long profit=',profit2)
+                    
+                else:
+                    r2=0
+                    maximum_markdown=0
+                    profit2=0
+                    
+                    print('date:',df['TIME'][last_day-k],'No transaction','profit=',0)
+            
+            
+            if r2!=0:
+                m+=1
+                s+=1
+            
+            if r2>0:
+                p+=1
+            R=R+r2
+        else:
+            R=R
+            r2=0
+            maximum_markdown=0
+            profit2=0
+            
+            
+        TC=TC+profit1+profit2
+        TCC=np.vstack((TCC,TC))
+        
+        i=((np.array(df['C'])[-k])-(np.array(df['O'])[-k]))/(np.array(df['O'])[-k])
+        I=I+i
+        
+        b=((np.array(df['C'])[-k])-(np.array(df['C'])[-k-1]))
+        B=B+b
+        
+        
+        BB=np.vstack((BB,B))
+        RR=np.vstack((RR,R))  
+        II=np.vstack((II,I))
+        
+        maximum_markdown_final=np.vstack((maximum_markdown_final,maximum_markdown))
+        rr=np.vstack((rr,r2))
+        
+        if r1!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        if r2!=0:
+            CR=CR*(1+r1)
+        else:
+            CR=CR
+        
+        CRR=np.vstack((CRR,(CR-1)*10))
+    k=k-1
+    
+    
+
+    
+    
+    
+RR=RR[1:]
+II=II[1:]
+tt=tt[1:]
+
+TCC=TCC[1:]
+
+
+
+#plt.plot(tt,RR)               
+#plt.plot(tt,II) 
+plt.plot(tt,TCC) 
+BB=BB[1:]
+plt.plot(tt,BB)
+
+
+  
+maximum_markdown_final=maximum_markdown_final[1:]        
+#plt.plot(tt,maximum_markdown_final)  
+final_maximum=min(maximum_markdown_final)
+rr=rr[1:]
+maximum_loss=min(rr) 
+
+     
+
+
+print("Final total capital=",TC)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
date: 2018-08-03 19:28:00 buy price= 0.44346 sell price= 0.43077 long profit= -0.013127115000000035
+date: 2018-08-04 15:28:00 No transaction profit= 0
+date: 2018-08-05 11:28:00 buy price= 0.44091 sell price= 0.431 short profit= 0.00947404500000003
+date: 2018-08-06 07:28:00 No transaction profit= 0
+date: 2018-08-07 03:28:00 buy price= 0.42807 sell price= 0.42658 long profit= -0.0019173249999999914
+date: 2018-08-07 23:28:00 buy price= 0.41407000000000005 sell price= 0.41065 long profit= -0.003832360000000034
+date: 2018-08-08 19:28:00 buy price= 0.41063 sell price= 0.35993 long profit= -0.05108527999999996
+date: 2018-08-09 15:28:00 buy price= 0.35003 sell price= 0.32774 long profit= -0.022628885000000033
+date: 2018-08-10 11:28:00 No transaction profit= 0
+date: 2018-08-11 07:28:00 buy price= 0.3403900000000001 sell price= 0.33399 long profit= -0.006737190000000072
+date: 2018-08-12 03:28:00 buy price= 0.31805999999999995 sell price= 0.29648 long profit= -0.021887269999999934
+date: 2018-08-12 23:28:00 No transaction profit= 0
+date: 2018-08-13 19:28:00 No transaction profit= 0
+date: 2018-08-14 15:28:00 buy price= 0.29869 sell price= 0.27905 long profit= -0.01992886999999999
+date: 2018-08-15 11:28:00 buy price= 0.26883 sell price= 0.26128 long profit= -0.007815055000000001
+date: 2018-08-16 07:28:00 No transaction profit= 0
+date: 2018-08-17 03:28:00 buy price= 0.2985799999999999 sell price= 0.29254 short profit= 0.0057444399999998785
+date: 2018-08-17 23:28:00 buy price= 0.28711000000000003 sell price= 0.30559 long profit= 0.01818364999999994
+date: 2018-08-18 19:28:00 No transaction profit= 0
+date: 2018-08-19 15:28:00 buy price= 0.34432 sell price= 0.3267 short profit= 0.017284490000000024
+date: 2018-08-20 11:28:00 No transaction profit= 0
+date: 2018-08-21 07:28:00 buy price= 0.34359000000000006 sell price= 0.33101 short profit= 0.012242700000000035
+date: 2018-08-22 03:28:00 No transaction profit= 0
+date: 2018-08-22 23:28:00 No transaction profit= 0
+date: 2018-08-23 19:28:00 buy price= 0.32311999999999996 sell price= 0.31797 long profit= -0.005470544999999988
+date: 2018-08-24 15:28:00 buy price= 0.3185 sell price= 0.32546 long profit= 0.006638020000000022
+date: 2018-08-25 11:28:00 No transaction profit= 0
+date: 2018-08-26 07:28:00 buy price= 0.32611 sell price= 0.32732 short profit= -0.0015367149999999889
+date: 2018-08-27 03:28:00 buy price= 0.32752 sell price= 0.32327 long profit= -0.004575394999999976
+date: 2018-08-27 23:28:00 No transaction profit= 0
+date: 2018-08-28 19:28:00 buy price= 0.33515000000000006 sell price= 0.33921 short profit= -0.004397179999999952
+date: 2018-08-29 15:28:00 buy price= 0.33921 sell price= 0.35328 short profit= -0.014416244999999972
+date: 2018-08-30 11:28:00 No transaction profit= 0
+date: 2018-08-31 07:28:00 buy price= 0.34105 sell price= 0.32931 long profit= -0.012075180000000027
+date: 2018-09-01 03:28:00 buy price= 0.32926 sell price= 0.33284 long profit= 0.0032489500000000278
+date: 2018-09-01 23:28:00 buy price= 0.34439000000000003 sell price= 0.33909 short profit= 0.004958260000000027
+date: 2018-09-02 19:28:00 buy price= 0.3531599999999999 sell price= 0.3446 short profit= 0.008211119999999902
+date: 2018-09-03 15:28:00 buy price= 0.33642 sell price= 0.34138 long profit= 0.0046211000000000195
+date: 2018-09-04 11:28:00 No transaction profit= 0
+date: 2018-09-05 07:28:00 buy price= 0.33856 sell price= 0.33732 long profit= -0.0015779400000000188
+date: 2018-09-06 03:28:00 buy price= 0.33732 sell price= 0.302 long profit= -0.03563966000000002
+date: 2018-09-06 23:28:00 buy price= 0.30172 sell price= 0.28183 long profit= -0.02018177499999996
+date: 2018-09-07 19:28:00 No transaction profit= 0
+date: 2018-09-08 15:28:00 buy price= 0.30096 sell price= 0.28888 short profit= 0.01178507999999998
+date: 2018-09-09 11:28:00 buy price= 0.2880600000000001 sell price= 0.27339 long profit= -0.014950725000000071
+date: 2018-09-10 07:28:00 No transaction profit= 0
+date: 2018-09-11 03:28:00 No transaction profit= 0
+date: 2018-09-11 23:28:00 buy price= 0.27245 sell price= 0.26838 long profit= -0.0043404150000000185
+date: 2018-09-12 19:28:00 buy price= 0.2562600000000001 sell price= 0.25656 long profit= 4.3589999999911374e-05
+date: 2018-09-13 15:28:00 No transaction profit= 0
+date: 2018-09-14 11:28:00 buy price= 0.27984 sell price= 0.28 short profit= -0.000439920000000049
+date: 2018-09-15 07:28:00 No transaction profit= 0
+date: 2018-09-16 03:28:00 No transaction profit= 0
+date: 2018-09-16 23:28:00 No transaction profit= 0
+date: 2018-09-17 19:28:00 No transaction profit= 0
+date: 2018-09-18 15:28:00 No transaction profit= 0
+date: 2018-09-19 11:28:00 No transaction profit= 0
+date: 2018-09-20 07:28:00 buy price= 0.32304999999999995 sell price= 0.32576 short profit= -0.0030344050000000455
+date: 2018-09-21 03:28:00 buy price= 0.32229 sell price= 0.35734 long profit= 0.03471018499999997
+date: 2018-09-21 23:28:00 buy price= 0.36338000000000004 sell price= 0.46801 short profit= -0.10504569499999994
+date: 2018-09-22 19:28:00 buy price= 0.46801 sell price= 0.51288 short profit= -0.04536044500000002
+date: 2018-09-23 15:28:00 buy price= 0.55869 sell price= 0.566 short profit= -0.007872344999999928
+date: 2018-09-24 11:28:00 buy price= 0.5731399999999999 sell price= 0.56738 short profit= 0.005189739999999877
+date: 2018-09-25 07:28:00 No transaction profit= 0
+date: 2018-09-26 03:28:00 No transaction profit= 0
+date: 2018-09-26 23:28:00 buy price= 0.49274 sell price= 0.53235 short profit= -0.04012254499999998
+date: 2018-09-27 19:28:00 No transaction profit= 0
+date: 2018-09-28 15:28:00 buy price= 0.535 sell price= 0.54269 long profit= 0.007151154999999974
+date: 2018-09-29 11:28:00 No transaction profit= 0
+date: 2018-09-30 07:28:00 No transaction profit= 0
+date: 2018-10-01 03:28:00 No transaction profit= 0
+date: 2018-10-01 23:28:00 No transaction profit= 0
+date: 2018-10-02 19:28:00 buy price= 0.58218 sell price= 0.57041 long profit= -0.01234629500000006
+date: 2018-10-03 15:28:00 buy price= 0.57 sell price= 0.52271 short profit= 0.046743644999999945
+date: 2018-10-04 11:28:00 No transaction profit= 0
+date: 2018-10-05 07:28:00 buy price= 0.52 sell price= 0.53338 long profit= 0.012853309999999948
+date: 2018-10-06 03:28:00 No transaction profit= 0
+date: 2018-10-06 23:28:00 No transaction profit= 0
+date: 2018-10-07 19:28:00 buy price= 0.47138 sell price= 0.47998 long profit= 0.008124319999999996
+date: 2018-10-08 15:28:00 buy price= 0.4772700000000001 sell price= 0.47428 long profit= -0.0034657750000001036
+date: 2018-10-09 11:28:00 buy price= 0.47428 sell price= 0.49375 long profit= 0.018985985000000042
+date: 2018-10-10 07:28:00 buy price= 0.48189000000000015 sell price= 0.4786 long profit= -0.0037702450000001264
+date: 2018-10-11 03:28:00 buy price= 0.47616 sell price= 0.47293 long profit= -0.0037045450000000105
+date: 2018-10-11 23:28:00 buy price= 0.43383000000000005 sell price= 0.4045 long profit= -0.029749165000000025
+date: 2018-10-12 19:28:00 buy price= 0.3988 sell price= 0.39431 long profit= -0.004886554999999994
+date: 2018-10-13 15:28:00 buy price= 0.39357 sell price= 0.42557 long profit= 0.03159043000000003
+date: 2018-10-14 11:28:00 No transaction profit= 0
+date: 2018-10-15 07:28:00 No transaction profit= 0
+date: 2018-10-16 03:28:00 No transaction profit= 0
+date: 2018-10-16 23:28:00 buy price= 0.47884 sell price= 0.4745 short profit= 0.0038633300000000107
+date: 2018-10-17 19:28:00 buy price= 0.4743 sell price= 0.4816 long profit= 0.006822049999999973
+date: 2018-10-18 15:28:00 buy price= 0.47565999999999997 sell price= 0.48503 long profit= 0.008889655000000045
+date: 2018-10-19 11:28:00 buy price= 0.48839000000000005 sell price= 0.46259 short profit= 0.025324510000000047
+date: 2018-10-20 10:58:00 No transaction profit= 0
+date: 2018-10-21 06:57:00 buy price= 0.45787999999999995 sell price= 0.46813 long profit= 0.009786995000000036
+date: 2018-10-22 02:57:00 buy price= 0.46814 sell price= 0.47222 long profit= 0.003609819999999973
+date: 2018-10-22 22:57:00 buy price= 0.47169 sell price= 0.46708 long profit= -0.005079385000000003
+date: 2018-10-23 18:57:00 No transaction profit= 0
+date: 2018-10-24 14:57:00 buy price= 0.46214 sell price= 0.46663 short profit= -0.0049543849999999934
+date: 2018-10-25 10:57:00 buy price= 0.47255 sell price= 0.46982 short profit= 0.00225881500000001
+date: 2018-10-26 06:57:00 buy price= 0.46981 sell price= 0.46404 long profit= -0.006236924999999997
+date: 2018-10-27 02:57:00 No transaction profit= 0
+date: 2018-10-27 22:57:00 buy price= 0.46071 sell price= 0.46405 long profit= 0.0028776200000000095
+date: 2018-10-28 18:57:00 No transaction profit= 0
+date: 2018-10-29 14:57:00 buy price= 0.4605 sell price= 0.46114 long profit= 0.00017917999999997387
+date: 2018-10-30 10:57:00 buy price= 0.45536 sell price= 0.44489 long profit= -0.010920124999999978
+date: 2018-10-31 06:57:00 buy price= 0.44489 sell price= 0.44901 long profit= 0.0036730500000000128
+date: 2018-11-01 02:57:00 buy price= 0.44741 sell price= 0.44542 long profit= -0.0024364149999999917
+date: 2018-11-01 22:57:00 buy price= 0.4417799999999999 sell price= 0.45268 long profit= 0.010452770000000132
+date: 2018-11-02 18:57:00 buy price= 0.45266 sell price= 0.46371 long profit= 0.010591815000000004
+date: 2018-11-03 14:57:00 No transaction profit= 0
+date: 2018-11-04 10:57:00 buy price= 0.46255 sell price= 0.45628 long profit= -0.006729414999999998
+date: 2018-11-05 06:57:00 buy price= 0.4526899999999999 sell price= 0.45632 long profit= 0.0031754950000000776
+date: 2018-11-06 02:57:00 buy price= 0.46358000000000005 sell price= 0.46601 short profit= -0.0028947949999999323
+date: 2018-11-06 22:57:00 buy price= 0.47703999999999996 sell price= 0.52913 short profit= -0.052593085000000026
+date: 2018-11-07 18:57:00 buy price= 0.52872 sell price= 0.53758 short profit= -0.009393149999999979
+date: 2018-11-08 14:57:00 buy price= 0.53102 sell price= 0.54019 long profit= 0.0086343949999999
+date: 2018-11-09 10:57:00 buy price= 0.54023 sell price= 0.50392 short profit= 0.03578792499999995
+date: 2018-11-10 06:57:00 buy price= 0.5136099999999999 sell price= 0.50099 short profit= 0.012112699999999853
+date: 2018-11-11 02:57:00 No transaction profit= 0
+date: 2018-11-11 22:57:00 buy price= 0.5138299999999999 sell price= 0.50853 short profit= 0.00478881999999986
+date: 2018-11-12 18:57:00 buy price= 0.50853 sell price= 0.51055 long profit= 0.0015104599999999108
+date: 2018-11-13 14:57:00 No transaction profit= 0
+date: 2018-11-14 10:57:00 buy price= 0.5210400000000001 sell price= 0.52201 long profit= 0.0004484749999999154
+date: 2018-11-15 13:56:00 buy price= 0.52256 sell price= 0.47176 long profit= -0.051297160000000015
+date: 2018-11-16 09:56:00 buy price= 0.47129 sell price= 0.47409 long profit= 0.0023273100000000247
+date: 2018-11-17 05:56:00 buy price= 0.4761099999999999 sell price= 0.47863 short profit= -0.0029973700000000777
+date: 2018-11-18 01:56:00 No transaction profit= 0
+date: 2018-11-18 21:56:00 buy price= 0.47600999999999993 sell price= 0.52507 long profit= 0.0485594600000001
+date: 2018-11-19 17:56:00 No transaction profit= 0
+date: 2018-11-20 13:56:00 buy price= 0.50405 sell price= 0.4957 long profit= -0.008849875000000024
+date: 2018-11-21 09:56:00 buy price= 0.49568 sell price= 0.4556 long profit= -0.040555640000000004
+date: 2018-11-22 05:56:00 buy price= 0.45539 sell price= 0.44041 short profit= 0.014532099999999994
+date: 2018-11-23 01:56:00 No transaction profit= 0
+date: 2018-11-23 21:56:00 buy price= 0.4191600000000001 sell price= 0.41437 long profit= -0.005206765000000072
+date: 2018-11-24 17:56:00 buy price= 0.4062999999999999 sell price= 0.42474 long profit= 0.018024480000000124
+date: 2018-11-25 13:56:00 buy price= 0.38464000000000004 sell price= 0.38887 long profit= 0.003843244999999956
+date: 2018-11-26 09:56:00 buy price= 0.37368 sell price= 0.34274 long profit= -0.03129821000000002
+date: 2018-11-27 05:56:00 buy price= 0.34243 sell price= 0.36651 long profit= 0.02372552999999999
+date: 2018-11-28 01:56:00 No transaction profit= 0
+date: 2018-11-28 21:56:00 buy price= 0.35444 sell price= 0.37703 long profit= 0.022224265
+date: 2018-11-29 17:56:00 No transaction profit= 0
+date: 2018-11-30 13:56:00 No transaction profit= 0
+date: 2018-12-01 09:56:00 buy price= 0.37851 sell price= 0.36621 long profit= -0.012672360000000032
+date: 2018-12-02 05:56:00 No transaction profit= 0
+date: 2018-12-03 01:56:00 No transaction profit= 0
+date: 2018-12-03 21:56:00 buy price= 0.37382000000000004 sell price= 0.36249 short profit= 0.010961845000000062
+date: 2018-12-04 17:56:00 buy price= 0.36164999999999997 sell price= 0.35255 long profit= -0.009457099999999998
+date: 2018-12-05 13:56:00 buy price= 0.34023999999999993 sell price= 0.35251 long profit= 0.01192362500000006
+date: 2018-12-06 09:56:00 buy price= 0.35228 sell price= 0.34255 long profit= -0.010077414999999961
+date: 2018-12-07 05:56:00 buy price= 0.34093 sell price= 0.33333 long profit= -0.007937129999999995
+date: 2018-12-08 01:56:00 buy price= 0.32433 sell price= 0.29758 long profit= -0.027060954999999994
+date: 2018-12-08 21:56:00 buy price= 0.28764 sell price= 0.30785 long profit= 0.019912255000000007
+date: 2018-12-09 17:56:00 buy price= 0.3078100000000001 sell price= 0.30384 long profit= -0.004275825000000085
+date: 2018-12-10 13:56:00 No transaction profit= 0
+date: 2018-12-11 09:56:00 buy price= 0.29943 sell price= 0.29804 long profit= -0.0016887349999999467
+date: 2018-12-12 05:56:00 No transaction profit= 0
+date: 2018-12-13 01:56:00 No transaction profit= 0
+date: 2018-12-13 21:56:00 No transaction profit= 0
+date: 2018-12-14 17:56:00 buy price= 0.3003 sell price= 0.2992 long profit= -0.0013997499999999898
+date: 2018-12-15 13:56:00 buy price= 0.28859 sell price= 0.28456 long profit= -0.004316575000000033
+date: 2018-12-16 09:56:00 buy price= 0.28426999999999997 sell price= 0.28235 long profit= -0.002203309999999977
+date: 2018-12-17 05:56:00 buy price= 0.28232 sell price= 0.29049 long profit= 0.00788359500000001
+date: 2018-12-18 01:56:00 buy price= 0.28800000000000003 sell price= 0.28943 long profit= 0.0011412849999999867
+date: 2018-12-18 21:56:00 buy price= 0.28833 sell price= 0.32909 long profit= 0.040451290000000015
+date: 2018-12-19 17:56:00 buy price= 0.32892 sell price= 0.35694 short profit= -0.02836292999999999
+date: 2018-12-20 13:56:00 buy price= 0.35677 sell price= 0.3427 short profit= 0.013720264999999971
+date: 2018-12-21 09:56:00 buy price= 0.34288 sell price= 0.3682 long profit= 0.02496446000000001
+date: 2018-12-22 05:56:00 buy price= 0.36804 sell price= 0.37151 short profit= -0.0038397750000000288
+date: 2018-12-23 01:56:00 No transaction profit= 0
+date: 2018-12-23 21:56:00 No transaction profit= 0
+date: 2018-12-24 17:56:00 buy price= 0.36341 sell price= 0.38603 short profit= -0.022994719999999975
+date: 2018-12-25 13:56:00 buy price= 0.41152999999999995 sell price= 0.41145 short profit= -0.000331490000000031
+date: 2018-12-26 09:56:00 buy price= 0.41156 sell price= 0.36405 long profit= -0.047897805
+date: 2018-12-27 05:56:00 No transaction profit= 0
+date: 2018-12-28 01:56:00 No transaction profit= 0
+date: 2018-12-28 21:56:00 No transaction profit= 0
+date: 2018-12-29 17:56:00 buy price= 0.34064 sell price= 0.37013 long profit= 0.029134615000000013
+date: 2018-12-30 13:56:00 No transaction profit= 0
+date: 2018-12-31 09:56:00 No transaction profit= 0
+date: 2019-01-01 05:56:00 buy price= 0.34944000000000003 sell price= 0.35044 long profit= 0.0006500599999999454
+date: 2019-01-02 01:56:00 No transaction profit= 0
+date: 2019-01-02 21:56:00 No transaction profit= 0
+date: 2019-01-03 17:56:00 buy price= 0.35713 sell price= 0.36421 long profit= 0.006719329999999975
+date: 2019-01-04 13:56:00 buy price= 0.3527799999999999 sell price= 0.35274 long profit= -0.0003927599999999289
+date: 2019-01-05 09:56:00 No transaction profit= 0
+date: 2019-01-06 05:56:00 buy price= 0.34865 sell price= 0.35299 long profit= 0.0039891800000000106
+date: 2019-01-07 01:56:00 No transaction profit= 0
+date: 2019-01-07 21:56:00 buy price= 0.34941 sell price= 0.36044 long profit= 0.010675074999999984
+date: 2019-01-08 17:56:00 buy price= 0.36045 sell price= 0.35818 short profit= 0.0019106849999999944
+date: 2019-01-09 13:56:00 No transaction profit= 0
+date: 2019-01-10 09:56:00 buy price= 0.3589 sell price= 0.36118 long profit= 0.0019199600000000042
+date: 2019-01-11 05:56:00 buy price= 0.35760000000000003 sell price= 0.33857 long profit= -0.01937808500000005
+date: 2019-01-12 01:56:00 buy price= 0.33851 sell price= 0.32587 long profit= -0.012972189999999984
+date: 2019-01-12 21:56:00 buy price= 0.32361000000000006 sell price= 0.32502 long profit= 0.0010856849999999112
+date: 2019-01-13 17:56:00 buy price= 0.32574 sell price= 0.3233 short profit= 0.0021154799999999977
+date: 2019-01-14 13:56:00 buy price= 0.32319 sell price= 0.31227 long profit= -0.011237729999999986
+date: 2019-01-15 09:56:00 No transaction profit= 0
+date: 2019-01-16 05:56:00 No transaction profit= 0
+date: 2019-01-17 01:56:00 buy price= 0.32754000000000005 sell price= 0.32691 long profit= -0.0009572250000000749
+date: 2019-01-17 21:56:00 buy price= 0.32519 sell price= 0.32228 long profit= -0.0032337349999999685
+date: 2019-01-18 17:56:00 No transaction profit= 0
+date: 2019-01-19 13:56:00 No transaction profit= 0
+date: 2019-01-20 09:56:00 No transaction profit= 0
+date: 2019-01-21 05:56:00 buy price= 0.32729 sell price= 0.31636 long profit= -0.011251825000000052
+date: 2019-01-22 01:56:00 buy price= 0.31173 sell price= 0.31596 long profit= 0.003916155000000011
+date: 2019-01-22 21:56:00 buy price= 0.31581 sell price= 0.31531 long profit= -0.0008155600000000004
+date: 2019-01-23 17:56:00 buy price= 0.31177999999999995 sell price= 0.31789 long profit= 0.00579516500000006
+date: 2019-01-24 13:56:00 buy price= 0.31792 sell price= 0.31348 long profit= -0.004755699999999999
+date: 2019-01-25 09:56:00 No transaction profit= 0
+date: 2019-01-26 05:56:00 buy price= 0.31425 sell price= 0.31357 short profit= 0.00036608999999995843
+date: 2019-01-27 01:56:00 buy price= 0.31292 sell price= 0.31596 long profit= 0.0027255600000000426
+date: 2019-01-27 21:56:00 buy price= 0.31585 sell price= 0.31155 long profit= -0.004613700000000026
+date: 2019-01-28 17:56:00 buy price= 0.30713999999999997 sell price= 0.30376 long profit= -0.003685449999999994
+date: 2019-01-29 13:56:00 buy price= 0.3039 sell price= 0.28983 long profit= -0.014366865000000027
+date: 2019-01-30 09:56:00 buy price= 0.28918999999999995 sell price= 0.28878 long profit= -0.0006989849999999659
+date: 2019-01-31 05:56:00 buy price= 0.28877 sell price= 0.31875 long profit= 0.02967623999999995
+date: 2019-02-01 01:56:00 buy price= 0.31875 sell price= 0.31052 short profit= 0.007915364999999959
+date: 2019-02-01 21:56:00 buy price= 0.30272999999999994 sell price= 0.30035 long profit= -0.0026815399999999376
+date: 2019-02-02 17:56:00 No transaction profit= 0
+date: 2019-02-03 13:56:00 buy price= 0.30674 sell price= 0.3058 short profit= 0.0006337299999999964
+date: 2019-02-04 09:56:00 No transaction profit= 0
+date: 2019-02-05 05:56:00 No transaction profit= 0
+date: 2019-02-06 01:56:00 No transaction profit= 0
+date: 2019-02-06 21:56:00 No transaction profit= 0
+date: 2019-02-07 17:56:00 buy price= 0.2904 sell price= 0.2909 long profit= 0.00020935000000000045
+date: 2019-02-08 13:56:00 No transaction profit= 0
+date: 2019-02-09 09:56:00 buy price= 0.29011999999999993 sell price= 0.31593 long profit= 0.025506975000000057
+date: 2019-02-10 05:56:00 buy price= 0.31599 sell price= 0.31368 short profit= 0.0019951649999999784
+date: 2019-02-11 01:56:00 buy price= 0.30596999999999996 sell price= 0.30256 long profit= -0.003714264999999969
+date: 2019-02-11 21:56:00 buy price= 0.30202 sell price= 0.30159 long profit= -0.000731804999999986
+date: 2019-02-12 17:56:00 buy price= 0.30272000000000004 sell price= 0.30011 short profit= 0.0023085850000000565
+date: 2019-02-13 13:56:00 No transaction profit= 0
+date: 2019-02-14 09:56:00 No transaction profit= 0
+date: 2019-02-15 05:56:00 No transaction profit= 0
+date: 2019-02-16 01:56:00 buy price= 0.30062000000000005 sell price= 0.30252 long profit= 0.0015984299999999571
+date: 2019-02-16 21:56:00 buy price= 0.30104 sell price= 0.30087 long profit= -0.00047095499999994796
+date: 2019-02-17 17:56:00 buy price= 0.30089 sell price= 0.30089 long profit= -0.00030089
+date: 2019-02-18 13:56:00 buy price= 0.30221 sell price= 0.30165 short profit= 0.000258070000000005
+date: 2019-02-19 09:56:00 buy price= 0.30159 sell price= 0.32305 short profit= -0.021772319999999977
+date: 2019-02-20 05:56:00 buy price= 0.32397999999999993 sell price= 0.34292 short profit= -0.019273450000000067
+date: 2019-02-21 01:56:00 buy price= 0.3412700000000001 sell price= 0.32704 long profit= -0.014564155000000077
+date: 2019-02-21 21:56:00 buy price= 0.32705999999999996 sell price= 0.32964 long profit= 0.002251650000000027
+date: 2019-02-22 17:56:00 buy price= 0.3303999999999999 sell price= 0.32093 short profit= 0.009144334999999922
+date: 2019-02-23 13:56:00 No transaction profit= 0
+date: 2019-02-24 09:56:00 No transaction profit= 0
+date: 2019-02-25 05:56:00 No transaction profit= 0
+date: 2019-02-26 01:56:00 buy price= 0.33253 sell price= 0.30079 long profit= -0.03205665999999999
+date: 2019-02-26 21:56:00 No transaction profit= 0
+date: 2019-02-27 17:56:00 buy price= 0.31882000000000005 sell price= 0.31153 short profit= 0.006974825000000073
+date: 2019-02-28 13:56:00 No transaction profit= 0
+date: 2019-03-01 09:56:00 buy price= 0.30664 sell price= 0.30974 long profit= 0.0027918099999999914
+date: 2019-03-02 05:56:00 No transaction profit= 0
+date: 2019-03-03 01:56:00 No transaction profit= 0
+date: 2019-03-03 21:56:00 No transaction profit= 0
+date: 2019-03-04 17:56:00 buy price= 0.3088000000000001 sell price= 0.31044 long profit= 0.0013303799999999193
+date: 2019-03-05 13:56:00 No transaction profit= 0
+date: 2019-03-06 09:56:00 buy price= 0.31184 sell price= 0.31313 short profit= -0.0016024850000000133
+date: 2019-03-07 05:56:00 No transaction profit= 0
+date: 2019-03-08 01:56:00 buy price= 0.31427 sell price= 0.31322 long profit= -0.0013637449999999954
+date: 2019-03-08 21:56:00 No transaction profit= 0
+date: 2019-03-09 17:56:00 buy price= 0.30536 sell price= 0.30809 long profit= 0.002423274999999955
+date: 2019-03-10 13:56:00 buy price= 0.31871 sell price= 0.31295 short profit= 0.005444169999999988
+date: 2019-03-11 09:56:00 buy price= 0.31295 sell price= 0.31412 long profit= 0.0008564650000000043
+date: 2019-03-12 05:56:00 buy price= 0.31306 sell price= 0.31071 long profit= -0.0026618850000000183
+date: 2019-03-13 07:56:00 buy price= 0.31071 sell price= 0.30901 long profit= -0.002009859999999979
+date: 2019-03-14 03:55:00 No transaction profit= 0
+date: 2019-03-14 23:55:00 buy price= 0.3136300000000001 sell price= 0.31044 short profit= 0.0028779650000000812
+date: 2019-03-15 19:55:00 buy price= 0.31029 sell price= 0.31119 long profit= 0.0005892600000000119
+date: 2019-03-16 15:55:00 No transaction profit= 0
+date: 2019-03-17 11:55:00 No transaction profit= 0
+date: 2019-03-18 07:55:00 buy price= 0.31769000000000003 sell price= 0.3164 long profit= -0.0016070450000000135
+date: 2019-03-19 03:55:00 buy price= 0.31645 sell price= 0.31299 long profit= -0.0037747200000000187
+date: 2019-03-19 23:55:00 buy price= 0.31291 sell price= 0.31337 long profit= 0.00014685999999996044
+date: 2019-03-20 19:55:00 No transaction profit= 0
+date: 2019-03-21 15:55:00 buy price= 0.31306 sell price= 0.31741 long profit= 0.00403476500000002
+date: 2019-03-22 11:55:00 buy price= 0.31588 sell price= 0.30901 long profit= -0.007182444999999987
+date: 2019-03-23 07:55:00 No transaction profit= 0
+date: 2019-03-24 03:55:00 buy price= 0.31101 sell price= 0.3108 long profit= -0.000520904999999988
+date: 2019-03-24 23:55:00 buy price= 0.3104900000000001 sell price= 0.3084 long profit= -0.002399445000000092
+date: 2019-03-25 19:55:00 buy price= 0.3084 sell price= 0.30719 long profit= -0.001517794999999989
+date: 2019-03-26 15:55:00 No transaction profit= 0
+date: 2019-03-27 11:55:00 buy price= 0.30316 sell price= 0.2982 long profit= -0.005260679999999965
+date: 2019-03-28 07:55:00 buy price= 0.298 sell price= 0.30731 long profit= 0.00900734500000004
+date: 2019-03-29 03:55:00 buy price= 0.30490999999999996 sell price= 0.30454 long profit= -0.0006747249999999815
+date: 2019-03-29 23:55:00 No transaction profit= 0
+date: 2019-03-30 19:55:00 No transaction profit= 0
+date: 2019-03-31 15:55:00 buy price= 0.31612 sell price= 0.311 short profit= 0.004806440000000013
+date: 2019-04-01 11:55:00 buy price= 0.31102 sell price= 0.30947 long profit= -0.0018602449999999958
+date: 2019-04-02 07:55:00 No transaction profit= 0
+date: 2019-04-03 03:55:00 buy price= 0.31429 sell price= 0.3286 short profit= -0.014631444999999988
+date: 2019-04-03 23:55:00 buy price= 0.33709 sell price= 0.34778 short profit= -0.011032434999999978
+date: 2019-04-04 19:55:00 buy price= 0.3478 sell price= 0.3374 short profit= 0.01005740000000002
+date: 2019-04-05 15:55:00 buy price= 0.33587000000000006 sell price= 0.32932 long profit= -0.0068825950000000555
+date: 2019-04-06 11:55:00 buy price= 0.33104 sell price= 0.35946 short profit= -0.02876525
+date: 2019-04-07 07:55:00 No transaction profit= 0
+date: 2019-04-08 03:55:00 No transaction profit= 0
+date: 2019-04-08 23:55:00 No transaction profit= 0
+date: 2019-04-09 19:55:00 buy price= 0.35625 sell price= 0.34894 short profit= 0.006957405000000038
+date: 2019-04-10 15:55:00 No transaction profit= 0
+date: 2019-04-11 11:55:00 No transaction profit= 0
+date: 2019-04-12 07:55:00 No transaction profit= 0
+date: 2019-04-13 03:55:00 buy price= 0.3235 sell price= 0.32494 long profit= 0.0011157799999999968
+date: 2019-04-13 23:55:00 No transaction profit= 0
+date: 2019-04-14 19:55:00 buy price= 0.32551 sell price= 0.32408 long profit= -0.0017547950000000425
+date: 2019-04-15 15:55:00 buy price= 0.32398 sell price= 0.32711 long profit= 0.0028044550000000217
+date: 2019-04-16 11:55:00 No transaction profit= 0
+date: 2019-04-17 07:55:00 buy price= 0.3153500000000001 sell price= 0.31849 long profit= 0.0028230799999999206
+date: 2019-04-18 03:55:00 buy price= 0.31849 sell price= 0.32222 long profit= 0.003409645000000011
+date: 2019-04-18 23:55:00 No transaction profit= 0
+date: 2019-04-19 19:55:00 No transaction profit= 0
+date: 2019-04-20 15:55:00 No transaction profit= 0
+date: 2019-04-21 11:55:00 buy price= 0.3323 sell price= 0.32777 short profit= 0.004199964999999978
+date: 2019-04-22 07:55:00 No transaction profit= 0
+date: 2019-04-23 03:55:00 buy price= 0.31805 sell price= 0.32461 long profit= 0.00623867000000001
+date: 2019-04-23 23:55:00 No transaction profit= 0
+date: 2019-04-24 19:55:00 buy price= 0.32506999999999997 sell price= 0.31831 short profit= 0.006438309999999988
+date: 2019-04-25 15:55:00 buy price= 0.316 sell price= 0.29926 long profit= -0.017047629999999977
+date: 2019-04-26 11:55:00 No transaction profit= 0
+date: 2019-04-27 07:55:00 buy price= 0.30131 sell price= 0.29576 long profit= -0.005848535
+date: 2019-04-28 03:55:00 buy price= 0.29579000000000005 sell price= 0.29867 long profit= 0.0025827699999999383
+date: 2019-04-28 23:55:00 No transaction profit= 0
+date: 2019-04-29 19:55:00 No transaction profit= 0
+date: 2019-04-30 15:55:00 buy price= 0.29895 sell price= 0.29299 long profit= -0.00625597000000002
+date: 2019-05-01 11:55:00 No transaction profit= 0
+date: 2019-05-02 07:55:00 No transaction profit= 0
+date: 2019-05-03 03:55:00 buy price= 0.30305 sell price= 0.30406 long profit= 0.0007064450000000108
+date: 2019-05-03 23:55:00 buy price= 0.3023100000000001 sell price= 0.30195 long profit= -0.0006621300000000825
+date: 2019-05-04 19:55:00 No transaction profit= 0
+date: 2019-05-05 15:55:00 No transaction profit= 0
+date: 2019-05-06 11:55:00 No transaction profit= 0
+date: 2019-05-07 07:55:00 buy price= 0.29995 sell price= 0.30258 long profit= 0.002328735000000021
+date: 2019-05-08 03:55:00 buy price= 0.30272 sell price= 0.30307 short profit= -0.0006528950000000169
+date: 2019-05-08 23:55:00 buy price= 0.30306 sell price= 0.30027 long profit= -0.0030916650000000147
+date: 2019-05-09 19:55:00 No transaction profit= 0
+date: 2019-05-10 15:55:00 buy price= 0.29628000000000004 sell price= 0.29457 long profit= -0.002005425000000045
+date: 2019-05-11 11:55:00 buy price= 0.29446 sell price= 0.29893 long profit= 0.004173304999999974
+date: 2019-05-12 07:55:00 buy price= 0.29941999999999996 sell price= 0.32322 short profit= -0.024111320000000044
+date: 2019-05-13 03:55:00 buy price= 0.32325 sell price= 0.312 short profit= 0.010932374999999982
+date: 2019-05-13 23:55:00 buy price= 0.31139 sell price= 0.31769 long profit= 0.005985459999999972
+date: 2019-05-14 19:55:00 No transaction profit= 0
+date: 2019-05-15 15:55:00 buy price= 0.37159 sell price= 0.41199 short profit= -0.04079179000000005
+date: 2019-05-16 21:54:00 buy price= 0.43628000000000006 sell price= 0.44595 short profit= -0.010111114999999957
+date: 2019-05-17 17:54:00 buy price= 0.44596 sell price= 0.40051 short profit= 0.045026765000000045
+date: 2019-05-18 13:54:00 buy price= 0.40619999999999995 sell price= 0.3842 short profit= 0.021604799999999962
+date: 2019-05-19 09:54:00 No transaction profit= 0
+date: 2019-05-20 05:54:00 No transaction profit= 0
+date: 2019-05-21 01:54:00 No transaction profit= 0
+date: 2019-05-21 21:54:00 No transaction profit= 0
+date: 2019-05-22 17:54:00 No transaction profit= 0
+date: 2019-05-23 13:54:00 buy price= 0.3859800000000001 sell price= 0.37052 long profit= -0.015838250000000085
+date: 2019-05-24 09:54:00 buy price= 0.37039 sell price= 0.37337 long profit= 0.002608119999999983
+date: 2019-05-25 05:54:00 buy price= 0.3719799999999999 sell price= 0.38738 long profit= 0.01502032000000008
+date: 2019-05-26 01:54:00 buy price= 0.3873 sell price= 0.38692 short profit= -7.110000000008543e-06
+date: 2019-05-26 21:54:00 No transaction profit= 0
+date: 2019-05-27 17:54:00 No transaction profit= 0
+date: 2019-05-28 13:54:00 buy price= 0.40989000000000003 sell price= 0.42607 short profit= -0.016597979999999974
+date: 2019-05-29 09:54:00 buy price= 0.44008 sell price= 0.45397 short profit= -0.014337024999999958
+date: 2019-05-30 05:54:00 buy price= 0.45386 sell price= 0.45415 short profit= -0.0007440050000000124
+date: 2019-05-31 01:54:00 buy price= 0.45415 sell price= 0.46255 short profit= -0.008858350000000018
+date: 2019-05-31 21:54:00 No transaction profit= 0
+date: 2019-06-01 17:54:00 buy price= 0.41608 sell price= 0.43857 long profit= 0.02206267500000001
+date: 2019-06-02 13:54:00 No transaction profit= 0
+date: 2019-06-03 09:54:00 buy price= 0.43526 sell price= 0.43715 short profit= -0.0023262050000000026
+date: 2019-06-04 05:54:00 buy price= 0.43738 sell price= 0.44062 long profit= 0.0028010000000000205
+date: 2019-06-05 01:54:00 buy price= 0.39412 sell price= 0.41211 long profit= 0.01758688499999995
+date: 2019-06-05 21:54:00 buy price= 0.41221 sell price= 0.39649 long profit= -0.016124350000000013
+date: 2019-06-06 17:54:00 buy price= 0.393 sell price= 0.40232 long profit= 0.008922339999999994
+date: 2019-06-07 13:54:00 buy price= 0.4043899999999999 sell price= 0.41953 short profit= -0.015551960000000099
+date: 2019-06-08 09:54:00 buy price= 0.423 sell price= 0.42804 short profit= -0.0054655199999999885
+date: 2019-06-09 06:54:00 No transaction profit= 0
+date: 2019-06-10 02:54:00 No transaction profit= 0
+date: 2019-06-10 22:54:00 buy price= 0.40767 sell price= 0.38997 long profit= -0.018098819999999995
+date: 2019-06-11 18:54:00 buy price= 0.39017 sell price= 0.39379 long profit= 0.0032280199999999565
+date: 2019-06-12 14:54:00 No transaction profit= 0
+date: 2019-06-13 10:54:00 No transaction profit= 0
+date: 2019-06-14 06:54:00 No transaction profit= 0
+date: 2019-06-15 02:54:00 No transaction profit= 0
+date: 2019-06-15 22:54:00 buy price= 0.39763 sell price= 0.40567 long profit= 0.007638349999999992
+date: 2019-06-16 18:54:00 buy price= 0.40568 sell price= 0.4175 short profit= -0.012231589999999997
+date: 2019-06-17 14:54:00 buy price= 0.42464 sell price= 0.4309 short profit= -0.006687769999999988
+date: 2019-06-18 10:54:00 buy price= 0.43444 sell price= 0.42752 short profit= 0.006489019999999982
+date: 2019-06-19 06:54:00 No transaction profit= 0
+date: 2019-06-20 02:54:00 No transaction profit= 0
+date: 2019-06-20 22:54:00 No transaction profit= 0
+date: 2019-06-21 18:54:00 No transaction profit= 0
+date: 2019-06-22 14:54:00 buy price= 0.43599 sell price= 0.44021 short profit= -0.004658100000000002
+date: 2019-06-23 10:54:00 buy price= 0.44736 sell price= 0.4779 short profit= -0.031002630000000014
+date: 2019-06-24 06:54:00 buy price= 0.47773 sell price= 0.47602 short profit= 0.0012331249999999892
+date: 2019-06-25 02:54:00 buy price= 0.47534 sell price= 0.46719 long profit= -0.00862126499999999
+date: 2019-06-25 22:54:00 buy price= 0.47212 sell price= 0.46865 short profit= 0.002999614999999973
+date: 2019-06-26 18:54:00 buy price= 0.47299 sell price= 0.46914 short profit= 0.00337893500000002
+date: 2019-06-27 14:54:00 No transaction profit= 0
+date: 2019-06-28 10:54:00 buy price= 0.46026 sell price= 0.41344 long profit= -0.04725685000000003
+date: 2019-06-29 06:54:00 buy price= 0.40461 sell price= 0.41385 long profit= 0.00883076999999997
+date: 2019-06-30 02:54:00 buy price= 0.41394 sell price= 0.41727 long profit= 0.0029143949999999997
+date: 2019-06-30 22:54:00 buy price= 0.41746 sell price= 0.42334 long profit= 0.005459599999999997
+date: 2019-07-01 18:54:00 buy price= 0.41634000000000004 sell price= 0.413 long profit= -0.0037546700000000654
+date: 2019-07-02 14:54:00 No transaction profit= 0
+date: 2019-07-03 10:54:00 buy price= 0.40159 sell price= 0.39741 long profit= -0.004579500000000018
+date: 2019-07-04 06:54:00 buy price= 0.3975 sell price= 0.398 long profit= 0.00010225000000000043
+date: 2019-07-05 02:54:00 buy price= 0.3979 sell price= 0.392 long profit= -0.006294949999999961
+date: 2019-07-05 22:54:00 buy price= 0.38165999999999994 sell price= 0.37987 long profit= -0.002170764999999958
+date: 2019-07-06 18:54:00 No transaction profit= 0
+date: 2019-07-07 14:54:00 No transaction profit= 0
+date: 2019-07-08 10:54:00 buy price= 0.38916 sell price= 0.39303 long profit= 0.0034789049999999844
+date: 2019-07-09 06:54:00 No transaction profit= 0
+date: 2019-07-10 02:54:00 No transaction profit= 0
+date: 2019-07-10 22:54:00 buy price= 0.39668999999999993 sell price= 0.39493 short profit= 0.0013641899999999284
+date: 2019-07-11 18:54:00 No transaction profit= 0
+date: 2019-07-12 14:54:00 buy price= 0.35962 sell price= 0.32709 long profit= -0.03287335500000001
+date: 2019-07-13 10:54:00 buy price= 0.32708 sell price= 0.34357 long profit= 0.016154675000000004
+date: 2019-07-14 06:54:00 buy price= 0.34348 sell price= 0.33426 short profit= 0.008881130000000006
+date: 2019-07-15 02:54:00 buy price= 0.3344 sell price= 0.31693 long profit= -0.017795664999999985
+date: 2019-07-15 22:54:00 No transaction profit= 0
+date: 2019-07-16 18:54:00 No transaction profit= 0
+date: 2019-07-17 14:54:00 buy price= 0.31333 sell price= 0.29609 long profit= -0.017544709999999977
+date: 2019-07-18 10:54:00 No transaction profit= 0
+date: 2019-07-19 06:54:00 buy price= 0.31888 sell price= 0.32053 short profit= -0.001969704999999985
+date: 2019-07-20 02:54:00 buy price= 0.32044 sell price= 0.31396 short profit= 0.006162799999999986
+date: 2019-07-20 22:54:00 buy price= 0.31389 sell price= 0.32825 long profit= 0.014038929999999984
+date: 2019-07-21 18:54:00 No transaction profit= 0
+date: 2019-07-22 14:54:00 No transaction profit= 0
+date: 2019-07-23 10:54:00 buy price= 0.32936 sell price= 0.32076 long profit= -0.008925059999999997
+date: 2019-07-24 06:54:00 buy price= 0.32066 sell price= 0.31034 short profit= 0.010004499999999996
+date: 2019-07-25 02:54:00 No transaction profit= 0
+date: 2019-07-25 22:54:00 buy price= 0.30717 sell price= 0.31717 long profit= 0.00968783000000001
+date: 2019-07-26 18:54:00 buy price= 0.31650999999999996 sell price= 0.30918 long profit= -0.007642844999999948
+date: 2019-07-27 14:54:00 No transaction profit= 0
+date: 2019-07-28 10:54:00 buy price= 0.32444 sell price= 0.30814 short profit= 0.01598370999999998
+date: 2019-07-29 06:54:00 No transaction profit= 0
+date: 2019-07-30 02:54:00 buy price= 0.30895 sell price= 0.30923 long profit= -2.908999999999754e-05
+date: 2019-07-30 22:54:00 No transaction profit= 0
+date: 2019-07-31 18:54:00 No transaction profit= 0
+date: 2019-08-01 14:54:00 No transaction profit= 0
+date: 2019-08-02 10:54:00 buy price= 0.31787 sell price= 0.3139 long profit= -0.004285884999999974
+date: 2019-08-03 06:54:00 buy price= 0.31382 sell price= 0.31526 long profit= 0.001125459999999997
+date: 2019-08-04 02:54:00 buy price= 0.31524 sell price= 0.31472 long profit= -0.0008349800000000205
+date: 2019-08-04 22:54:00 No transaction profit= 0
+date: 2019-08-05 18:54:00 buy price= 0.31213 sell price= 0.32229 long profit= 0.009842790000000002
+date: 2019-08-06 14:54:00 buy price= 0.3224 sell price= 0.32353 short profit= -0.0014529649999999643
+date: 2019-08-07 10:54:00 buy price= 0.32353 sell price= 0.31376 long profit= -0.010088645
+date: 2019-08-08 06:54:00 buy price= 0.31321999999999994 sell price= 0.31243 long profit= -0.0011028249999999575
+date: 2019-08-09 02:54:00 buy price= 0.31050999999999995 sell price= 0.30731 long profit= -0.003508909999999925
+date: 2019-08-09 22:54:00 No transaction profit= 0
+date: 2019-08-10 18:54:00 buy price= 0.30489 sell price= 0.30048 long profit= -0.00471268499999997
+date: 2019-08-11 14:54:00 No transaction profit= 0
+date: 2019-08-12 10:54:00 buy price= 0.29761 sell price= 0.30564 long profit= 0.007728375000000037
+date: 2019-08-13 06:54:00 buy price= 0.3005200000000001 sell price= 0.30177 long profit= 0.0009488549999998624
+date: 2019-08-14 02:54:00 buy price= 0.29929999999999995 sell price= 0.29827 long profit= -0.0013287849999999751
+date: 2019-08-14 22:54:00 buy price= 0.29391 sell price= 0.29621 long profit= 0.002004939999999969
+date: 2019-08-16 02:54:00 buy price= 0.29466999999999993 sell price= 0.26325 long profit= -0.03169895999999995
+date: 2019-08-16 22:53:00 buy price= 0.26315 sell price= 0.25752 long profit= -0.005890334999999969
+date: 2019-08-17 18:53:00 No transaction profit= 0
+date: 2019-08-18 14:53:00 buy price= 0.25698999999999994 sell price= 0.26601 long profit= 0.008758500000000084
+date: 2019-08-19 10:53:00 buy price= 0.26394999999999996 sell price= 0.2893 long profit= 0.02507337500000004
+date: 2019-08-20 06:53:00 No transaction profit= 0
+date: 2019-08-21 02:53:00 buy price= 0.27795000000000003 sell price= 0.27321 long profit= -0.005015580000000022
+date: 2019-08-21 22:53:00 buy price= 0.27321 sell price= 0.26551 long profit= -0.007969359999999984
+date: 2019-08-22 18:53:00 No transaction profit= 0
+date: 2019-08-23 14:53:00 No transaction profit= 0
+date: 2019-08-24 10:53:00 No transaction profit= 0
+date: 2019-08-25 06:53:00 buy price= 0.2660200000000001 sell price= 0.26738 long profit= 0.0010932999999999167
+date: 2019-08-26 02:53:00 No transaction profit= 0
+date: 2019-08-26 22:53:00 buy price= 0.27155000000000007 sell price= 0.2713 long profit= -0.0005214250000000835
+date: 2019-08-27 18:53:00 No transaction profit= 0
+date: 2019-08-28 14:53:00 No transaction profit= 0
+date: 2019-08-29 10:53:00 buy price= 0.2688 sell price= 0.25572 short profit= 0.01281773999999998
+date: 2019-08-30 06:53:00 buy price= 0.25561 sell price= 0.24997 long profit= -0.005892790000000006
+date: 2019-08-31 02:53:00 No transaction profit= 0
+date: 2019-08-31 22:53:00 buy price= 0.2524700000000001 sell price= 0.25656 long profit= 0.003835484999999927
+date: 2019-09-01 18:53:00 buy price= 0.25655 sell price= 0.257 long profit= 0.0001932250000000059
+date: 2019-09-02 14:53:00 No transaction profit= 0
+date: 2019-09-03 10:53:00 No transaction profit= 0
+date: 2019-09-04 06:53:00 buy price= 0.26001 sell price= 0.2644 long profit= 0.004127795000000005
+date: 2019-09-05 02:53:00 buy price= 0.2644 sell price= 0.25926 long profit= -0.005401830000000034
+date: 2019-09-05 22:53:00 buy price= 0.2593 sell price= 0.25685 long profit= -0.002708074999999952
+date: 2019-09-06 18:53:00 buy price= 0.25685 sell price= 0.25483 short profit= 0.0017641600000000218
+date: 2019-09-07 14:53:00 buy price= 0.25814000000000004 sell price= 0.2514 short profit= 0.006485230000000023
+date: 2019-09-08 10:53:00 buy price= 0.25137 sell price= 0.26073 long profit= 0.009103950000000034
+date: 2019-09-09 06:53:00 buy price= 0.25558999999999993 sell price= 0.26211 long profit= 0.006261150000000082
+date: 2019-09-10 02:53:00 buy price= 0.2597000000000001 sell price= 0.26186 long profit= 0.0018992199999998843
+date: 2019-09-10 22:53:00 buy price= 0.25983999999999996 sell price= 0.26076 long profit= 0.0006597000000000319
+date: 2019-09-11 18:53:00 buy price= 0.25732999999999995 sell price= 0.2571 long profit= -0.00048721499999995245
+date: 2019-09-12 14:53:00 buy price= 0.2571 sell price= 0.25444 long profit= -0.0029157699999999955
+date: 2019-09-13 10:53:00 buy price= 0.25443 sell price= 0.25258 long profit= -0.0021035049999999626
+date: 2019-09-14 06:53:00 buy price= 0.25233 sell price= 0.25348 long profit= 0.0008970949999999844
+date: 2019-09-15 02:53:00 No transaction profit= 0
+date: 2019-09-15 22:53:00 No transaction profit= 0
+date: 2019-09-16 18:53:00 buy price= 0.26002000000000003 sell price= 0.26228 long profit= 0.0019988499999999843
+date: 2019-09-17 14:53:00 buy price= 0.2604200000000001 sell price= 0.26109 long profit= 0.0004092449999998928
+date: 2019-09-18 10:53:00 buy price= 0.2611 sell price= 0.28827 long profit= 0.026895315000000027
+date: 2019-09-19 06:53:00 buy price= 0.28933000000000003 sell price= 0.32129 short profit= -0.03226530999999999
+date: 2019-09-20 02:53:00 No transaction profit= 0
+date: 2019-09-20 22:53:00 buy price= 0.29139000000000004 sell price= 0.29619 long profit= 0.004506209999999971
+date: 2019-09-21 18:53:00 buy price= 0.29628 sell price= 0.29254 short profit= 0.0034455899999999654
+date: 2019-09-22 14:53:00 No transaction profit= 0
+date: 2019-09-23 10:53:00 No transaction profit= 0
+date: 2019-09-24 06:53:00 No transaction profit= 0
+date: 2019-09-25 02:53:00 buy price= 0.27964999999999995 sell price= 0.26854 short profit= 0.010835904999999953
+Final total capital= 99999.56562212492
+
+
+
+ +
+ +
+ + + + +
+ +
+ +
+ +
+
+ +
+
+
+
In [5]:
+
+
+
past_history = 35 
+
+
+
+last_day=len(df['TIME'])
+
+
+
+
+day=500
+k=day
+#for k in range(3000):
+
+h=0
+y=0
+z=0
+u=0
+
+
+
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        if trend>0 and trend_real>0:
+            h+=1
+            y+=1
+            
+        if trend>0 and trend_real<0:
+            h=h
+            y+=1
+        if trend<0 and trend_real<0:
+            z+=1
+            u+=1
+        if trend<0 and trend_real>0:
+            z=z
+            u+=1
+        
+        
+        
+        
+        
+        
+    k=k-1
+    
+print('accuracy of buy=',h/y)   
+    
+print('accuracy of sell=',z/u) 
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
accuracy of buy= 0.5892857142857143
+accuracy of sell= 0.7012195121951219
+
+
+
+ +
+
+ +
+
+
+
In [6]:
+
+
+
past_history = 35 
+
+
+
+last_day=len(df['TIME'])
+
+
+
+
+day=500
+k=day
+#for k in range(3000):
+
+h=0
+y=0
+z=0
+u=0
+
+H=[0]
+Z=[0]
+
+a=0
+
+while k<=day and k>0:
+    
+    if k>0:
+        data=np.array(features[-past_history-k:-1-k])
+        data2=np.array(features.iloc[-1-k])
+        data=np.vstack((data,data2))
+
+        
+        t+=1 
+        
+        tt=np.vstack((tt,t))
+        
+        
+        
+        j=[0]
+        
+        for i in data:
+            i=np.array([i])
+            j=np.vstack((j,i))
+        #print(j.shape)
+
+        j=j[1:past_history+1]
+        #print(j.shape)
+        j=[j]
+        
+        
+        
+        
+        
+        
+        #data.reshape((240,1))
+        #print(data.shape)
+        data=tf.convert_to_tensor(j)
+        #print(data)
+
+
+
+        x=np.array(model.predict(data))
+
+        
+        
+        trend=x[0][0]-MV[-1-k]            #预测正负
+        
+        trend_real=MV[-k]-MV[-1-k]          #实际正负
+        
+        
+        if trend>0 and trend_real>0:
+            h+=1
+            y+=1
+            
+        if trend>0 and trend_real<0:
+            h=h
+            y+=1
+        if trend<0 and trend_real<0:
+            z+=1
+            u+=1
+        if trend<0 and trend_real>0:
+            z=z
+            u+=1
+        
+        a+=1
+        
+        if a%15==0:
+            #print("counter=",a)
+            
+            H=np.vstack((H,h/y))
+            h=0
+            y=0
+            Z=np.vstack((Z,z/u))
+            z=0
+            u=0
+        
+        
+    k=k-1
+    
+H=H[1:]
+Z=Z[1:]
+
+print('success rate of buying in every 15 units',H)
+print('success rate of selling in every 15 units',Z)
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
success rate of buying in every 15 units [[0.30769231]
+ [0.625     ]
+ [0.33333333]
+ [0.9       ]
+ [0.75      ]
+ [0.57142857]
+ [0.5       ]
+ [0.66666667]
+ [0.4       ]
+ [0.69230769]
+ [0.5       ]
+ [0.8       ]
+ [0.66666667]
+ [0.53846154]
+ [0.5       ]
+ [0.6       ]
+ [0.625     ]
+ [0.63636364]
+ [0.35714286]
+ [0.66666667]
+ [0.72727273]
+ [0.58333333]
+ [0.75      ]
+ [0.66666667]
+ [0.55555556]
+ [0.83333333]
+ [0.5       ]
+ [0.7       ]
+ [0.7       ]
+ [0.41666667]
+ [0.61538462]
+ [0.5       ]
+ [0.76923077]]
+success rate of selling in every 15 units [[0.5       ]
+ [0.71428571]
+ [0.66666667]
+ [0.4       ]
+ [0.72727273]
+ [0.        ]
+ [0.8       ]
+ [0.5       ]
+ [0.8       ]
+ [1.        ]
+ [1.        ]
+ [0.7       ]
+ [0.66666667]
+ [1.        ]
+ [0.8       ]
+ [0.8       ]
+ [0.85714286]
+ [0.75      ]
+ [1.        ]
+ [0.55555556]
+ [1.        ]
+ [1.        ]
+ [0.42857143]
+ [0.44444444]
+ [0.5       ]
+ [0.44444444]
+ [1.        ]
+ [0.8       ]
+ [1.        ]
+ [0.66666667]
+ [1.        ]
+ [1.        ]
+ [0.5       ]]
+
+
+
+ +
+
+ +
+
+
+
In [7]:
+
+
+
from scipy import stats
+stats.ttest_1samp(H,0.5)               #t test of buying success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[7]:
+ + + + +
+
Ttest_1sampResult(statistic=array([4.15964169]), pvalue=array([0.00022318]))
+
+ +
+ +
+
+ +
+
+
+
In [8]:
+
+
+
stats.ttest_1samp(Z,0.5)               #t test of selling success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[8]:
+ + + + +
+
Ttest_1sampResult(statistic=array([5.34421909]), pvalue=array([7.29773285e-06]))
+
+ +
+ +
+
+ +
+
+
+
In [9]:
+
+
+
import numpy as np, scipy.stats as st
+st.t.interval(0.95, len(H)-1, loc=np.mean(H), scale=st.sem(H))      #95% Confidence interval of buying success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[9]:
+ + + + +
+
(array([0.55341517]), array([0.65592868]))
+
+ +
+ +
+
+ +
+
+
+
In [10]:
+
+
+
import numpy as np, scipy.stats as st
+st.t.interval(0.95, len(Z)-1, loc=np.mean(Z), scale=st.sem(Z))       #95% Confidence interval of selling success rate 
+
+ +
+
+
+ +
+
+ + +
+ +
Out[10]:
+ + + + +
+
(array([0.64105566]), array([0.81480598]))
+
+ +
+ +
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+ + + + + +