master
EduCoderStudent0014 1 year ago
parent a59a1d03c2
commit f362aae512

@ -0,0 +1 @@
!coverage.py: This is a private format, don't read it directly!{"lines":{"D:\\PycharmProject\\WebStockPredict\\manage.py":[2,3,5,6,7,8,15],"D:\\PycharmProject\\WebStockPredict\\WebStockPredict\\__init__.py":[1],"D:\\PycharmProject\\WebStockPredict\\WebStockPredict\\settings.py":[11,13,16,23,26,28,34,35,36,37,38,39,40,44,45,46,47,48,49,50,53,57,58,59,61,62,63,64,65,71,78,79,80,90,93,96,99,107,109,111,113,115,121],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\__init__.py":[1],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\apps.py":[1,4,5],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\models.py":[1,3,7,8,9,11,12,13,14,15,16,17,18,19,20,23,24,25,26,28,38,41,42,43,44,46,56,39,57,29,30,31,35,36,47,48,49,53,54,32,33,50,51],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\admin.py":[1,2,5,6,7],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\migrations\\__init__.py":[1],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\tests.py":[1,2,4,5,6,8,9,10,11,12,14,15,31,41,50,51,67,77,87,90,93,94,104,122,142,162,163,175,200,209,210,231,232,240,259,262,263,275,276,282,283,167,168,169,170,171,172,267,268,269,270,88,271,272,273,108,109,111,112,113,115,116,118,119,120,126,127,128,129,130,131,133,134,135,139,146,148,149,151,152,153,155,156,157,158,159,160,98,99,100,101,102,45,46,47,48,35,36,37,38,39,19,21,22,23,24,25,26,27,28,215,216,201,202,203,205,206,208,217,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,219,220,221,222,223,224,225,226,227,228,287,81,82,83,84,71,72,73,74,75,55,57,58,59,60,61,62,63,64,236,237,238,244,245,246,248,249,250,251,252,253,254,255,256,280],"D:\\PycharmProject\\WebStockPredict\\LSTMPredictStock\\__init__.py":[1],"D:\\PycharmProject\\WebStockPredict\\LSTMPredictStock\\run.py":[1,3,4,5,6,8,9,10,11,12,13,14,15,16,17,18,21,31,44,107,173,212,222,232,243,248,253,213,214,254,215,216,217,218,219,111,244,245,112,113,114,249,250,115,116,119,120,121,122,125,126,127,131,132,133,136,137,138,141,142,144,145,146,148,149,154,156,157,158,161,165,171,174,175,176,177,179,180,182,183,184,185,186,181,188,233,234,235,236,237,238,240,223,224,225,226,227,49,50,53,54,55,57,58,59,60,63,64,78,79,80,81,82,83,84,86,87,88,89,90,94,229],"D:\\PycharmProject\\WebStockPredict\\LSTMPredictStock\\core\\__init__.py":[5,6,7,8,10,11],"D:\\PycharmProject\\WebStockPredict\\LSTMPredictStock\\core\\data_processor.py":[2,3,5,6,8,23,41,56,72,81,14,15,16,17,18,19,20,29,30,31,33,34,36,37,39,83,84,85,86,87,88,89,90,91,92,58,59,60,61,62,63,66,74,75,76,77,79,67,68,69,70,65],"D:\\PycharmProject\\WebStockPredict\\LSTMPredictStock\\core\\model.py":[1,2,3,4,5,6,7,8,9,11,12,14,17,25,53,76,102,112,127,139,15,22,23,141,142,143,144,145,146,147,30,31,33,34,35,36,37,38,39,41,43,44,45,46,42,48,50,51,80,81,82,83,86,88,90,91,92,93,94,95,98,99],"D:\\PycharmProject\\WebStockPredict\\LSTMPredictStock\\core\\utils.py":[1,3,5,8,11,6,9,12,13],"D:\\PycharmProject\\WebStockPredict\\LSTMPredictStock\\core\\get_domestic_hist_stock.py":[2,3,4,5,7,36,52,62,54,55,56,57,59,9,10,12,13,14,16,17,19,20,21,22,23,24,25,27,28,29,30,31,32,33,37,38,40,41,44,45,46,47,49,50],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\views.py":[1,2,4,5,6,7,8,9,10,12,16,60,76,89,95,112,65,66,67,68,69,70,71,72,73,74,17,19,21,28,29,30,31,32,33,37,38,40,47,48,49,50,51,55,56,58,22,23,24,25,26,41,42,43,44,45,34,35,52,53,90,91,92,80,81,85,86,93,96,98,99,100,101],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\add_companies_to_db.py":[1,3,4,5,7,8,9,10,11],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\migrations\\0002_auto_20181212_1138.py":[3,6,9,13,14,15,16,18,19,20,21],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\migrations\\0004_auto_20181213_1455.py":[3,6,9,13,14,15,16,18,19,20,21],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\migrations\\0006_stockindex_zong_he.py":[3,6,9,13,14,15,16],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\migrations\\0001_initial.py":[3,4,7,9,11,15,16,18,19,20,23,24,26,27,28,31,32,34,35,36],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\migrations\\0003_auto_20181212_1206.py":[3,6,9,13,14,15,16,18,19,20,21],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\migrations\\0005_stockindex.py":[3,4,7,10,14,15,17,18,19,20,21,22,23,24,25],"D:\\PycharmProject\\WebStockPredict\\WebStockPredict\\urls.py":[15,16,17,20,21],"D:\\PycharmProject\\WebStockPredict\\stock_predict\\urls.py":[1,2,3,6,9,10],"D:\\PycharmProject\\WebStockPredict\\WebStockPredict\\wsgi.py":[]}}

3
.gitignore vendored

@ -0,0 +1,3 @@
*.pyc
.idea
*.iml

@ -0,0 +1,25 @@
# LSTM Neural Network for Time Series Prediction
LSTM built using the Keras Python package to predict time series steps and sequences. Includes sine wave and stock market data.
[Full article write-up for this code](https://www.altumintelligence.com/articles/a/Time-Series-Prediction-Using-LSTM-Deep-Neural-Networks)
[Video on the workings and usage of LSTMs and run-through of this code](https://www.youtube.com/watch?v=2np77NOdnwk)
## Requirements
Install requirements.txt file to make sure correct versions of libraries are being used.
* Python 3.5.x
* TensorFlow 1.10.0
* Numpy 1.15.0
* Keras 2.2.2
* Matplotlib 2.2.2
Output for sine wave sequential prediction:
![Output for sin wave sequential prediction](https://www.altumintelligence.com/assets/time-series-prediction-using-lstm-deep-neural-networks/sinwave_full_seq.png)
Output for stock market multi-dimensional multi-sequential predictions:
![Output for stock market multiple sequential predictions](https://www.altumintelligence.com/assets/time-series-prediction-using-lstm-deep-neural-networks/sp500_multi_2d.png)

@ -0,0 +1,54 @@
{
"data": {
"filename": "drjt_600718_stock.csv",
"columns": [
"Close","Open","High","Low"
],
"sequence_length": 30,
"train_test_split": 0.85,
"normalise": true
},
"training": {
"epochs": 1,
"batch_size": 8
},
"model": {
"loss": "mse",
"optimizer": "adam",
"save_dir": "saved_models",
"layers": [
{
"type": "lstm",
"neurons": 100,
"input_timesteps": 29,
"input_dim": 4,
"return_seq": true
},
{
"type": "dropout",
"rate": 0.2
},
{
"type": "lstm",
"neurons": 100,
"return_seq": true
},
{
"type": "lstm",
"neurons": 100,
"return_seq": false
},
{
"type": "dropout",
"rate": 0.2
},
{
"type": "dense",
"neurons": 1,
"activation": "linear"
}
]
},
"companies":{"600718":"drjt","000651":"gldq","600839":"scch","600320":"zhzg","601988":"zgyh",
"000066": "zgcc","601766":"zgzc","601390":"zgzt","000768":"zhfj","000063":"zxtx"}
}

@ -0,0 +1,11 @@
# this lstm core module implementation provides an implementation
# of time series prediction using a lstm approach. It is provided
# as is with no warranties or support.
__author__ = "Jakob Aungiers"
__copyright__ = "Jakob Aungiers 2018"
__version__ = "2.0.0"
__license__ = "MIT"
import warnings
warnings.filterwarnings("ignore") # ignore messy numpy warnings

@ -0,0 +1,92 @@
import numpy as np
import pandas as pd
class DataLoader():
"""A class for loading and transforming data for the lstm model"""
def __init__(self, filename, split, cols):
'''
filename:数据所在文件名 '.csv'格式文件
split:训练与测试数据分割变量
cols:选择data的一列或者多列进行分析 Close Volume
'''
dataframe = pd.read_csv(filename)
i_split = int(len(dataframe) * split)
self.data_train = dataframe.get(cols).values[:i_split] #选择指定的列 进行分割 得到 未处理的训练数据
self.data_test = dataframe.get(cols).values[i_split:]
self.len_train = len(self.data_train)
self.len_test = len(self.data_test)
self.len_train_windows = None
def get_test_data(self, seq_len, normalise):
'''
Create x, y test data windows
Warning: batch method, not generative, make sure you have enough memory to
load data, otherwise reduce size of the training split.
'''
data_windows = []
for i in range(self.len_test - seq_len):
data_windows.append(self.data_test[i:i+seq_len]) #每一个元素是长度为seq_len的 list即一个window
data_windows = np.array(data_windows).astype(float)
data_windows = self.normalise_windows(data_windows, single_window=False) if normalise else data_windows
x = data_windows[:, :-1]
y = data_windows[:, -1, [0]]
return x, y
def get_train_data(self, seq_len, normalise):
'''
Create x, y train data windows
Warning: batch method, not generative, make sure you have enough memory to
load data, otherwise use generate_training_window() method.
'''
data_x = []
data_y = []
for i in range(self.len_train - seq_len):
x, y = self._next_window(i, seq_len, normalise)
data_x.append(x)
data_y.append(y)
return np.array(data_x), np.array(data_y)
def generate_train_batch(self, seq_len, batch_size, normalise):
'''Yield a generator of training data from filename on given list of cols split for train/test'''
i = 0
while i < (self.len_train - seq_len):
x_batch = []
y_batch = []
for b in range(batch_size):
if i >= (self.len_train - seq_len):
# stop-condition for a smaller final batch if data doesn't divide evenly
yield np.array(x_batch), np.array(y_batch)
x, y = self._next_window(i, seq_len, normalise)
x_batch.append(x)
y_batch.append(y)
i += 1
yield np.array(x_batch), np.array(y_batch)
def _next_window(self, i, seq_len, normalise):
'''Generates the next data window from the given index location i'''
window = self.data_train[i:i+seq_len]
window = self.normalise_windows(window, single_window=True)[0] if normalise else window
x = window[:-1]
y = window[-1, [0]] # 最后一行的 0个元素 组成array类型若是[0,2]则取第0个和第2个元素组成array[-1, 0]则是取最后一行第0个元素
# 只返回该元素的值[]和()用于索引都是切片操作所以这里的y即label是 第一列Close列
return x, y
def normalise_windows(self, window_data, single_window=False):
'''Normalise window with a base value of zero'''
normalised_data = []
window_data = [window_data] if single_window else window_data
for window in window_data:
normalised_window = []
for col_i in range(window.shape[1]):
normalised_col = [((float(p) / float(window[0, col_i])) - 1) for p in window[:, col_i]]
normalised_window.append(normalised_col)
normalised_window = np.array(normalised_window).T # reshape and transpose array back into original multidimensional format
normalised_data.append(normalised_window)
return np.array(normalised_data)

@ -0,0 +1,64 @@
# 获取国内股票历史数据
import json
import os
import requests
from datetime import datetime,timedelta
def get_domestic_stock(sticker_code, start_date, end_date):
# 从网易接口获取数据
api_adr = 'http://quotes.money.163.com/service/chddata.html'
fields = "TOPEN;TCLOSE;HIGH;LOW;VOTURNOVER"
# 注意获取上海证券与深圳证券股票的数据需要构造不同的URL
tag = "0" # 上海证券
if sticker_code in ['000063','000066','000768','000651']:
tag = "1" # 深圳证券
params = {'code': tag + sticker_code, 'start': start_date, 'end': end_date, 'fields': fields}
r = requests.get(api_adr, params=params)
print(r.url)
txt_list = r.text.split('\n') # r.content二进制数据 r.text 文本数据
txt_list.reverse()
txt_list[0] = txt_list[-1] # 列名替换开头的空字符
col_name = "Date,Code,Name,Open,Close,High,Low,Volume\n"
txt_list[0] = col_name
txt_list.pop(-1)
root = os.path.dirname(os.path.dirname(__file__))
dir_path = os.path.join(root,"data")
filename = sticker_code + ".csv"
print(os.path.join(dir_path,filename))
with open(os.path.join(dir_path,filename), "w+", encoding='utf-8') as f:
for line in txt_list:
if line.split(',')[3] != '0.0': # 去除无效数据
f.write(line)
def get_all_last_data(start_date): # 得到从start_date至今日 所有最新数据
root = os.path.dirname(os.path.dirname(__file__))
config_path = os.path.join(root,"config.json")
configs = json.load(open(config_path, 'r'))
companies = configs['companies']
# start_date = '2010-06-21' # 只能按整年获取至今日数据
cur = datetime.now()
year = timedelta(days=365)
cur = cur + year # 在当前日期上加一年
end_date = cur.strftime("%Y-%m-%d") # 获取今年最新数据
for code, company_name in companies.items():
get_domestic_stock(code, start_date, end_date)
def get_single_last_data(stock_code,start_date="2010-01-01"):
# start_date = '2010-06-21' # 只能按整年获取至今日数据
cur = datetime.now()
year = timedelta(days=365)
cur = cur + year # 在当前日期上加一年
end_date = cur.strftime("%Y-%m-%d") # 获取今年最新数据
get_domestic_stock(stock_code, start_date, end_date)
if __name__ == '__main__':
get_all_last_data("2010-01-01")

@ -0,0 +1,147 @@
import os
import math
import numpy as np
import datetime as dt
from numpy import newaxis
from LSTMPredictStock.core.utils import Timer
from keras.layers import Dense, Activation, Dropout, LSTM
from keras.models import Sequential, load_model
from keras.callbacks import EarlyStopping, ModelCheckpoint
class Model():
"""A class for an building and inferencing an lstm model"""
def __init__(self):
self.model = Sequential()
def load_model(self, filepath):
'''
从本地保存的模型参数来加载模型
filepath: .h5 格式文件
'''
print('[Model] Loading model from file %s' % filepath)
self.model = load_model(filepath)
def build_model(self, configs):
"""
新建一个模型
configs:配置文件
"""
timer = Timer()
timer.start()
for layer in configs['model']['layers']:
neurons = layer['neurons'] if 'neurons' in layer else None
dropout_rate = layer['rate'] if 'rate' in layer else None
activation = layer['activation'] if 'activation' in layer else None
return_seq = layer['return_seq'] if 'return_seq' in layer else None
input_timesteps = layer['input_timesteps'] if 'input_timesteps' in layer else None
input_dim = layer['input_dim'] if 'input_dim' in layer else None
if layer['type'] == 'dense':
self.model.add(Dense(neurons, activation=activation))
if layer['type'] == 'lstm':
self.model.add(LSTM(neurons, input_shape=(input_timesteps, input_dim), return_sequences=return_seq))
if layer['type'] == 'dropout':
self.model.add(Dropout(dropout_rate))
self.model.compile(loss=configs['model']['loss'], optimizer=configs['model']['optimizer'])
print('[Model] Model Compiled')
timer.stop() #输出构建一个模型耗时
def train(self, x, y, epochs, batch_size, save_dir):
timer = Timer()
timer.start()
print('[Model] Training Started')
print('[Model] %s epochs, %s batch size' % (epochs, batch_size))
save_fname = os.path.join(save_dir, '%s-e%s.h5' % (dt.datetime.now().strftime('%d%m%Y-%H%M%S'), str(epochs)))
callbacks = [
EarlyStopping(monitor='val_loss', patience=2),
ModelCheckpoint(filepath=save_fname, monitor='val_loss', save_best_only=True)
]
self.model.fit(
x,
y,
epochs=epochs,
batch_size=batch_size,
callbacks=callbacks
)
self.model.save(save_fname) #保存训练好的模型
print('[Model] Training Completed. Model saved as %s' % save_fname)
timer.stop() #输出训练耗时
def train_generator(self, data_gen, epochs, batch_size, steps_per_epoch, save_dir,save_name):
'''
由data_gen数据产生器来逐步产生训练数据而不是一次性将数据读入到内存
'''
timer = Timer()
timer.start()
print('[Model] Training Started')
print('[Model] %s epochs, %s batch size, %s batches per epoch' % (epochs, batch_size, steps_per_epoch))
# save_fname = os.path.join(save_dir, '%s-e%s.h5' % (dt.datetime.now().strftime('%d%m%Y-%H%M%S'), str(epochs)))
save_fname = os.path.join(save_dir, save_name+'.h5')
callbacks = [
ModelCheckpoint(filepath=save_fname, monitor='loss', save_best_only=True)
]
self.model.fit_generator(
data_gen,
steps_per_epoch=steps_per_epoch,
epochs=epochs,
callbacks=callbacks,
workers=1
)
print('[Model] Training Completed. Model saved as %s' % save_fname)
timer.stop()
# data必须是三维数据即shape:(a,b,c)
def predict_point_by_point(self, data):
#Predict each timestep given the last sequence of true data, in effect only predicting 1 step ahead each time
predicted = self.model.predict(data) # data有多少行就输出多少个预测值,返回的预测值是一个2维数组:(a,1) a:为data的行数
predicted = np.reshape(predicted, (predicted.size,)) # 这里将二维数组,变成一维数组
return predicted # 返回一维数组元素个数与data的a相同
# 对data进行多段预测每段预测基于一个窗口大小window_size的数据然后输出prediction_len长的预测值一维数组
# 再从上一个窗口移动prediction_len的长度得到下一个窗口的数据并基于该数据再预测prediction_len长的预测值
# 所以prediction_len决定了窗口的移位步数每次的窗口大小是一样的所以最后预测的段数 = 窗口个数/预测长度
# 相当于多次调用predict_1_win_sequence方法
def predict_sequences_multiple(self, data, window_size, prediction_len):
#Predict sequence of 50 steps before shifting prediction run forward by 50 steps
prediction_seqs = []
for i in range(int(len(data)/prediction_len)):
curr_frame = data[i*prediction_len]
predicted = []
for j in range(prediction_len):
predicted.append(self.model.predict(curr_frame[newaxis,:,:])[0,0]) # newaxis增加新轴使得curr_frame变成(1,x,x)三维数据
curr_frame = curr_frame[1:]
curr_frame = np.insert(curr_frame, [window_size-2], predicted[-1], axis=0)
prediction_seqs.append(predicted)
return prediction_seqs
# 输入一个窗口的数据指定预测的长度data:依旧是三维数组(1,win_len,fea_len)
# 返回预测数组
def predict_sequence_full(self, data, window_size): # window_size为输入数据的长度
#Shift the window by 1 new prediction each time, re-run predictions on new window
curr_frame = data[0] # 基于data[0]一个窗口的数据来预测len(data)个输出
predicted = []
for i in range(len(data)):
predicted.append(self.model.predict(curr_frame[newaxis,:,:])[0,0]) # append了一个预测值标量
curr_frame = curr_frame[1:]
curr_frame = np.insert(curr_frame, [window_size-2], predicted[-1], axis=0) # 插入位置[window_size-2]:curr_frame的末尾predicted[-1]:插入值
return predicted
# 输入一个窗口的数据指定预测的长度data:依旧是三维数组(1,win_len,fea_len)
# 返回预测数组
def predict_1_win_sequence(self, data, window_size,predict_length): # window_sizedata的窗口大小
#Shift the window by 1 new prediction each time, re-run predictions on new window
curr_frame = data[0]
predicted = []
for i in range(predict_length): # range(len(data))
predicted.append(self.model.predict(curr_frame[newaxis,:,:])[0,0]) # append了一个预测值标量
curr_frame = curr_frame[1:]
curr_frame = np.insert(curr_frame, [window_size-2], predicted[-1], axis=0) # 插入位置[window_size-2]:curr_frame的末尾predicted[-1]:插入值
return predicted

@ -0,0 +1,13 @@
import datetime as dt
class Timer():
def __init__(self):
self.start_dt = None
def start(self):
self.start_dt = dt.datetime.now()
def stop(self):
end_dt = dt.datetime.now()
print('Time taken: %s' % (end_dt - self.start_dt))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

@ -0,0 +1,260 @@
import keras
__author__ = "Jakob Aungiers"
__copyright__ = "Jakob Aungiers 2018"
__version__ = "2.0.0"
__license__ = "MIT"
import os
import json
import numpy as np
import math
import pandas as pd
import matplotlib.pyplot as plt
from LSTMPredictStock.core.data_processor import DataLoader
from LSTMPredictStock.core.model import Model
from datetime import datetime,timedelta
from LSTMPredictStock.core.get_domestic_hist_stock import get_all_last_data
from LSTMPredictStock.core.get_domestic_hist_stock import get_single_last_data
def plot_results(predicted_data, true_data): # predicted_data与true_data同长度一维数组
fig = plt.figure(facecolor='white')
ax = fig.add_subplot(111)
ax.plot(true_data, label='True Data')
plt.plot(predicted_data, label='Prediction')
plt.legend()
plt.show()
# predicted_data每个元素的长度必须为prediction_len
def plot_results_multiple(predicted_data, true_data, prediction_len):
fig = plt.figure(facecolor='white')
ax = fig.add_subplot(111)
ax.plot(true_data, label='True Data')
# Pad the list of predictions to shift it in the graph to it's correct start
for i, data in enumerate(predicted_data): # data为一维数组长度为prediction_len。predicted_data二维数组每个元素为list
padding = [None for p in range(i * prediction_len)]
plt.plot(padding + data, label='Prediction') # padding + datalist拼接操作
plt.legend()
plt.show()
# 只用于训练模型,但同时可根据参数进行模型的评估
def train_model(stock_code, predict=False): # 训练指定股票代码的模型
'''
训练并保存模型同时根据测试数据对模型进行评估绘图方式
'''
configs = json.load(open(get_config_path(), 'r'))
if not os.path.exists(os.path.join(get_parent_dir(),configs['model']['save_dir'])):
os.makedirs(os.path.join(get_parent_dir(),configs['model']['save_dir'])) # 创建保存模型的目录
split = configs['data']['train_test_split']
if not predict:
split = 1 # 若不评估模型准确度,则将全部历史数据用于训练
data = DataLoader( # 从本地加载训练和测试数据
os.path.join(get_parent_dir(),os.path.join('data', stock_code + ".csv")), # configs['data']['filename']
split,
configs['data']['columns'] # 选择某些列的数据进行训练
)
model = Model()
model.build_model(configs) # 根据配置文件新建模型
'''
# in-memory training
model.train(
x,
y,
epochs = configs['training']['epochs'],
batch_size = configs['training']['batch_size'],
save_dir = configs['model']['save_dir']
)
'''
# 训练模型:
# out-of memory generative training
steps_per_epoch = math.ceil(
(data.len_train - configs['data']['sequence_length']) / configs['training']['batch_size'])
model.train_generator(
data_gen=data.generate_train_batch(
seq_len=configs['data']['sequence_length'],
batch_size=configs['training']['batch_size'],
normalise=configs['data']['normalise']
),
epochs=configs['training']['epochs'],
batch_size=configs['training']['batch_size'],
steps_per_epoch=steps_per_epoch,
save_dir=os.path.join(get_parent_dir(),configs['model']['save_dir']),
save_name=stock_code
)
# 预测
if predict:
x_test, y_test = data.get_test_data(
seq_len=configs['data']['sequence_length'],
normalise=configs['data']['normalise']
)
predictions = model.predict_sequences_multiple(x_test, configs['data']['sequence_length'],
configs['data']['sequence_length'])
print("训练:\n", predictions)
# plot_results_multiple(predictions, y_test, configs['data']['sequence_length'])
# 对指定公司的股票进行预测
def prediction(stock_code, real=True, pre_len=30, plot=False):
'''
使用保存的模型对输入数据进行预测
'''
config_path = get_config_path()
configs = json.load(open(config_path, 'r'))
data = DataLoader(
os.path.join(get_data_path(), stock_code + ".csv"), # configs['data']['filename']
configs['data']['train_test_split'],
configs['data']['columns']
)
file_path = os.path.join(get_parent_dir(),os.path.join("saved_models",stock_code + ".h5"))
model = Model()
keras.backend.clear_session()
model.load_model(file_path) # 根据配置文件新建模型
# predict_length = configs['data']['sequence_length'] # 预测长度
predict_length = pre_len
if real: # 用最近一个窗口的数据进行预测,没有对比数据
win_position = -1
else: # 用指定位置的一个窗口数据进行预测,有对比真实数据(用于绘图对比)
win_position = -configs['data']['sequence_length']
x_test, y_test = data.get_test_data(
seq_len=configs['data']['sequence_length'],
normalise=False
)
x_test = x_test[win_position]
x_test = x_test[np.newaxis, :, :]
if not real:
y_test_real = y_test[win_position:win_position + predict_length]
base = x_test[0][0][0]
print("base value:\n", base)
x_test, y_test = data.get_test_data(
seq_len=configs['data']['sequence_length'],
normalise=configs['data']['normalise']
)
x_test = x_test[win_position]
x_test = x_test[np.newaxis, :, :]
# predictions = model.predict_sequences_multiple(x_test, configs['data']['sequence_length'],
# predict_length)
predictions = model.predict_1_win_sequence(x_test, configs['data']['sequence_length'], predict_length)
# 反归一化
predictions_array = np.array(predictions)
predictions_array = base * (1 + predictions_array)
predictions = predictions_array.tolist()
print("预测数据:\n", predictions)
if not real:
print("真实数据:\n", y_test_real)
# plot_results_multiple(predictions, y_test, predict_length)
if plot:
if real:
plot_results(predictions, [])
else:
plot_results(predictions, y_test_real)
return format_predictions(predictions)
def format_predictions(predictions): # 给预测数据添加对应日期
date_predict = []
cur = datetime.now()
cur += timedelta(days=1)
counter = 0
while counter < len(predictions):
if cur.isoweekday() == 6:
cur = cur + timedelta(days=2)
if cur.isoweekday() == 7:
cur = cur + timedelta(days=1)
date_predict.append([cur.strftime("%Y-%m-%d"),predictions[counter]])
cur = cur + timedelta(days=1)
counter += 1
return date_predict
'''
def main(stock_code, train=False, predict=False):
configs = json.load(open(get_config_path(), 'r'))
companies = configs['companies']
if stock_code not in companies.keys():
print("该公司不在指定范围内")
return -1
if train:
train_model(stock_code)
return 0 # 训练完成
if predict:
# for root, dirs, files in os.walk('saved_models'):
# root:当前目录路径 dirs: 当前路径下所有子目录 files:当前路径下所有非目录子文件
if stock_code + ".h5" in os.listdir("saved_models"): # os.listdir:获得当前目录下的所有文件名。不包括子目录
return prediction(stock_code=stock_code, real=True, pre_len=20)
else:
return -2 # 该公司还没有训练模型
'''
# 二维数组:[[data,value],[...]]
def get_hist_data(stock_code, recent_day=30): # 获取某股票指定天数的历史close数据,包含日期
get_single_last_data(stock_code)
root_dir = get_parent_dir()
file_path = os.path.join(root_dir, "data/" + stock_code + ".csv")
cols = ['Date', 'Close']
data_frame = pd.read_csv(file_path)
close_data = data_frame.get(cols).values[-recent_day:]
return close_data.tolist()
def train_all_stock(): #
get_all_last_data(start_date="2010-01-01")
configs = json.load(open(get_config_path(), 'r'))
companies = configs['companies']
for stock_code in companies.keys():
train_model(stock_code)
return 0
def predict_all_stock(pre_len=10):
file_path = get_config_path()
configs = json.load(open(file_path, 'r'))
companies = configs['companies']
predict_list = []
for stock_code in companies.keys():
predict_list.append(prediction(stock_code=stock_code, real=True, pre_len=pre_len))
return predict_list
def get_config_path(): # config.json的绝对路径
root_dir = get_parent_dir()
return os.path.join(root_dir, "config.json")
def get_data_path(): # data目录的绝对路径
root_dir = get_parent_dir()
return os.path.join(root_dir, "data")
def get_parent_dir(): # 当前文件的父目录绝对路径
return os.path.dirname(__file__)
if __name__ == '__main__':
# train_all_stock()
predict_all_stock()
# train_model("000063", predict=False)

@ -1,2 +1,114 @@
# Stock-Forecast
# WebStockPredict
此project是基于django的web app。它能给出指定范围内公司(此处为10个)的历史股票数据与未来某段时间的预测数据以及对该股票的一些评价指标。
股票预测模型是使用[jaungiers](https://github.com/jaungiers/LSTM-Neural-Network-for-Time-Series-Prediction)提出的一种LSTM Neural Network模型。
并使用以tensorflow作为backend的keras来搭建、训练模型。
## 目录说明
+ display_img:保存演示图片
+ htmlcov:使用coverage.py集成测试自动生成的文件夹
+ LSTMPredictStock:包含了有关模型的一切包括训练数据及其获取代码模型搭建、训练的代码、训练好的模型以及关于该python包的配置文件config.json
+ stock_predict:基于django开发框架的Web app包含了一个web应用的相关内容。
+ WebStockPredict:包含了对django project进行管理、配置的程序
+ db.sqlite3:此Web应用所需的数据就存放在sqlite3数据库中
+ manage.py:管理django project的快捷API
## 运行项目
### 环境要求
如果只运行web项目则只需安装如下包
+ python 3.6.x
+ django >= 2.1.4 或者使用conda安装最新版
+ pandas >= 0.23.4 或者使用conda安装最新版
+ numpy >= 1.15.2 或者使用conda安装最新版
+ apscheduler = 2.1.2 请用pip install apscheduler==2.1.2 安装conda装的版本不兼容
如果需要训练模型或者使用模型来预测(注:需要保证本机拥有 NVIDIA GPU以及显卡驱动),则还需要安装:
+ tensorflow-gpu >= 1.10.0 可以使用conda安装最新版。如用conda安装cudatoolkit和cudnn会被自动安装
+ cudatoolkit >= 9.0 根据自己本机的显卡型号决定请去NVIDIA官网查看
+ cudnn >= 7.1.4 版本与cudatoolkit9.0对应的其他版本请去NVIDIA官网查看对应的cudatoolkit版本
+ keras >= 2.2.2 可以使用conda安装最新版
+ matplotlib >= 2.2.2 可以使用conda安装最新版
或者可以通过控制台在根目录路径下输入:`pip install -r requirements.txt`安装上述所有包注意修改cudatoolkit和cudnn的版本与自己电脑的GPU型号一致
### 使用django自带的服务器在本地运行
首先你需要将此项目clone或者download到本地。然后在控制台进入项目根目录即WebStockPredict(包含有manage.py的目录)输入如下面命令启动Web应用
`python manage.py runserver`
当控制台输出如下内容时证明Web项目已成功启动:
```
Using TensorFlow backend.
System check identified no issues (0 silenced).
December 24, 2018 - 19:57:52
Django version 2.1.4, using settings 'WebStockPredict.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
```
此时在浏览器中输入:`http://http://127.0.0.1:8000/stock_predict/home/`即可访问应用通过下拉框选择查看某个公司过去20天的历史股票数据和未来10天的预测数据。
![home page](/display_img/home.png "股票预测系统首页")
**注在Web app中绘制的10天预测数据大多都是朝着一个方向变化。这是因为股票数据是一个随机过程无法使用既有的模型去准确预测未来一段时间的数据只能给出股票未来变化的趋势。
在我们使用[jaungiers](https://www.altumintelligence.com/articles/a/Time-Series-Prediction-Using-LSTM-Deep-Neural-Networks)提出的模型中他详细阐述了这个问题。
我们预测输出符合他给出的实验图,如下:**
![multi-sequence](/display_img/multi-sequence.png "多段预测输出")
## 数据
本项目为了演示方便只使用了10个公司的股票数据来进行模型训练实际上可以依据个人需求训练成百上千个公司的数据。
*注:这个项目只是用来演示,并不保证预测的真实性,请勿用于真实炒股*
### 数据来源
+ #### 训练数据
训练模型的数据即10个公司的历史股票数据。获取国内上市公司历史股票数据来源于网易的API'http://quotes.money.163.com/service/chddata.html'
详细使用请参考[数据接口-免费版股票数据API](https://blog.csdn.net/llingmiao/article/details/79941066)。
在LSTMPredictStock/core/get_domestic_hist_stock.py 中`get_domestic_stock(sticker_code, start_date, end_date):`
函数用于获取10个公司起始至终止日期的股票数据并以csv格式保存在 LSTMPredictStock/data下。csv格式方便用pandas读取输入到LSTM神经网络模型
用于训练模型以及预测股票数据。
+ #### 股票指标数据
我们的Web app还给出了每个公司的股票评价指标。这些数据是从[数据猫](http://www.gpdatacat.com/)的网站上爬取的,在数据猫的网站上给出了股票的很多项评价指标(如下图),
而我们只选择了其中几个评价指标来展示。爬虫程序stock_predict/get_stock_index.py调用`main(stockcode)`方法可以获得指定股票代码的评价指标数据,
它会在stock_predict下创建stock_index文件夹以csv格式保存爬取的数据。另外需要注意的是因为数据猫需要用户登录以后才能查看相应的股票数据所以在
运行get_stock_index.py时需要自己先在浏览器登录数据猫后得到cookie中的参数按F12选择Application选项卡即可看到如下图
然后在get_stock_index.py中修改下面代码块中对应的字符串变量+’后面的值
![cookie](/display_img/cookie.png "获取cookie参数")
```
UM_distinctid = "UM_distinctid=" + "167d4244a665d3-0bc7b9a22f42f1-4313362-144000-167d4244a67440;"
PHPSESSID = "PHPSESSID=" + "4j67ed7bo6ogs6ntjmo3fb62n4;"
CNZZDATA1256448133 = "CNZZDATA1256448133=" + "1846506456-1545449269-%7C1545479258;"
amvid = "amvid=" + "6447ffafff063060f1a560d94128a33f"
cookie={'Cookie':UM_distinctid+PHPSESSID+CNZZDATA1256448133+amvid}
```
![data_cat](/display_img/data_cat.png "股票评价指标")
### 训练模型
1. 调用run.py中的`train_all_stock`,它首先会调用`get_all_last_data(start_date="2010-01-01")`方法获得10个公司从2010年至今年的历史数据
2. 接着调用的`train_model(stock_code, predict=False)`方法基于上述数据来训练模型若predict=True则在训练完后会进行模型正确性的验证
主要是通过绘图方式来对比预测数据与真实数据之间的吻合度
3. 并分别将10个公司的训练好的模型保存于LSTMPredictStock/saved_models下'xxx.h5'格式),用于后续恢复模型来预测数据
### 预测股票数据
1. 调用run.py中的`predict_all_stock(pre_len=10)`来对10个公司的股票进行预测pre_len指定预测的天数默认是10天
2. 上一步调用的函数实际上调用了`prediction(stock_code, real=True, pre_len=30, plot=False)`来完成预测。
在` model.load_model(file_path)`这里恢复了模型。它默认使用每个公司近30天的历史数据作为模型输入来得到pre_len天的预测数据
### 项目测试
#### 单元测试
使用django自带的测试工具来实现单元测试测试程序位于stock_predict/test.py在控制台根目录下使用命令`python manage.py test stock_predict'
来运行test.py。
#### 集成测试
如果想完成集成测试则需要借助第三方库coverage.py可以通过`pip install coverage`安装,详情使用参考[coverage.py](https://pypi.org/project/coverage/)。
1. 控制台在根目录WebStockPredict下输入命令`coverage run --source='.' manage.py test stock_predict`来执行test.py
2. 下一步输入`coverage report`命令,可以生成简易的测试报告
3. 为了获得更详细的测试报告,可输入`coverage html`命令其会在根目录下生成htmlcov文件夹里面包含自动生成的html页面点击index.html可查看整个项目以及各个文件的测试覆盖率如下图
![coverage_index](/display_img/coverage_index.png "集成测试")
### 本机硬软件环境
+ win10-64bit
+ NVIDIA GeForce GTX1060
+ NVIDIA显卡驱动版本391.24
### 参考
[LSTM-Neural-Network-for-Time-Series-Prediction](https://github.com/jaungiers/LSTM-Neural-Network-for-Time-Series-Prediction)
[数据接口-免费版股票数据API](https://blog.csdn.net/llingmiao/article/details/79941066)

@ -0,0 +1,121 @@
"""
Django settings for WebStockPredict project.
Generated by 'django-admin startproject' using Django 2.1.4.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 's^-*g$$lhg4j-q=#bad#x+$086ptt$l7op1u5h8p%4l3cq7v8s'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'stock_predict.apps.StockPredictConfig'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'WebStockPredict.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'WebStockPredict.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'zh-hans' # en-us
TIME_ZONE = 'Asia/Shanghai' # UTC
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'

@ -0,0 +1,24 @@
"""WebStockPredict URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from django.urls import path,include
from django.views.generic import RedirectView
urlpatterns = [
path('admin/', admin.site.urls),
path("stock_predict/",include('stock_predict.urls')),
]

@ -0,0 +1,16 @@
"""
WSGI config for WebStockPredict project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'WebStockPredict.settings')
application = get_wsgi_application()

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for LSTMPredictStock\__init__.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>LSTMPredictStock\__init__.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
0 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">0 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
</td>
<td class="text">
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,111 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for LSTMPredictStock\core\__init__.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>LSTMPredictStock\core\__init__.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
6 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">6 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="pln"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="stm run hide_run"><a href="#n10">10</a></p>
<p id="n11" class="stm run hide_run"><a href="#n11">11</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com"># this lstm core module implementation provides an implementation</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="com"># of time series prediction using a lstm approach. It is provided</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="pln"><span class="com"># as is with no warranties or support.</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="nam">__author__</span> <span class="op">=</span> <span class="str">"Jakob Aungiers"</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="nam">__copyright__</span> <span class="op">=</span> <span class="str">"Jakob Aungiers 2018"</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"><span class="nam">__version__</span> <span class="op">=</span> <span class="str">"2.0.0"</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"><span class="nam">__license__</span> <span class="op">=</span> <span class="str">"MIT"</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t10" class="stm run hide_run"><span class="key">import</span> <span class="nam">warnings</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="stm run hide_run"><span class="nam">warnings</span><span class="op">.</span><span class="nam">filterwarnings</span><span class="op">(</span><span class="str">"ignore"</span><span class="op">)</span> <span class="com"># ignore messy numpy warnings</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,273 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for LSTMPredictStock\core\data_processor.py: 88%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>LSTMPredictStock\core\data_processor.py</b> :
<span class="pc_cov">88%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
58 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">51 run</span>
<span class="mis shortkey_m button_toggle_mis">7 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="stm run hide_run"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="stm run hide_run"><a href="#n14">14</a></p>
<p id="n15" class="stm run hide_run"><a href="#n15">15</a></p>
<p id="n16" class="stm run hide_run"><a href="#n16">16</a></p>
<p id="n17" class="stm run hide_run"><a href="#n17">17</a></p>
<p id="n18" class="stm run hide_run"><a href="#n18">18</a></p>
<p id="n19" class="stm run hide_run"><a href="#n19">19</a></p>
<p id="n20" class="stm run hide_run"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
<p id="n23" class="stm run hide_run"><a href="#n23">23</a></p>
<p id="n24" class="pln"><a href="#n24">24</a></p>
<p id="n25" class="pln"><a href="#n25">25</a></p>
<p id="n26" class="pln"><a href="#n26">26</a></p>
<p id="n27" class="pln"><a href="#n27">27</a></p>
<p id="n28" class="pln"><a href="#n28">28</a></p>
<p id="n29" class="stm run hide_run"><a href="#n29">29</a></p>
<p id="n30" class="stm run hide_run"><a href="#n30">30</a></p>
<p id="n31" class="stm run hide_run"><a href="#n31">31</a></p>
<p id="n32" class="pln"><a href="#n32">32</a></p>
<p id="n33" class="stm run hide_run"><a href="#n33">33</a></p>
<p id="n34" class="stm run hide_run"><a href="#n34">34</a></p>
<p id="n35" class="pln"><a href="#n35">35</a></p>
<p id="n36" class="stm run hide_run"><a href="#n36">36</a></p>
<p id="n37" class="stm run hide_run"><a href="#n37">37</a></p>
<p id="n38" class="pln"><a href="#n38">38</a></p>
<p id="n39" class="stm run hide_run"><a href="#n39">39</a></p>
<p id="n40" class="pln"><a href="#n40">40</a></p>
<p id="n41" class="stm run hide_run"><a href="#n41">41</a></p>
<p id="n42" class="pln"><a href="#n42">42</a></p>
<p id="n43" class="pln"><a href="#n43">43</a></p>
<p id="n44" class="pln"><a href="#n44">44</a></p>
<p id="n45" class="pln"><a href="#n45">45</a></p>
<p id="n46" class="pln"><a href="#n46">46</a></p>
<p id="n47" class="stm mis"><a href="#n47">47</a></p>
<p id="n48" class="stm mis"><a href="#n48">48</a></p>
<p id="n49" class="stm mis"><a href="#n49">49</a></p>
<p id="n50" class="stm mis"><a href="#n50">50</a></p>
<p id="n51" class="stm mis"><a href="#n51">51</a></p>
<p id="n52" class="stm mis"><a href="#n52">52</a></p>
<p id="n53" class="pln"><a href="#n53">53</a></p>
<p id="n54" class="stm mis"><a href="#n54">54</a></p>
<p id="n55" class="pln"><a href="#n55">55</a></p>
<p id="n56" class="stm run hide_run"><a href="#n56">56</a></p>
<p id="n57" class="pln"><a href="#n57">57</a></p>
<p id="n58" class="stm run hide_run"><a href="#n58">58</a></p>
<p id="n59" class="stm run hide_run"><a href="#n59">59</a></p>
<p id="n60" class="stm run hide_run"><a href="#n60">60</a></p>
<p id="n61" class="stm run hide_run"><a href="#n61">61</a></p>
<p id="n62" class="stm run hide_run"><a href="#n62">62</a></p>
<p id="n63" class="stm run hide_run"><a href="#n63">63</a></p>
<p id="n64" class="pln"><a href="#n64">64</a></p>
<p id="n65" class="stm run hide_run"><a href="#n65">65</a></p>
<p id="n66" class="stm run hide_run"><a href="#n66">66</a></p>
<p id="n67" class="stm run hide_run"><a href="#n67">67</a></p>
<p id="n68" class="stm run hide_run"><a href="#n68">68</a></p>
<p id="n69" class="stm run hide_run"><a href="#n69">69</a></p>
<p id="n70" class="stm run hide_run"><a href="#n70">70</a></p>
<p id="n71" class="pln"><a href="#n71">71</a></p>
<p id="n72" class="stm run hide_run"><a href="#n72">72</a></p>
<p id="n73" class="pln"><a href="#n73">73</a></p>
<p id="n74" class="stm run hide_run"><a href="#n74">74</a></p>
<p id="n75" class="stm run hide_run"><a href="#n75">75</a></p>
<p id="n76" class="stm run hide_run"><a href="#n76">76</a></p>
<p id="n77" class="stm run hide_run"><a href="#n77">77</a></p>
<p id="n78" class="pln"><a href="#n78">78</a></p>
<p id="n79" class="stm run hide_run"><a href="#n79">79</a></p>
<p id="n80" class="pln"><a href="#n80">80</a></p>
<p id="n81" class="stm run hide_run"><a href="#n81">81</a></p>
<p id="n82" class="pln"><a href="#n82">82</a></p>
<p id="n83" class="stm run hide_run"><a href="#n83">83</a></p>
<p id="n84" class="stm run hide_run"><a href="#n84">84</a></p>
<p id="n85" class="stm run hide_run"><a href="#n85">85</a></p>
<p id="n86" class="stm run hide_run"><a href="#n86">86</a></p>
<p id="n87" class="stm run hide_run"><a href="#n87">87</a></p>
<p id="n88" class="stm run hide_run"><a href="#n88">88</a></p>
<p id="n89" class="stm run hide_run"><a href="#n89">89</a></p>
<p id="n90" class="stm run hide_run"><a href="#n90">90</a></p>
<p id="n91" class="stm run hide_run"><a href="#n91">91</a></p>
<p id="n92" class="stm run hide_run"><a href="#n92">92</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">numpy</span> <span class="key">as</span> <span class="nam">np</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">import</span> <span class="nam">pandas</span> <span class="key">as</span> <span class="nam">pd</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="key">class</span> <span class="nam">DataLoader</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"> <span class="str">"""A class for loading and transforming data for the lstm model"""</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">filename</span><span class="op">,</span> <span class="nam">split</span><span class="op">,</span> <span class="nam">cols</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"> <span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"><span class="str"> filename:&#25968;&#25454;&#25152;&#22312;&#25991;&#20214;&#21517;&#65292; '.csv'&#26684;&#24335;&#25991;&#20214;</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="str"> split:&#35757;&#32451;&#19982;&#27979;&#35797;&#25968;&#25454;&#20998;&#21106;&#21464;&#37327;</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"><span class="str"> cols:&#36873;&#25321;data&#30340;&#19968;&#21015;&#25110;&#32773;&#22810;&#21015;&#36827;&#34892;&#20998;&#26512;&#65292;&#22914; Close &#21644; Volume</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"><span class="str"> '''</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="stm run hide_run"> <span class="nam">dataframe</span> <span class="op">=</span> <span class="nam">pd</span><span class="op">.</span><span class="nam">read_csv</span><span class="op">(</span><span class="nam">filename</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="stm run hide_run"> <span class="nam">i_split</span> <span class="op">=</span> <span class="nam">int</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">dataframe</span><span class="op">)</span> <span class="op">*</span> <span class="nam">split</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">data_train</span> <span class="op">=</span> <span class="nam">dataframe</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="nam">cols</span><span class="op">)</span><span class="op">.</span><span class="nam">values</span><span class="op">[</span><span class="op">:</span><span class="nam">i_split</span><span class="op">]</span> <span class="com">#&#36873;&#25321;&#25351;&#23450;&#30340;&#21015; &#36827;&#34892;&#20998;&#21106; &#24471;&#21040; &#26410;&#22788;&#29702;&#30340;&#35757;&#32451;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">data_test</span> <span class="op">=</span> <span class="nam">dataframe</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="nam">cols</span><span class="op">)</span><span class="op">.</span><span class="nam">values</span><span class="op">[</span><span class="nam">i_split</span><span class="op">:</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">len_train</span> <span class="op">=</span> <span class="nam">len</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">data_train</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">len_test</span> <span class="op">=</span> <span class="nam">len</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">data_test</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">len_train_windows</span> <span class="op">=</span> <span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm run hide_run"> <span class="key">def</span> <span class="nam">get_test_data</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">seq_len</span><span class="op">,</span> <span class="nam">normalise</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="pln"> <span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="pln"><span class="str"> Create x, y test data windows</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="pln"><span class="str"> Warning: batch method, not generative, make sure you have enough memory to</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="pln"><span class="str"> load data, otherwise reduce size of the training split.</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="pln"><span class="str"> '''</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="stm run hide_run"> <span class="nam">data_windows</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t30" class="stm run hide_run"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">len_test</span> <span class="op">-</span> <span class="nam">seq_len</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t31" class="stm run hide_run"> <span class="nam">data_windows</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">data_test</span><span class="op">[</span><span class="nam">i</span><span class="op">:</span><span class="nam">i</span><span class="op">+</span><span class="nam">seq_len</span><span class="op">]</span><span class="op">)</span> <span class="com">#&#27599;&#19968;&#20010;&#20803;&#32032;&#26159;&#38271;&#24230;&#20026;seq_len&#30340; list&#21363;&#19968;&#20010;window</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t33" class="stm run hide_run"> <span class="nam">data_windows</span> <span class="op">=</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">data_windows</span><span class="op">)</span><span class="op">.</span><span class="nam">astype</span><span class="op">(</span><span class="nam">float</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="stm run hide_run"> <span class="nam">data_windows</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">normalise_windows</span><span class="op">(</span><span class="nam">data_windows</span><span class="op">,</span> <span class="nam">single_window</span><span class="op">=</span><span class="key">False</span><span class="op">)</span> <span class="key">if</span> <span class="nam">normalise</span> <span class="key">else</span> <span class="nam">data_windows</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t36" class="stm run hide_run"> <span class="nam">x</span> <span class="op">=</span> <span class="nam">data_windows</span><span class="op">[</span><span class="op">:</span><span class="op">,</span> <span class="op">:</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="stm run hide_run"> <span class="nam">y</span> <span class="op">=</span> <span class="nam">data_windows</span><span class="op">[</span><span class="op">:</span><span class="op">,</span> <span class="op">-</span><span class="num">1</span><span class="op">,</span> <span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t39" class="stm run hide_run"> <span class="key">return</span> <span class="nam">x</span><span class="op">,</span> <span class="nam">y</span><span class="strut">&nbsp;</span></p>
<p id="t40" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t41" class="stm run hide_run"> <span class="key">def</span> <span class="nam">get_train_data</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">seq_len</span><span class="op">,</span> <span class="nam">normalise</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t42" class="pln"> <span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t43" class="pln"><span class="str"> Create x, y train data windows</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="pln"><span class="str"> Warning: batch method, not generative, make sure you have enough memory to</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="pln"><span class="str"> load data, otherwise use generate_training_window() method.</span><span class="strut">&nbsp;</span></p>
<p id="t46" class="pln"><span class="str"> '''</span><span class="strut">&nbsp;</span></p>
<p id="t47" class="stm mis"> <span class="nam">data_x</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t48" class="stm mis"> <span class="nam">data_y</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t49" class="stm mis"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">len_train</span> <span class="op">-</span> <span class="nam">seq_len</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t50" class="stm mis"> <span class="nam">x</span><span class="op">,</span> <span class="nam">y</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_next_window</span><span class="op">(</span><span class="nam">i</span><span class="op">,</span> <span class="nam">seq_len</span><span class="op">,</span> <span class="nam">normalise</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="stm mis"> <span class="nam">data_x</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">x</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t52" class="stm mis"> <span class="nam">data_y</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">y</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t53" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t54" class="stm mis"> <span class="key">return</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">data_x</span><span class="op">)</span><span class="op">,</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">data_y</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t55" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t56" class="stm run hide_run"> <span class="key">def</span> <span class="nam">generate_train_batch</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">seq_len</span><span class="op">,</span> <span class="nam">batch_size</span><span class="op">,</span> <span class="nam">normalise</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t57" class="pln"> <span class="str">'''Yield a generator of training data from filename on given list of cols split for train/test'''</span><span class="strut">&nbsp;</span></p>
<p id="t58" class="stm run hide_run"> <span class="nam">i</span> <span class="op">=</span> <span class="num">0</span><span class="strut">&nbsp;</span></p>
<p id="t59" class="stm run hide_run"> <span class="key">while</span> <span class="nam">i</span> <span class="op">&lt;</span> <span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">len_train</span> <span class="op">-</span> <span class="nam">seq_len</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t60" class="stm run hide_run"> <span class="nam">x_batch</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t61" class="stm run hide_run"> <span class="nam">y_batch</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t62" class="stm run hide_run"> <span class="key">for</span> <span class="nam">b</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">batch_size</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t63" class="stm run hide_run"> <span class="key">if</span> <span class="nam">i</span> <span class="op">>=</span> <span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">len_train</span> <span class="op">-</span> <span class="nam">seq_len</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t64" class="pln"> <span class="com"># stop-condition for a smaller final batch if data doesn't divide evenly</span><span class="strut">&nbsp;</span></p>
<p id="t65" class="stm run hide_run"> <span class="key">yield</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">x_batch</span><span class="op">)</span><span class="op">,</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">y_batch</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t66" class="stm run hide_run"> <span class="nam">x</span><span class="op">,</span> <span class="nam">y</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">_next_window</span><span class="op">(</span><span class="nam">i</span><span class="op">,</span> <span class="nam">seq_len</span><span class="op">,</span> <span class="nam">normalise</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t67" class="stm run hide_run"> <span class="nam">x_batch</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">x</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t68" class="stm run hide_run"> <span class="nam">y_batch</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">y</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t69" class="stm run hide_run"> <span class="nam">i</span> <span class="op">+=</span> <span class="num">1</span><span class="strut">&nbsp;</span></p>
<p id="t70" class="stm run hide_run"> <span class="key">yield</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">x_batch</span><span class="op">)</span><span class="op">,</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">y_batch</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t71" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t72" class="stm run hide_run"> <span class="key">def</span> <span class="nam">_next_window</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">i</span><span class="op">,</span> <span class="nam">seq_len</span><span class="op">,</span> <span class="nam">normalise</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t73" class="pln"> <span class="str">'''Generates the next data window from the given index location i'''</span><span class="strut">&nbsp;</span></p>
<p id="t74" class="stm run hide_run"> <span class="nam">window</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">data_train</span><span class="op">[</span><span class="nam">i</span><span class="op">:</span><span class="nam">i</span><span class="op">+</span><span class="nam">seq_len</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t75" class="stm run hide_run"> <span class="nam">window</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">normalise_windows</span><span class="op">(</span><span class="nam">window</span><span class="op">,</span> <span class="nam">single_window</span><span class="op">=</span><span class="key">True</span><span class="op">)</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="key">if</span> <span class="nam">normalise</span> <span class="key">else</span> <span class="nam">window</span><span class="strut">&nbsp;</span></p>
<p id="t76" class="stm run hide_run"> <span class="nam">x</span> <span class="op">=</span> <span class="nam">window</span><span class="op">[</span><span class="op">:</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t77" class="stm run hide_run"> <span class="nam">y</span> <span class="op">=</span> <span class="nam">window</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">,</span> <span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">]</span> <span class="com"># &#26368;&#21518;&#19968;&#34892;&#30340; 0&#20010;&#20803;&#32032; &#32452;&#25104;array&#31867;&#22411;&#65292;&#33509;&#26159;[0,2]&#21017;&#21462;&#31532;0&#20010;&#21644;&#31532;2&#20010;&#20803;&#32032;&#32452;&#25104;array&#65292;[-1, 0]&#65306;&#21017;&#26159;&#21462;&#26368;&#21518;&#19968;&#34892;&#31532;0&#20010;&#20803;&#32032;&#65292;</span><span class="strut">&nbsp;</span></p>
<p id="t78" class="pln"> <span class="com"># &#21482;&#36820;&#22238;&#35813;&#20803;&#32032;&#30340;&#20540;[]&#21644;()&#29992;&#20110;&#32034;&#24341;&#37117;&#26159;&#20999;&#29255;&#25805;&#20316;&#65292;&#25152;&#20197;&#36825;&#37324;&#30340;y&#21363;label&#26159; &#31532;&#19968;&#21015;Close&#21015;</span><span class="strut">&nbsp;</span></p>
<p id="t79" class="stm run hide_run"> <span class="key">return</span> <span class="nam">x</span><span class="op">,</span> <span class="nam">y</span><span class="strut">&nbsp;</span></p>
<p id="t80" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t81" class="stm run hide_run"> <span class="key">def</span> <span class="nam">normalise_windows</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">window_data</span><span class="op">,</span> <span class="nam">single_window</span><span class="op">=</span><span class="key">False</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t82" class="pln"> <span class="str">'''Normalise window with a base value of zero'''</span><span class="strut">&nbsp;</span></p>
<p id="t83" class="stm run hide_run"> <span class="nam">normalised_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t84" class="stm run hide_run"> <span class="nam">window_data</span> <span class="op">=</span> <span class="op">[</span><span class="nam">window_data</span><span class="op">]</span> <span class="key">if</span> <span class="nam">single_window</span> <span class="key">else</span> <span class="nam">window_data</span><span class="strut">&nbsp;</span></p>
<p id="t85" class="stm run hide_run"> <span class="key">for</span> <span class="nam">window</span> <span class="key">in</span> <span class="nam">window_data</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t86" class="stm run hide_run"> <span class="nam">normalised_window</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t87" class="stm run hide_run"> <span class="key">for</span> <span class="nam">col_i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">window</span><span class="op">.</span><span class="nam">shape</span><span class="op">[</span><span class="num">1</span><span class="op">]</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t88" class="stm run hide_run"> <span class="nam">normalised_col</span> <span class="op">=</span> <span class="op">[</span><span class="op">(</span><span class="op">(</span><span class="nam">float</span><span class="op">(</span><span class="nam">p</span><span class="op">)</span> <span class="op">/</span> <span class="nam">float</span><span class="op">(</span><span class="nam">window</span><span class="op">[</span><span class="num">0</span><span class="op">,</span> <span class="nam">col_i</span><span class="op">]</span><span class="op">)</span><span class="op">)</span> <span class="op">-</span> <span class="num">1</span><span class="op">)</span> <span class="key">for</span> <span class="nam">p</span> <span class="key">in</span> <span class="nam">window</span><span class="op">[</span><span class="op">:</span><span class="op">,</span> <span class="nam">col_i</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t89" class="stm run hide_run"> <span class="nam">normalised_window</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">normalised_col</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t90" class="stm run hide_run"> <span class="nam">normalised_window</span> <span class="op">=</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">normalised_window</span><span class="op">)</span><span class="op">.</span><span class="nam">T</span> <span class="com"># reshape and transpose array back into original multidimensional format</span><span class="strut">&nbsp;</span></p>
<p id="t91" class="stm run hide_run"> <span class="nam">normalised_data</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">normalised_window</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t92" class="stm run hide_run"> <span class="key">return</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">normalised_data</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 16:41
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,215 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for LSTMPredictStock\core\get_domestic_hist_stock.py: 98%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>LSTMPredictStock\core\get_domestic_hist_stock.py</b> :
<span class="pc_cov">98%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
45 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">44 run</span>
<span class="mis shortkey_m button_toggle_mis">1 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="stm run hide_run"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="pln"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="stm run hide_run"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="stm run hide_run"><a href="#n13">13</a></p>
<p id="n14" class="stm run hide_run"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="stm run hide_run"><a href="#n16">16</a></p>
<p id="n17" class="stm run hide_run"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="stm run hide_run"><a href="#n19">19</a></p>
<p id="n20" class="stm run hide_run"><a href="#n20">20</a></p>
<p id="n21" class="stm run hide_run"><a href="#n21">21</a></p>
<p id="n22" class="stm run hide_run"><a href="#n22">22</a></p>
<p id="n23" class="stm run hide_run"><a href="#n23">23</a></p>
<p id="n24" class="stm run hide_run"><a href="#n24">24</a></p>
<p id="n25" class="stm run hide_run"><a href="#n25">25</a></p>
<p id="n26" class="pln"><a href="#n26">26</a></p>
<p id="n27" class="stm run hide_run"><a href="#n27">27</a></p>
<p id="n28" class="stm run hide_run"><a href="#n28">28</a></p>
<p id="n29" class="stm run hide_run"><a href="#n29">29</a></p>
<p id="n30" class="stm run hide_run"><a href="#n30">30</a></p>
<p id="n31" class="stm run hide_run"><a href="#n31">31</a></p>
<p id="n32" class="stm run hide_run"><a href="#n32">32</a></p>
<p id="n33" class="stm run hide_run"><a href="#n33">33</a></p>
<p id="n34" class="pln"><a href="#n34">34</a></p>
<p id="n35" class="pln"><a href="#n35">35</a></p>
<p id="n36" class="stm run hide_run"><a href="#n36">36</a></p>
<p id="n37" class="stm run hide_run"><a href="#n37">37</a></p>
<p id="n38" class="stm run hide_run"><a href="#n38">38</a></p>
<p id="n39" class="pln"><a href="#n39">39</a></p>
<p id="n40" class="stm run hide_run"><a href="#n40">40</a></p>
<p id="n41" class="stm run hide_run"><a href="#n41">41</a></p>
<p id="n42" class="pln"><a href="#n42">42</a></p>
<p id="n43" class="pln"><a href="#n43">43</a></p>
<p id="n44" class="stm run hide_run"><a href="#n44">44</a></p>
<p id="n45" class="stm run hide_run"><a href="#n45">45</a></p>
<p id="n46" class="stm run hide_run"><a href="#n46">46</a></p>
<p id="n47" class="stm run hide_run"><a href="#n47">47</a></p>
<p id="n48" class="pln"><a href="#n48">48</a></p>
<p id="n49" class="stm run hide_run"><a href="#n49">49</a></p>
<p id="n50" class="stm run hide_run"><a href="#n50">50</a></p>
<p id="n51" class="pln"><a href="#n51">51</a></p>
<p id="n52" class="stm run hide_run"><a href="#n52">52</a></p>
<p id="n53" class="pln"><a href="#n53">53</a></p>
<p id="n54" class="stm run hide_run"><a href="#n54">54</a></p>
<p id="n55" class="stm run hide_run"><a href="#n55">55</a></p>
<p id="n56" class="stm run hide_run"><a href="#n56">56</a></p>
<p id="n57" class="stm run hide_run"><a href="#n57">57</a></p>
<p id="n58" class="pln"><a href="#n58">58</a></p>
<p id="n59" class="stm run hide_run"><a href="#n59">59</a></p>
<p id="n60" class="pln"><a href="#n60">60</a></p>
<p id="n61" class="pln"><a href="#n61">61</a></p>
<p id="n62" class="stm run hide_run"><a href="#n62">62</a></p>
<p id="n63" class="stm mis"><a href="#n63">63</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com"># &#33719;&#21462;&#22269;&#20869;&#32929;&#31080;&#21382;&#21490;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">json</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"><span class="key">import</span> <span class="nam">requests</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="key">from</span> <span class="nam">datetime</span> <span class="key">import</span> <span class="nam">datetime</span><span class="op">,</span><span class="nam">timedelta</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_domestic_stock</span><span class="op">(</span><span class="nam">sticker_code</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">,</span> <span class="nam">end_date</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="pln"> <span class="com"># &#20174;&#32593;&#26131;&#25509;&#21475;&#33719;&#21462;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"> <span class="nam">api_adr</span> <span class="op">=</span> <span class="str">'http://quotes.money.163.com/service/chddata.html'</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="stm run hide_run"> <span class="nam">fields</span> <span class="op">=</span> <span class="str">"TOPEN;TCLOSE;HIGH;LOW;VOTURNOVER"</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"> <span class="nam">tag</span> <span class="op">=</span> <span class="str">"0"</span> <span class="com"># &#19978;&#28023;&#35777;&#21048;</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="stm run hide_run"> <span class="key">if</span> <span class="nam">sticker_code</span> <span class="key">in</span> <span class="op">[</span><span class="str">'000063'</span><span class="op">,</span><span class="str">'000066'</span><span class="op">,</span><span class="str">'000768'</span><span class="op">,</span><span class="str">'000651'</span><span class="op">]</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="stm run hide_run"> <span class="nam">tag</span> <span class="op">=</span> <span class="str">"1"</span> <span class="com"># &#28145;&#22323;&#35777;&#21048;</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t16" class="stm run hide_run"> <span class="nam">params</span> <span class="op">=</span> <span class="op">{</span><span class="str">'code'</span><span class="op">:</span> <span class="nam">tag</span> <span class="op">+</span> <span class="nam">sticker_code</span><span class="op">,</span> <span class="str">'start'</span><span class="op">:</span> <span class="nam">start_date</span><span class="op">,</span> <span class="str">'end'</span><span class="op">:</span> <span class="nam">end_date</span><span class="op">,</span> <span class="str">'fields'</span><span class="op">:</span> <span class="nam">fields</span><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="stm run hide_run"> <span class="nam">r</span> <span class="op">=</span> <span class="nam">requests</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="nam">api_adr</span><span class="op">,</span> <span class="nam">params</span><span class="op">=</span><span class="nam">params</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t19" class="stm run hide_run"> <span class="nam">print</span><span class="op">(</span><span class="nam">r</span><span class="op">.</span><span class="nam">url</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="stm run hide_run"> <span class="nam">txt_list</span> <span class="op">=</span> <span class="nam">r</span><span class="op">.</span><span class="nam">text</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">'\n'</span><span class="op">)</span> <span class="com"># r.content&#20108;&#36827;&#21046;&#25968;&#25454; r.text &#25991;&#26412;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="stm run hide_run"> <span class="nam">txt_list</span><span class="op">.</span><span class="nam">reverse</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="stm run hide_run"> <span class="nam">txt_list</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="op">=</span> <span class="nam">txt_list</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span> <span class="com"># &#21015;&#21517;&#26367;&#25442;&#24320;&#22836;&#30340;&#31354;&#23383;&#31526;</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm run hide_run"> <span class="nam">col_name</span> <span class="op">=</span> <span class="str">"Date,Code,Name,Open,Close,High,Low,Volume\n"</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="stm run hide_run"> <span class="nam">txt_list</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="op">=</span> <span class="nam">col_name</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="stm run hide_run"> <span class="nam">txt_list</span><span class="op">.</span><span class="nam">pop</span><span class="op">(</span><span class="op">-</span><span class="num">1</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t27" class="stm run hide_run"> <span class="nam">root</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">__file__</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="stm run hide_run"> <span class="nam">dir_path</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">root</span><span class="op">,</span><span class="str">"data"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="stm run hide_run"> <span class="nam">filename</span> <span class="op">=</span> <span class="nam">sticker_code</span> <span class="op">+</span> <span class="str">".csv"</span><span class="strut">&nbsp;</span></p>
<p id="t30" class="stm run hide_run"> <span class="key">with</span> <span class="nam">open</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">dir_path</span><span class="op">,</span><span class="nam">filename</span><span class="op">)</span><span class="op">,</span> <span class="str">"w+"</span><span class="op">,</span> <span class="nam">encoding</span><span class="op">=</span><span class="str">'utf-8'</span><span class="op">)</span> <span class="key">as</span> <span class="nam">f</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t31" class="stm run hide_run"> <span class="key">for</span> <span class="nam">line</span> <span class="key">in</span> <span class="nam">txt_list</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="stm run hide_run"> <span class="key">if</span> <span class="nam">line</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">','</span><span class="op">)</span><span class="op">[</span><span class="num">3</span><span class="op">]</span> <span class="op">!=</span> <span class="str">'0.0'</span><span class="op">:</span> <span class="com"># &#21435;&#38500;&#26080;&#25928;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t33" class="stm run hide_run"> <span class="nam">f</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">line</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t35" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t36" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_all_last_data</span><span class="op">(</span><span class="nam">start_date</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#24471;&#21040;&#20174;start_date&#33267;&#20170;&#26085; &#25152;&#26377;&#26368;&#26032;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="stm run hide_run"> <span class="nam">root</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">__file__</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="stm run hide_run"> <span class="nam">config_path</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">root</span><span class="op">,</span><span class="str">"config.json"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t40" class="stm run hide_run"> <span class="nam">configs</span> <span class="op">=</span> <span class="nam">json</span><span class="op">.</span><span class="nam">load</span><span class="op">(</span><span class="nam">open</span><span class="op">(</span><span class="nam">config_path</span><span class="op">,</span> <span class="str">'r'</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t41" class="stm run hide_run"> <span class="nam">companies</span> <span class="op">=</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'companies'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t42" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t43" class="pln"> <span class="com"># start_date = '2010-06-21' # &#21482;&#33021;&#25353;&#25972;&#24180;&#33719;&#21462;&#33267;&#20170;&#26085;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="stm run hide_run"> <span class="nam">year</span> <span class="op">=</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">365</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t46" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">=</span> <span class="nam">cur</span> <span class="op">+</span> <span class="nam">year</span> <span class="com"># &#22312;&#24403;&#21069;&#26085;&#26399;&#19978;&#21152;&#19968;&#24180;</span><span class="strut">&nbsp;</span></p>
<p id="t47" class="stm run hide_run"> <span class="nam">end_date</span> <span class="op">=</span> <span class="nam">cur</span><span class="op">.</span><span class="nam">strftime</span><span class="op">(</span><span class="str">"%Y-%m-%d"</span><span class="op">)</span> <span class="com"># &#33719;&#21462;&#20170;&#24180;&#26368;&#26032;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t48" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t49" class="stm run hide_run"> <span class="key">for</span> <span class="nam">code</span><span class="op">,</span> <span class="nam">company_name</span> <span class="key">in</span> <span class="nam">companies</span><span class="op">.</span><span class="nam">items</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t50" class="stm run hide_run"> <span class="nam">get_domestic_stock</span><span class="op">(</span><span class="nam">code</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">,</span> <span class="nam">end_date</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t52" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_single_last_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">,</span><span class="nam">start_date</span><span class="op">=</span><span class="str">"2010-01-01"</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t53" class="pln"> <span class="com"># start_date = '2010-06-21' # &#21482;&#33021;&#25353;&#25972;&#24180;&#33719;&#21462;&#33267;&#20170;&#26085;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t54" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t55" class="stm run hide_run"> <span class="nam">year</span> <span class="op">=</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">365</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t56" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">=</span> <span class="nam">cur</span> <span class="op">+</span> <span class="nam">year</span> <span class="com"># &#22312;&#24403;&#21069;&#26085;&#26399;&#19978;&#21152;&#19968;&#24180;</span><span class="strut">&nbsp;</span></p>
<p id="t57" class="stm run hide_run"> <span class="nam">end_date</span> <span class="op">=</span> <span class="nam">cur</span><span class="op">.</span><span class="nam">strftime</span><span class="op">(</span><span class="str">"%Y-%m-%d"</span><span class="op">)</span> <span class="com"># &#33719;&#21462;&#20170;&#24180;&#26368;&#26032;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t58" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t59" class="stm run hide_run"> <span class="nam">get_domestic_stock</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">,</span> <span class="nam">end_date</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t60" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t61" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t62" class="stm run hide_run"><span class="key">if</span> <span class="nam">__name__</span> <span class="op">==</span> <span class="str">'__main__'</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t63" class="stm mis"> <span class="nam">get_all_last_data</span><span class="op">(</span><span class="str">"2010-01-01"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 16:41
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,201 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for LSTMPredictStock\core\get_stocks_data.py: 0%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>LSTMPredictStock\core\get_stocks_data.py</b> :
<span class="pc_cov">0%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
36 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">0 run</span>
<span class="mis shortkey_m button_toggle_mis">36 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm mis"><a href="#n1">1</a></p>
<p id="n2" class="stm mis"><a href="#n2">2</a></p>
<p id="n3" class="stm mis"><a href="#n3">3</a></p>
<p id="n4" class="stm mis"><a href="#n4">4</a></p>
<p id="n5" class="stm mis"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="stm mis"><a href="#n7">7</a></p>
<p id="n8" class="pln"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="stm mis"><a href="#n18">18</a></p>
<p id="n19" class="stm mis"><a href="#n19">19</a></p>
<p id="n20" class="stm mis"><a href="#n20">20</a></p>
<p id="n21" class="stm mis"><a href="#n21">21</a></p>
<p id="n22" class="stm mis"><a href="#n22">22</a></p>
<p id="n23" class="stm mis"><a href="#n23">23</a></p>
<p id="n24" class="stm mis"><a href="#n24">24</a></p>
<p id="n25" class="stm mis"><a href="#n25">25</a></p>
<p id="n26" class="stm mis"><a href="#n26">26</a></p>
<p id="n27" class="pln"><a href="#n27">27</a></p>
<p id="n28" class="stm mis"><a href="#n28">28</a></p>
<p id="n29" class="stm mis"><a href="#n29">29</a></p>
<p id="n30" class="stm mis"><a href="#n30">30</a></p>
<p id="n31" class="pln"><a href="#n31">31</a></p>
<p id="n32" class="pln"><a href="#n32">32</a></p>
<p id="n33" class="pln"><a href="#n33">33</a></p>
<p id="n34" class="pln"><a href="#n34">34</a></p>
<p id="n35" class="stm mis"><a href="#n35">35</a></p>
<p id="n36" class="stm mis"><a href="#n36">36</a></p>
<p id="n37" class="stm mis"><a href="#n37">37</a></p>
<p id="n38" class="pln"><a href="#n38">38</a></p>
<p id="n39" class="pln"><a href="#n39">39</a></p>
<p id="n40" class="stm mis"><a href="#n40">40</a></p>
<p id="n41" class="stm mis"><a href="#n41">41</a></p>
<p id="n42" class="stm mis"><a href="#n42">42</a></p>
<p id="n43" class="stm mis"><a href="#n43">43</a></p>
<p id="n44" class="stm mis"><a href="#n44">44</a></p>
<p id="n45" class="stm mis"><a href="#n45">45</a></p>
<p id="n46" class="pln"><a href="#n46">46</a></p>
<p id="n47" class="pln"><a href="#n47">47</a></p>
<p id="n48" class="stm mis"><a href="#n48">48</a></p>
<p id="n49" class="stm mis"><a href="#n49">49</a></p>
<p id="n50" class="stm mis"><a href="#n50">50</a></p>
<p id="n51" class="stm mis"><a href="#n51">51</a></p>
<p id="n52" class="stm mis"><a href="#n52">52</a></p>
<p id="n53" class="stm mis"><a href="#n53">53</a></p>
<p id="n54" class="stm mis"><a href="#n54">54</a></p>
<p id="n55" class="stm mis"><a href="#n55">55</a></p>
<p id="n56" class="stm mis"><a href="#n56">56</a></p>
</td>
<td class="text">
<p id="t1" class="stm mis"><span class="key">import</span> <span class="nam">json</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm mis"><span class="key">import</span> <span class="nam">pandas_datareader</span><span class="op">.</span><span class="nam">data</span> <span class="key">as</span> <span class="nam">pdr</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm mis"><span class="key">import</span> <span class="nam">fix_yahoo_finance</span> <span class="key">as</span> <span class="nam">fix</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm mis"><span class="key">import</span> <span class="nam">time</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm mis"><span class="nam">fix</span><span class="op">.</span><span class="nam">pdr_override</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm mis"><span class="key">def</span> <span class="nam">get_stock_data</span><span class="op">(</span><span class="nam">ticker</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">,</span> <span class="nam">end_date</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"><span class="str"> Gets historical stock data of given tickers between dates</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"><span class="str"> :param ticker: company, or companies whose data is to fetched</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="str"> :type ticker: string or list of strings</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"><span class="str"> :param start_date: starting date for stock prices</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"><span class="str"> :type start_date: string of date "YYYY-mm-dd"</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"><span class="str"> :param end_date: end date for stock prices</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"><span class="str"> :type end_date: string of date "YYYY-mm-dd"</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"><span class="str"> :return: stock_data.csv</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="stm mis"> <span class="nam">i</span> <span class="op">=</span> <span class="num">1</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="stm mis"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="stm mis"> <span class="nam">all_data</span> <span class="op">=</span> <span class="nam">pdr</span><span class="op">.</span><span class="nam">get_data_yahoo</span><span class="op">(</span><span class="nam">ticker</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">,</span> <span class="nam">end_date</span><span class="op">)</span> <span class="com">#&#25968;&#25454;&#21015;&#21253;&#25324;&#65306;Date Open High Low Close Adj Close Volume</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="stm mis"> <span class="key">except</span> <span class="nam">ValueError</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">"ValueError, trying again"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm mis"> <span class="nam">i</span> <span class="op">+=</span> <span class="num">1</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="stm mis"> <span class="key">if</span> <span class="nam">i</span> <span class="op">&lt;</span> <span class="num">5</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="stm mis"> <span class="nam">time</span><span class="op">.</span><span class="nam">sleep</span><span class="op">(</span><span class="num">10</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="stm mis"> <span class="nam">get_stock_data</span><span class="op">(</span><span class="nam">ticker</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">,</span> <span class="nam">end_date</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">"Tried 5 times, Yahoo error. Trying after 2 minutes"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="stm mis"> <span class="nam">time</span><span class="op">.</span><span class="nam">sleep</span><span class="op">(</span><span class="num">120</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t30" class="stm mis"> <span class="nam">get_stock_data</span><span class="op">(</span><span class="nam">ticker</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">,</span> <span class="nam">end_date</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t31" class="pln"> <span class="com"># print("date:%s - %s" % (start_date,end_date))</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="pln"> <span class="com"># print("all_data:\n",all_data)</span><span class="strut">&nbsp;</span></p>
<p id="t33" class="pln"> <span class="com"># all_data.to_csv("stock_all_prices.csv")</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="pln"> <span class="com"># stock_data = all_data["Adj Close"]</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="stm mis"> <span class="nam">stock_data</span> <span class="op">=</span> <span class="nam">all_data</span><span class="strut">&nbsp;</span></p>
<p id="t36" class="stm mis"> <span class="nam">filename</span> <span class="op">=</span> <span class="str">"..\\data\\"</span><span class="op">+</span><span class="nam">ticker</span><span class="op">.</span><span class="nam">lower</span><span class="op">(</span><span class="op">)</span><span class="op">+</span><span class="str">"_stock.csv"</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="stm mis"> <span class="nam">stock_data</span><span class="op">.</span><span class="nam">to_csv</span><span class="op">(</span><span class="nam">filename</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="pln"> <span class="com"># insert_date_close_col(filename)</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t40" class="stm mis"><span class="key">def</span> <span class="nam">insert_date_close_col</span><span class="op">(</span><span class="nam">filename</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t41" class="stm mis"> <span class="key">with</span> <span class="nam">open</span><span class="op">(</span><span class="nam">filename</span><span class="op">,</span><span class="str">"r+"</span><span class="op">)</span> <span class="key">as</span> <span class="nam">f</span><span class="op">:</span> <span class="com"># r&#21482;&#35835;&#65292;r+&#35835;&#20889;&#65292;&#19981;&#21019;&#24314;&#12290;&#25991;&#20214;&#19981;&#23384;&#22312;&#21017;&#25253;&#38169;</span><span class="strut">&nbsp;</span></p>
<p id="t42" class="stm mis"> <span class="nam">old</span> <span class="op">=</span> <span class="nam">f</span><span class="op">.</span><span class="nam">read</span><span class="op">(</span><span class="op">)</span> <span class="com"># &#35835;&#21462;&#21407;&#26469;&#25152;&#26377;&#20869;&#23481;</span><span class="strut">&nbsp;</span></p>
<p id="t43" class="stm mis"> <span class="nam">f</span><span class="op">.</span><span class="nam">seek</span><span class="op">(</span><span class="num">0</span><span class="op">)</span> <span class="com"># &#23558;&#25991;&#20214;&#32034;&#24341;&#37325;&#23450;&#20301;&#21040;&#25991;&#20214;&#22836;</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="stm mis"> <span class="nam">f</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="str">"Date,Close\n"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="stm mis"> <span class="nam">f</span><span class="op">.</span><span class="nam">write</span><span class="op">(</span><span class="nam">old</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t46" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t47" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t48" class="stm mis"><span class="key">if</span> <span class="nam">__name__</span> <span class="op">==</span> <span class="str">"__main__"</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t49" class="stm mis"> <span class="nam">start_date</span> <span class="op">=</span> <span class="str">"2014-04-25"</span><span class="strut">&nbsp;</span></p>
<p id="t50" class="stm mis"> <span class="nam">end_date</span> <span class="op">=</span> <span class="str">"2018-05-25"</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="stm mis"> <span class="nam">config</span> <span class="op">=</span> <span class="nam">json</span><span class="op">.</span><span class="nam">load</span><span class="op">(</span><span class="nam">open</span><span class="op">(</span><span class="str">"..\\config.json"</span><span class="op">,</span><span class="str">"r"</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t52" class="stm mis"> <span class="nam">companies_name</span> <span class="op">=</span> <span class="nam">config</span><span class="op">[</span><span class="str">"companies"</span><span class="op">]</span><span class="op">[</span><span class="str">"name"</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t53" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="nam">companies_name</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t54" class="stm mis"> <span class="key">for</span> <span class="nam">name</span> <span class="key">in</span> <span class="nam">companies_name</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t55" class="stm mis"> <span class="nam">get_stock_data</span><span class="op">(</span><span class="nam">name</span><span class="op">,</span><span class="nam">start_date</span><span class="op">,</span><span class="nam">end_date</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t56" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">"finish!\n"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,383 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for LSTMPredictStock\core\model.py: 65%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>LSTMPredictStock\core\model.py</b> :
<span class="pc_cov">65%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
86 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">56 run</span>
<span class="mis shortkey_m button_toggle_mis">30 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="stm run hide_run"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="stm run hide_run"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="stm run hide_run"><a href="#n14">14</a></p>
<p id="n15" class="stm run hide_run"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="stm run hide_run"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="pln"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="stm run hide_run"><a href="#n22">22</a></p>
<p id="n23" class="stm run hide_run"><a href="#n23">23</a></p>
<p id="n24" class="pln"><a href="#n24">24</a></p>
<p id="n25" class="stm run hide_run"><a href="#n25">25</a></p>
<p id="n26" class="pln"><a href="#n26">26</a></p>
<p id="n27" class="pln"><a href="#n27">27</a></p>
<p id="n28" class="pln"><a href="#n28">28</a></p>
<p id="n29" class="pln"><a href="#n29">29</a></p>
<p id="n30" class="stm run hide_run"><a href="#n30">30</a></p>
<p id="n31" class="stm run hide_run"><a href="#n31">31</a></p>
<p id="n32" class="pln"><a href="#n32">32</a></p>
<p id="n33" class="stm run hide_run"><a href="#n33">33</a></p>
<p id="n34" class="stm run hide_run"><a href="#n34">34</a></p>
<p id="n35" class="stm run hide_run"><a href="#n35">35</a></p>
<p id="n36" class="stm run hide_run"><a href="#n36">36</a></p>
<p id="n37" class="stm run hide_run"><a href="#n37">37</a></p>
<p id="n38" class="stm run hide_run"><a href="#n38">38</a></p>
<p id="n39" class="stm run hide_run"><a href="#n39">39</a></p>
<p id="n40" class="pln"><a href="#n40">40</a></p>
<p id="n41" class="stm run hide_run"><a href="#n41">41</a></p>
<p id="n42" class="stm run hide_run"><a href="#n42">42</a></p>
<p id="n43" class="stm run hide_run"><a href="#n43">43</a></p>
<p id="n44" class="stm run hide_run"><a href="#n44">44</a></p>
<p id="n45" class="stm run hide_run"><a href="#n45">45</a></p>
<p id="n46" class="stm run hide_run"><a href="#n46">46</a></p>
<p id="n47" class="pln"><a href="#n47">47</a></p>
<p id="n48" class="stm run hide_run"><a href="#n48">48</a></p>
<p id="n49" class="pln"><a href="#n49">49</a></p>
<p id="n50" class="stm run hide_run"><a href="#n50">50</a></p>
<p id="n51" class="stm run hide_run"><a href="#n51">51</a></p>
<p id="n52" class="pln"><a href="#n52">52</a></p>
<p id="n53" class="stm run hide_run"><a href="#n53">53</a></p>
<p id="n54" class="stm mis"><a href="#n54">54</a></p>
<p id="n55" class="stm mis"><a href="#n55">55</a></p>
<p id="n56" class="stm mis"><a href="#n56">56</a></p>
<p id="n57" class="stm mis"><a href="#n57">57</a></p>
<p id="n58" class="pln"><a href="#n58">58</a></p>
<p id="n59" class="stm mis"><a href="#n59">59</a></p>
<p id="n60" class="stm mis"><a href="#n60">60</a></p>
<p id="n61" class="pln"><a href="#n61">61</a></p>
<p id="n62" class="pln"><a href="#n62">62</a></p>
<p id="n63" class="pln"><a href="#n63">63</a></p>
<p id="n64" class="stm mis"><a href="#n64">64</a></p>
<p id="n65" class="pln"><a href="#n65">65</a></p>
<p id="n66" class="pln"><a href="#n66">66</a></p>
<p id="n67" class="pln"><a href="#n67">67</a></p>
<p id="n68" class="pln"><a href="#n68">68</a></p>
<p id="n69" class="pln"><a href="#n69">69</a></p>
<p id="n70" class="pln"><a href="#n70">70</a></p>
<p id="n71" class="stm mis"><a href="#n71">71</a></p>
<p id="n72" class="pln"><a href="#n72">72</a></p>
<p id="n73" class="stm mis"><a href="#n73">73</a></p>
<p id="n74" class="stm mis"><a href="#n74">74</a></p>
<p id="n75" class="pln"><a href="#n75">75</a></p>
<p id="n76" class="stm run hide_run"><a href="#n76">76</a></p>
<p id="n77" class="pln"><a href="#n77">77</a></p>
<p id="n78" class="pln"><a href="#n78">78</a></p>
<p id="n79" class="pln"><a href="#n79">79</a></p>
<p id="n80" class="stm run hide_run"><a href="#n80">80</a></p>
<p id="n81" class="stm run hide_run"><a href="#n81">81</a></p>
<p id="n82" class="stm run hide_run"><a href="#n82">82</a></p>
<p id="n83" class="stm run hide_run"><a href="#n83">83</a></p>
<p id="n84" class="pln"><a href="#n84">84</a></p>
<p id="n85" class="pln"><a href="#n85">85</a></p>
<p id="n86" class="stm run hide_run"><a href="#n86">86</a></p>
<p id="n87" class="stm run hide_run"><a href="#n87">87</a></p>
<p id="n88" class="pln"><a href="#n88">88</a></p>
<p id="n89" class="pln"><a href="#n89">89</a></p>
<p id="n90" class="stm run hide_run"><a href="#n90">90</a></p>
<p id="n91" class="pln"><a href="#n91">91</a></p>
<p id="n92" class="pln"><a href="#n92">92</a></p>
<p id="n93" class="pln"><a href="#n93">93</a></p>
<p id="n94" class="pln"><a href="#n94">94</a></p>
<p id="n95" class="pln"><a href="#n95">95</a></p>
<p id="n96" class="pln"><a href="#n96">96</a></p>
<p id="n97" class="pln"><a href="#n97">97</a></p>
<p id="n98" class="stm run hide_run"><a href="#n98">98</a></p>
<p id="n99" class="stm run hide_run"><a href="#n99">99</a></p>
<p id="n100" class="pln"><a href="#n100">100</a></p>
<p id="n101" class="pln"><a href="#n101">101</a></p>
<p id="n102" class="stm run hide_run"><a href="#n102">102</a></p>
<p id="n103" class="pln"><a href="#n103">103</a></p>
<p id="n104" class="stm mis"><a href="#n104">104</a></p>
<p id="n105" class="stm mis"><a href="#n105">105</a></p>
<p id="n106" class="stm mis"><a href="#n106">106</a></p>
<p id="n107" class="pln"><a href="#n107">107</a></p>
<p id="n108" class="pln"><a href="#n108">108</a></p>
<p id="n109" class="pln"><a href="#n109">109</a></p>
<p id="n110" class="pln"><a href="#n110">110</a></p>
<p id="n111" class="pln"><a href="#n111">111</a></p>
<p id="n112" class="stm run hide_run"><a href="#n112">112</a></p>
<p id="n113" class="pln"><a href="#n113">113</a></p>
<p id="n114" class="stm mis"><a href="#n114">114</a></p>
<p id="n115" class="stm mis"><a href="#n115">115</a></p>
<p id="n116" class="stm mis"><a href="#n116">116</a></p>
<p id="n117" class="stm mis"><a href="#n117">117</a></p>
<p id="n118" class="stm mis"><a href="#n118">118</a></p>
<p id="n119" class="stm mis"><a href="#n119">119</a></p>
<p id="n120" class="stm mis"><a href="#n120">120</a></p>
<p id="n121" class="stm mis"><a href="#n121">121</a></p>
<p id="n122" class="stm mis"><a href="#n122">122</a></p>
<p id="n123" class="stm mis"><a href="#n123">123</a></p>
<p id="n124" class="pln"><a href="#n124">124</a></p>
<p id="n125" class="pln"><a href="#n125">125</a></p>
<p id="n126" class="pln"><a href="#n126">126</a></p>
<p id="n127" class="stm run hide_run"><a href="#n127">127</a></p>
<p id="n128" class="pln"><a href="#n128">128</a></p>
<p id="n129" class="stm mis"><a href="#n129">129</a></p>
<p id="n130" class="stm mis"><a href="#n130">130</a></p>
<p id="n131" class="stm mis"><a href="#n131">131</a></p>
<p id="n132" class="stm mis"><a href="#n132">132</a></p>
<p id="n133" class="stm mis"><a href="#n133">133</a></p>
<p id="n134" class="stm mis"><a href="#n134">134</a></p>
<p id="n135" class="stm mis"><a href="#n135">135</a></p>
<p id="n136" class="pln"><a href="#n136">136</a></p>
<p id="n137" class="pln"><a href="#n137">137</a></p>
<p id="n138" class="pln"><a href="#n138">138</a></p>
<p id="n139" class="stm run hide_run"><a href="#n139">139</a></p>
<p id="n140" class="pln"><a href="#n140">140</a></p>
<p id="n141" class="stm run hide_run"><a href="#n141">141</a></p>
<p id="n142" class="stm run hide_run"><a href="#n142">142</a></p>
<p id="n143" class="stm run hide_run"><a href="#n143">143</a></p>
<p id="n144" class="stm run hide_run"><a href="#n144">144</a></p>
<p id="n145" class="stm run hide_run"><a href="#n145">145</a></p>
<p id="n146" class="stm run hide_run"><a href="#n146">146</a></p>
<p id="n147" class="stm run hide_run"><a href="#n147">147</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">math</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">import</span> <span class="nam">numpy</span> <span class="key">as</span> <span class="nam">np</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"><span class="key">import</span> <span class="nam">datetime</span> <span class="key">as</span> <span class="nam">dt</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="key">from</span> <span class="nam">numpy</span> <span class="key">import</span> <span class="nam">newaxis</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="key">from</span> <span class="nam">LSTMPredictStock</span><span class="op">.</span><span class="nam">core</span><span class="op">.</span><span class="nam">utils</span> <span class="key">import</span> <span class="nam">Timer</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"><span class="key">from</span> <span class="nam">keras</span><span class="op">.</span><span class="nam">layers</span> <span class="key">import</span> <span class="nam">Dense</span><span class="op">,</span> <span class="nam">Activation</span><span class="op">,</span> <span class="nam">Dropout</span><span class="op">,</span> <span class="nam">LSTM</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"><span class="key">from</span> <span class="nam">keras</span><span class="op">.</span><span class="nam">models</span> <span class="key">import</span> <span class="nam">Sequential</span><span class="op">,</span> <span class="nam">load_model</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"><span class="key">from</span> <span class="nam">keras</span><span class="op">.</span><span class="nam">callbacks</span> <span class="key">import</span> <span class="nam">EarlyStopping</span><span class="op">,</span> <span class="nam">ModelCheckpoint</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t11" class="stm run hide_run"><span class="key">class</span> <span class="nam">Model</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"> <span class="str">"""A class for an building and inferencing an lstm model"""</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t14" class="stm run hide_run"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span> <span class="op">=</span> <span class="nam">Sequential</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t17" class="stm run hide_run"> <span class="key">def</span> <span class="nam">load_model</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">filepath</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"> <span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="pln"><span class="str"> &#20174;&#26412;&#22320;&#20445;&#23384;&#30340;&#27169;&#22411;&#21442;&#25968;&#26469;&#21152;&#36733;&#27169;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"><span class="str"> filepath: .h5 &#26684;&#24335;&#25991;&#20214;</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"><span class="str"> '''</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="stm run hide_run"> <span class="nam">print</span><span class="op">(</span><span class="str">'[Model] Loading model from file %s'</span> <span class="op">%</span> <span class="nam">filepath</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span> <span class="op">=</span> <span class="nam">load_model</span><span class="op">(</span><span class="nam">filepath</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t25" class="stm run hide_run"> <span class="key">def</span> <span class="nam">build_model</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">configs</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="pln"><span class="str"> &#26032;&#24314;&#19968;&#20010;&#27169;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="pln"><span class="str"> configs:&#37197;&#32622;&#25991;&#20214;</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t30" class="stm run hide_run"> <span class="nam">timer</span> <span class="op">=</span> <span class="nam">Timer</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t31" class="stm run hide_run"> <span class="nam">timer</span><span class="op">.</span><span class="nam">start</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t33" class="stm run hide_run"> <span class="key">for</span> <span class="nam">layer</span> <span class="key">in</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'model'</span><span class="op">]</span><span class="op">[</span><span class="str">'layers'</span><span class="op">]</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="stm run hide_run"> <span class="nam">neurons</span> <span class="op">=</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'neurons'</span><span class="op">]</span> <span class="key">if</span> <span class="str">'neurons'</span> <span class="key">in</span> <span class="nam">layer</span> <span class="key">else</span> <span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="stm run hide_run"> <span class="nam">dropout_rate</span> <span class="op">=</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'rate'</span><span class="op">]</span> <span class="key">if</span> <span class="str">'rate'</span> <span class="key">in</span> <span class="nam">layer</span> <span class="key">else</span> <span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t36" class="stm run hide_run"> <span class="nam">activation</span> <span class="op">=</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'activation'</span><span class="op">]</span> <span class="key">if</span> <span class="str">'activation'</span> <span class="key">in</span> <span class="nam">layer</span> <span class="key">else</span> <span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="stm run hide_run"> <span class="nam">return_seq</span> <span class="op">=</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'return_seq'</span><span class="op">]</span> <span class="key">if</span> <span class="str">'return_seq'</span> <span class="key">in</span> <span class="nam">layer</span> <span class="key">else</span> <span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="stm run hide_run"> <span class="nam">input_timesteps</span> <span class="op">=</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'input_timesteps'</span><span class="op">]</span> <span class="key">if</span> <span class="str">'input_timesteps'</span> <span class="key">in</span> <span class="nam">layer</span> <span class="key">else</span> <span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="stm run hide_run"> <span class="nam">input_dim</span> <span class="op">=</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'input_dim'</span><span class="op">]</span> <span class="key">if</span> <span class="str">'input_dim'</span> <span class="key">in</span> <span class="nam">layer</span> <span class="key">else</span> <span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t40" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t41" class="stm run hide_run"> <span class="key">if</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'type'</span><span class="op">]</span> <span class="op">==</span> <span class="str">'dense'</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t42" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">Dense</span><span class="op">(</span><span class="nam">neurons</span><span class="op">,</span> <span class="nam">activation</span><span class="op">=</span><span class="nam">activation</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t43" class="stm run hide_run"> <span class="key">if</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'type'</span><span class="op">]</span> <span class="op">==</span> <span class="str">'lstm'</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">LSTM</span><span class="op">(</span><span class="nam">neurons</span><span class="op">,</span> <span class="nam">input_shape</span><span class="op">=</span><span class="op">(</span><span class="nam">input_timesteps</span><span class="op">,</span> <span class="nam">input_dim</span><span class="op">)</span><span class="op">,</span> <span class="nam">return_sequences</span><span class="op">=</span><span class="nam">return_seq</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="stm run hide_run"> <span class="key">if</span> <span class="nam">layer</span><span class="op">[</span><span class="str">'type'</span><span class="op">]</span> <span class="op">==</span> <span class="str">'dropout'</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t46" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">add</span><span class="op">(</span><span class="nam">Dropout</span><span class="op">(</span><span class="nam">dropout_rate</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t47" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t48" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">compile</span><span class="op">(</span><span class="nam">loss</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'model'</span><span class="op">]</span><span class="op">[</span><span class="str">'loss'</span><span class="op">]</span><span class="op">,</span> <span class="nam">optimizer</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'model'</span><span class="op">]</span><span class="op">[</span><span class="str">'optimizer'</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t49" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t50" class="stm run hide_run"> <span class="nam">print</span><span class="op">(</span><span class="str">'[Model] Model Compiled'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="stm run hide_run"> <span class="nam">timer</span><span class="op">.</span><span class="nam">stop</span><span class="op">(</span><span class="op">)</span> <span class="com">#&#36755;&#20986;&#26500;&#24314;&#19968;&#20010;&#27169;&#22411;&#32791;&#26102;</span><span class="strut">&nbsp;</span></p>
<p id="t52" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t53" class="stm run hide_run"> <span class="key">def</span> <span class="nam">train</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">x</span><span class="op">,</span> <span class="nam">y</span><span class="op">,</span> <span class="nam">epochs</span><span class="op">,</span> <span class="nam">batch_size</span><span class="op">,</span> <span class="nam">save_dir</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t54" class="stm mis"> <span class="nam">timer</span> <span class="op">=</span> <span class="nam">Timer</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t55" class="stm mis"> <span class="nam">timer</span><span class="op">.</span><span class="nam">start</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t56" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">'[Model] Training Started'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t57" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">'[Model] %s epochs, %s batch size'</span> <span class="op">%</span> <span class="op">(</span><span class="nam">epochs</span><span class="op">,</span> <span class="nam">batch_size</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t58" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t59" class="stm mis"> <span class="nam">save_fname</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">save_dir</span><span class="op">,</span> <span class="str">'%s-e%s.h5'</span> <span class="op">%</span> <span class="op">(</span><span class="nam">dt</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">strftime</span><span class="op">(</span><span class="str">'%d%m%Y-%H%M%S'</span><span class="op">)</span><span class="op">,</span> <span class="nam">str</span><span class="op">(</span><span class="nam">epochs</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t60" class="stm mis"> <span class="nam">callbacks</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t61" class="pln"> <span class="nam">EarlyStopping</span><span class="op">(</span><span class="nam">monitor</span><span class="op">=</span><span class="str">'val_loss'</span><span class="op">,</span> <span class="nam">patience</span><span class="op">=</span><span class="num">2</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t62" class="pln"> <span class="nam">ModelCheckpoint</span><span class="op">(</span><span class="nam">filepath</span><span class="op">=</span><span class="nam">save_fname</span><span class="op">,</span> <span class="nam">monitor</span><span class="op">=</span><span class="str">'val_loss'</span><span class="op">,</span> <span class="nam">save_best_only</span><span class="op">=</span><span class="key">True</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t63" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t64" class="stm mis"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">fit</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t65" class="pln"> <span class="nam">x</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t66" class="pln"> <span class="nam">y</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t67" class="pln"> <span class="nam">epochs</span><span class="op">=</span><span class="nam">epochs</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t68" class="pln"> <span class="nam">batch_size</span><span class="op">=</span><span class="nam">batch_size</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t69" class="pln"> <span class="nam">callbacks</span><span class="op">=</span><span class="nam">callbacks</span><span class="strut">&nbsp;</span></p>
<p id="t70" class="pln"> <span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t71" class="stm mis"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">save</span><span class="op">(</span><span class="nam">save_fname</span><span class="op">)</span> <span class="com">#&#20445;&#23384;&#35757;&#32451;&#22909;&#30340;&#27169;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t72" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t73" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">'[Model] Training Completed. Model saved as %s'</span> <span class="op">%</span> <span class="nam">save_fname</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t74" class="stm mis"> <span class="nam">timer</span><span class="op">.</span><span class="nam">stop</span><span class="op">(</span><span class="op">)</span> <span class="com">#&#36755;&#20986;&#35757;&#32451;&#32791;&#26102;</span><span class="strut">&nbsp;</span></p>
<p id="t75" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t76" class="stm run hide_run"> <span class="key">def</span> <span class="nam">train_generator</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">data_gen</span><span class="op">,</span> <span class="nam">epochs</span><span class="op">,</span> <span class="nam">batch_size</span><span class="op">,</span> <span class="nam">steps_per_epoch</span><span class="op">,</span> <span class="nam">save_dir</span><span class="op">,</span><span class="nam">save_name</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t77" class="pln"> <span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t78" class="pln"><span class="str"> &#30001;data_gen&#25968;&#25454;&#20135;&#29983;&#22120;&#26469;&#65292;&#36880;&#27493;&#20135;&#29983;&#35757;&#32451;&#25968;&#25454;&#65292;&#32780;&#19981;&#26159;&#19968;&#27425;&#24615;&#23558;&#25968;&#25454;&#35835;&#20837;&#21040;&#20869;&#23384;</span><span class="strut">&nbsp;</span></p>
<p id="t79" class="pln"><span class="str"> '''</span><span class="strut">&nbsp;</span></p>
<p id="t80" class="stm run hide_run"> <span class="nam">timer</span> <span class="op">=</span> <span class="nam">Timer</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t81" class="stm run hide_run"> <span class="nam">timer</span><span class="op">.</span><span class="nam">start</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t82" class="stm run hide_run"> <span class="nam">print</span><span class="op">(</span><span class="str">'[Model] Training Started'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t83" class="stm run hide_run"> <span class="nam">print</span><span class="op">(</span><span class="str">'[Model] %s epochs, %s batch size, %s batches per epoch'</span> <span class="op">%</span> <span class="op">(</span><span class="nam">epochs</span><span class="op">,</span> <span class="nam">batch_size</span><span class="op">,</span> <span class="nam">steps_per_epoch</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t84" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t85" class="pln"> <span class="com"># save_fname = os.path.join(save_dir, '%s-e%s.h5' % (dt.datetime.now().strftime('%d%m%Y-%H%M%S'), str(epochs)))</span><span class="strut">&nbsp;</span></p>
<p id="t86" class="stm run hide_run"> <span class="nam">save_fname</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">save_dir</span><span class="op">,</span> <span class="nam">save_name</span><span class="op">+</span><span class="str">'.h5'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t87" class="stm run hide_run"> <span class="nam">callbacks</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t88" class="pln"> <span class="nam">ModelCheckpoint</span><span class="op">(</span><span class="nam">filepath</span><span class="op">=</span><span class="nam">save_fname</span><span class="op">,</span> <span class="nam">monitor</span><span class="op">=</span><span class="str">'loss'</span><span class="op">,</span> <span class="nam">save_best_only</span><span class="op">=</span><span class="key">True</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t89" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t90" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">fit_generator</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t91" class="pln"> <span class="nam">data_gen</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t92" class="pln"> <span class="nam">steps_per_epoch</span><span class="op">=</span><span class="nam">steps_per_epoch</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t93" class="pln"> <span class="nam">epochs</span><span class="op">=</span><span class="nam">epochs</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t94" class="pln"> <span class="nam">callbacks</span><span class="op">=</span><span class="nam">callbacks</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t95" class="pln"> <span class="nam">workers</span><span class="op">=</span><span class="num">1</span><span class="strut">&nbsp;</span></p>
<p id="t96" class="pln"> <span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t97" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t98" class="stm run hide_run"> <span class="nam">print</span><span class="op">(</span><span class="str">'[Model] Training Completed. Model saved as %s'</span> <span class="op">%</span> <span class="nam">save_fname</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t99" class="stm run hide_run"> <span class="nam">timer</span><span class="op">.</span><span class="nam">stop</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t100" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t101" class="pln"> <span class="com">#&#12288;data&#24517;&#39035;&#26159;&#19977;&#32500;&#25968;&#25454;&#65292;&#21363;shape:(a,b,c)</span><span class="strut">&nbsp;</span></p>
<p id="t102" class="stm run hide_run"> <span class="key">def</span> <span class="nam">predict_point_by_point</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">data</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t103" class="pln"> <span class="com">#Predict each timestep given the last sequence of true data, in effect only predicting 1 step ahead each time</span><span class="strut">&nbsp;</span></p>
<p id="t104" class="stm mis"> <span class="nam">predicted</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">predict</span><span class="op">(</span><span class="nam">data</span><span class="op">)</span> <span class="com"># data&#26377;&#22810;&#23569;&#34892;&#23601;&#36755;&#20986;&#22810;&#23569;&#20010;&#39044;&#27979;&#20540;,&#36820;&#22238;&#30340;&#39044;&#27979;&#20540;&#26159;&#19968;&#20010;2&#32500;&#25968;&#32452;:(a,1) a:&#20026;data&#30340;&#34892;&#25968;</span><span class="strut">&nbsp;</span></p>
<p id="t105" class="stm mis"> <span class="nam">predicted</span> <span class="op">=</span> <span class="nam">np</span><span class="op">.</span><span class="nam">reshape</span><span class="op">(</span><span class="nam">predicted</span><span class="op">,</span> <span class="op">(</span><span class="nam">predicted</span><span class="op">.</span><span class="nam">size</span><span class="op">,</span><span class="op">)</span><span class="op">)</span> <span class="com"># &#36825;&#37324;&#23558;&#20108;&#32500;&#25968;&#32452;&#65292;&#21464;&#25104;&#19968;&#32500;&#25968;&#32452;</span><span class="strut">&nbsp;</span></p>
<p id="t106" class="stm mis"> <span class="key">return</span> <span class="nam">predicted</span> <span class="com"># &#36820;&#22238;&#19968;&#32500;&#25968;&#32452;&#65292;&#20803;&#32032;&#20010;&#25968;&#19982;data&#30340;a&#30456;&#21516;</span><span class="strut">&nbsp;</span></p>
<p id="t107" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t108" class="pln"> <span class="com"># &#23545;data&#36827;&#34892;&#22810;&#27573;&#39044;&#27979;&#65292;&#27599;&#27573;&#39044;&#27979;&#22522;&#20110;&#19968;&#20010;&#31383;&#21475;&#22823;&#23567;&#65288;window_size&#65289;&#30340;&#25968;&#25454;&#65292;&#28982;&#21518;&#36755;&#20986;prediction_len&#38271;&#30340;&#39044;&#27979;&#20540;&#65288;&#19968;&#32500;&#25968;&#32452;&#65289;</span><span class="strut">&nbsp;</span></p>
<p id="t109" class="pln"> <span class="com"># &#20877;&#20174;&#19978;&#19968;&#20010;&#31383;&#21475;&#31227;&#21160;prediction_len&#30340;&#38271;&#24230;&#65292;&#24471;&#21040;&#19979;&#19968;&#20010;&#31383;&#21475;&#30340;&#25968;&#25454;&#65292;&#24182;&#22522;&#20110;&#35813;&#25968;&#25454;&#20877;&#39044;&#27979;prediction_len&#38271;&#30340;&#39044;&#27979;&#20540;</span><span class="strut">&nbsp;</span></p>
<p id="t110" class="pln"> <span class="com"># &#25152;&#20197;prediction_len&#20915;&#23450;&#20102;&#31383;&#21475;&#30340;&#31227;&#20301;&#27493;&#25968;&#65292;&#27599;&#27425;&#30340;&#31383;&#21475;&#22823;&#23567;&#26159;&#19968;&#26679;&#30340;&#65292;&#25152;&#20197;&#26368;&#21518;&#39044;&#27979;&#30340;&#27573;&#25968; = &#31383;&#21475;&#20010;&#25968;/&#39044;&#27979;&#38271;&#24230;</span><span class="strut">&nbsp;</span></p>
<p id="t111" class="pln"> <span class="com"># &#30456;&#24403;&#20110;&#22810;&#27425;&#35843;&#29992;predict_1_win_sequence&#26041;&#27861;</span><span class="strut">&nbsp;</span></p>
<p id="t112" class="stm run hide_run"> <span class="key">def</span> <span class="nam">predict_sequences_multiple</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">data</span><span class="op">,</span> <span class="nam">window_size</span><span class="op">,</span> <span class="nam">prediction_len</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t113" class="pln"> <span class="com">#Predict sequence of 50 steps before shifting prediction run forward by 50 steps</span><span class="strut">&nbsp;</span></p>
<p id="t114" class="stm mis"> <span class="nam">prediction_seqs</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t115" class="stm mis"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">int</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">data</span><span class="op">)</span><span class="op">/</span><span class="nam">prediction_len</span><span class="op">)</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t116" class="stm mis"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">data</span><span class="op">[</span><span class="nam">i</span><span class="op">*</span><span class="nam">prediction_len</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t117" class="stm mis"> <span class="nam">predicted</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t118" class="stm mis"> <span class="key">for</span> <span class="nam">j</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">prediction_len</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t119" class="stm mis"> <span class="nam">predicted</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">predict</span><span class="op">(</span><span class="nam">curr_frame</span><span class="op">[</span><span class="nam">newaxis</span><span class="op">,</span><span class="op">:</span><span class="op">,</span><span class="op">:</span><span class="op">]</span><span class="op">)</span><span class="op">[</span><span class="num">0</span><span class="op">,</span><span class="num">0</span><span class="op">]</span><span class="op">)</span> <span class="com"># newaxis&#65306;&#22686;&#21152;&#26032;&#36724;&#65292;&#20351;&#24471;curr_frame&#21464;&#25104;(1,x,x)&#19977;&#32500;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t120" class="stm mis"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">curr_frame</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t121" class="stm mis"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">np</span><span class="op">.</span><span class="nam">insert</span><span class="op">(</span><span class="nam">curr_frame</span><span class="op">,</span> <span class="op">[</span><span class="nam">window_size</span><span class="op">-</span><span class="num">2</span><span class="op">]</span><span class="op">,</span> <span class="nam">predicted</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="op">,</span> <span class="nam">axis</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t122" class="stm mis"> <span class="nam">prediction_seqs</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">predicted</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t123" class="stm mis"> <span class="key">return</span> <span class="nam">prediction_seqs</span><span class="strut">&nbsp;</span></p>
<p id="t124" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t125" class="pln"> <span class="com"># &#36755;&#20837;&#19968;&#20010;&#31383;&#21475;&#30340;&#25968;&#25454;&#65292;&#25351;&#23450;&#39044;&#27979;&#30340;&#38271;&#24230;&#65292;data:&#20381;&#26087;&#26159;&#19977;&#32500;&#25968;&#32452;(1,win_len,fea_len)</span><span class="strut">&nbsp;</span></p>
<p id="t126" class="pln"> <span class="com"># &#36820;&#22238;&#39044;&#27979;&#25968;&#32452;</span><span class="strut">&nbsp;</span></p>
<p id="t127" class="stm run hide_run"> <span class="key">def</span> <span class="nam">predict_sequence_full</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">data</span><span class="op">,</span> <span class="nam">window_size</span><span class="op">)</span><span class="op">:</span> <span class="com"># window_size&#65306;&#20026;&#36755;&#20837;&#25968;&#25454;&#30340;&#38271;&#24230;</span><span class="strut">&nbsp;</span></p>
<p id="t128" class="pln"> <span class="com">#Shift the window by 1 new prediction each time, re-run predictions on new window</span><span class="strut">&nbsp;</span></p>
<p id="t129" class="stm mis"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="com"># &#22522;&#20110;data[0]&#19968;&#20010;&#31383;&#21475;&#30340;&#25968;&#25454;&#65292;&#26469;&#39044;&#27979;len(data)&#20010;&#36755;&#20986;</span><span class="strut">&nbsp;</span></p>
<p id="t130" class="stm mis"> <span class="nam">predicted</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t131" class="stm mis"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">len</span><span class="op">(</span><span class="nam">data</span><span class="op">)</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t132" class="stm mis"> <span class="nam">predicted</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">predict</span><span class="op">(</span><span class="nam">curr_frame</span><span class="op">[</span><span class="nam">newaxis</span><span class="op">,</span><span class="op">:</span><span class="op">,</span><span class="op">:</span><span class="op">]</span><span class="op">)</span><span class="op">[</span><span class="num">0</span><span class="op">,</span><span class="num">0</span><span class="op">]</span><span class="op">)</span> <span class="com"># append&#20102;&#19968;&#20010;&#39044;&#27979;&#20540;&#65288;&#26631;&#37327;&#65289;</span><span class="strut">&nbsp;</span></p>
<p id="t133" class="stm mis"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">curr_frame</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t134" class="stm mis"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">np</span><span class="op">.</span><span class="nam">insert</span><span class="op">(</span><span class="nam">curr_frame</span><span class="op">,</span> <span class="op">[</span><span class="nam">window_size</span><span class="op">-</span><span class="num">2</span><span class="op">]</span><span class="op">,</span> <span class="nam">predicted</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="op">,</span> <span class="nam">axis</span><span class="op">=</span><span class="num">0</span><span class="op">)</span> <span class="com"># &#25554;&#20837;&#20301;&#32622;[window_size-2]:curr_frame&#30340;&#26411;&#23614;&#65292;predicted[-1]&#65306;&#25554;&#20837;&#20540;</span><span class="strut">&nbsp;</span></p>
<p id="t135" class="stm mis"> <span class="key">return</span> <span class="nam">predicted</span><span class="strut">&nbsp;</span></p>
<p id="t136" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t137" class="pln"> <span class="com"># &#36755;&#20837;&#19968;&#20010;&#31383;&#21475;&#30340;&#25968;&#25454;&#65292;&#25351;&#23450;&#39044;&#27979;&#30340;&#38271;&#24230;&#65292;data:&#20381;&#26087;&#26159;&#19977;&#32500;&#25968;&#32452;(1,win_len,fea_len)</span><span class="strut">&nbsp;</span></p>
<p id="t138" class="pln"> <span class="com"># &#36820;&#22238;&#39044;&#27979;&#25968;&#32452;</span><span class="strut">&nbsp;</span></p>
<p id="t139" class="stm run hide_run"> <span class="key">def</span> <span class="nam">predict_1_win_sequence</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">data</span><span class="op">,</span> <span class="nam">window_size</span><span class="op">,</span><span class="nam">predict_length</span><span class="op">)</span><span class="op">:</span> <span class="com"># window_size&#65306;data&#30340;&#31383;&#21475;&#22823;&#23567;</span><span class="strut">&nbsp;</span></p>
<p id="t140" class="pln"> <span class="com">#Shift the window by 1 new prediction each time, re-run predictions on new window</span><span class="strut">&nbsp;</span></p>
<p id="t141" class="stm run hide_run"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t142" class="stm run hide_run"> <span class="nam">predicted</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t143" class="stm run hide_run"> <span class="key">for</span> <span class="nam">i</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">predict_length</span><span class="op">)</span><span class="op">:</span> <span class="com"># range(len(data))</span><span class="strut">&nbsp;</span></p>
<p id="t144" class="stm run hide_run"> <span class="nam">predicted</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">model</span><span class="op">.</span><span class="nam">predict</span><span class="op">(</span><span class="nam">curr_frame</span><span class="op">[</span><span class="nam">newaxis</span><span class="op">,</span><span class="op">:</span><span class="op">,</span><span class="op">:</span><span class="op">]</span><span class="op">)</span><span class="op">[</span><span class="num">0</span><span class="op">,</span><span class="num">0</span><span class="op">]</span><span class="op">)</span> <span class="com"># append&#20102;&#19968;&#20010;&#39044;&#27979;&#20540;&#65288;&#26631;&#37327;&#65289;</span><span class="strut">&nbsp;</span></p>
<p id="t145" class="stm run hide_run"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">curr_frame</span><span class="op">[</span><span class="num">1</span><span class="op">:</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t146" class="stm run hide_run"> <span class="nam">curr_frame</span> <span class="op">=</span> <span class="nam">np</span><span class="op">.</span><span class="nam">insert</span><span class="op">(</span><span class="nam">curr_frame</span><span class="op">,</span> <span class="op">[</span><span class="nam">window_size</span><span class="op">-</span><span class="num">2</span><span class="op">]</span><span class="op">,</span> <span class="nam">predicted</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="op">,</span> <span class="nam">axis</span><span class="op">=</span><span class="num">0</span><span class="op">)</span> <span class="com"># &#25554;&#20837;&#20301;&#32622;[window_size-2]:curr_frame&#30340;&#26411;&#23614;&#65292;predicted[-1]&#65306;&#25554;&#20837;&#20540;</span><span class="strut">&nbsp;</span></p>
<p id="t147" class="stm run hide_run"> <span class="key">return</span> <span class="nam">predicted</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 16:41
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,115 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for LSTMPredictStock\core\utils.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>LSTMPredictStock\core\utils.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
9 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">9 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="stm run hide_run"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="stm run hide_run"><a href="#n13">13</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">import</span> <span class="nam">datetime</span> <span class="key">as</span> <span class="nam">dt</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">class</span> <span class="nam">Timer</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"> <span class="key">def</span> <span class="nam">__init__</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">start_dt</span> <span class="op">=</span> <span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="key">def</span> <span class="nam">start</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">start_dt</span> <span class="op">=</span> <span class="nam">dt</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t11" class="stm run hide_run"> <span class="key">def</span> <span class="nam">stop</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"> <span class="nam">end_dt</span> <span class="op">=</span> <span class="nam">dt</span><span class="op">.</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="stm run hide_run"> <span class="nam">print</span><span class="op">(</span><span class="str">'Time taken: %s'</span> <span class="op">%</span> <span class="op">(</span><span class="nam">end_dt</span> <span class="op">-</span> <span class="nam">self</span><span class="op">.</span><span class="nam">start_dt</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 16:41
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,609 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for LSTMPredictStock\run.py: 81%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>LSTMPredictStock\run.py</b> :
<span class="pc_cov">81%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
126 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">102 run</span>
<span class="mis shortkey_m button_toggle_mis">24 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="stm run hide_run"><a href="#n10">10</a></p>
<p id="n11" class="stm run hide_run"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="stm run hide_run"><a href="#n13">13</a></p>
<p id="n14" class="stm run hide_run"><a href="#n14">14</a></p>
<p id="n15" class="stm run hide_run"><a href="#n15">15</a></p>
<p id="n16" class="stm run hide_run"><a href="#n16">16</a></p>
<p id="n17" class="stm run hide_run"><a href="#n17">17</a></p>
<p id="n18" class="stm run hide_run"><a href="#n18">18</a></p>
<p id="n19" class="pln"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="stm run hide_run"><a href="#n21">21</a></p>
<p id="n22" class="stm mis"><a href="#n22">22</a></p>
<p id="n23" class="stm mis"><a href="#n23">23</a></p>
<p id="n24" class="stm mis"><a href="#n24">24</a></p>
<p id="n25" class="stm mis"><a href="#n25">25</a></p>
<p id="n26" class="stm mis"><a href="#n26">26</a></p>
<p id="n27" class="stm mis"><a href="#n27">27</a></p>
<p id="n28" class="pln"><a href="#n28">28</a></p>
<p id="n29" class="pln"><a href="#n29">29</a></p>
<p id="n30" class="pln"><a href="#n30">30</a></p>
<p id="n31" class="stm run hide_run"><a href="#n31">31</a></p>
<p id="n32" class="stm mis"><a href="#n32">32</a></p>
<p id="n33" class="stm mis"><a href="#n33">33</a></p>
<p id="n34" class="stm mis"><a href="#n34">34</a></p>
<p id="n35" class="pln"><a href="#n35">35</a></p>
<p id="n36" class="stm mis"><a href="#n36">36</a></p>
<p id="n37" class="stm mis"><a href="#n37">37</a></p>
<p id="n38" class="stm mis"><a href="#n38">38</a></p>
<p id="n39" class="stm mis"><a href="#n39">39</a></p>
<p id="n40" class="stm mis"><a href="#n40">40</a></p>
<p id="n41" class="pln"><a href="#n41">41</a></p>
<p id="n42" class="pln"><a href="#n42">42</a></p>
<p id="n43" class="pln"><a href="#n43">43</a></p>
<p id="n44" class="stm run hide_run"><a href="#n44">44</a></p>
<p id="n45" class="pln"><a href="#n45">45</a></p>
<p id="n46" class="pln"><a href="#n46">46</a></p>
<p id="n47" class="pln"><a href="#n47">47</a></p>
<p id="n48" class="pln"><a href="#n48">48</a></p>
<p id="n49" class="stm run hide_run"><a href="#n49">49</a></p>
<p id="n50" class="stm run hide_run"><a href="#n50">50</a></p>
<p id="n51" class="stm mis"><a href="#n51">51</a></p>
<p id="n52" class="pln"><a href="#n52">52</a></p>
<p id="n53" class="stm run hide_run"><a href="#n53">53</a></p>
<p id="n54" class="stm run hide_run"><a href="#n54">54</a></p>
<p id="n55" class="stm run hide_run"><a href="#n55">55</a></p>
<p id="n56" class="pln"><a href="#n56">56</a></p>
<p id="n57" class="stm run hide_run"><a href="#n57">57</a></p>
<p id="n58" class="pln"><a href="#n58">58</a></p>
<p id="n59" class="pln"><a href="#n59">59</a></p>
<p id="n60" class="pln"><a href="#n60">60</a></p>
<p id="n61" class="pln"><a href="#n61">61</a></p>
<p id="n62" class="pln"><a href="#n62">62</a></p>
<p id="n63" class="stm run hide_run"><a href="#n63">63</a></p>
<p id="n64" class="stm run hide_run"><a href="#n64">64</a></p>
<p id="n65" class="pln"><a href="#n65">65</a></p>
<p id="n66" class="pln"><a href="#n66">66</a></p>
<p id="n67" class="pln"><a href="#n67">67</a></p>
<p id="n68" class="pln"><a href="#n68">68</a></p>
<p id="n69" class="pln"><a href="#n69">69</a></p>
<p id="n70" class="pln"><a href="#n70">70</a></p>
<p id="n71" class="pln"><a href="#n71">71</a></p>
<p id="n72" class="pln"><a href="#n72">72</a></p>
<p id="n73" class="pln"><a href="#n73">73</a></p>
<p id="n74" class="pln"><a href="#n74">74</a></p>
<p id="n75" class="pln"><a href="#n75">75</a></p>
<p id="n76" class="pln"><a href="#n76">76</a></p>
<p id="n77" class="pln"><a href="#n77">77</a></p>
<p id="n78" class="stm run hide_run"><a href="#n78">78</a></p>
<p id="n79" class="pln"><a href="#n79">79</a></p>
<p id="n80" class="stm run hide_run"><a href="#n80">80</a></p>
<p id="n81" class="pln"><a href="#n81">81</a></p>
<p id="n82" class="pln"><a href="#n82">82</a></p>
<p id="n83" class="pln"><a href="#n83">83</a></p>
<p id="n84" class="pln"><a href="#n84">84</a></p>
<p id="n85" class="pln"><a href="#n85">85</a></p>
<p id="n86" class="pln"><a href="#n86">86</a></p>
<p id="n87" class="pln"><a href="#n87">87</a></p>
<p id="n88" class="pln"><a href="#n88">88</a></p>
<p id="n89" class="pln"><a href="#n89">89</a></p>
<p id="n90" class="pln"><a href="#n90">90</a></p>
<p id="n91" class="pln"><a href="#n91">91</a></p>
<p id="n92" class="pln"><a href="#n92">92</a></p>
<p id="n93" class="pln"><a href="#n93">93</a></p>
<p id="n94" class="stm run hide_run"><a href="#n94">94</a></p>
<p id="n95" class="stm mis"><a href="#n95">95</a></p>
<p id="n96" class="pln"><a href="#n96">96</a></p>
<p id="n97" class="pln"><a href="#n97">97</a></p>
<p id="n98" class="pln"><a href="#n98">98</a></p>
<p id="n99" class="pln"><a href="#n99">99</a></p>
<p id="n100" class="stm mis"><a href="#n100">100</a></p>
<p id="n101" class="pln"><a href="#n101">101</a></p>
<p id="n102" class="stm mis"><a href="#n102">102</a></p>
<p id="n103" class="pln"><a href="#n103">103</a></p>
<p id="n104" class="pln"><a href="#n104">104</a></p>
<p id="n105" class="pln"><a href="#n105">105</a></p>
<p id="n106" class="pln"><a href="#n106">106</a></p>
<p id="n107" class="stm run hide_run"><a href="#n107">107</a></p>
<p id="n108" class="pln"><a href="#n108">108</a></p>
<p id="n109" class="pln"><a href="#n109">109</a></p>
<p id="n110" class="pln"><a href="#n110">110</a></p>
<p id="n111" class="stm run hide_run"><a href="#n111">111</a></p>
<p id="n112" class="stm run hide_run"><a href="#n112">112</a></p>
<p id="n113" class="stm run hide_run"><a href="#n113">113</a></p>
<p id="n114" class="pln"><a href="#n114">114</a></p>
<p id="n115" class="pln"><a href="#n115">115</a></p>
<p id="n116" class="pln"><a href="#n116">116</a></p>
<p id="n117" class="pln"><a href="#n117">117</a></p>
<p id="n118" class="pln"><a href="#n118">118</a></p>
<p id="n119" class="stm run hide_run"><a href="#n119">119</a></p>
<p id="n120" class="stm run hide_run"><a href="#n120">120</a></p>
<p id="n121" class="stm run hide_run"><a href="#n121">121</a></p>
<p id="n122" class="stm run hide_run"><a href="#n122">122</a></p>
<p id="n123" class="pln"><a href="#n123">123</a></p>
<p id="n124" class="pln"><a href="#n124">124</a></p>
<p id="n125" class="stm run hide_run"><a href="#n125">125</a></p>
<p id="n126" class="stm run hide_run"><a href="#n126">126</a></p>
<p id="n127" class="stm run hide_run"><a href="#n127">127</a></p>
<p id="n128" class="pln"><a href="#n128">128</a></p>
<p id="n129" class="stm mis"><a href="#n129">129</a></p>
<p id="n130" class="pln"><a href="#n130">130</a></p>
<p id="n131" class="stm run hide_run"><a href="#n131">131</a></p>
<p id="n132" class="pln"><a href="#n132">132</a></p>
<p id="n133" class="pln"><a href="#n133">133</a></p>
<p id="n134" class="pln"><a href="#n134">134</a></p>
<p id="n135" class="pln"><a href="#n135">135</a></p>
<p id="n136" class="stm run hide_run"><a href="#n136">136</a></p>
<p id="n137" class="stm run hide_run"><a href="#n137">137</a></p>
<p id="n138" class="stm run hide_run"><a href="#n138">138</a></p>
<p id="n139" class="stm mis"><a href="#n139">139</a></p>
<p id="n140" class="pln"><a href="#n140">140</a></p>
<p id="n141" class="stm run hide_run"><a href="#n141">141</a></p>
<p id="n142" class="stm run hide_run"><a href="#n142">142</a></p>
<p id="n143" class="pln"><a href="#n143">143</a></p>
<p id="n144" class="stm run hide_run"><a href="#n144">144</a></p>
<p id="n145" class="pln"><a href="#n145">145</a></p>
<p id="n146" class="pln"><a href="#n146">146</a></p>
<p id="n147" class="pln"><a href="#n147">147</a></p>
<p id="n148" class="stm run hide_run"><a href="#n148">148</a></p>
<p id="n149" class="stm run hide_run"><a href="#n149">149</a></p>
<p id="n150" class="pln"><a href="#n150">150</a></p>
<p id="n151" class="pln"><a href="#n151">151</a></p>
<p id="n152" class="pln"><a href="#n152">152</a></p>
<p id="n153" class="pln"><a href="#n153">153</a></p>
<p id="n154" class="stm run hide_run"><a href="#n154">154</a></p>
<p id="n155" class="pln"><a href="#n155">155</a></p>
<p id="n156" class="stm run hide_run"><a href="#n156">156</a></p>
<p id="n157" class="stm run hide_run"><a href="#n157">157</a></p>
<p id="n158" class="stm run hide_run"><a href="#n158">158</a></p>
<p id="n159" class="pln"><a href="#n159">159</a></p>
<p id="n160" class="pln"><a href="#n160">160</a></p>
<p id="n161" class="stm run hide_run"><a href="#n161">161</a></p>
<p id="n162" class="stm mis"><a href="#n162">162</a></p>
<p id="n163" class="pln"><a href="#n163">163</a></p>
<p id="n164" class="pln"><a href="#n164">164</a></p>
<p id="n165" class="stm run hide_run"><a href="#n165">165</a></p>
<p id="n166" class="stm mis"><a href="#n166">166</a></p>
<p id="n167" class="stm mis"><a href="#n167">167</a></p>
<p id="n168" class="pln"><a href="#n168">168</a></p>
<p id="n169" class="stm mis"><a href="#n169">169</a></p>
<p id="n170" class="pln"><a href="#n170">170</a></p>
<p id="n171" class="stm run hide_run"><a href="#n171">171</a></p>
<p id="n172" class="pln"><a href="#n172">172</a></p>
<p id="n173" class="stm run hide_run"><a href="#n173">173</a></p>
<p id="n174" class="stm run hide_run"><a href="#n174">174</a></p>
<p id="n175" class="stm run hide_run"><a href="#n175">175</a></p>
<p id="n176" class="stm run hide_run"><a href="#n176">176</a></p>
<p id="n177" class="stm run hide_run"><a href="#n177">177</a></p>
<p id="n178" class="pln"><a href="#n178">178</a></p>
<p id="n179" class="stm run hide_run"><a href="#n179">179</a></p>
<p id="n180" class="stm run hide_run"><a href="#n180">180</a></p>
<p id="n181" class="stm run hide_run"><a href="#n181">181</a></p>
<p id="n182" class="stm run hide_run"><a href="#n182">182</a></p>
<p id="n183" class="stm run hide_run"><a href="#n183">183</a></p>
<p id="n184" class="stm run hide_run"><a href="#n184">184</a></p>
<p id="n185" class="stm run hide_run"><a href="#n185">185</a></p>
<p id="n186" class="stm run hide_run"><a href="#n186">186</a></p>
<p id="n187" class="pln"><a href="#n187">187</a></p>
<p id="n188" class="stm run hide_run"><a href="#n188">188</a></p>
<p id="n189" class="pln"><a href="#n189">189</a></p>
<p id="n190" class="pln"><a href="#n190">190</a></p>
<p id="n191" class="pln"><a href="#n191">191</a></p>
<p id="n192" class="pln"><a href="#n192">192</a></p>
<p id="n193" class="pln"><a href="#n193">193</a></p>
<p id="n194" class="pln"><a href="#n194">194</a></p>
<p id="n195" class="pln"><a href="#n195">195</a></p>
<p id="n196" class="pln"><a href="#n196">196</a></p>
<p id="n197" class="pln"><a href="#n197">197</a></p>
<p id="n198" class="pln"><a href="#n198">198</a></p>
<p id="n199" class="pln"><a href="#n199">199</a></p>
<p id="n200" class="pln"><a href="#n200">200</a></p>
<p id="n201" class="pln"><a href="#n201">201</a></p>
<p id="n202" class="pln"><a href="#n202">202</a></p>
<p id="n203" class="pln"><a href="#n203">203</a></p>
<p id="n204" class="pln"><a href="#n204">204</a></p>
<p id="n205" class="pln"><a href="#n205">205</a></p>
<p id="n206" class="pln"><a href="#n206">206</a></p>
<p id="n207" class="pln"><a href="#n207">207</a></p>
<p id="n208" class="pln"><a href="#n208">208</a></p>
<p id="n209" class="pln"><a href="#n209">209</a></p>
<p id="n210" class="pln"><a href="#n210">210</a></p>
<p id="n211" class="pln"><a href="#n211">211</a></p>
<p id="n212" class="stm run hide_run"><a href="#n212">212</a></p>
<p id="n213" class="stm run hide_run"><a href="#n213">213</a></p>
<p id="n214" class="stm run hide_run"><a href="#n214">214</a></p>
<p id="n215" class="stm run hide_run"><a href="#n215">215</a></p>
<p id="n216" class="stm run hide_run"><a href="#n216">216</a></p>
<p id="n217" class="stm run hide_run"><a href="#n217">217</a></p>
<p id="n218" class="stm run hide_run"><a href="#n218">218</a></p>
<p id="n219" class="stm run hide_run"><a href="#n219">219</a></p>
<p id="n220" class="pln"><a href="#n220">220</a></p>
<p id="n221" class="pln"><a href="#n221">221</a></p>
<p id="n222" class="stm run hide_run"><a href="#n222">222</a></p>
<p id="n223" class="stm run hide_run"><a href="#n223">223</a></p>
<p id="n224" class="stm run hide_run"><a href="#n224">224</a></p>
<p id="n225" class="stm run hide_run"><a href="#n225">225</a></p>
<p id="n226" class="stm run hide_run"><a href="#n226">226</a></p>
<p id="n227" class="stm run hide_run"><a href="#n227">227</a></p>
<p id="n228" class="pln"><a href="#n228">228</a></p>
<p id="n229" class="stm run hide_run"><a href="#n229">229</a></p>
<p id="n230" class="pln"><a href="#n230">230</a></p>
<p id="n231" class="pln"><a href="#n231">231</a></p>
<p id="n232" class="stm run hide_run"><a href="#n232">232</a></p>
<p id="n233" class="stm run hide_run"><a href="#n233">233</a></p>
<p id="n234" class="stm run hide_run"><a href="#n234">234</a></p>
<p id="n235" class="stm run hide_run"><a href="#n235">235</a></p>
<p id="n236" class="stm run hide_run"><a href="#n236">236</a></p>
<p id="n237" class="stm run hide_run"><a href="#n237">237</a></p>
<p id="n238" class="stm run hide_run"><a href="#n238">238</a></p>
<p id="n239" class="pln"><a href="#n239">239</a></p>
<p id="n240" class="stm run hide_run"><a href="#n240">240</a></p>
<p id="n241" class="pln"><a href="#n241">241</a></p>
<p id="n242" class="pln"><a href="#n242">242</a></p>
<p id="n243" class="stm run hide_run"><a href="#n243">243</a></p>
<p id="n244" class="stm run hide_run"><a href="#n244">244</a></p>
<p id="n245" class="stm run hide_run"><a href="#n245">245</a></p>
<p id="n246" class="pln"><a href="#n246">246</a></p>
<p id="n247" class="pln"><a href="#n247">247</a></p>
<p id="n248" class="stm run hide_run"><a href="#n248">248</a></p>
<p id="n249" class="stm run hide_run"><a href="#n249">249</a></p>
<p id="n250" class="stm run hide_run"><a href="#n250">250</a></p>
<p id="n251" class="pln"><a href="#n251">251</a></p>
<p id="n252" class="pln"><a href="#n252">252</a></p>
<p id="n253" class="stm run hide_run"><a href="#n253">253</a></p>
<p id="n254" class="stm run hide_run"><a href="#n254">254</a></p>
<p id="n255" class="pln"><a href="#n255">255</a></p>
<p id="n256" class="pln"><a href="#n256">256</a></p>
<p id="n257" class="pln"><a href="#n257">257</a></p>
<p id="n258" class="pln"><a href="#n258">258</a></p>
<p id="n259" class="pln"><a href="#n259">259</a></p>
<p id="n260" class="pln"><a href="#n260">260</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">import</span> <span class="nam">keras</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="nam">__author__</span> <span class="op">=</span> <span class="str">"Jakob Aungiers"</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"><span class="nam">__copyright__</span> <span class="op">=</span> <span class="str">"Jakob Aungiers 2018"</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="nam">__version__</span> <span class="op">=</span> <span class="str">"2.0.0"</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="nam">__license__</span> <span class="op">=</span> <span class="str">"MIT"</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"><span class="key">import</span> <span class="nam">json</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="stm run hide_run"><span class="key">import</span> <span class="nam">numpy</span> <span class="key">as</span> <span class="nam">np</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="stm run hide_run"><span class="key">import</span> <span class="nam">math</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"><span class="key">import</span> <span class="nam">pandas</span> <span class="key">as</span> <span class="nam">pd</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="stm run hide_run"><span class="key">import</span> <span class="nam">matplotlib</span><span class="op">.</span><span class="nam">pyplot</span> <span class="key">as</span> <span class="nam">plt</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="stm run hide_run"><span class="key">from</span> <span class="nam">LSTMPredictStock</span><span class="op">.</span><span class="nam">core</span><span class="op">.</span><span class="nam">data_processor</span> <span class="key">import</span> <span class="nam">DataLoader</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="stm run hide_run"><span class="key">from</span> <span class="nam">LSTMPredictStock</span><span class="op">.</span><span class="nam">core</span><span class="op">.</span><span class="nam">model</span> <span class="key">import</span> <span class="nam">Model</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="stm run hide_run"><span class="key">from</span> <span class="nam">datetime</span> <span class="key">import</span> <span class="nam">datetime</span><span class="op">,</span><span class="nam">timedelta</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="stm run hide_run"><span class="key">from</span> <span class="nam">LSTMPredictStock</span><span class="op">.</span><span class="nam">core</span><span class="op">.</span><span class="nam">get_domestic_hist_stock</span> <span class="key">import</span> <span class="nam">get_all_last_data</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="stm run hide_run"><span class="key">from</span> <span class="nam">LSTMPredictStock</span><span class="op">.</span><span class="nam">core</span><span class="op">.</span><span class="nam">get_domestic_hist_stock</span> <span class="key">import</span> <span class="nam">get_single_last_data</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t21" class="stm run hide_run"><span class="key">def</span> <span class="nam">plot_results</span><span class="op">(</span><span class="nam">predicted_data</span><span class="op">,</span> <span class="nam">true_data</span><span class="op">)</span><span class="op">:</span> <span class="com"># predicted_data&#19982;true_data&#65306;&#21516;&#38271;&#24230;&#19968;&#32500;&#25968;&#32452;</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="stm mis"> <span class="nam">fig</span> <span class="op">=</span> <span class="nam">plt</span><span class="op">.</span><span class="nam">figure</span><span class="op">(</span><span class="nam">facecolor</span><span class="op">=</span><span class="str">'white'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm mis"> <span class="nam">ax</span> <span class="op">=</span> <span class="nam">fig</span><span class="op">.</span><span class="nam">add_subplot</span><span class="op">(</span><span class="num">111</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="stm mis"> <span class="nam">ax</span><span class="op">.</span><span class="nam">plot</span><span class="op">(</span><span class="nam">true_data</span><span class="op">,</span> <span class="nam">label</span><span class="op">=</span><span class="str">'True Data'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="stm mis"> <span class="nam">plt</span><span class="op">.</span><span class="nam">plot</span><span class="op">(</span><span class="nam">predicted_data</span><span class="op">,</span> <span class="nam">label</span><span class="op">=</span><span class="str">'Prediction'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="stm mis"> <span class="nam">plt</span><span class="op">.</span><span class="nam">legend</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="stm mis"> <span class="nam">plt</span><span class="op">.</span><span class="nam">show</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t29" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t30" class="pln"><span class="com"># predicted_data&#27599;&#20010;&#20803;&#32032;&#30340;&#38271;&#24230;&#24517;&#39035;&#20026;prediction_len</span><span class="strut">&nbsp;</span></p>
<p id="t31" class="stm run hide_run"><span class="key">def</span> <span class="nam">plot_results_multiple</span><span class="op">(</span><span class="nam">predicted_data</span><span class="op">,</span> <span class="nam">true_data</span><span class="op">,</span> <span class="nam">prediction_len</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="stm mis"> <span class="nam">fig</span> <span class="op">=</span> <span class="nam">plt</span><span class="op">.</span><span class="nam">figure</span><span class="op">(</span><span class="nam">facecolor</span><span class="op">=</span><span class="str">'white'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t33" class="stm mis"> <span class="nam">ax</span> <span class="op">=</span> <span class="nam">fig</span><span class="op">.</span><span class="nam">add_subplot</span><span class="op">(</span><span class="num">111</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="stm mis"> <span class="nam">ax</span><span class="op">.</span><span class="nam">plot</span><span class="op">(</span><span class="nam">true_data</span><span class="op">,</span> <span class="nam">label</span><span class="op">=</span><span class="str">'True Data'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="pln"> <span class="com"># Pad the list of predictions to shift it in the graph to it's correct start</span><span class="strut">&nbsp;</span></p>
<p id="t36" class="stm mis"> <span class="key">for</span> <span class="nam">i</span><span class="op">,</span> <span class="nam">data</span> <span class="key">in</span> <span class="nam">enumerate</span><span class="op">(</span><span class="nam">predicted_data</span><span class="op">)</span><span class="op">:</span> <span class="com"># data&#20026;&#19968;&#32500;&#25968;&#32452;&#65292;&#38271;&#24230;&#20026;prediction_len&#12290;predicted_data&#65306;&#20108;&#32500;&#25968;&#32452;&#65292;&#27599;&#20010;&#20803;&#32032;&#20026;list</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="stm mis"> <span class="nam">padding</span> <span class="op">=</span> <span class="op">[</span><span class="key">None</span> <span class="key">for</span> <span class="nam">p</span> <span class="key">in</span> <span class="nam">range</span><span class="op">(</span><span class="nam">i</span> <span class="op">*</span> <span class="nam">prediction_len</span><span class="op">)</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="stm mis"> <span class="nam">plt</span><span class="op">.</span><span class="nam">plot</span><span class="op">(</span><span class="nam">padding</span> <span class="op">+</span> <span class="nam">data</span><span class="op">,</span> <span class="nam">label</span><span class="op">=</span><span class="str">'Prediction'</span><span class="op">)</span> <span class="com"># padding + data&#65306;list&#25340;&#25509;&#25805;&#20316;</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="stm mis"> <span class="nam">plt</span><span class="op">.</span><span class="nam">legend</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t40" class="stm mis"> <span class="nam">plt</span><span class="op">.</span><span class="nam">show</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t41" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t42" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t43" class="pln"><span class="com"># &#21482;&#29992;&#20110;&#35757;&#32451;&#27169;&#22411;&#65292;&#20294;&#21516;&#26102;&#21487;&#26681;&#25454;&#21442;&#25968;&#36827;&#34892;&#27169;&#22411;&#30340;&#35780;&#20272;</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="stm run hide_run"><span class="key">def</span> <span class="nam">train_model</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">,</span> <span class="nam">predict</span><span class="op">=</span><span class="key">False</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#35757;&#32451;&#25351;&#23450;&#32929;&#31080;&#20195;&#30721;&#30340;&#27169;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="pln"> <span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t46" class="pln"><span class="str"> &#35757;&#32451;&#24182;&#20445;&#23384;&#27169;&#22411;&#65292;&#21516;&#26102;&#26681;&#25454;&#27979;&#35797;&#25968;&#25454;&#23545;&#27169;&#22411;&#36827;&#34892;&#35780;&#20272;&#65288;&#32472;&#22270;&#26041;&#24335;&#65289;</span><span class="strut">&nbsp;</span></p>
<p id="t47" class="pln"><span class="str"> '''</span><span class="strut">&nbsp;</span></p>
<p id="t48" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t49" class="stm run hide_run"> <span class="nam">configs</span> <span class="op">=</span> <span class="nam">json</span><span class="op">.</span><span class="nam">load</span><span class="op">(</span><span class="nam">open</span><span class="op">(</span><span class="nam">get_config_path</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'r'</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t50" class="stm run hide_run"> <span class="key">if</span> <span class="key">not</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">exists</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="nam">configs</span><span class="op">[</span><span class="str">'model'</span><span class="op">]</span><span class="op">[</span><span class="str">'save_dir'</span><span class="op">]</span><span class="op">)</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="stm mis"> <span class="nam">os</span><span class="op">.</span><span class="nam">makedirs</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="nam">configs</span><span class="op">[</span><span class="str">'model'</span><span class="op">]</span><span class="op">[</span><span class="str">'save_dir'</span><span class="op">]</span><span class="op">)</span><span class="op">)</span> <span class="com"># &#21019;&#24314;&#20445;&#23384;&#27169;&#22411;&#30340;&#30446;&#24405;</span><span class="strut">&nbsp;</span></p>
<p id="t52" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t53" class="stm run hide_run"> <span class="nam">split</span> <span class="op">=</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'train_test_split'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t54" class="stm run hide_run"> <span class="key">if</span> <span class="key">not</span> <span class="nam">predict</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t55" class="stm run hide_run"> <span class="nam">split</span> <span class="op">=</span> <span class="num">1</span> <span class="com"># &#33509;&#19981;&#35780;&#20272;&#27169;&#22411;&#20934;&#30830;&#24230;&#65292;&#21017;&#23558;&#20840;&#37096;&#21382;&#21490;&#25968;&#25454;&#29992;&#20110;&#35757;&#32451;</span><span class="strut">&nbsp;</span></p>
<p id="t56" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t57" class="stm run hide_run"> <span class="nam">data</span> <span class="op">=</span> <span class="nam">DataLoader</span><span class="op">(</span> <span class="com"># &#20174;&#26412;&#22320;&#21152;&#36733;&#35757;&#32451;&#21644;&#27979;&#35797;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t58" class="pln"> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="str">'data'</span><span class="op">,</span> <span class="nam">stock_code</span> <span class="op">+</span> <span class="str">".csv"</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> <span class="com"># configs['data']['filename']</span><span class="strut">&nbsp;</span></p>
<p id="t59" class="pln"> <span class="nam">split</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t60" class="pln"> <span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'columns'</span><span class="op">]</span> <span class="com"># &#36873;&#25321;&#26576;&#20123;&#21015;&#30340;&#25968;&#25454;&#36827;&#34892;&#35757;&#32451;</span><span class="strut">&nbsp;</span></p>
<p id="t61" class="pln"> <span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t62" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t63" class="stm run hide_run"> <span class="nam">model</span> <span class="op">=</span> <span class="nam">Model</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t64" class="stm run hide_run"> <span class="nam">model</span><span class="op">.</span><span class="nam">build_model</span><span class="op">(</span><span class="nam">configs</span><span class="op">)</span> <span class="com"># &#26681;&#25454;&#37197;&#32622;&#25991;&#20214;&#26032;&#24314;&#27169;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t65" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t66" class="pln"> <span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t67" class="pln"><span class="str"> # in-memory training</span><span class="strut">&nbsp;</span></p>
<p id="t68" class="pln"><span class="str"> model.train(</span><span class="strut">&nbsp;</span></p>
<p id="t69" class="pln"><span class="str"> x,</span><span class="strut">&nbsp;</span></p>
<p id="t70" class="pln"><span class="str"> y,</span><span class="strut">&nbsp;</span></p>
<p id="t71" class="pln"><span class="str"> epochs = configs['training']['epochs'],</span><span class="strut">&nbsp;</span></p>
<p id="t72" class="pln"><span class="str"> batch_size = configs['training']['batch_size'],</span><span class="strut">&nbsp;</span></p>
<p id="t73" class="pln"><span class="str"> save_dir = configs['model']['save_dir']</span><span class="strut">&nbsp;</span></p>
<p id="t74" class="pln"><span class="str"> )</span><span class="strut">&nbsp;</span></p>
<p id="t75" class="pln"><span class="str"> '''</span><span class="strut">&nbsp;</span></p>
<p id="t76" class="pln"> <span class="com"># &#35757;&#32451;&#27169;&#22411;&#65306;</span><span class="strut">&nbsp;</span></p>
<p id="t77" class="pln"> <span class="com"># out-of memory generative training</span><span class="strut">&nbsp;</span></p>
<p id="t78" class="stm run hide_run"> <span class="nam">steps_per_epoch</span> <span class="op">=</span> <span class="nam">math</span><span class="op">.</span><span class="nam">ceil</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t79" class="pln"> <span class="op">(</span><span class="nam">data</span><span class="op">.</span><span class="nam">len_train</span> <span class="op">-</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="op">)</span> <span class="op">/</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'training'</span><span class="op">]</span><span class="op">[</span><span class="str">'batch_size'</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t80" class="stm run hide_run"> <span class="nam">model</span><span class="op">.</span><span class="nam">train_generator</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t81" class="pln"> <span class="nam">data_gen</span><span class="op">=</span><span class="nam">data</span><span class="op">.</span><span class="nam">generate_train_batch</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t82" class="pln"> <span class="nam">seq_len</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t83" class="pln"> <span class="nam">batch_size</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'training'</span><span class="op">]</span><span class="op">[</span><span class="str">'batch_size'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t84" class="pln"> <span class="nam">normalise</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'normalise'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t85" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t86" class="pln"> <span class="nam">epochs</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'training'</span><span class="op">]</span><span class="op">[</span><span class="str">'epochs'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t87" class="pln"> <span class="nam">batch_size</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'training'</span><span class="op">]</span><span class="op">[</span><span class="str">'batch_size'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t88" class="pln"> <span class="nam">steps_per_epoch</span><span class="op">=</span><span class="nam">steps_per_epoch</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t89" class="pln"> <span class="nam">save_dir</span><span class="op">=</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="nam">configs</span><span class="op">[</span><span class="str">'model'</span><span class="op">]</span><span class="op">[</span><span class="str">'save_dir'</span><span class="op">]</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t90" class="pln"> <span class="nam">save_name</span><span class="op">=</span><span class="nam">stock_code</span><span class="strut">&nbsp;</span></p>
<p id="t91" class="pln"> <span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t92" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t93" class="pln"> <span class="com"># &#39044;&#27979;</span><span class="strut">&nbsp;</span></p>
<p id="t94" class="stm run hide_run"> <span class="key">if</span> <span class="nam">predict</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t95" class="stm mis"> <span class="nam">x_test</span><span class="op">,</span> <span class="nam">y_test</span> <span class="op">=</span> <span class="nam">data</span><span class="op">.</span><span class="nam">get_test_data</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t96" class="pln"> <span class="nam">seq_len</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t97" class="pln"> <span class="nam">normalise</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'normalise'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t98" class="pln"> <span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t99" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t100" class="stm mis"> <span class="nam">predictions</span> <span class="op">=</span> <span class="nam">model</span><span class="op">.</span><span class="nam">predict_sequences_multiple</span><span class="op">(</span><span class="nam">x_test</span><span class="op">,</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t101" class="pln"> <span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t102" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">"&#35757;&#32451;&#65306;\n"</span><span class="op">,</span> <span class="nam">predictions</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t103" class="pln"> <span class="com"># plot_results_multiple(predictions, y_test, configs['data']['sequence_length'])</span><span class="strut">&nbsp;</span></p>
<p id="t104" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t105" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t106" class="pln"><span class="com"># &#23545;&#25351;&#23450;&#20844;&#21496;&#30340;&#32929;&#31080;&#36827;&#34892;&#39044;&#27979;</span><span class="strut">&nbsp;</span></p>
<p id="t107" class="stm run hide_run"><span class="key">def</span> <span class="nam">prediction</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">,</span> <span class="nam">real</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">pre_len</span><span class="op">=</span><span class="num">30</span><span class="op">,</span> <span class="nam">plot</span><span class="op">=</span><span class="key">False</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t108" class="pln"> <span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t109" class="pln"><span class="str"> &#20351;&#29992;&#20445;&#23384;&#30340;&#27169;&#22411;&#65292;&#23545;&#36755;&#20837;&#25968;&#25454;&#36827;&#34892;&#39044;&#27979;</span><span class="strut">&nbsp;</span></p>
<p id="t110" class="pln"><span class="str"> '''</span><span class="strut">&nbsp;</span></p>
<p id="t111" class="stm run hide_run"> <span class="nam">config_path</span> <span class="op">=</span> <span class="nam">get_config_path</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t112" class="stm run hide_run"> <span class="nam">configs</span> <span class="op">=</span> <span class="nam">json</span><span class="op">.</span><span class="nam">load</span><span class="op">(</span><span class="nam">open</span><span class="op">(</span><span class="nam">config_path</span><span class="op">,</span> <span class="str">'r'</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t113" class="stm run hide_run"> <span class="nam">data</span> <span class="op">=</span> <span class="nam">DataLoader</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t114" class="pln"> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">get_data_path</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="nam">stock_code</span> <span class="op">+</span> <span class="str">".csv"</span><span class="op">)</span><span class="op">,</span> <span class="com"># configs['data']['filename']</span><span class="strut">&nbsp;</span></p>
<p id="t115" class="pln"> <span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'train_test_split'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t116" class="pln"> <span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'columns'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t117" class="pln"> <span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t118" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t119" class="stm run hide_run"> <span class="nam">file_path</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="str">"saved_models"</span><span class="op">,</span><span class="nam">stock_code</span> <span class="op">+</span> <span class="str">".h5"</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t120" class="stm run hide_run"> <span class="nam">model</span> <span class="op">=</span> <span class="nam">Model</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t121" class="stm run hide_run"> <span class="nam">keras</span><span class="op">.</span><span class="nam">backend</span><span class="op">.</span><span class="nam">clear_session</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t122" class="stm run hide_run"> <span class="nam">model</span><span class="op">.</span><span class="nam">load_model</span><span class="op">(</span><span class="nam">file_path</span><span class="op">)</span> <span class="com"># &#26681;&#25454;&#37197;&#32622;&#25991;&#20214;&#26032;&#24314;&#27169;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t123" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t124" class="pln"> <span class="com"># predict_length = configs['data']['sequence_length'] # &#39044;&#27979;&#38271;&#24230;</span><span class="strut">&nbsp;</span></p>
<p id="t125" class="stm run hide_run"> <span class="nam">predict_length</span> <span class="op">=</span> <span class="nam">pre_len</span><span class="strut">&nbsp;</span></p>
<p id="t126" class="stm run hide_run"> <span class="key">if</span> <span class="nam">real</span><span class="op">:</span> <span class="com"># &#29992;&#26368;&#36817;&#19968;&#20010;&#31383;&#21475;&#30340;&#25968;&#25454;&#36827;&#34892;&#39044;&#27979;&#65292;&#27809;&#26377;&#23545;&#27604;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t127" class="stm run hide_run"> <span class="nam">win_position</span> <span class="op">=</span> <span class="op">-</span><span class="num">1</span><span class="strut">&nbsp;</span></p>
<p id="t128" class="pln"> <span class="key">else</span><span class="op">:</span> <span class="com"># &#29992;&#25351;&#23450;&#20301;&#32622;&#30340;&#19968;&#20010;&#31383;&#21475;&#25968;&#25454;&#36827;&#34892;&#39044;&#27979;&#65292;&#26377;&#23545;&#27604;&#30495;&#23454;&#25968;&#25454;&#65288;&#29992;&#20110;&#32472;&#22270;&#23545;&#27604;&#65289;</span><span class="strut">&nbsp;</span></p>
<p id="t129" class="stm mis"> <span class="nam">win_position</span> <span class="op">=</span> <span class="op">-</span><span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t130" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t131" class="stm run hide_run"> <span class="nam">x_test</span><span class="op">,</span> <span class="nam">y_test</span> <span class="op">=</span> <span class="nam">data</span><span class="op">.</span><span class="nam">get_test_data</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t132" class="pln"> <span class="nam">seq_len</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t133" class="pln"> <span class="nam">normalise</span><span class="op">=</span><span class="key">False</span><span class="strut">&nbsp;</span></p>
<p id="t134" class="pln"> <span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t135" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t136" class="stm run hide_run"> <span class="nam">x_test</span> <span class="op">=</span> <span class="nam">x_test</span><span class="op">[</span><span class="nam">win_position</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t137" class="stm run hide_run"> <span class="nam">x_test</span> <span class="op">=</span> <span class="nam">x_test</span><span class="op">[</span><span class="nam">np</span><span class="op">.</span><span class="nam">newaxis</span><span class="op">,</span> <span class="op">:</span><span class="op">,</span> <span class="op">:</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t138" class="stm run hide_run"> <span class="key">if</span> <span class="key">not</span> <span class="nam">real</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t139" class="stm mis"> <span class="nam">y_test_real</span> <span class="op">=</span> <span class="nam">y_test</span><span class="op">[</span><span class="nam">win_position</span><span class="op">:</span><span class="nam">win_position</span> <span class="op">+</span> <span class="nam">predict_length</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t140" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t141" class="stm run hide_run"> <span class="nam">base</span> <span class="op">=</span> <span class="nam">x_test</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t142" class="stm run hide_run"> <span class="nam">print</span><span class="op">(</span><span class="str">"base value:\n"</span><span class="op">,</span> <span class="nam">base</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t143" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t144" class="stm run hide_run"> <span class="nam">x_test</span><span class="op">,</span> <span class="nam">y_test</span> <span class="op">=</span> <span class="nam">data</span><span class="op">.</span><span class="nam">get_test_data</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t145" class="pln"> <span class="nam">seq_len</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t146" class="pln"> <span class="nam">normalise</span><span class="op">=</span><span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'normalise'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t147" class="pln"> <span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t148" class="stm run hide_run"> <span class="nam">x_test</span> <span class="op">=</span> <span class="nam">x_test</span><span class="op">[</span><span class="nam">win_position</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t149" class="stm run hide_run"> <span class="nam">x_test</span> <span class="op">=</span> <span class="nam">x_test</span><span class="op">[</span><span class="nam">np</span><span class="op">.</span><span class="nam">newaxis</span><span class="op">,</span> <span class="op">:</span><span class="op">,</span> <span class="op">:</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t150" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t151" class="pln"> <span class="com"># predictions = model.predict_sequences_multiple(x_test, configs['data']['sequence_length'],</span><span class="strut">&nbsp;</span></p>
<p id="t152" class="pln"> <span class="com"># predict_length)</span><span class="strut">&nbsp;</span></p>
<p id="t153" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t154" class="stm run hide_run"> <span class="nam">predictions</span> <span class="op">=</span> <span class="nam">model</span><span class="op">.</span><span class="nam">predict_1_win_sequence</span><span class="op">(</span><span class="nam">x_test</span><span class="op">,</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'data'</span><span class="op">]</span><span class="op">[</span><span class="str">'sequence_length'</span><span class="op">]</span><span class="op">,</span> <span class="nam">predict_length</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t155" class="pln"> <span class="com"># &#21453;&#24402;&#19968;&#21270;</span><span class="strut">&nbsp;</span></p>
<p id="t156" class="stm run hide_run"> <span class="nam">predictions_array</span> <span class="op">=</span> <span class="nam">np</span><span class="op">.</span><span class="nam">array</span><span class="op">(</span><span class="nam">predictions</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t157" class="stm run hide_run"> <span class="nam">predictions_array</span> <span class="op">=</span> <span class="nam">base</span> <span class="op">*</span> <span class="op">(</span><span class="num">1</span> <span class="op">+</span> <span class="nam">predictions_array</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t158" class="stm run hide_run"> <span class="nam">predictions</span> <span class="op">=</span> <span class="nam">predictions_array</span><span class="op">.</span><span class="nam">tolist</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t159" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t160" class="pln"> <span class="com"># print("&#39044;&#27979;&#25968;&#25454;:\n", predictions)</span><span class="strut">&nbsp;</span></p>
<p id="t161" class="stm run hide_run"> <span class="key">if</span> <span class="key">not</span> <span class="nam">real</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t162" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">"&#30495;&#23454;&#25968;&#25454;&#65306;\n"</span><span class="op">,</span> <span class="nam">y_test_real</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t163" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t164" class="pln"> <span class="com"># plot_results_multiple(predictions, y_test, predict_length)</span><span class="strut">&nbsp;</span></p>
<p id="t165" class="stm run hide_run"> <span class="key">if</span> <span class="nam">plot</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t166" class="stm mis"> <span class="key">if</span> <span class="nam">real</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t167" class="stm mis"> <span class="nam">plot_results</span><span class="op">(</span><span class="nam">predictions</span><span class="op">,</span> <span class="op">[</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t168" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t169" class="stm mis"> <span class="nam">plot_results</span><span class="op">(</span><span class="nam">predictions</span><span class="op">,</span> <span class="nam">y_test_real</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t170" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t171" class="stm run hide_run"> <span class="key">return</span> <span class="nam">format_predictions</span><span class="op">(</span><span class="nam">predictions</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t172" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t173" class="stm run hide_run"><span class="key">def</span> <span class="nam">format_predictions</span><span class="op">(</span><span class="nam">predictions</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#32473;&#39044;&#27979;&#25968;&#25454;&#28155;&#21152;&#23545;&#24212;&#26085;&#26399;</span><span class="strut">&nbsp;</span></p>
<p id="t174" class="stm run hide_run"> <span class="nam">date_predict</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t175" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t176" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">+=</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">1</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t177" class="stm run hide_run"> <span class="nam">counter</span> <span class="op">=</span> <span class="num">0</span><span class="strut">&nbsp;</span></p>
<p id="t178" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t179" class="stm run hide_run"> <span class="key">while</span> <span class="nam">counter</span> <span class="op">&lt;</span> <span class="nam">len</span><span class="op">(</span><span class="nam">predictions</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t180" class="stm run hide_run"> <span class="key">if</span> <span class="nam">cur</span><span class="op">.</span><span class="nam">isoweekday</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="num">6</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t181" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">=</span> <span class="nam">cur</span> <span class="op">+</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">2</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t182" class="stm run hide_run"> <span class="key">if</span> <span class="nam">cur</span><span class="op">.</span><span class="nam">isoweekday</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="num">7</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t183" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">=</span> <span class="nam">cur</span> <span class="op">+</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">1</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t184" class="stm run hide_run"> <span class="nam">date_predict</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="op">[</span><span class="nam">cur</span><span class="op">.</span><span class="nam">strftime</span><span class="op">(</span><span class="str">"%Y-%m-%d"</span><span class="op">)</span><span class="op">,</span><span class="nam">predictions</span><span class="op">[</span><span class="nam">counter</span><span class="op">]</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t185" class="stm run hide_run"> <span class="nam">cur</span> <span class="op">=</span> <span class="nam">cur</span> <span class="op">+</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">1</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t186" class="stm run hide_run"> <span class="nam">counter</span> <span class="op">+=</span> <span class="num">1</span><span class="strut">&nbsp;</span></p>
<p id="t187" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t188" class="stm run hide_run"> <span class="key">return</span> <span class="nam">date_predict</span><span class="strut">&nbsp;</span></p>
<p id="t189" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t190" class="pln"><span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t191" class="pln"><span class="str">def main(stock_code, train=False, predict=False):</span><span class="strut">&nbsp;</span></p>
<p id="t192" class="pln"><span class="str"> configs = json.load(open(get_config_path(), 'r'))</span><span class="strut">&nbsp;</span></p>
<p id="t193" class="pln"><span class="str"> companies = configs['companies']</span><span class="strut">&nbsp;</span></p>
<p id="t194" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t195" class="pln"><span class="str"> if stock_code not in companies.keys():</span><span class="strut">&nbsp;</span></p>
<p id="t196" class="pln"><span class="str"> print("&#35813;&#20844;&#21496;&#19981;&#22312;&#25351;&#23450;&#33539;&#22260;&#20869;")</span><span class="strut">&nbsp;</span></p>
<p id="t197" class="pln"><span class="str"> return -1</span><span class="strut">&nbsp;</span></p>
<p id="t198" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t199" class="pln"><span class="str"> if train:</span><span class="strut">&nbsp;</span></p>
<p id="t200" class="pln"><span class="str"> train_model(stock_code)</span><span class="strut">&nbsp;</span></p>
<p id="t201" class="pln"><span class="str"> return 0 # &#35757;&#32451;&#23436;&#25104;</span><span class="strut">&nbsp;</span></p>
<p id="t202" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t203" class="pln"><span class="str"> if predict:</span><span class="strut">&nbsp;</span></p>
<p id="t204" class="pln"><span class="str"> # for root, dirs, files in os.walk('saved_models'):</span><span class="strut">&nbsp;</span></p>
<p id="t205" class="pln"><span class="str"> # root:&#24403;&#21069;&#30446;&#24405;&#36335;&#24452; dirs: &#24403;&#21069;&#36335;&#24452;&#19979;&#25152;&#26377;&#23376;&#30446;&#24405; files:&#24403;&#21069;&#36335;&#24452;&#19979;&#25152;&#26377;&#38750;&#30446;&#24405;&#23376;&#25991;&#20214;</span><span class="strut">&nbsp;</span></p>
<p id="t206" class="pln"><span class="str"> if stock_code + ".h5" in os.listdir("saved_models"): # os.listdir:&#33719;&#24471;&#24403;&#21069;&#30446;&#24405;&#19979;&#30340;&#25152;&#26377;&#25991;&#20214;&#21517;&#12290;&#19981;&#21253;&#25324;&#23376;&#30446;&#24405;</span><span class="strut">&nbsp;</span></p>
<p id="t207" class="pln"><span class="str"> return prediction(stock_code=stock_code, real=True, pre_len=20)</span><span class="strut">&nbsp;</span></p>
<p id="t208" class="pln"><span class="str"> else:</span><span class="strut">&nbsp;</span></p>
<p id="t209" class="pln"><span class="str"> return -2 # &#35813;&#20844;&#21496;&#36824;&#27809;&#26377;&#35757;&#32451;&#27169;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t210" class="pln"><span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t211" class="pln"> <span class="com"># &#20108;&#32500;&#25968;&#32452;&#65306;[[data,value],[...]]</span><span class="strut">&nbsp;</span></p>
<p id="t212" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_hist_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">,</span> <span class="nam">recent_day</span><span class="op">=</span><span class="num">30</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#33719;&#21462;&#26576;&#32929;&#31080;&#65292;&#25351;&#23450;&#22825;&#25968;&#30340;&#21382;&#21490;close&#25968;&#25454;,&#21253;&#21547;&#26085;&#26399;</span><span class="strut">&nbsp;</span></p>
<p id="t213" class="stm run hide_run"> <span class="nam">get_single_last_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t214" class="stm run hide_run"> <span class="nam">root_dir</span> <span class="op">=</span> <span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t215" class="stm run hide_run"> <span class="nam">file_path</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">root_dir</span><span class="op">,</span> <span class="str">"data/"</span> <span class="op">+</span> <span class="nam">stock_code</span> <span class="op">+</span> <span class="str">".csv"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t216" class="stm run hide_run"> <span class="nam">cols</span> <span class="op">=</span> <span class="op">[</span><span class="str">'Date'</span><span class="op">,</span> <span class="str">'Close'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t217" class="stm run hide_run"> <span class="nam">data_frame</span> <span class="op">=</span> <span class="nam">pd</span><span class="op">.</span><span class="nam">read_csv</span><span class="op">(</span><span class="nam">file_path</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t218" class="stm run hide_run"> <span class="nam">close_data</span> <span class="op">=</span> <span class="nam">data_frame</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="nam">cols</span><span class="op">)</span><span class="op">.</span><span class="nam">values</span><span class="op">[</span><span class="op">-</span><span class="nam">recent_day</span><span class="op">:</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t219" class="stm run hide_run"> <span class="key">return</span> <span class="nam">close_data</span><span class="op">.</span><span class="nam">tolist</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t220" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t221" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t222" class="stm run hide_run"><span class="key">def</span> <span class="nam">train_all_stock</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> <span class="com">#</span><span class="strut">&nbsp;</span></p>
<p id="t223" class="stm run hide_run"> <span class="nam">get_all_last_data</span><span class="op">(</span><span class="nam">start_date</span><span class="op">=</span><span class="str">"2010-01-01"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t224" class="stm run hide_run"> <span class="nam">configs</span> <span class="op">=</span> <span class="nam">json</span><span class="op">.</span><span class="nam">load</span><span class="op">(</span><span class="nam">open</span><span class="op">(</span><span class="nam">get_config_path</span><span class="op">(</span><span class="op">)</span><span class="op">,</span> <span class="str">'r'</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t225" class="stm run hide_run"> <span class="nam">companies</span> <span class="op">=</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'companies'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t226" class="stm run hide_run"> <span class="key">for</span> <span class="nam">stock_code</span> <span class="key">in</span> <span class="nam">companies</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t227" class="stm run hide_run"> <span class="nam">train_model</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t228" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t229" class="stm run hide_run"> <span class="key">return</span> <span class="num">0</span><span class="strut">&nbsp;</span></p>
<p id="t230" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t231" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t232" class="stm run hide_run"><span class="key">def</span> <span class="nam">predict_all_stock</span><span class="op">(</span><span class="nam">pre_len</span><span class="op">=</span><span class="num">10</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t233" class="stm run hide_run"> <span class="nam">file_path</span> <span class="op">=</span> <span class="nam">get_config_path</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t234" class="stm run hide_run"> <span class="nam">configs</span> <span class="op">=</span> <span class="nam">json</span><span class="op">.</span><span class="nam">load</span><span class="op">(</span><span class="nam">open</span><span class="op">(</span><span class="nam">file_path</span><span class="op">,</span> <span class="str">'r'</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t235" class="stm run hide_run"> <span class="nam">companies</span> <span class="op">=</span> <span class="nam">configs</span><span class="op">[</span><span class="str">'companies'</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t236" class="stm run hide_run"> <span class="nam">predict_list</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t237" class="stm run hide_run"> <span class="key">for</span> <span class="nam">stock_code</span> <span class="key">in</span> <span class="nam">companies</span><span class="op">.</span><span class="nam">keys</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t238" class="stm run hide_run"> <span class="nam">predict_list</span><span class="op">.</span><span class="nam">append</span><span class="op">(</span><span class="nam">prediction</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">stock_code</span><span class="op">,</span> <span class="nam">real</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">pre_len</span><span class="op">=</span><span class="nam">pre_len</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t239" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t240" class="stm run hide_run"> <span class="key">return</span> <span class="nam">predict_list</span><span class="strut">&nbsp;</span></p>
<p id="t241" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t242" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t243" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_config_path</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> <span class="com"># config.json&#30340;&#32477;&#23545;&#36335;&#24452;</span><span class="strut">&nbsp;</span></p>
<p id="t244" class="stm run hide_run"> <span class="nam">root_dir</span> <span class="op">=</span> <span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t245" class="stm run hide_run"> <span class="key">return</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">root_dir</span><span class="op">,</span> <span class="str">"config.json"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t246" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t247" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t248" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_data_path</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> <span class="com"># data&#30446;&#24405;&#30340;&#32477;&#23545;&#36335;&#24452;</span><span class="strut">&nbsp;</span></p>
<p id="t249" class="stm run hide_run"> <span class="nam">root_dir</span> <span class="op">=</span> <span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t250" class="stm run hide_run"> <span class="key">return</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">root_dir</span><span class="op">,</span> <span class="str">"data"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t251" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t252" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t253" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_parent_dir</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#24403;&#21069;&#25991;&#20214;&#30340;&#29238;&#30446;&#24405;&#32477;&#23545;&#36335;&#24452;</span><span class="strut">&nbsp;</span></p>
<p id="t254" class="stm run hide_run"> <span class="key">return</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">__file__</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t255" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t256" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t257" class="pln"><span class="com"># if __name__ == '__main__':</span><span class="strut">&nbsp;</span></p>
<p id="t258" class="pln"><span class="com"># # get_all_last_data("2010-01-01") # &#20808;&#33719;&#24471;&#26368;&#26032;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t259" class="pln"><span class="com"># train_all_stock()</span><span class="strut">&nbsp;</span></p>
<p id="t260" class="pln"><span class="com"># # predict_all_stock()</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 16:41
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for WebStockPredict\__init__.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>WebStockPredict\__init__.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
0 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">0 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
</td>
<td class="text">
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,331 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for WebStockPredict\settings.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>WebStockPredict\settings.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
18 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">18 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="pln"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="pln"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
<p id="n13" class="stm run hide_run"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="stm run hide_run"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="pln"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
<p id="n23" class="stm run hide_run"><a href="#n23">23</a></p>
<p id="n24" class="pln"><a href="#n24">24</a></p>
<p id="n25" class="pln"><a href="#n25">25</a></p>
<p id="n26" class="stm run hide_run"><a href="#n26">26</a></p>
<p id="n27" class="pln"><a href="#n27">27</a></p>
<p id="n28" class="stm run hide_run"><a href="#n28">28</a></p>
<p id="n29" class="pln"><a href="#n29">29</a></p>
<p id="n30" class="pln"><a href="#n30">30</a></p>
<p id="n31" class="pln"><a href="#n31">31</a></p>
<p id="n32" class="pln"><a href="#n32">32</a></p>
<p id="n33" class="stm run hide_run"><a href="#n33">33</a></p>
<p id="n34" class="pln"><a href="#n34">34</a></p>
<p id="n35" class="pln"><a href="#n35">35</a></p>
<p id="n36" class="pln"><a href="#n36">36</a></p>
<p id="n37" class="pln"><a href="#n37">37</a></p>
<p id="n38" class="pln"><a href="#n38">38</a></p>
<p id="n39" class="pln"><a href="#n39">39</a></p>
<p id="n40" class="pln"><a href="#n40">40</a></p>
<p id="n41" class="pln"><a href="#n41">41</a></p>
<p id="n42" class="pln"><a href="#n42">42</a></p>
<p id="n43" class="stm run hide_run"><a href="#n43">43</a></p>
<p id="n44" class="pln"><a href="#n44">44</a></p>
<p id="n45" class="pln"><a href="#n45">45</a></p>
<p id="n46" class="pln"><a href="#n46">46</a></p>
<p id="n47" class="pln"><a href="#n47">47</a></p>
<p id="n48" class="pln"><a href="#n48">48</a></p>
<p id="n49" class="pln"><a href="#n49">49</a></p>
<p id="n50" class="pln"><a href="#n50">50</a></p>
<p id="n51" class="pln"><a href="#n51">51</a></p>
<p id="n52" class="pln"><a href="#n52">52</a></p>
<p id="n53" class="stm run hide_run"><a href="#n53">53</a></p>
<p id="n54" class="pln"><a href="#n54">54</a></p>
<p id="n55" class="stm run hide_run"><a href="#n55">55</a></p>
<p id="n56" class="pln"><a href="#n56">56</a></p>
<p id="n57" class="pln"><a href="#n57">57</a></p>
<p id="n58" class="pln"><a href="#n58">58</a></p>
<p id="n59" class="pln"><a href="#n59">59</a></p>
<p id="n60" class="pln"><a href="#n60">60</a></p>
<p id="n61" class="pln"><a href="#n61">61</a></p>
<p id="n62" class="pln"><a href="#n62">62</a></p>
<p id="n63" class="pln"><a href="#n63">63</a></p>
<p id="n64" class="pln"><a href="#n64">64</a></p>
<p id="n65" class="pln"><a href="#n65">65</a></p>
<p id="n66" class="pln"><a href="#n66">66</a></p>
<p id="n67" class="pln"><a href="#n67">67</a></p>
<p id="n68" class="pln"><a href="#n68">68</a></p>
<p id="n69" class="pln"><a href="#n69">69</a></p>
<p id="n70" class="pln"><a href="#n70">70</a></p>
<p id="n71" class="stm run hide_run"><a href="#n71">71</a></p>
<p id="n72" class="pln"><a href="#n72">72</a></p>
<p id="n73" class="pln"><a href="#n73">73</a></p>
<p id="n74" class="pln"><a href="#n74">74</a></p>
<p id="n75" class="pln"><a href="#n75">75</a></p>
<p id="n76" class="pln"><a href="#n76">76</a></p>
<p id="n77" class="stm run hide_run"><a href="#n77">77</a></p>
<p id="n78" class="pln"><a href="#n78">78</a></p>
<p id="n79" class="pln"><a href="#n79">79</a></p>
<p id="n80" class="pln"><a href="#n80">80</a></p>
<p id="n81" class="pln"><a href="#n81">81</a></p>
<p id="n82" class="pln"><a href="#n82">82</a></p>
<p id="n83" class="pln"><a href="#n83">83</a></p>
<p id="n84" class="pln"><a href="#n84">84</a></p>
<p id="n85" class="pln"><a href="#n85">85</a></p>
<p id="n86" class="pln"><a href="#n86">86</a></p>
<p id="n87" class="pln"><a href="#n87">87</a></p>
<p id="n88" class="stm run hide_run"><a href="#n88">88</a></p>
<p id="n89" class="pln"><a href="#n89">89</a></p>
<p id="n90" class="pln"><a href="#n90">90</a></p>
<p id="n91" class="pln"><a href="#n91">91</a></p>
<p id="n92" class="pln"><a href="#n92">92</a></p>
<p id="n93" class="pln"><a href="#n93">93</a></p>
<p id="n94" class="pln"><a href="#n94">94</a></p>
<p id="n95" class="pln"><a href="#n95">95</a></p>
<p id="n96" class="pln"><a href="#n96">96</a></p>
<p id="n97" class="pln"><a href="#n97">97</a></p>
<p id="n98" class="pln"><a href="#n98">98</a></p>
<p id="n99" class="pln"><a href="#n99">99</a></p>
<p id="n100" class="pln"><a href="#n100">100</a></p>
<p id="n101" class="pln"><a href="#n101">101</a></p>
<p id="n102" class="pln"><a href="#n102">102</a></p>
<p id="n103" class="pln"><a href="#n103">103</a></p>
<p id="n104" class="pln"><a href="#n104">104</a></p>
<p id="n105" class="pln"><a href="#n105">105</a></p>
<p id="n106" class="pln"><a href="#n106">106</a></p>
<p id="n107" class="stm run hide_run"><a href="#n107">107</a></p>
<p id="n108" class="pln"><a href="#n108">108</a></p>
<p id="n109" class="stm run hide_run"><a href="#n109">109</a></p>
<p id="n110" class="pln"><a href="#n110">110</a></p>
<p id="n111" class="stm run hide_run"><a href="#n111">111</a></p>
<p id="n112" class="pln"><a href="#n112">112</a></p>
<p id="n113" class="stm run hide_run"><a href="#n113">113</a></p>
<p id="n114" class="pln"><a href="#n114">114</a></p>
<p id="n115" class="stm run hide_run"><a href="#n115">115</a></p>
<p id="n116" class="pln"><a href="#n116">116</a></p>
<p id="n117" class="pln"><a href="#n117">117</a></p>
<p id="n118" class="pln"><a href="#n118">118</a></p>
<p id="n119" class="pln"><a href="#n119">119</a></p>
<p id="n120" class="pln"><a href="#n120">120</a></p>
<p id="n121" class="stm run hide_run"><a href="#n121">121</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="str">Django settings for WebStockPredict project.</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="str">Generated by 'django-admin startproject' using Django 2.1.4.</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="str">For more information on this file, see</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="str">https://docs.djangoproject.com/en/2.1/topics/settings/</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"><span class="str">For the full list of settings and their values, see</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"><span class="str">https://docs.djangoproject.com/en/2.1/ref/settings/</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t13" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"><span class="com"># Build paths inside the project like this: os.path.join(BASE_DIR, ...)</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="stm run hide_run"><span class="nam">BASE_DIR</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">abspath</span><span class="op">(</span><span class="nam">__file__</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t19" class="pln"><span class="com"># Quick-start development settings - unsuitable for production</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"><span class="com"># See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"><span class="com"># SECURITY WARNING: keep the secret key used in production secret!</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm run hide_run"><span class="nam">SECRET_KEY</span> <span class="op">=</span> <span class="str">'s^-*g$$lhg4j-q=#bad#x+$086ptt$l7op1u5h8p%4l3cq7v8s'</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t25" class="pln"><span class="com"># SECURITY WARNING: don't run with debug turned on in production!</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="stm run hide_run"><span class="nam">DEBUG</span> <span class="op">=</span> <span class="key">True</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t28" class="stm run hide_run"><span class="nam">ALLOWED_HOSTS</span> <span class="op">=</span> <span class="op">[</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t30" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t31" class="pln"><span class="com"># Application definition</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t33" class="stm run hide_run"><span class="nam">INSTALLED_APPS</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="pln"> <span class="str">'django.contrib.admin'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="pln"> <span class="str">'django.contrib.auth'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t36" class="pln"> <span class="str">'django.contrib.contenttypes'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="pln"> <span class="str">'django.contrib.sessions'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="pln"> <span class="str">'django.contrib.messages'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="pln"> <span class="str">'django.contrib.staticfiles'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t40" class="pln"> <span class="str">'stock_predict.apps.StockPredictConfig'</span><span class="strut">&nbsp;</span></p>
<p id="t41" class="pln"><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t42" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t43" class="stm run hide_run"><span class="nam">MIDDLEWARE</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="pln"> <span class="str">'django.middleware.security.SecurityMiddleware'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="pln"> <span class="str">'django.contrib.sessions.middleware.SessionMiddleware'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t46" class="pln"> <span class="str">'django.middleware.common.CommonMiddleware'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t47" class="pln"> <span class="str">'django.middleware.csrf.CsrfViewMiddleware'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t48" class="pln"> <span class="str">'django.contrib.auth.middleware.AuthenticationMiddleware'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t49" class="pln"> <span class="str">'django.contrib.messages.middleware.MessageMiddleware'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t50" class="pln"> <span class="str">'django.middleware.clickjacking.XFrameOptionsMiddleware'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="pln"><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t52" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t53" class="stm run hide_run"><span class="nam">ROOT_URLCONF</span> <span class="op">=</span> <span class="str">'WebStockPredict.urls'</span><span class="strut">&nbsp;</span></p>
<p id="t54" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t55" class="stm run hide_run"><span class="nam">TEMPLATES</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t56" class="pln"> <span class="op">{</span><span class="strut">&nbsp;</span></p>
<p id="t57" class="pln"> <span class="str">'BACKEND'</span><span class="op">:</span> <span class="str">'django.template.backends.django.DjangoTemplates'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t58" class="pln"> <span class="str">'DIRS'</span><span class="op">:</span> <span class="op">[</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t59" class="pln"> <span class="str">'APP_DIRS'</span><span class="op">:</span> <span class="key">True</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t60" class="pln"> <span class="str">'OPTIONS'</span><span class="op">:</span> <span class="op">{</span><span class="strut">&nbsp;</span></p>
<p id="t61" class="pln"> <span class="str">'context_processors'</span><span class="op">:</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t62" class="pln"> <span class="str">'django.template.context_processors.debug'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t63" class="pln"> <span class="str">'django.template.context_processors.request'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t64" class="pln"> <span class="str">'django.contrib.auth.context_processors.auth'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t65" class="pln"> <span class="str">'django.contrib.messages.context_processors.messages'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t66" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t67" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t68" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t69" class="pln"><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t70" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t71" class="stm run hide_run"><span class="nam">WSGI_APPLICATION</span> <span class="op">=</span> <span class="str">'WebStockPredict.wsgi.application'</span><span class="strut">&nbsp;</span></p>
<p id="t72" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t73" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t74" class="pln"><span class="com"># Database</span><span class="strut">&nbsp;</span></p>
<p id="t75" class="pln"><span class="com"># https://docs.djangoproject.com/en/2.1/ref/settings/#databases</span><span class="strut">&nbsp;</span></p>
<p id="t76" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t77" class="stm run hide_run"><span class="nam">DATABASES</span> <span class="op">=</span> <span class="op">{</span><span class="strut">&nbsp;</span></p>
<p id="t78" class="pln"> <span class="str">'default'</span><span class="op">:</span> <span class="op">{</span><span class="strut">&nbsp;</span></p>
<p id="t79" class="pln"> <span class="str">'ENGINE'</span><span class="op">:</span> <span class="str">'django.db.backends.sqlite3'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t80" class="pln"> <span class="str">'NAME'</span><span class="op">:</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">BASE_DIR</span><span class="op">,</span> <span class="str">'db.sqlite3'</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t81" class="pln"> <span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t82" class="pln"><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t83" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t84" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t85" class="pln"><span class="com"># Password validation</span><span class="strut">&nbsp;</span></p>
<p id="t86" class="pln"><span class="com"># https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators</span><span class="strut">&nbsp;</span></p>
<p id="t87" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t88" class="stm run hide_run"><span class="nam">AUTH_PASSWORD_VALIDATORS</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t89" class="pln"> <span class="op">{</span><span class="strut">&nbsp;</span></p>
<p id="t90" class="pln"> <span class="str">'NAME'</span><span class="op">:</span> <span class="str">'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t91" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t92" class="pln"> <span class="op">{</span><span class="strut">&nbsp;</span></p>
<p id="t93" class="pln"> <span class="str">'NAME'</span><span class="op">:</span> <span class="str">'django.contrib.auth.password_validation.MinimumLengthValidator'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t94" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t95" class="pln"> <span class="op">{</span><span class="strut">&nbsp;</span></p>
<p id="t96" class="pln"> <span class="str">'NAME'</span><span class="op">:</span> <span class="str">'django.contrib.auth.password_validation.CommonPasswordValidator'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t97" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t98" class="pln"> <span class="op">{</span><span class="strut">&nbsp;</span></p>
<p id="t99" class="pln"> <span class="str">'NAME'</span><span class="op">:</span> <span class="str">'django.contrib.auth.password_validation.NumericPasswordValidator'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t100" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t101" class="pln"><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t102" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t103" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t104" class="pln"><span class="com"># Internationalization</span><span class="strut">&nbsp;</span></p>
<p id="t105" class="pln"><span class="com"># https://docs.djangoproject.com/en/2.1/topics/i18n/</span><span class="strut">&nbsp;</span></p>
<p id="t106" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t107" class="stm run hide_run"><span class="nam">LANGUAGE_CODE</span> <span class="op">=</span> <span class="str">'zh-hans'</span> <span class="com"># en-us</span><span class="strut">&nbsp;</span></p>
<p id="t108" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t109" class="stm run hide_run"><span class="nam">TIME_ZONE</span> <span class="op">=</span> <span class="str">'Asia/Shanghai'</span> <span class="com"># UTC</span><span class="strut">&nbsp;</span></p>
<p id="t110" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t111" class="stm run hide_run"><span class="nam">USE_I18N</span> <span class="op">=</span> <span class="key">True</span><span class="strut">&nbsp;</span></p>
<p id="t112" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t113" class="stm run hide_run"><span class="nam">USE_L10N</span> <span class="op">=</span> <span class="key">True</span><span class="strut">&nbsp;</span></p>
<p id="t114" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t115" class="stm run hide_run"><span class="nam">USE_TZ</span> <span class="op">=</span> <span class="key">True</span><span class="strut">&nbsp;</span></p>
<p id="t116" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t117" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t118" class="pln"><span class="com"># Static files (CSS, JavaScript, Images)</span><span class="strut">&nbsp;</span></p>
<p id="t119" class="pln"><span class="com"># https://docs.djangoproject.com/en/2.1/howto/static-files/</span><span class="strut">&nbsp;</span></p>
<p id="t120" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t121" class="stm run hide_run"><span class="nam">STATIC_URL</span> <span class="op">=</span> <span class="str">'/static/'</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,133 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for WebStockPredict\urls.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>WebStockPredict\urls.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
3 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">3 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="pln"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="pln"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="stm run hide_run"><a href="#n16">16</a></p>
<p id="n17" class="stm run hide_run"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="stm run hide_run"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="str">"""WebStockPredict URL Configuration</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="pln"><span class="str">The `urlpatterns` list routes URLs to views. For more information please see:</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="str"> https://docs.djangoproject.com/en/2.1/topics/http/urls/</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="str">Examples:</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="str">Function views</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="str"> 1. Add an import: from my_app import views</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="pln"><span class="str"> 2. Add a URL to urlpatterns: path('', views.home, name='home')</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"><span class="str">Class-based views</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"><span class="str"> 1. Add an import: from other_app.views import Home</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="str"> 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"><span class="str">Including another URLconf</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"><span class="str"> 1. Import the include() function: from django.urls import include, path</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"><span class="str"> 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"><span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">contrib</span> <span class="key">import</span> <span class="nam">admin</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">urls</span> <span class="key">import</span> <span class="nam">path</span><span class="op">,</span><span class="nam">include</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t19" class="stm run hide_run"><span class="nam">urlpatterns</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"> <span class="nam">path</span><span class="op">(</span><span class="str">'admin/'</span><span class="op">,</span> <span class="nam">admin</span><span class="op">.</span><span class="nam">site</span><span class="op">.</span><span class="nam">urls</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"> <span class="nam">path</span><span class="op">(</span><span class="str">"stock_predict/"</span><span class="op">,</span><span class="nam">include</span><span class="op">(</span><span class="str">'stock_predict.urls'</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"><span class="op">]</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 17:21
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for WebStockPredict\wsgi.py: 0%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>WebStockPredict\wsgi.py</b> :
<span class="pc_cov">0%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
4 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">0 run</span>
<span class="mis shortkey_m button_toggle_mis">4 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="pln"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="pln"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="stm mis"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="stm mis"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="stm mis"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="stm mis"><a href="#n16">16</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="str">WSGI config for WebStockPredict project.</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="str">It exposes the WSGI callable as a module-level variable named ``application``.</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="str">For more information on this file, see</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="str">https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="pln"><span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t10" class="stm mis"><span class="key">import</span> <span class="nam">os</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm mis"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">core</span><span class="op">.</span><span class="nam">wsgi</span> <span class="key">import</span> <span class="nam">get_wsgi_application</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t14" class="stm mis"><span class="nam">os</span><span class="op">.</span><span class="nam">environ</span><span class="op">.</span><span class="nam">setdefault</span><span class="op">(</span><span class="str">'DJANGO_SETTINGS_MODULE'</span><span class="op">,</span> <span class="str">'WebStockPredict.settings'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t16" class="stm mis"><span class="nam">application</span> <span class="op">=</span> <span class="nam">get_wsgi_application</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,584 @@
// Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
// For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
// Coverage.py HTML report browser code.
/*jslint browser: true, sloppy: true, vars: true, plusplus: true, maxerr: 50, indent: 4 */
/*global coverage: true, document, window, $ */
coverage = {};
// Find all the elements with shortkey_* class, and use them to assign a shortcut key.
coverage.assign_shortkeys = function () {
$("*[class*='shortkey_']").each(function (i, e) {
$.each($(e).attr("class").split(" "), function (i, c) {
if (/^shortkey_/.test(c)) {
$(document).bind('keydown', c.substr(9), function () {
$(e).click();
});
}
});
});
};
// Create the events for the help panel.
coverage.wire_up_help_panel = function () {
$("#keyboard_icon").click(function () {
// Show the help panel, and position it so the keyboard icon in the
// panel is in the same place as the keyboard icon in the header.
$(".help_panel").show();
var koff = $("#keyboard_icon").offset();
var poff = $("#panel_icon").position();
$(".help_panel").offset({
top: koff.top-poff.top,
left: koff.left-poff.left
});
});
$("#panel_icon").click(function () {
$(".help_panel").hide();
});
};
// Create the events for the filter box.
coverage.wire_up_filter = function () {
// Cache elements.
var table = $("table.index");
var table_rows = table.find("tbody tr");
var table_row_names = table_rows.find("td.name a");
var no_rows = $("#no_rows");
// Create a duplicate table footer that we can modify with dynamic summed values.
var table_footer = $("table.index tfoot tr");
var table_dynamic_footer = table_footer.clone();
table_dynamic_footer.attr('class', 'total_dynamic hidden');
table_footer.after(table_dynamic_footer);
// Observe filter keyevents.
$("#filter").on("keyup change", $.debounce(150, function (event) {
var filter_value = $(this).val();
if (filter_value === "") {
// Filter box is empty, remove all filtering.
table_rows.removeClass("hidden");
// Show standard footer, hide dynamic footer.
table_footer.removeClass("hidden");
table_dynamic_footer.addClass("hidden");
// Hide placeholder, show table.
if (no_rows.length > 0) {
no_rows.hide();
}
table.show();
}
else {
// Filter table items by value.
var hidden = 0;
var shown = 0;
// Hide / show elements.
$.each(table_row_names, function () {
var element = $(this).parents("tr");
if ($(this).text().indexOf(filter_value) === -1) {
// hide
element.addClass("hidden");
hidden++;
}
else {
// show
element.removeClass("hidden");
shown++;
}
});
// Show placeholder if no rows will be displayed.
if (no_rows.length > 0) {
if (shown === 0) {
// Show placeholder, hide table.
no_rows.show();
table.hide();
}
else {
// Hide placeholder, show table.
no_rows.hide();
table.show();
}
}
// Manage dynamic header:
if (hidden > 0) {
// Calculate new dynamic sum values based on visible rows.
for (var column = 2; column < 20; column++) {
// Calculate summed value.
var cells = table_rows.find('td:nth-child(' + column + ')');
if (!cells.length) {
// No more columns...!
break;
}
var sum = 0, numer = 0, denom = 0;
$.each(cells.filter(':visible'), function () {
var ratio = $(this).data("ratio");
if (ratio) {
var splitted = ratio.split(" ");
numer += parseInt(splitted[0], 10);
denom += parseInt(splitted[1], 10);
}
else {
sum += parseInt(this.innerHTML, 10);
}
});
// Get footer cell element.
var footer_cell = table_dynamic_footer.find('td:nth-child(' + column + ')');
// Set value into dynamic footer cell element.
if (cells[0].innerHTML.indexOf('%') > -1) {
// Percentage columns use the numerator and denominator,
// and adapt to the number of decimal places.
var match = /\.([0-9]+)/.exec(cells[0].innerHTML);
var places = 0;
if (match) {
places = match[1].length;
}
var pct = numer * 100 / denom;
footer_cell.text(pct.toFixed(places) + '%');
}
else {
footer_cell.text(sum);
}
}
// Hide standard footer, show dynamic footer.
table_footer.addClass("hidden");
table_dynamic_footer.removeClass("hidden");
}
else {
// Show standard footer, hide dynamic footer.
table_footer.removeClass("hidden");
table_dynamic_footer.addClass("hidden");
}
}
}));
// Trigger change event on setup, to force filter on page refresh
// (filter value may still be present).
$("#filter").trigger("change");
};
// Loaded on index.html
coverage.index_ready = function ($) {
// Look for a cookie containing previous sort settings:
var sort_list = [];
var cookie_name = "COVERAGE_INDEX_SORT";
var i;
// This almost makes it worth installing the jQuery cookie plugin:
if (document.cookie.indexOf(cookie_name) > -1) {
var cookies = document.cookie.split(";");
for (i = 0; i < cookies.length; i++) {
var parts = cookies[i].split("=");
if ($.trim(parts[0]) === cookie_name && parts[1]) {
sort_list = eval("[[" + parts[1] + "]]");
break;
}
}
}
// Create a new widget which exists only to save and restore
// the sort order:
$.tablesorter.addWidget({
id: "persistentSort",
// Format is called by the widget before displaying:
format: function (table) {
if (table.config.sortList.length === 0 && sort_list.length > 0) {
// This table hasn't been sorted before - we'll use
// our stored settings:
$(table).trigger('sorton', [sort_list]);
}
else {
// This is not the first load - something has
// already defined sorting so we'll just update
// our stored value to match:
sort_list = table.config.sortList;
}
}
});
// Configure our tablesorter to handle the variable number of
// columns produced depending on report options:
var headers = [];
var col_count = $("table.index > thead > tr > th").length;
headers[0] = { sorter: 'text' };
for (i = 1; i < col_count-1; i++) {
headers[i] = { sorter: 'digit' };
}
headers[col_count-1] = { sorter: 'percent' };
// Enable the table sorter:
$("table.index").tablesorter({
widgets: ['persistentSort'],
headers: headers
});
coverage.assign_shortkeys();
coverage.wire_up_help_panel();
coverage.wire_up_filter();
// Watch for page unload events so we can save the final sort settings:
$(window).unload(function () {
document.cookie = cookie_name + "=" + sort_list.toString() + "; path=/";
});
};
// -- pyfile stuff --
coverage.pyfile_ready = function ($) {
// If we're directed to a particular line number, highlight the line.
var frag = location.hash;
if (frag.length > 2 && frag[1] === 'n') {
$(frag).addClass('highlight');
coverage.set_sel(parseInt(frag.substr(2), 10));
}
else {
coverage.set_sel(0);
}
$(document)
.bind('keydown', 'j', coverage.to_next_chunk_nicely)
.bind('keydown', 'k', coverage.to_prev_chunk_nicely)
.bind('keydown', '0', coverage.to_top)
.bind('keydown', '1', coverage.to_first_chunk)
;
$(".button_toggle_run").click(function (evt) {coverage.toggle_lines(evt.target, "run");});
$(".button_toggle_exc").click(function (evt) {coverage.toggle_lines(evt.target, "exc");});
$(".button_toggle_mis").click(function (evt) {coverage.toggle_lines(evt.target, "mis");});
$(".button_toggle_par").click(function (evt) {coverage.toggle_lines(evt.target, "par");});
coverage.assign_shortkeys();
coverage.wire_up_help_panel();
coverage.init_scroll_markers();
// Rebuild scroll markers after window high changing
$(window).resize(coverage.resize_scroll_markers);
};
coverage.toggle_lines = function (btn, cls) {
btn = $(btn);
var hide = "hide_"+cls;
if (btn.hasClass(hide)) {
$("#source ."+cls).removeClass(hide);
btn.removeClass(hide);
}
else {
$("#source ."+cls).addClass(hide);
btn.addClass(hide);
}
};
// Return the nth line div.
coverage.line_elt = function (n) {
return $("#t" + n);
};
// Return the nth line number div.
coverage.num_elt = function (n) {
return $("#n" + n);
};
// Return the container of all the code.
coverage.code_container = function () {
return $(".linenos");
};
// Set the selection. b and e are line numbers.
coverage.set_sel = function (b, e) {
// The first line selected.
coverage.sel_begin = b;
// The next line not selected.
coverage.sel_end = (e === undefined) ? b+1 : e;
};
coverage.to_top = function () {
coverage.set_sel(0, 1);
coverage.scroll_window(0);
};
coverage.to_first_chunk = function () {
coverage.set_sel(0, 1);
coverage.to_next_chunk();
};
coverage.is_transparent = function (color) {
// Different browsers return different colors for "none".
return color === "transparent" || color === "rgba(0, 0, 0, 0)";
};
coverage.to_next_chunk = function () {
var c = coverage;
// Find the start of the next colored chunk.
var probe = c.sel_end;
var color, probe_line;
while (true) {
probe_line = c.line_elt(probe);
if (probe_line.length === 0) {
return;
}
color = probe_line.css("background-color");
if (!c.is_transparent(color)) {
break;
}
probe++;
}
// There's a next chunk, `probe` points to it.
var begin = probe;
// Find the end of this chunk.
var next_color = color;
while (next_color === color) {
probe++;
probe_line = c.line_elt(probe);
next_color = probe_line.css("background-color");
}
c.set_sel(begin, probe);
c.show_selection();
};
coverage.to_prev_chunk = function () {
var c = coverage;
// Find the end of the prev colored chunk.
var probe = c.sel_begin-1;
var probe_line = c.line_elt(probe);
if (probe_line.length === 0) {
return;
}
var color = probe_line.css("background-color");
while (probe > 0 && c.is_transparent(color)) {
probe--;
probe_line = c.line_elt(probe);
if (probe_line.length === 0) {
return;
}
color = probe_line.css("background-color");
}
// There's a prev chunk, `probe` points to its last line.
var end = probe+1;
// Find the beginning of this chunk.
var prev_color = color;
while (prev_color === color) {
probe--;
probe_line = c.line_elt(probe);
prev_color = probe_line.css("background-color");
}
c.set_sel(probe+1, end);
c.show_selection();
};
// Return the line number of the line nearest pixel position pos
coverage.line_at_pos = function (pos) {
var l1 = coverage.line_elt(1),
l2 = coverage.line_elt(2),
result;
if (l1.length && l2.length) {
var l1_top = l1.offset().top,
line_height = l2.offset().top - l1_top,
nlines = (pos - l1_top) / line_height;
if (nlines < 1) {
result = 1;
}
else {
result = Math.ceil(nlines);
}
}
else {
result = 1;
}
return result;
};
// Returns 0, 1, or 2: how many of the two ends of the selection are on
// the screen right now?
coverage.selection_ends_on_screen = function () {
if (coverage.sel_begin === 0) {
return 0;
}
var top = coverage.line_elt(coverage.sel_begin);
var next = coverage.line_elt(coverage.sel_end-1);
return (
(top.isOnScreen() ? 1 : 0) +
(next.isOnScreen() ? 1 : 0)
);
};
coverage.to_next_chunk_nicely = function () {
coverage.finish_scrolling();
if (coverage.selection_ends_on_screen() === 0) {
// The selection is entirely off the screen: select the top line on
// the screen.
var win = $(window);
coverage.select_line_or_chunk(coverage.line_at_pos(win.scrollTop()));
}
coverage.to_next_chunk();
};
coverage.to_prev_chunk_nicely = function () {
coverage.finish_scrolling();
if (coverage.selection_ends_on_screen() === 0) {
var win = $(window);
coverage.select_line_or_chunk(coverage.line_at_pos(win.scrollTop() + win.height()));
}
coverage.to_prev_chunk();
};
// Select line number lineno, or if it is in a colored chunk, select the
// entire chunk
coverage.select_line_or_chunk = function (lineno) {
var c = coverage;
var probe_line = c.line_elt(lineno);
if (probe_line.length === 0) {
return;
}
var the_color = probe_line.css("background-color");
if (!c.is_transparent(the_color)) {
// The line is in a highlighted chunk.
// Search backward for the first line.
var probe = lineno;
var color = the_color;
while (probe > 0 && color === the_color) {
probe--;
probe_line = c.line_elt(probe);
if (probe_line.length === 0) {
break;
}
color = probe_line.css("background-color");
}
var begin = probe + 1;
// Search forward for the last line.
probe = lineno;
color = the_color;
while (color === the_color) {
probe++;
probe_line = c.line_elt(probe);
color = probe_line.css("background-color");
}
coverage.set_sel(begin, probe);
}
else {
coverage.set_sel(lineno);
}
};
coverage.show_selection = function () {
var c = coverage;
// Highlight the lines in the chunk
c.code_container().find(".highlight").removeClass("highlight");
for (var probe = c.sel_begin; probe > 0 && probe < c.sel_end; probe++) {
c.num_elt(probe).addClass("highlight");
}
c.scroll_to_selection();
};
coverage.scroll_to_selection = function () {
// Scroll the page if the chunk isn't fully visible.
if (coverage.selection_ends_on_screen() < 2) {
// Need to move the page. The html,body trick makes it scroll in all
// browsers, got it from http://stackoverflow.com/questions/3042651
var top = coverage.line_elt(coverage.sel_begin);
var top_pos = parseInt(top.offset().top, 10);
coverage.scroll_window(top_pos - 30);
}
};
coverage.scroll_window = function (to_pos) {
$("html,body").animate({scrollTop: to_pos}, 200);
};
coverage.finish_scrolling = function () {
$("html,body").stop(true, true);
};
coverage.init_scroll_markers = function () {
var c = coverage;
// Init some variables
c.lines_len = $('td.text p').length;
c.body_h = $('body').height();
c.header_h = $('div#header').height();
c.missed_lines = $('td.text p.mis, td.text p.par');
// Build html
c.resize_scroll_markers();
};
coverage.resize_scroll_markers = function () {
var c = coverage,
min_line_height = 3,
max_line_height = 10,
visible_window_h = $(window).height();
$('#scroll_marker').remove();
// Don't build markers if the window has no scroll bar.
if (c.body_h <= visible_window_h) {
return;
}
$("body").append("<div id='scroll_marker'>&nbsp;</div>");
var scroll_marker = $('#scroll_marker'),
marker_scale = scroll_marker.height() / c.body_h,
line_height = scroll_marker.height() / c.lines_len;
// Line height must be between the extremes.
if (line_height > min_line_height) {
if (line_height > max_line_height) {
line_height = max_line_height;
}
}
else {
line_height = min_line_height;
}
var previous_line = -99,
last_mark,
last_top;
c.missed_lines.each(function () {
var line_top = Math.round($(this).offset().top * marker_scale),
id_name = $(this).attr('id'),
line_number = parseInt(id_name.substring(1, id_name.length));
if (line_number === previous_line + 1) {
// If this solid missed block just make previous mark higher.
last_mark.css({
'height': line_top + line_height - last_top
});
}
else {
// Add colored line in scroll_marker block.
scroll_marker.append('<div id="m' + line_number + '" class="marker"></div>');
last_mark = $('#m' + line_number);
last_mark.css({
'height': line_height,
'top': line_top
});
last_top = line_top;
}
previous_line = line_number;
});
};

@ -0,0 +1,338 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Coverage report</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.ba-throttle-debounce.min.js"></script>
<script type="text/javascript" src="jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.index_ready);
</script>
</head>
<body class="indexfile">
<div id="header">
<div class="content">
<h1>Coverage report:
<span class="pc_cov">90%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<form id="filter_container">
<input id="filter" type="text" value="" placeholder="filter..." />
</form>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">n</span>
<span class="key">s</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">c</span> &nbsp; change column sorting
</p>
</div>
</div>
<div id="index">
<table class="index">
<thead>
<tr class="tablehead" title="Click to sort">
<th class="name left headerSortDown shortkey_n">Module</th>
<th class="shortkey_s">statements</th>
<th class="shortkey_m">missing</th>
<th class="shortkey_x">excluded</th>
<th class="right shortkey_c">coverage</th>
</tr>
</thead>
<tfoot>
<tr class="total">
<td class="name left">Total</td>
<td>698</td>
<td>71</td>
<td>0</td>
<td class="right" data-ratio="627 698">90%</td>
</tr>
</tfoot>
<tbody>
<tr class="file">
<td class="name left"><a href="LSTMPredictStock___init___py.html">LSTMPredictStock\__init__.py</a></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="0 0">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="LSTMPredictStock_core___init___py.html">LSTMPredictStock\core\__init__.py</a></td>
<td>6</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="6 6">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="LSTMPredictStock_core_data_processor_py.html">LSTMPredictStock\core\data_processor.py</a></td>
<td>58</td>
<td>7</td>
<td>0</td>
<td class="right" data-ratio="51 58">88%</td>
</tr>
<tr class="file">
<td class="name left"><a href="LSTMPredictStock_core_get_domestic_hist_stock_py.html">LSTMPredictStock\core\get_domestic_hist_stock.py</a></td>
<td>45</td>
<td>1</td>
<td>0</td>
<td class="right" data-ratio="44 45">98%</td>
</tr>
<tr class="file">
<td class="name left"><a href="LSTMPredictStock_core_model_py.html">LSTMPredictStock\core\model.py</a></td>
<td>86</td>
<td>30</td>
<td>0</td>
<td class="right" data-ratio="56 86">65%</td>
</tr>
<tr class="file">
<td class="name left"><a href="LSTMPredictStock_core_utils_py.html">LSTMPredictStock\core\utils.py</a></td>
<td>9</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="9 9">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="LSTMPredictStock_run_py.html">LSTMPredictStock\run.py</a></td>
<td>126</td>
<td>24</td>
<td>0</td>
<td class="right" data-ratio="102 126">81%</td>
</tr>
<tr class="file">
<td class="name left"><a href="WebStockPredict___init___py.html">WebStockPredict\__init__.py</a></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="0 0">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="WebStockPredict_settings_py.html">WebStockPredict\settings.py</a></td>
<td>18</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="18 18">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="WebStockPredict_urls_py.html">WebStockPredict\urls.py</a></td>
<td>3</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="3 3">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="WebStockPredict_wsgi_py.html">WebStockPredict\wsgi.py</a></td>
<td>4</td>
<td>4</td>
<td>0</td>
<td class="right" data-ratio="0 4">0%</td>
</tr>
<tr class="file">
<td class="name left"><a href="manage_py.html">manage.py</a></td>
<td>9</td>
<td>2</td>
<td>0</td>
<td class="right" data-ratio="7 9">78%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict___init___py.html">stock_predict\__init__.py</a></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="0 0">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_add_companies_to_db_py.html">stock_predict\add_companies_to_db.py</a></td>
<td>8</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="8 8">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_admin_py.html">stock_predict\admin.py</a></td>
<td>5</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="5 5">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_apps_py.html">stock_predict\apps.py</a></td>
<td>3</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="3 3">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_migrations_0001_initial_py.html">stock_predict\migrations\0001_initial.py</a></td>
<td>6</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="6 6">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_migrations_0002_auto_20181212_1138_py.html">stock_predict\migrations\0002_auto_20181212_1138.py</a></td>
<td>4</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="4 4">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_migrations_0003_auto_20181212_1206_py.html">stock_predict\migrations\0003_auto_20181212_1206.py</a></td>
<td>4</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="4 4">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_migrations_0004_auto_20181213_1455_py.html">stock_predict\migrations\0004_auto_20181213_1455.py</a></td>
<td>4</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="4 4">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_migrations_0005_stockindex_py.html">stock_predict\migrations\0005_stockindex.py</a></td>
<td>5</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="5 5">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_migrations_0006_stockindex_zong_he_py.html">stock_predict\migrations\0006_stockindex_zong_he.py</a></td>
<td>4</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="4 4">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_migrations___init___py.html">stock_predict\migrations\__init__.py</a></td>
<td>0</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="0 0">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_models_py.html">stock_predict\models.py</a></td>
<td>43</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="43 43">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_tests_py.html">stock_predict\tests.py</a></td>
<td>170</td>
<td>2</td>
<td>0</td>
<td class="right" data-ratio="168 170">99%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_urls_py.html">stock_predict\urls.py</a></td>
<td>5</td>
<td>0</td>
<td>0</td>
<td class="right" data-ratio="5 5">100%</td>
</tr>
<tr class="file">
<td class="name left"><a href="stock_predict_views_py.html">stock_predict\views.py</a></td>
<td>73</td>
<td>1</td>
<td>0</td>
<td class="right" data-ratio="72 73">99%</td>
</tr>
</tbody>
</table>
<p id="no_rows">
No items found using the specified filter.
</p>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 16:41
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,9 @@
/*
* jQuery throttle / debounce - v1.1 - 3/7/2010
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);

@ -0,0 +1,99 @@
/*
* jQuery Hotkeys Plugin
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Based upon the plugin by Tzury Bar Yochay:
* http://github.com/tzuryby/hotkeys
*
* Original idea by:
* Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
*/
(function(jQuery){
jQuery.hotkeys = {
version: "0.8",
specialKeys: {
8: "backspace", 9: "tab", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause",
20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home",
37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del",
96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7",
104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/",
112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8",
120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 191: "/", 224: "meta"
},
shiftNums: {
"`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&",
"8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<",
".": ">", "/": "?", "\\": "|"
}
};
function keyHandler( handleObj ) {
// Only care when a possible input has been specified
if ( typeof handleObj.data !== "string" ) {
return;
}
var origHandler = handleObj.handler,
keys = handleObj.data.toLowerCase().split(" ");
handleObj.handler = function( event ) {
// Don't fire in text-accepting inputs that we didn't directly bind to
if ( this !== event.target && (/textarea|select/i.test( event.target.nodeName ) ||
event.target.type === "text") ) {
return;
}
// Keypress represents characters, not special keys
var special = event.type !== "keypress" && jQuery.hotkeys.specialKeys[ event.which ],
character = String.fromCharCode( event.which ).toLowerCase(),
key, modif = "", possible = {};
// check combinations (alt|ctrl|shift+anything)
if ( event.altKey && special !== "alt" ) {
modif += "alt+";
}
if ( event.ctrlKey && special !== "ctrl" ) {
modif += "ctrl+";
}
// TODO: Need to make sure this works consistently across platforms
if ( event.metaKey && !event.ctrlKey && special !== "meta" ) {
modif += "meta+";
}
if ( event.shiftKey && special !== "shift" ) {
modif += "shift+";
}
if ( special ) {
possible[ modif + special ] = true;
} else {
possible[ modif + character ] = true;
possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true;
// "$" can be triggered as "Shift+4" or "Shift+$" or just "$"
if ( modif === "shift+" ) {
possible[ jQuery.hotkeys.shiftNums[ character ] ] = true;
}
}
for ( var i = 0, l = keys.length; i < l; i++ ) {
if ( possible[ keys[i] ] ) {
return origHandler.apply( this, arguments );
}
}
};
}
jQuery.each([ "keydown", "keyup", "keypress" ], function() {
jQuery.event.special[ this ] = { add: keyHandler };
});
})( jQuery );

@ -0,0 +1,53 @@
/* Copyright (c) 2010
* @author Laurence Wheway
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* @version 1.2.0
*/
(function($) {
jQuery.extend({
isOnScreen: function(box, container) {
//ensure numbers come in as intgers (not strings) and remove 'px' is it's there
for(var i in box){box[i] = parseFloat(box[i])};
for(var i in container){container[i] = parseFloat(container[i])};
if(!container){
container = {
left: $(window).scrollLeft(),
top: $(window).scrollTop(),
width: $(window).width(),
height: $(window).height()
}
}
if( box.left+box.width-container.left > 0 &&
box.left < container.width+container.left &&
box.top+box.height-container.top > 0 &&
box.top < container.height+container.top
) return true;
return false;
}
})
jQuery.fn.isOnScreen = function (container) {
for(var i in container){container[i] = parseFloat(container[i])};
if(!container){
container = {
left: $(window).scrollLeft(),
top: $(window).scrollTop(),
width: $(window).width(),
height: $(window).height()
}
}
if( $(this).offset().left+$(this).width()-container.left > 0 &&
$(this).offset().left < container.width+container.left &&
$(this).offset().top+$(this).height()-container.top > 0 &&
$(this).offset().top < container.height+container.top
) return true;
return false;
}
})(jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

@ -0,0 +1,119 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for manage.py: 78%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>manage.py</b> :
<span class="pc_cov">78%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
9 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">7 run</span>
<span class="mis shortkey_m button_toggle_mis">2 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="stm run hide_run"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="stm mis"><a href="#n9">9</a></p>
<p id="n10" class="stm mis"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="stm run hide_run"><a href="#n15">15</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com">#!/usr/bin/env python</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">import</span> <span class="nam">sys</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="key">if</span> <span class="nam">__name__</span> <span class="op">==</span> <span class="str">'__main__'</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"> <span class="nam">os</span><span class="op">.</span><span class="nam">environ</span><span class="op">.</span><span class="nam">setdefault</span><span class="op">(</span><span class="str">'DJANGO_SETTINGS_MODULE'</span><span class="op">,</span> <span class="str">'WebStockPredict.settings'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">core</span><span class="op">.</span><span class="nam">management</span> <span class="key">import</span> <span class="nam">execute_from_command_line</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm mis"> <span class="key">except</span> <span class="nam">ImportError</span> <span class="key">as</span> <span class="nam">exc</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="stm mis"> <span class="key">raise</span> <span class="nam">ImportError</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"> <span class="str">"Couldn't import Django. Are you sure it's installed and "</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"> <span class="str">"available on your PYTHONPATH environment variable? Did you "</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"> <span class="str">"forget to activate a virtual environment?"</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"> <span class="op">)</span> <span class="key">from</span> <span class="nam">exc</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="stm run hide_run"> <span class="nam">execute_from_command_line</span><span class="op">(</span><span class="nam">sys</span><span class="op">.</span><span class="nam">argv</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\__init__.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\__init__.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
0 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">0 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
</td>
<td class="text">
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,113 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\add_companies_to_db.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\add_companies_to_db.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
8 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">8 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="stm run hide_run"><a href="#n10">10</a></p>
<p id="n11" class="stm run hide_run"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">from</span> <span class="nam">stock_predict</span> <span class="key">import</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">def</span> <span class="nam">add_company</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"> <span class="nam">companies</span> <span class="op">=</span> <span class="op">{</span><span class="str">"600718"</span><span class="op">:</span><span class="str">"&#19996;&#36719;&#38598;&#22242;"</span><span class="op">,</span><span class="str">"000651"</span><span class="op">:</span><span class="str">"&#26684;&#21147;&#30005;&#22120;"</span><span class="op">,</span><span class="str">"600839"</span><span class="op">:</span><span class="str">"&#22235;&#24029;&#38271;&#34425;"</span><span class="op">,</span><span class="str">"600320"</span><span class="op">:</span><span class="str">"&#25391;&#21326;&#37325;&#24037;"</span><span class="op">,</span><span class="str">"601988"</span><span class="op">:</span><span class="str">"&#20013;&#22269;&#38134;&#34892;"</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"> <span class="str">"000066"</span><span class="op">:</span> <span class="str">"&#20013;&#22269;&#38271;&#22478;"</span><span class="op">,</span><span class="str">"601766"</span><span class="op">:</span><span class="str">"&#20013;&#22269;&#20013;&#36710;"</span><span class="op">,</span><span class="str">"601390"</span><span class="op">:</span><span class="str">"&#20013;&#22269;&#20013;&#38081;"</span><span class="op">,</span><span class="str">"000768"</span><span class="op">:</span><span class="str">"&#20013;&#33322;&#39134;&#26426;"</span><span class="op">,</span><span class="str">"000063"</span><span class="op">:</span><span class="str">"&#20013;&#20852;&#36890;&#35759;"</span><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"> <span class="key">for</span> <span class="nam">code</span><span class="op">,</span><span class="nam">name</span> <span class="key">in</span> <span class="nam">companies</span><span class="op">.</span><span class="nam">items</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="nam">company</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">Company</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"> <span class="nam">company</span><span class="op">.</span><span class="nam">stock_code</span> <span class="op">=</span> <span class="nam">code</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="stm run hide_run"> <span class="nam">company</span><span class="op">.</span><span class="nam">name</span> <span class="op">=</span> <span class="nam">name</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="stm run hide_run"> <span class="nam">company</span><span class="op">.</span><span class="nam">save</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 15:25
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,103 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\admin.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\admin.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
5 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">5 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="stm run hide_run"><a href="#n2">2</a></p>
<p id="n3" class="pln"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">contrib</span> <span class="key">import</span> <span class="nam">admin</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm run hide_run"><span class="key">from</span> <span class="op">.</span><span class="nam">models</span> <span class="key">import</span> <span class="nam">Company</span><span class="op">,</span><span class="nam">HistoryData</span><span class="op">,</span><span class="nam">PredictData</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="pln"><span class="com"># Register your models here.</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="nam">admin</span><span class="op">.</span><span class="nam">site</span><span class="op">.</span><span class="nam">register</span><span class="op">(</span><span class="nam">Company</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="nam">admin</span><span class="op">.</span><span class="nam">site</span><span class="op">.</span><span class="nam">register</span><span class="op">(</span><span class="nam">HistoryData</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"><span class="nam">admin</span><span class="op">.</span><span class="nam">site</span><span class="op">.</span><span class="nam">register</span><span class="op">(</span><span class="nam">PredictData</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\apps.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\apps.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
3 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">3 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="pln"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">apps</span> <span class="key">import</span> <span class="nam">AppConfig</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"><span class="key">class</span> <span class="nam">StockPredictConfig</span><span class="op">(</span><span class="nam">AppConfig</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"> <span class="nam">name</span> <span class="op">=</span> <span class="str">'stock_predict'</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,167 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\migrations\0001_initial.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\migrations\0001_initial.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
6 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">6 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="pln"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="stm run hide_run"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="stm run hide_run"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="pln"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
<p id="n23" class="pln"><a href="#n23">23</a></p>
<p id="n24" class="pln"><a href="#n24">24</a></p>
<p id="n25" class="pln"><a href="#n25">25</a></p>
<p id="n26" class="pln"><a href="#n26">26</a></p>
<p id="n27" class="pln"><a href="#n27">27</a></p>
<p id="n28" class="pln"><a href="#n28">28</a></p>
<p id="n29" class="pln"><a href="#n29">29</a></p>
<p id="n30" class="pln"><a href="#n30">30</a></p>
<p id="n31" class="pln"><a href="#n31">31</a></p>
<p id="n32" class="pln"><a href="#n32">32</a></p>
<p id="n33" class="pln"><a href="#n33">33</a></p>
<p id="n34" class="pln"><a href="#n34">34</a></p>
<p id="n35" class="pln"><a href="#n35">35</a></p>
<p id="n36" class="pln"><a href="#n36">36</a></p>
<p id="n37" class="pln"><a href="#n37">37</a></p>
<p id="n38" class="pln"><a href="#n38">38</a></p>
<p id="n39" class="pln"><a href="#n39">39</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com"># Generated by Django 2.1.4 on 2018-12-12 03:15</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span> <span class="key">import</span> <span class="nam">migrations</span><span class="op">,</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"><span class="key">import</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span><span class="op">.</span><span class="nam">models</span><span class="op">.</span><span class="nam">deletion</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"><span class="key">class</span> <span class="nam">Migration</span><span class="op">(</span><span class="nam">migrations</span><span class="op">.</span><span class="nam">Migration</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"> <span class="nam">initial</span> <span class="op">=</span> <span class="key">True</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t11" class="stm run hide_run"> <span class="nam">dependencies</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t14" class="stm run hide_run"> <span class="nam">operations</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">CreateModel</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'Company'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"> <span class="nam">fields</span><span class="op">=</span><span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"> <span class="op">(</span><span class="str">'id'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">AutoField</span><span class="op">(</span><span class="nam">auto_created</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">primary_key</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">serialize</span><span class="op">=</span><span class="key">False</span><span class="op">,</span> <span class="nam">verbose_name</span><span class="op">=</span><span class="str">'ID'</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="pln"> <span class="op">(</span><span class="str">'stock_code'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">20</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"> <span class="op">(</span><span class="str">'name'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">100</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">CreateModel</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'HistoryData'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="pln"> <span class="nam">fields</span><span class="op">=</span><span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="pln"> <span class="op">(</span><span class="str">'id'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">AutoField</span><span class="op">(</span><span class="nam">auto_created</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">primary_key</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">serialize</span><span class="op">=</span><span class="key">False</span><span class="op">,</span> <span class="nam">verbose_name</span><span class="op">=</span><span class="str">'ID'</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="pln"> <span class="op">(</span><span class="str">'data'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">TextField</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="pln"> <span class="op">(</span><span class="str">'company'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">ForeignKey</span><span class="op">(</span><span class="nam">on_delete</span><span class="op">=</span><span class="nam">django</span><span class="op">.</span><span class="nam">db</span><span class="op">.</span><span class="nam">models</span><span class="op">.</span><span class="nam">deletion</span><span class="op">.</span><span class="nam">CASCADE</span><span class="op">,</span> <span class="nam">to</span><span class="op">=</span><span class="str">'stock_predict.Company'</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t30" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t31" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">CreateModel</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'PredictData'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t33" class="pln"> <span class="nam">fields</span><span class="op">=</span><span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="pln"> <span class="op">(</span><span class="str">'id'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">AutoField</span><span class="op">(</span><span class="nam">auto_created</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">primary_key</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">serialize</span><span class="op">=</span><span class="key">False</span><span class="op">,</span> <span class="nam">verbose_name</span><span class="op">=</span><span class="str">'ID'</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="pln"> <span class="op">(</span><span class="str">'data'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">TextField</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t36" class="pln"> <span class="op">(</span><span class="str">'company'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">ForeignKey</span><span class="op">(</span><span class="nam">on_delete</span><span class="op">=</span><span class="nam">django</span><span class="op">.</span><span class="nam">db</span><span class="op">.</span><span class="nam">models</span><span class="op">.</span><span class="nam">deletion</span><span class="op">.</span><span class="nam">CASCADE</span><span class="op">,</span> <span class="nam">to</span><span class="op">=</span><span class="str">'stock_predict.Company'</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,135 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\migrations\0002_auto_20181212_1138.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\migrations\0002_auto_20181212_1138.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
4 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">4 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="pln"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
<p id="n23" class="pln"><a href="#n23">23</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com"># Generated by Django 2.1.4 on 2018-12-12 03:38</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span> <span class="key">import</span> <span class="nam">migrations</span><span class="op">,</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="key">class</span> <span class="nam">Migration</span><span class="op">(</span><span class="nam">migrations</span><span class="op">.</span><span class="nam">Migration</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="nam">dependencies</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"> <span class="op">(</span><span class="str">'stock_predict'</span><span class="op">,</span> <span class="str">'0001_initial'</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"> <span class="nam">operations</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">AddField</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"> <span class="nam">model_name</span><span class="op">=</span><span class="str">'historydata'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'start_date'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"> <span class="nam">field</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">DateTimeField</span><span class="op">(</span><span class="nam">null</span><span class="op">=</span><span class="key">True</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">AddField</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="pln"> <span class="nam">model_name</span><span class="op">=</span><span class="str">'predictdata'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'start_date'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"> <span class="nam">field</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">DateTimeField</span><span class="op">(</span><span class="nam">null</span><span class="op">=</span><span class="key">True</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,135 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\migrations\0003_auto_20181212_1206.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\migrations\0003_auto_20181212_1206.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
4 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">4 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="pln"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
<p id="n23" class="pln"><a href="#n23">23</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com"># Generated by Django 2.1.4 on 2018-12-12 04:06</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span> <span class="key">import</span> <span class="nam">migrations</span><span class="op">,</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="key">class</span> <span class="nam">Migration</span><span class="op">(</span><span class="nam">migrations</span><span class="op">.</span><span class="nam">Migration</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="nam">dependencies</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"> <span class="op">(</span><span class="str">'stock_predict'</span><span class="op">,</span> <span class="str">'0002_auto_20181212_1138'</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"> <span class="nam">operations</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">AlterField</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"> <span class="nam">model_name</span><span class="op">=</span><span class="str">'historydata'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'start_date'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"> <span class="nam">field</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">DateField</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">AlterField</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="pln"> <span class="nam">model_name</span><span class="op">=</span><span class="str">'predictdata'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'start_date'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"> <span class="nam">field</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">DateField</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,135 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\migrations\0004_auto_20181213_1455.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\migrations\0004_auto_20181213_1455.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
4 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">4 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="pln"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
<p id="n23" class="pln"><a href="#n23">23</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com"># Generated by Django 2.1.4 on 2018-12-13 06:55</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span> <span class="key">import</span> <span class="nam">migrations</span><span class="op">,</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="key">class</span> <span class="nam">Migration</span><span class="op">(</span><span class="nam">migrations</span><span class="op">.</span><span class="nam">Migration</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="nam">dependencies</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"> <span class="op">(</span><span class="str">'stock_predict'</span><span class="op">,</span> <span class="str">'0003_auto_20181212_1206'</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"> <span class="nam">operations</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">AlterField</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"> <span class="nam">model_name</span><span class="op">=</span><span class="str">'historydata'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'start_date'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"> <span class="nam">field</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">30</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">AlterField</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="pln"> <span class="nam">model_name</span><span class="op">=</span><span class="str">'predictdata'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'start_date'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"> <span class="nam">field</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">30</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,145 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\migrations\0005_stockindex.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\migrations\0005_stockindex.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
5 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">5 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="pln"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="pln"><a href="#n12">12</a></p>
<p id="n13" class="stm run hide_run"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="pln"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
<p id="n23" class="pln"><a href="#n23">23</a></p>
<p id="n24" class="pln"><a href="#n24">24</a></p>
<p id="n25" class="pln"><a href="#n25">25</a></p>
<p id="n26" class="pln"><a href="#n26">26</a></p>
<p id="n27" class="pln"><a href="#n27">27</a></p>
<p id="n28" class="pln"><a href="#n28">28</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com"># Generated by Django 2.1.4 on 2018-12-22 01:36</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span> <span class="key">import</span> <span class="nam">migrations</span><span class="op">,</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"><span class="key">import</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span><span class="op">.</span><span class="nam">models</span><span class="op">.</span><span class="nam">deletion</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"><span class="key">class</span> <span class="nam">Migration</span><span class="op">(</span><span class="nam">migrations</span><span class="op">.</span><span class="nam">Migration</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"> <span class="nam">dependencies</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"> <span class="op">(</span><span class="str">'stock_predict'</span><span class="op">,</span> <span class="str">'0004_auto_20181213_1455'</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t13" class="stm run hide_run"> <span class="nam">operations</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">CreateModel</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'StockIndex'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"> <span class="nam">fields</span><span class="op">=</span><span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"> <span class="op">(</span><span class="str">'id'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">AutoField</span><span class="op">(</span><span class="nam">auto_created</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">primary_key</span><span class="op">=</span><span class="key">True</span><span class="op">,</span> <span class="nam">serialize</span><span class="op">=</span><span class="key">False</span><span class="op">,</span> <span class="nam">verbose_name</span><span class="op">=</span><span class="str">'ID'</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"> <span class="op">(</span><span class="str">'ri_qi'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">30</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="pln"> <span class="op">(</span><span class="str">'zi_jin'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"> <span class="op">(</span><span class="str">'qiang_du'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"> <span class="op">(</span><span class="str">'feng_xian'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"> <span class="op">(</span><span class="str">'zhuan_qiang'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="pln"> <span class="op">(</span><span class="str">'chang_yu'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="pln"> <span class="op">(</span><span class="str">'jin_zi'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="pln"> <span class="op">(</span><span class="str">'company'</span><span class="op">,</span> <span class="nam">models</span><span class="op">.</span><span class="nam">ForeignKey</span><span class="op">(</span><span class="nam">on_delete</span><span class="op">=</span><span class="nam">django</span><span class="op">.</span><span class="nam">db</span><span class="op">.</span><span class="nam">models</span><span class="op">.</span><span class="nam">deletion</span><span class="op">.</span><span class="nam">CASCADE</span><span class="op">,</span> <span class="nam">to</span><span class="op">=</span><span class="str">'stock_predict.Company'</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 13:36
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,125 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\migrations\0006_stockindex_zong_he.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\migrations\0006_stockindex_zong_he.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
4 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">4 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="pln"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
</td>
<td class="text">
<p id="t1" class="pln"><span class="com"># Generated by Django 2.1.4 on 2018-12-22 02:03</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span> <span class="key">import</span> <span class="nam">migrations</span><span class="op">,</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="key">class</span> <span class="nam">Migration</span><span class="op">(</span><span class="nam">migrations</span><span class="op">.</span><span class="nam">Migration</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="nam">dependencies</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"> <span class="op">(</span><span class="str">'stock_predict'</span><span class="op">,</span> <span class="str">'0005_stockindex'</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"> <span class="nam">operations</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"> <span class="nam">migrations</span><span class="op">.</span><span class="nam">AddField</span><span class="op">(</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"> <span class="nam">model_name</span><span class="op">=</span><span class="str">'stockindex'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"> <span class="nam">name</span><span class="op">=</span><span class="str">'zong_he'</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"> <span class="nam">field</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"> <span class="op">]</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 13:36
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\migrations\__init__.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\migrations\__init__.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
0 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">0 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
</td>
<td class="text">
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 12:11
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,203 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\models.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\models.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
43 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">43 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="pln"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="pln"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="stm run hide_run"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="stm run hide_run"><a href="#n13">13</a></p>
<p id="n14" class="stm run hide_run"><a href="#n14">14</a></p>
<p id="n15" class="stm run hide_run"><a href="#n15">15</a></p>
<p id="n16" class="stm run hide_run"><a href="#n16">16</a></p>
<p id="n17" class="stm run hide_run"><a href="#n17">17</a></p>
<p id="n18" class="stm run hide_run"><a href="#n18">18</a></p>
<p id="n19" class="stm run hide_run"><a href="#n19">19</a></p>
<p id="n20" class="stm run hide_run"><a href="#n20">20</a></p>
<p id="n21" class="pln"><a href="#n21">21</a></p>
<p id="n22" class="pln"><a href="#n22">22</a></p>
<p id="n23" class="stm run hide_run"><a href="#n23">23</a></p>
<p id="n24" class="stm run hide_run"><a href="#n24">24</a></p>
<p id="n25" class="stm run hide_run"><a href="#n25">25</a></p>
<p id="n26" class="stm run hide_run"><a href="#n26">26</a></p>
<p id="n27" class="pln"><a href="#n27">27</a></p>
<p id="n28" class="stm run hide_run"><a href="#n28">28</a></p>
<p id="n29" class="stm run hide_run"><a href="#n29">29</a></p>
<p id="n30" class="stm run hide_run"><a href="#n30">30</a></p>
<p id="n31" class="stm run hide_run"><a href="#n31">31</a></p>
<p id="n32" class="stm run hide_run"><a href="#n32">32</a></p>
<p id="n33" class="stm run hide_run"><a href="#n33">33</a></p>
<p id="n34" class="pln"><a href="#n34">34</a></p>
<p id="n35" class="stm run hide_run"><a href="#n35">35</a></p>
<p id="n36" class="stm run hide_run"><a href="#n36">36</a></p>
<p id="n37" class="pln"><a href="#n37">37</a></p>
<p id="n38" class="stm run hide_run"><a href="#n38">38</a></p>
<p id="n39" class="stm run hide_run"><a href="#n39">39</a></p>
<p id="n40" class="pln"><a href="#n40">40</a></p>
<p id="n41" class="stm run hide_run"><a href="#n41">41</a></p>
<p id="n42" class="stm run hide_run"><a href="#n42">42</a></p>
<p id="n43" class="stm run hide_run"><a href="#n43">43</a></p>
<p id="n44" class="stm run hide_run"><a href="#n44">44</a></p>
<p id="n45" class="pln"><a href="#n45">45</a></p>
<p id="n46" class="stm run hide_run"><a href="#n46">46</a></p>
<p id="n47" class="stm run hide_run"><a href="#n47">47</a></p>
<p id="n48" class="stm run hide_run"><a href="#n48">48</a></p>
<p id="n49" class="stm run hide_run"><a href="#n49">49</a></p>
<p id="n50" class="stm run hide_run"><a href="#n50">50</a></p>
<p id="n51" class="stm run hide_run"><a href="#n51">51</a></p>
<p id="n52" class="pln"><a href="#n52">52</a></p>
<p id="n53" class="stm run hide_run"><a href="#n53">53</a></p>
<p id="n54" class="stm run hide_run"><a href="#n54">54</a></p>
<p id="n55" class="pln"><a href="#n55">55</a></p>
<p id="n56" class="stm run hide_run"><a href="#n56">56</a></p>
<p id="n57" class="stm run hide_run"><a href="#n57">57</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">import</span> <span class="nam">json</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">db</span> <span class="key">import</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="pln"><span class="com"># Create your models here.</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"><span class="key">class</span> <span class="nam">Company</span><span class="op">(</span><span class="nam">models</span><span class="op">.</span><span class="nam">Model</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"> <span class="nam">stock_code</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">20</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"> <span class="nam">name</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">100</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t11" class="stm run hide_run"><span class="key">class</span> <span class="nam">StockIndex</span><span class="op">(</span><span class="nam">models</span><span class="op">.</span><span class="nam">Model</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"> <span class="nam">company</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">ForeignKey</span><span class="op">(</span><span class="nam">Company</span><span class="op">,</span> <span class="nam">on_delete</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">CASCADE</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="stm run hide_run"> <span class="nam">ri_qi</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">30</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t14" class="stm run hide_run"> <span class="nam">zi_jin</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="stm run hide_run"> <span class="nam">qiang_du</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="stm run hide_run"> <span class="nam">feng_xian</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="stm run hide_run"> <span class="nam">zhuan_qiang</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="stm run hide_run"> <span class="nam">chang_yu</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="stm run hide_run"> <span class="nam">jin_zi</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="stm run hide_run"> <span class="nam">zong_he</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">IntegerField</span><span class="op">(</span><span class="nam">default</span><span class="op">=</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t22" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm run hide_run"><span class="key">class</span> <span class="nam">HistoryData</span><span class="op">(</span><span class="nam">models</span><span class="op">.</span><span class="nam">Model</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="stm run hide_run"> <span class="nam">company</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">ForeignKey</span><span class="op">(</span><span class="nam">Company</span><span class="op">,</span> <span class="nam">on_delete</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">CASCADE</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="stm run hide_run"> <span class="nam">data</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">TextField</span><span class="op">(</span><span class="op">)</span> <span class="com"># &#23383;&#31526;&#20018;&#31867;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="stm run hide_run"> <span class="nam">start_date</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">30</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t28" class="stm run hide_run"> <span class="key">def</span> <span class="nam">set_data</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span><span class="nam">list_data</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#23558;list&#31867;&#22411;&#25968;&#25454;&#65292;&#36716;&#20026;&#23383;&#31526;&#20018;&#23384;&#20648;</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t30" class="stm run hide_run"> <span class="nam">start_da</span> <span class="op">=</span> <span class="nam">list_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="com"># &#35760;&#24405;&#31532;&#19968;&#26465;&#25968;&#25454;&#30340;&#26085;&#26399;</span><span class="strut">&nbsp;</span></p>
<p id="t31" class="stm run hide_run"> <span class="nam">data_json</span> <span class="op">=</span> <span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="nam">list_data</span><span class="op">)</span> <span class="com"># &#21487;&#20197;&#23558;list&#25110;dict&#31867;&#22411; &#36716;&#20026;&#23383;&#31526;&#20018;</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="stm run hide_run"> <span class="key">except</span> <span class="op">(</span><span class="nam">KeyError</span><span class="op">,</span><span class="nam">TypeError</span><span class="op">,</span><span class="nam">IndexError</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t33" class="stm run hide_run"> <span class="key">raise</span> <span class="nam">Exception</span><span class="op">(</span><span class="str">"list_data must be 2 dimensions list."</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">start_date</span> <span class="op">=</span> <span class="nam">start_da</span><span class="strut">&nbsp;</span></p>
<p id="t36" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">data</span> <span class="op">=</span> <span class="nam">data_json</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t38" class="stm run hide_run"> <span class="key">def</span> <span class="nam">get_data</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="stm run hide_run"> <span class="key">return</span> <span class="nam">json</span><span class="op">.</span><span class="nam">loads</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span> <span class="com"># &#21487;&#20197;&#23558;&#23383;&#31526;&#20018; &#36716;&#20026;list&#25110;dict&#31867;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t40" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t41" class="stm run hide_run"><span class="key">class</span> <span class="nam">PredictData</span><span class="op">(</span><span class="nam">models</span><span class="op">.</span><span class="nam">Model</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t42" class="stm run hide_run"> <span class="nam">company</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">ForeignKey</span><span class="op">(</span><span class="nam">Company</span><span class="op">,</span> <span class="nam">on_delete</span><span class="op">=</span><span class="nam">models</span><span class="op">.</span><span class="nam">CASCADE</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t43" class="stm run hide_run"> <span class="nam">data</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">TextField</span><span class="op">(</span><span class="op">)</span> <span class="com"># &#23383;&#31526;&#20018;&#31867;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="stm run hide_run"> <span class="nam">start_date</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">CharField</span><span class="op">(</span><span class="nam">max_length</span><span class="op">=</span><span class="num">30</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t46" class="stm run hide_run"> <span class="key">def</span> <span class="nam">set_data</span><span class="op">(</span><span class="nam">self</span><span class="op">,</span> <span class="nam">list_data</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#23558;list&#31867;&#22411;&#25968;&#25454;&#65292;&#36716;&#20026;&#23383;&#31526;&#20018;&#23384;&#20648;</span><span class="strut">&nbsp;</span></p>
<p id="t47" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t48" class="stm run hide_run"> <span class="nam">st_da</span> <span class="op">=</span> <span class="nam">list_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span> <span class="com"># &#35760;&#24405;&#31532;&#19968;&#26465;&#25968;&#25454;&#30340;&#26085;&#26399;</span><span class="strut">&nbsp;</span></p>
<p id="t49" class="stm run hide_run"> <span class="nam">data_json</span> <span class="op">=</span> <span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="nam">list_data</span><span class="op">)</span> <span class="com"># &#21487;&#20197;&#23558;list&#25110;dict&#31867;&#22411; &#36716;&#20026;&#23383;&#31526;&#20018;</span><span class="strut">&nbsp;</span></p>
<p id="t50" class="stm run hide_run"> <span class="key">except</span> <span class="op">(</span><span class="nam">KeyError</span><span class="op">,</span><span class="nam">TypeError</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="stm run hide_run"> <span class="key">raise</span> <span class="nam">Exception</span><span class="op">(</span><span class="str">"list_data must be 2 dimensions list."</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t52" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t53" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">start_date</span> <span class="op">=</span> <span class="nam">st_da</span><span class="strut">&nbsp;</span></p>
<p id="t54" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">data</span> <span class="op">=</span> <span class="nam">data_json</span><span class="strut">&nbsp;</span></p>
<p id="t55" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t56" class="stm run hide_run"> <span class="key">def</span> <span class="nam">get_data</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t57" class="stm run hide_run"> <span class="key">return</span> <span class="nam">json</span><span class="op">.</span><span class="nam">loads</span><span class="op">(</span><span class="nam">self</span><span class="op">.</span><span class="nam">data</span><span class="op">)</span> <span class="com"># &#21487;&#20197;&#23558;&#23383;&#31526;&#20018; &#36716;&#20026;list&#25110;dict&#31867;&#22411;</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 15:25
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,675 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\tests.py: 99%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\tests.py</b> :
<span class="pc_cov">99%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
170 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">168 run</span>
<span class="mis shortkey_m button_toggle_mis">2 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="stm run hide_run"><a href="#n2">2</a></p>
<p id="n3" class="pln"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="stm run hide_run"><a href="#n10">10</a></p>
<p id="n11" class="stm run hide_run"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="stm run hide_run"><a href="#n14">14</a></p>
<p id="n15" class="stm run hide_run"><a href="#n15">15</a></p>
<p id="n16" class="pln"><a href="#n16">16</a></p>
<p id="n17" class="pln"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="stm run hide_run"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="stm run hide_run"><a href="#n21">21</a></p>
<p id="n22" class="stm run hide_run"><a href="#n22">22</a></p>
<p id="n23" class="stm run hide_run"><a href="#n23">23</a></p>
<p id="n24" class="stm run hide_run"><a href="#n24">24</a></p>
<p id="n25" class="stm run hide_run"><a href="#n25">25</a></p>
<p id="n26" class="stm run hide_run"><a href="#n26">26</a></p>
<p id="n27" class="stm run hide_run"><a href="#n27">27</a></p>
<p id="n28" class="stm run hide_run"><a href="#n28">28</a></p>
<p id="n29" class="pln"><a href="#n29">29</a></p>
<p id="n30" class="pln"><a href="#n30">30</a></p>
<p id="n31" class="stm run hide_run"><a href="#n31">31</a></p>
<p id="n32" class="pln"><a href="#n32">32</a></p>
<p id="n33" class="pln"><a href="#n33">33</a></p>
<p id="n34" class="pln"><a href="#n34">34</a></p>
<p id="n35" class="stm run hide_run"><a href="#n35">35</a></p>
<p id="n36" class="stm run hide_run"><a href="#n36">36</a></p>
<p id="n37" class="stm run hide_run"><a href="#n37">37</a></p>
<p id="n38" class="stm run hide_run"><a href="#n38">38</a></p>
<p id="n39" class="stm run hide_run"><a href="#n39">39</a></p>
<p id="n40" class="pln"><a href="#n40">40</a></p>
<p id="n41" class="stm run hide_run"><a href="#n41">41</a></p>
<p id="n42" class="pln"><a href="#n42">42</a></p>
<p id="n43" class="pln"><a href="#n43">43</a></p>
<p id="n44" class="pln"><a href="#n44">44</a></p>
<p id="n45" class="stm run hide_run"><a href="#n45">45</a></p>
<p id="n46" class="stm run hide_run"><a href="#n46">46</a></p>
<p id="n47" class="stm run hide_run"><a href="#n47">47</a></p>
<p id="n48" class="stm run hide_run"><a href="#n48">48</a></p>
<p id="n49" class="pln"><a href="#n49">49</a></p>
<p id="n50" class="stm run hide_run"><a href="#n50">50</a></p>
<p id="n51" class="stm run hide_run"><a href="#n51">51</a></p>
<p id="n52" class="pln"><a href="#n52">52</a></p>
<p id="n53" class="pln"><a href="#n53">53</a></p>
<p id="n54" class="pln"><a href="#n54">54</a></p>
<p id="n55" class="stm run hide_run"><a href="#n55">55</a></p>
<p id="n56" class="pln"><a href="#n56">56</a></p>
<p id="n57" class="stm run hide_run"><a href="#n57">57</a></p>
<p id="n58" class="stm run hide_run"><a href="#n58">58</a></p>
<p id="n59" class="stm run hide_run"><a href="#n59">59</a></p>
<p id="n60" class="stm run hide_run"><a href="#n60">60</a></p>
<p id="n61" class="stm run hide_run"><a href="#n61">61</a></p>
<p id="n62" class="stm run hide_run"><a href="#n62">62</a></p>
<p id="n63" class="stm run hide_run"><a href="#n63">63</a></p>
<p id="n64" class="stm run hide_run"><a href="#n64">64</a></p>
<p id="n65" class="pln"><a href="#n65">65</a></p>
<p id="n66" class="pln"><a href="#n66">66</a></p>
<p id="n67" class="stm run hide_run"><a href="#n67">67</a></p>
<p id="n68" class="pln"><a href="#n68">68</a></p>
<p id="n69" class="pln"><a href="#n69">69</a></p>
<p id="n70" class="pln"><a href="#n70">70</a></p>
<p id="n71" class="stm run hide_run"><a href="#n71">71</a></p>
<p id="n72" class="stm run hide_run"><a href="#n72">72</a></p>
<p id="n73" class="stm run hide_run"><a href="#n73">73</a></p>
<p id="n74" class="stm run hide_run"><a href="#n74">74</a></p>
<p id="n75" class="stm run hide_run"><a href="#n75">75</a></p>
<p id="n76" class="pln"><a href="#n76">76</a></p>
<p id="n77" class="stm run hide_run"><a href="#n77">77</a></p>
<p id="n78" class="pln"><a href="#n78">78</a></p>
<p id="n79" class="pln"><a href="#n79">79</a></p>
<p id="n80" class="pln"><a href="#n80">80</a></p>
<p id="n81" class="stm run hide_run"><a href="#n81">81</a></p>
<p id="n82" class="stm run hide_run"><a href="#n82">82</a></p>
<p id="n83" class="stm run hide_run"><a href="#n83">83</a></p>
<p id="n84" class="stm run hide_run"><a href="#n84">84</a></p>
<p id="n85" class="pln"><a href="#n85">85</a></p>
<p id="n86" class="pln"><a href="#n86">86</a></p>
<p id="n87" class="stm run hide_run"><a href="#n87">87</a></p>
<p id="n88" class="stm run hide_run"><a href="#n88">88</a></p>
<p id="n89" class="pln"><a href="#n89">89</a></p>
<p id="n90" class="stm run hide_run"><a href="#n90">90</a></p>
<p id="n91" class="pln"><a href="#n91">91</a></p>
<p id="n92" class="pln"><a href="#n92">92</a></p>
<p id="n93" class="pln"><a href="#n93">93</a></p>
<p id="n94" class="stm run hide_run"><a href="#n94">94</a></p>
<p id="n95" class="pln"><a href="#n95">95</a></p>
<p id="n96" class="pln"><a href="#n96">96</a></p>
<p id="n97" class="pln"><a href="#n97">97</a></p>
<p id="n98" class="stm run hide_run"><a href="#n98">98</a></p>
<p id="n99" class="stm run hide_run"><a href="#n99">99</a></p>
<p id="n100" class="stm run hide_run"><a href="#n100">100</a></p>
<p id="n101" class="stm run hide_run"><a href="#n101">101</a></p>
<p id="n102" class="stm run hide_run"><a href="#n102">102</a></p>
<p id="n103" class="pln"><a href="#n103">103</a></p>
<p id="n104" class="stm run hide_run"><a href="#n104">104</a></p>
<p id="n105" class="pln"><a href="#n105">105</a></p>
<p id="n106" class="pln"><a href="#n106">106</a></p>
<p id="n107" class="pln"><a href="#n107">107</a></p>
<p id="n108" class="stm run hide_run"><a href="#n108">108</a></p>
<p id="n109" class="stm run hide_run"><a href="#n109">109</a></p>
<p id="n110" class="pln"><a href="#n110">110</a></p>
<p id="n111" class="stm run hide_run"><a href="#n111">111</a></p>
<p id="n112" class="stm run hide_run"><a href="#n112">112</a></p>
<p id="n113" class="stm run hide_run"><a href="#n113">113</a></p>
<p id="n114" class="pln"><a href="#n114">114</a></p>
<p id="n115" class="stm run hide_run"><a href="#n115">115</a></p>
<p id="n116" class="stm run hide_run"><a href="#n116">116</a></p>
<p id="n117" class="pln"><a href="#n117">117</a></p>
<p id="n118" class="stm run hide_run"><a href="#n118">118</a></p>
<p id="n119" class="stm run hide_run"><a href="#n119">119</a></p>
<p id="n120" class="stm run hide_run"><a href="#n120">120</a></p>
<p id="n121" class="pln"><a href="#n121">121</a></p>
<p id="n122" class="stm run hide_run"><a href="#n122">122</a></p>
<p id="n123" class="pln"><a href="#n123">123</a></p>
<p id="n124" class="pln"><a href="#n124">124</a></p>
<p id="n125" class="pln"><a href="#n125">125</a></p>
<p id="n126" class="stm run hide_run"><a href="#n126">126</a></p>
<p id="n127" class="stm run hide_run"><a href="#n127">127</a></p>
<p id="n128" class="stm run hide_run"><a href="#n128">128</a></p>
<p id="n129" class="stm run hide_run"><a href="#n129">129</a></p>
<p id="n130" class="stm run hide_run"><a href="#n130">130</a></p>
<p id="n131" class="stm run hide_run"><a href="#n131">131</a></p>
<p id="n132" class="pln"><a href="#n132">132</a></p>
<p id="n133" class="stm run hide_run"><a href="#n133">133</a></p>
<p id="n134" class="stm run hide_run"><a href="#n134">134</a></p>
<p id="n135" class="stm run hide_run"><a href="#n135">135</a></p>
<p id="n136" class="stm mis"><a href="#n136">136</a></p>
<p id="n137" class="stm mis"><a href="#n137">137</a></p>
<p id="n138" class="pln"><a href="#n138">138</a></p>
<p id="n139" class="stm run hide_run"><a href="#n139">139</a></p>
<p id="n140" class="pln"><a href="#n140">140</a></p>
<p id="n141" class="pln"><a href="#n141">141</a></p>
<p id="n142" class="stm run hide_run"><a href="#n142">142</a></p>
<p id="n143" class="pln"><a href="#n143">143</a></p>
<p id="n144" class="pln"><a href="#n144">144</a></p>
<p id="n145" class="pln"><a href="#n145">145</a></p>
<p id="n146" class="stm run hide_run"><a href="#n146">146</a></p>
<p id="n147" class="pln"><a href="#n147">147</a></p>
<p id="n148" class="stm run hide_run"><a href="#n148">148</a></p>
<p id="n149" class="stm run hide_run"><a href="#n149">149</a></p>
<p id="n150" class="pln"><a href="#n150">150</a></p>
<p id="n151" class="stm run hide_run"><a href="#n151">151</a></p>
<p id="n152" class="stm run hide_run"><a href="#n152">152</a></p>
<p id="n153" class="stm run hide_run"><a href="#n153">153</a></p>
<p id="n154" class="pln"><a href="#n154">154</a></p>
<p id="n155" class="stm run hide_run"><a href="#n155">155</a></p>
<p id="n156" class="stm run hide_run"><a href="#n156">156</a></p>
<p id="n157" class="stm run hide_run"><a href="#n157">157</a></p>
<p id="n158" class="stm run hide_run"><a href="#n158">158</a></p>
<p id="n159" class="stm run hide_run"><a href="#n159">159</a></p>
<p id="n160" class="stm run hide_run"><a href="#n160">160</a></p>
<p id="n161" class="pln"><a href="#n161">161</a></p>
<p id="n162" class="stm run hide_run"><a href="#n162">162</a></p>
<p id="n163" class="stm run hide_run"><a href="#n163">163</a></p>
<p id="n164" class="pln"><a href="#n164">164</a></p>
<p id="n165" class="pln"><a href="#n165">165</a></p>
<p id="n166" class="pln"><a href="#n166">166</a></p>
<p id="n167" class="stm run hide_run"><a href="#n167">167</a></p>
<p id="n168" class="stm run hide_run"><a href="#n168">168</a></p>
<p id="n169" class="stm run hide_run"><a href="#n169">169</a></p>
<p id="n170" class="stm run hide_run"><a href="#n170">170</a></p>
<p id="n171" class="stm run hide_run"><a href="#n171">171</a></p>
<p id="n172" class="stm run hide_run"><a href="#n172">172</a></p>
<p id="n173" class="pln"><a href="#n173">173</a></p>
<p id="n174" class="pln"><a href="#n174">174</a></p>
<p id="n175" class="stm run hide_run"><a href="#n175">175</a></p>
<p id="n176" class="stm run hide_run"><a href="#n176">176</a></p>
<p id="n177" class="pln"><a href="#n177">177</a></p>
<p id="n178" class="pln"><a href="#n178">178</a></p>
<p id="n179" class="stm run hide_run"><a href="#n179">179</a></p>
<p id="n180" class="pln"><a href="#n180">180</a></p>
<p id="n181" class="pln"><a href="#n181">181</a></p>
<p id="n182" class="stm run hide_run"><a href="#n182">182</a></p>
<p id="n183" class="pln"><a href="#n183">183</a></p>
<p id="n184" class="pln"><a href="#n184">184</a></p>
<p id="n185" class="stm run hide_run"><a href="#n185">185</a></p>
<p id="n186" class="pln"><a href="#n186">186</a></p>
<p id="n187" class="pln"><a href="#n187">187</a></p>
<p id="n188" class="pln"><a href="#n188">188</a></p>
<p id="n189" class="stm run hide_run"><a href="#n189">189</a></p>
<p id="n190" class="pln"><a href="#n190">190</a></p>
<p id="n191" class="pln"><a href="#n191">191</a></p>
<p id="n192" class="pln"><a href="#n192">192</a></p>
<p id="n193" class="stm run hide_run"><a href="#n193">193</a></p>
<p id="n194" class="pln"><a href="#n194">194</a></p>
<p id="n195" class="pln"><a href="#n195">195</a></p>
<p id="n196" class="pln"><a href="#n196">196</a></p>
<p id="n197" class="stm run hide_run"><a href="#n197">197</a></p>
<p id="n198" class="pln"><a href="#n198">198</a></p>
<p id="n199" class="pln"><a href="#n199">199</a></p>
<p id="n200" class="stm run hide_run"><a href="#n200">200</a></p>
<p id="n201" class="stm run hide_run"><a href="#n201">201</a></p>
<p id="n202" class="stm run hide_run"><a href="#n202">202</a></p>
<p id="n203" class="stm run hide_run"><a href="#n203">203</a></p>
<p id="n204" class="pln"><a href="#n204">204</a></p>
<p id="n205" class="stm run hide_run"><a href="#n205">205</a></p>
<p id="n206" class="stm run hide_run"><a href="#n206">206</a></p>
<p id="n207" class="pln"><a href="#n207">207</a></p>
<p id="n208" class="stm run hide_run"><a href="#n208">208</a></p>
<p id="n209" class="stm run hide_run"><a href="#n209">209</a></p>
<p id="n210" class="stm run hide_run"><a href="#n210">210</a></p>
<p id="n211" class="pln"><a href="#n211">211</a></p>
<p id="n212" class="pln"><a href="#n212">212</a></p>
<p id="n213" class="pln"><a href="#n213">213</a></p>
<p id="n214" class="pln"><a href="#n214">214</a></p>
<p id="n215" class="stm run hide_run"><a href="#n215">215</a></p>
<p id="n216" class="stm run hide_run"><a href="#n216">216</a></p>
<p id="n217" class="stm run hide_run"><a href="#n217">217</a></p>
<p id="n218" class="pln"><a href="#n218">218</a></p>
<p id="n219" class="stm run hide_run"><a href="#n219">219</a></p>
<p id="n220" class="stm run hide_run"><a href="#n220">220</a></p>
<p id="n221" class="stm run hide_run"><a href="#n221">221</a></p>
<p id="n222" class="stm run hide_run"><a href="#n222">222</a></p>
<p id="n223" class="stm run hide_run"><a href="#n223">223</a></p>
<p id="n224" class="stm run hide_run"><a href="#n224">224</a></p>
<p id="n225" class="stm run hide_run"><a href="#n225">225</a></p>
<p id="n226" class="stm run hide_run"><a href="#n226">226</a></p>
<p id="n227" class="stm run hide_run"><a href="#n227">227</a></p>
<p id="n228" class="stm run hide_run"><a href="#n228">228</a></p>
<p id="n229" class="pln"><a href="#n229">229</a></p>
<p id="n230" class="pln"><a href="#n230">230</a></p>
<p id="n231" class="stm run hide_run"><a href="#n231">231</a></p>
<p id="n232" class="stm run hide_run"><a href="#n232">232</a></p>
<p id="n233" class="pln"><a href="#n233">233</a></p>
<p id="n234" class="pln"><a href="#n234">234</a></p>
<p id="n235" class="pln"><a href="#n235">235</a></p>
<p id="n236" class="stm run hide_run"><a href="#n236">236</a></p>
<p id="n237" class="stm run hide_run"><a href="#n237">237</a></p>
<p id="n238" class="stm run hide_run"><a href="#n238">238</a></p>
<p id="n239" class="pln"><a href="#n239">239</a></p>
<p id="n240" class="stm run hide_run"><a href="#n240">240</a></p>
<p id="n241" class="pln"><a href="#n241">241</a></p>
<p id="n242" class="pln"><a href="#n242">242</a></p>
<p id="n243" class="pln"><a href="#n243">243</a></p>
<p id="n244" class="stm run hide_run"><a href="#n244">244</a></p>
<p id="n245" class="stm run hide_run"><a href="#n245">245</a></p>
<p id="n246" class="stm run hide_run"><a href="#n246">246</a></p>
<p id="n247" class="pln"><a href="#n247">247</a></p>
<p id="n248" class="stm run hide_run"><a href="#n248">248</a></p>
<p id="n249" class="stm run hide_run"><a href="#n249">249</a></p>
<p id="n250" class="stm run hide_run"><a href="#n250">250</a></p>
<p id="n251" class="stm run hide_run"><a href="#n251">251</a></p>
<p id="n252" class="stm run hide_run"><a href="#n252">252</a></p>
<p id="n253" class="stm run hide_run"><a href="#n253">253</a></p>
<p id="n254" class="stm run hide_run"><a href="#n254">254</a></p>
<p id="n255" class="stm run hide_run"><a href="#n255">255</a></p>
<p id="n256" class="stm run hide_run"><a href="#n256">256</a></p>
<p id="n257" class="pln"><a href="#n257">257</a></p>
<p id="n258" class="pln"><a href="#n258">258</a></p>
<p id="n259" class="stm run hide_run"><a href="#n259">259</a></p>
<p id="n260" class="pln"><a href="#n260">260</a></p>
<p id="n261" class="pln"><a href="#n261">261</a></p>
<p id="n262" class="pln"><a href="#n262">262</a></p>
<p id="n263" class="stm run hide_run"><a href="#n263">263</a></p>
<p id="n264" class="pln"><a href="#n264">264</a></p>
<p id="n265" class="pln"><a href="#n265">265</a></p>
<p id="n266" class="pln"><a href="#n266">266</a></p>
<p id="n267" class="stm run hide_run"><a href="#n267">267</a></p>
<p id="n268" class="pln"><a href="#n268">268</a></p>
<p id="n269" class="stm run hide_run"><a href="#n269">269</a></p>
<p id="n270" class="stm run hide_run"><a href="#n270">270</a></p>
<p id="n271" class="stm run hide_run"><a href="#n271">271</a></p>
<p id="n272" class="stm run hide_run"><a href="#n272">272</a></p>
<p id="n273" class="stm run hide_run"><a href="#n273">273</a></p>
<p id="n274" class="pln"><a href="#n274">274</a></p>
<p id="n275" class="stm run hide_run"><a href="#n275">275</a></p>
<p id="n276" class="stm run hide_run"><a href="#n276">276</a></p>
<p id="n277" class="pln"><a href="#n277">277</a></p>
<p id="n278" class="pln"><a href="#n278">278</a></p>
<p id="n279" class="pln"><a href="#n279">279</a></p>
<p id="n280" class="stm run hide_run"><a href="#n280">280</a></p>
<p id="n281" class="pln"><a href="#n281">281</a></p>
<p id="n282" class="stm run hide_run"><a href="#n282">282</a></p>
<p id="n283" class="stm run hide_run"><a href="#n283">283</a></p>
<p id="n284" class="pln"><a href="#n284">284</a></p>
<p id="n285" class="pln"><a href="#n285">285</a></p>
<p id="n286" class="pln"><a href="#n286">286</a></p>
<p id="n287" class="stm run hide_run"><a href="#n287">287</a></p>
<p id="n288" class="pln"><a href="#n288">288</a></p>
<p id="n289" class="pln"><a href="#n289">289</a></p>
<p id="n290" class="pln"><a href="#n290">290</a></p>
<p id="n291" class="pln"><a href="#n291">291</a></p>
<p id="n292" class="pln"><a href="#n292">292</a></p>
<p id="n293" class="pln"><a href="#n293">293</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">import</span> <span class="nam">json</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm run hide_run"><span class="key">from</span> <span class="nam">datetime</span> <span class="key">import</span> <span class="nam">datetime</span><span class="op">,</span> <span class="nam">timedelta</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">http</span> <span class="key">import</span> <span class="nam">Http404</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">test</span> <span class="key">import</span> <span class="nam">TestCase</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">urls</span> <span class="key">import</span> <span class="nam">reverse</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"><span class="key">from</span> <span class="nam">LSTMPredictStock</span> <span class="key">import</span> <span class="nam">run</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"><span class="key">from</span> <span class="op">.</span><span class="nam">models</span> <span class="key">import</span> <span class="nam">Company</span><span class="op">,</span> <span class="nam">HistoryData</span><span class="op">,</span> <span class="nam">PredictData</span><span class="op">,</span> <span class="nam">StockIndex</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="stm run hide_run"><span class="key">from</span> <span class="op">.</span><span class="nam">views</span> <span class="key">import</span> <span class="nam">get_hist_predict_data</span><span class="op">,</span><span class="nam">get_crawl_save_data</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="stm run hide_run"><span class="key">from</span> <span class="op">.</span><span class="nam">add_companies_to_db</span> <span class="key">import</span> <span class="nam">add_company</span><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"><span class="key">from</span> <span class="nam">apscheduler</span><span class="op">.</span><span class="nam">scheduler</span> <span class="key">import</span> <span class="nam">Scheduler</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t14" class="stm run hide_run"><span class="key">class</span> <span class="nam">HistoryDataModelTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_set_data_with_not_list</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t16" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="pln"><span class="str"> &#27979;&#35797;&#20351;&#29992;&#38750;list&#31867;&#22411;&#20256;&#20837;set_data&#65292;&#24212;&#35813;&#25243;&#20986;&#24322;&#24120;</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="stm run hide_run"> <span class="nam">hd</span> <span class="op">=</span> <span class="nam">HistoryData</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"> <span class="com"># &#27979;&#35797;&#20989;&#25968;hd.set_data&#65288;list_data=data&#65289;Raises Exception&#65292;&#24182;&#19988;&#21253;&#21547;&#25351;&#23450;&#25253;&#38169;msg</span><span class="strut">&nbsp;</span></p>
<p id="t21" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="stm run hide_run"> <span class="nam">hd</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">list_data</span><span class="op">=</span><span class="op">{</span><span class="str">'data'</span><span class="op">:</span> <span class="str">'aa'</span><span class="op">}</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm run hide_run"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">e</span><span class="op">.</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span> <span class="str">"list_data must be 2 dimensions list."</span><span class="op">)</span> <span class="com"># e.args:tuple</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="stm run hide_run"> <span class="nam">hd</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">list_data</span><span class="op">=</span><span class="num">123</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="stm run hide_run"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">e</span><span class="op">.</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span> <span class="str">"list_data must be 2 dimensions list."</span><span class="op">)</span> <span class="com"># e.args:tuple</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t30" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t31" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_set_data</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t33" class="pln"><span class="str"> &#27979;&#35797;&#27491;&#30830;&#35843;&#29992;set_data&#26041;&#27861;&#65292;&#39564;&#35777;HistoryData&#23545;&#35937;&#30340;&#23646;&#24615;data&#19982;start_date&#34987;&#20462;&#25913;</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="stm run hide_run"> <span class="nam">hd</span> <span class="op">=</span> <span class="nam">HistoryData</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t36" class="stm run hide_run"> <span class="nam">list_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'2018-02-03'</span><span class="op">,</span> <span class="num">1.2</span><span class="op">]</span><span class="op">,</span> <span class="op">[</span><span class="str">'2019-01-01'</span><span class="op">,</span> <span class="num">10</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t37" class="stm run hide_run"> <span class="nam">hd</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">list_data</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">hd</span><span class="op">.</span><span class="nam">start_date</span><span class="op">,</span> <span class="str">"2018-02-03"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">hd</span><span class="op">.</span><span class="nam">data</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">' '</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span><span class="op">,</span> <span class="str">'[["2018-02-03",1.2],["2019-01-01",10]]'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t40" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t41" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_get_data</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t42" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t43" class="pln"><span class="str"> &#27979;&#35797;test_get_data&#36820;&#22238; list&#23545;&#35937;</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="stm run hide_run"> <span class="nam">hd</span> <span class="op">=</span> <span class="nam">HistoryData</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t46" class="stm run hide_run"> <span class="nam">list_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'2018-02-03'</span><span class="op">,</span><span class="num">1.2</span><span class="op">]</span><span class="op">,</span> <span class="op">[</span><span class="str">'2019-01-01'</span><span class="op">,</span><span class="num">10</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t47" class="stm run hide_run"> <span class="nam">hd</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">list_data</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t48" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">hd</span><span class="op">.</span><span class="nam">get_data</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="nam">list_data</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t49" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t50" class="stm run hide_run"><span class="key">class</span> <span class="nam">PredictDataModelTests</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_set_data_with_not_list</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t52" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t53" class="pln"><span class="str"> &#27979;&#35797;&#20351;&#29992;&#38750;list&#31867;&#22411;&#20256;&#20837;set_data&#65292;&#24212;&#35813;&#25243;&#20986;&#24322;&#24120;</span><span class="strut">&nbsp;</span></p>
<p id="t54" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t55" class="stm run hide_run"> <span class="nam">pd</span> <span class="op">=</span> <span class="nam">PredictData</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t56" class="pln"> <span class="com"># &#27979;&#35797;&#20989;&#25968;hd.set_data&#65288;list_data=data&#65289;Raises Exception&#65292;&#24182;&#19988;&#21253;&#21547;&#25351;&#23450;&#25253;&#38169;msg</span><span class="strut">&nbsp;</span></p>
<p id="t57" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t58" class="stm run hide_run"> <span class="nam">pd</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">list_data</span><span class="op">=</span><span class="op">{</span><span class="str">'data'</span><span class="op">:</span> <span class="str">'aa'</span><span class="op">}</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t59" class="stm run hide_run"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t60" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">e</span><span class="op">.</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span> <span class="str">"list_data must be 2 dimensions list."</span><span class="op">)</span> <span class="com"># e.args:tuple</span><span class="strut">&nbsp;</span></p>
<p id="t61" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t62" class="stm run hide_run"> <span class="nam">pd</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">list_data</span><span class="op">=</span><span class="num">123</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t63" class="stm run hide_run"> <span class="key">except</span> <span class="nam">Exception</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t64" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">e</span><span class="op">.</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span> <span class="str">"list_data must be 2 dimensions list."</span><span class="op">)</span> <span class="com"># e.args:tuple</span><span class="strut">&nbsp;</span></p>
<p id="t65" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t66" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t67" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_set_data</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t68" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t69" class="pln"><span class="str"> &#27979;&#35797;&#27491;&#30830;&#35843;&#29992;set_data&#26041;&#27861;&#65292;&#39564;&#35777;HistoryData&#23545;&#35937;&#30340;&#23646;&#24615;data&#19982;start_date&#34987;&#27491;&#30830;&#20462;&#25913;</span><span class="strut">&nbsp;</span></p>
<p id="t70" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t71" class="stm run hide_run"> <span class="nam">pd</span> <span class="op">=</span> <span class="nam">PredictData</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t72" class="stm run hide_run"> <span class="nam">list_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'2018-02-03'</span><span class="op">,</span> <span class="num">1.2</span><span class="op">]</span><span class="op">,</span> <span class="op">[</span><span class="str">'2019-01-01'</span><span class="op">,</span> <span class="num">10</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t73" class="stm run hide_run"> <span class="nam">pd</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">list_data</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t74" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">pd</span><span class="op">.</span><span class="nam">start_date</span><span class="op">,</span> <span class="str">"2018-02-03"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t75" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">pd</span><span class="op">.</span><span class="nam">data</span><span class="op">.</span><span class="nam">replace</span><span class="op">(</span><span class="str">' '</span><span class="op">,</span> <span class="str">''</span><span class="op">)</span><span class="op">,</span> <span class="str">'[["2018-02-03",1.2],["2019-01-01",10]]'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t76" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t77" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_get_data</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t78" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t79" class="pln"><span class="str"> &#27979;&#35797;test_get_data&#36820;&#22238;&#30340;&#26159;list&#23545;&#35937;</span><span class="strut">&nbsp;</span></p>
<p id="t80" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t81" class="stm run hide_run"> <span class="nam">pd</span> <span class="op">=</span> <span class="nam">PredictData</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t82" class="stm run hide_run"> <span class="nam">list_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'2018-02-03'</span><span class="op">,</span><span class="num">1.2</span><span class="op">]</span><span class="op">,</span> <span class="op">[</span><span class="str">'2019-01-01'</span><span class="op">,</span><span class="num">10</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t83" class="stm run hide_run"> <span class="nam">pd</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">list_data</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t84" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">pd</span><span class="op">.</span><span class="nam">get_data</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="nam">list_data</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t85" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t86" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t87" class="stm run hide_run"><span class="key">def</span> <span class="nam">create_company</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">,</span><span class="nam">name</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t88" class="stm run hide_run"> <span class="key">return</span> <span class="nam">Company</span><span class="op">.</span><span class="nam">objects</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">stock_code</span><span class="op">,</span><span class="nam">name</span><span class="op">=</span><span class="nam">name</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t89" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t90" class="stm run hide_run"><span class="key">class</span> <span class="nam">HistPredictDataFun</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t91" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t92" class="pln"><span class="str"> &#27979;&#35797; get_hist_predict_data &#26041;&#27861;</span><span class="strut">&nbsp;</span></p>
<p id="t93" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t94" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_input_unknown_stock_code</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t95" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t96" class="pln"><span class="str"> &#20256;&#20837;&#26410;&#30693;&#30340;stock_code&#65292; &#36820;&#22238;404&#38169;&#35823;</span><span class="strut">&nbsp;</span></p>
<p id="t97" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t98" class="stm run hide_run"> <span class="nam">stock_code</span> <span class="op">=</span> <span class="str">"10000"</span><span class="strut">&nbsp;</span></p>
<p id="t99" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t100" class="stm run hide_run"> <span class="nam">get_hist_predict_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t101" class="stm run hide_run"> <span class="key">except</span> <span class="nam">Http404</span> <span class="key">as</span> <span class="nam">e</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t102" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">e</span><span class="op">.</span><span class="nam">args</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span><span class="str">"No Company matches the given query."</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t103" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t104" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_data_exist_in_db</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t105" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t106" class="pln"><span class="str"> &#24403;&#25968;&#25454;&#24211;&#23384;&#22312;&#25968;&#25454;&#19988;&#20026;&#26368;&#26032;&#25968;&#25454;&#26102;&#65292;&#36820;&#22238;&#25968;&#25454;&#24211;&#20013;&#30340;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t107" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t108" class="stm run hide_run"> <span class="nam">code</span> <span class="op">=</span> <span class="str">"600715"</span><span class="strut">&nbsp;</span></p>
<p id="t109" class="stm run hide_run"> <span class="nam">cp</span> <span class="op">=</span> <span class="nam">create_company</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">code</span><span class="op">,</span><span class="nam">name</span><span class="op">=</span><span class="str">"&#26684;&#21147;&#38598;&#22242;"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t110" class="pln"> <span class="com"># &#26500;&#36896;&#26368;&#26032;&#21382;&#21490;&#12289;&#39044;&#27979;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t111" class="stm run hide_run"> <span class="nam">now</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t112" class="stm run hide_run"> <span class="nam">hist_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'2018-12-20'</span><span class="op">,</span><span class="num">10</span><span class="op">]</span><span class="op">,</span><span class="op">[</span><span class="nam">str</span><span class="op">(</span><span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="num">10.2</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t113" class="stm run hide_run"> <span class="nam">pred_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="nam">str</span><span class="op">(</span><span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="num">10</span><span class="op">]</span><span class="op">,</span><span class="op">[</span><span class="nam">str</span><span class="op">(</span><span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span><span class="op">+</span><span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">1</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="num">10.2</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t114" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t115" class="stm run hide_run"> <span class="nam">cp</span><span class="op">.</span><span class="nam">historydata_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">data</span><span class="op">=</span><span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="op">(</span><span class="nam">hist_data</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="nam">start_date</span><span class="op">=</span><span class="nam">hist_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t116" class="stm run hide_run"> <span class="nam">cp</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">data</span><span class="op">=</span><span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="op">(</span><span class="nam">pred_data</span><span class="op">)</span><span class="op">)</span><span class="op">,</span><span class="nam">start_date</span><span class="op">=</span><span class="nam">pred_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t117" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t118" class="stm run hide_run"> <span class="nam">recent</span><span class="op">,</span><span class="nam">predict</span> <span class="op">=</span> <span class="nam">get_hist_predict_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t119" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">hist_data</span><span class="op">,</span><span class="nam">recent</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t120" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">pred_data</span><span class="op">,</span><span class="nam">predict</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t121" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t122" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_data_not_exist_in_db</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t123" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t124" class="pln"><span class="str"> &#27979;&#35797;&#24403;&#25351;&#23450;&#32929;&#31080;&#20195;&#30721;&#30340;&#21382;&#21490;&#25968;&#25454;&#21644;&#39044;&#27979;&#25968;&#25454;&#65292;&#22312;&#25968;&#25454;&#24211;&#20013;&#27809;&#26377;&#35760;&#24405;&#26102;&#65292;&#21017;&#20174;API&#33719;&#21462;&#21382;&#21490;&#25968;&#25454;&#65292;&#20351;&#29992;&#27169;&#22411;&#39044;&#27979;&#25968;&#25454;&#65292;&#28982;&#21518;&#20445;&#23384;&#21040;&#25968;&#25454;&#24211;</span><span class="strut">&nbsp;</span></p>
<p id="t125" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t126" class="stm run hide_run"> <span class="nam">c</span> <span class="op">=</span> <span class="nam">create_company</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="str">"000063"</span><span class="op">,</span><span class="nam">name</span><span class="op">=</span><span class="str">"&#20013;&#20852;&#36890;&#35759;"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t127" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">c</span><span class="op">.</span><span class="nam">historydata_set</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t128" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">c</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t129" class="stm run hide_run"> <span class="nam">get_hist_predict_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">c</span><span class="op">.</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t130" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertGreater</span><span class="op">(</span><span class="nam">c</span><span class="op">.</span><span class="nam">historydata_set</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t131" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertGreater</span><span class="op">(</span><span class="nam">c</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t132" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t133" class="stm run hide_run"> <span class="nam">now</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t134" class="stm run hide_run"> <span class="key">if</span> <span class="nam">now</span><span class="op">.</span><span class="nam">isoweekday</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="num">6</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t135" class="stm run hide_run"> <span class="nam">now</span> <span class="op">=</span> <span class="nam">now</span> <span class="op">+</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">2</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t136" class="stm mis"> <span class="key">elif</span> <span class="nam">now</span><span class="op">.</span><span class="nam">isoweekday</span><span class="op">(</span><span class="op">)</span> <span class="op">==</span> <span class="num">7</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t137" class="stm mis"> <span class="nam">now</span> <span class="op">=</span> <span class="nam">now</span> <span class="op">+</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">1</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t138" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t139" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">c</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">start_date</span><span class="op">,</span><span class="nam">str</span><span class="op">(</span><span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t140" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t141" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t142" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_get_data_exist_in_db</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t143" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t144" class="pln"><span class="str"> &#27979;&#35797;&#24403;&#25968;&#25454;&#24211;&#25152;&#23384;&#25968;&#25454;&#19981;&#26159;&#26368;&#26032;&#26102;&#65292;&#24212;&#35813;&#23558;&#25968;&#25454;&#26356;&#26032;</span><span class="strut">&nbsp;</span></p>
<p id="t145" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t146" class="stm run hide_run"> <span class="nam">cp</span> <span class="op">=</span> <span class="nam">create_company</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="str">"000063"</span><span class="op">,</span> <span class="nam">name</span><span class="op">=</span><span class="str">"&#20013;&#20852;&#36890;&#35759;"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t147" class="pln"> <span class="com"># &#26500;&#36896;&#36807;&#26102;&#21382;&#21490;&#12289;&#39044;&#27979;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t148" class="stm run hide_run"> <span class="nam">hist_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'2018-12-12'</span><span class="op">,</span> <span class="num">10</span><span class="op">]</span><span class="op">,</span> <span class="op">[</span><span class="str">'2018-12-13'</span><span class="op">,</span> <span class="num">10.2</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t149" class="stm run hide_run"> <span class="nam">pred_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="str">'2018-12-19'</span><span class="op">,</span> <span class="num">10</span><span class="op">]</span><span class="op">,</span> <span class="op">[</span><span class="str">'2018-12-20'</span><span class="op">,</span> <span class="num">10.2</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t150" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t151" class="stm run hide_run"> <span class="nam">cp</span><span class="op">.</span><span class="nam">historydata_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">data</span><span class="op">=</span><span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="op">(</span><span class="nam">hist_data</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">=</span><span class="nam">hist_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t152" class="stm run hide_run"> <span class="nam">cp</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">data</span><span class="op">=</span><span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="op">(</span><span class="nam">pred_data</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">=</span><span class="nam">pred_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t153" class="stm run hide_run"> <span class="nam">get_hist_predict_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">cp</span><span class="op">.</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t154" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t155" class="stm run hide_run"> <span class="nam">hd_new</span> <span class="op">=</span> <span class="nam">cp</span><span class="op">.</span><span class="nam">historydata_set</span><span class="op">.</span><span class="nam">last</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t156" class="stm run hide_run"> <span class="nam">hd_last_time</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">hd_new</span><span class="op">.</span><span class="nam">get_data</span><span class="op">(</span><span class="op">)</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span><span class="str">"%Y-%m-%d"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t157" class="stm run hide_run"> <span class="nam">pd_new</span> <span class="op">=</span> <span class="nam">cp</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">last</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t158" class="stm run hide_run"> <span class="nam">pd_last_time</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">pd_new</span><span class="op">.</span><span class="nam">start_date</span><span class="op">,</span> <span class="str">"%Y-%m-%d"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t159" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertGreater</span><span class="op">(</span><span class="nam">hd_last_time</span><span class="op">,</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">hist_data</span><span class="op">[</span><span class="num">1</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span><span class="str">"%Y-%m-%d"</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t160" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertGreater</span><span class="op">(</span><span class="nam">pd_last_time</span><span class="op">,</span><span class="nam">datetime</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">pred_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">,</span><span class="str">"%Y-%m-%d"</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t161" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t162" class="stm run hide_run"><span class="key">class</span> <span class="nam">FuncAddCompany2DB</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t163" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_add_company</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t164" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t165" class="pln"><span class="str"> &#27979;&#35797;&#35843;&#29992;&#35813;&#26041;&#27861;&#65292;&#25968;&#25454;&#24211;&#25104;&#21151;&#28155;&#21152;&#20102;&#32929;&#31080;&#20844;&#21496;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t166" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t167" class="stm run hide_run"> <span class="nam">companies</span> <span class="op">=</span> <span class="nam">Company</span><span class="op">.</span><span class="nam">objects</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t168" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertQuerysetEqual</span><span class="op">(</span><span class="nam">companies</span><span class="op">,</span><span class="op">[</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t169" class="stm run hide_run"> <span class="nam">add_company</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t170" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">Company</span><span class="op">.</span><span class="nam">objects</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="num">10</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t171" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">Company</span><span class="op">.</span><span class="nam">objects</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">stock_code</span><span class="op">,</span><span class="str">'600718'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t172" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">Company</span><span class="op">.</span><span class="nam">objects</span><span class="op">.</span><span class="nam">first</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">name</span><span class="op">,</span><span class="str">'&#19996;&#36719;&#38598;&#22242;'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t173" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t174" class="pln"><span class="com"># &#20026;&#20844;&#21496;&#21019;&#36896;&#25351;&#26631;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t175" class="stm run hide_run"><span class="key">def</span> <span class="nam">create_stock_index</span><span class="op">(</span><span class="nam">company</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t176" class="stm run hide_run"> <span class="nam">row</span> <span class="op">=</span> <span class="op">{</span><span class="str">'ri_qi'</span><span class="op">:</span> <span class="str">'2018-12-22'</span><span class="op">,</span> <span class="str">'zi_jin'</span><span class="op">:</span> <span class="num">8</span><span class="op">,</span> <span class="str">'qiang_du'</span><span class="op">:</span> <span class="num">6</span><span class="op">,</span> <span class="str">'feng_xian'</span><span class="op">:</span> <span class="num">8</span><span class="op">,</span> <span class="str">'zhuan_qiang'</span><span class="op">:</span> <span class="num">5</span><span class="op">,</span> <span class="str">'chang_yu'</span><span class="op">:</span> <span class="num">4</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t177" class="pln"> <span class="str">'jin_zi'</span><span class="op">:</span> <span class="num">7</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t178" class="pln"> <span class="str">'zong_he'</span><span class="op">:</span> <span class="num">9</span><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t179" class="stm run hide_run"> <span class="nam">row2</span> <span class="op">=</span> <span class="op">{</span><span class="str">'ri_qi'</span><span class="op">:</span> <span class="str">'2018-12-22'</span><span class="op">,</span> <span class="str">'zi_jin'</span><span class="op">:</span> <span class="num">5</span><span class="op">,</span> <span class="str">'qiang_du'</span><span class="op">:</span> <span class="num">7</span><span class="op">,</span> <span class="str">'feng_xian'</span><span class="op">:</span> <span class="num">8</span><span class="op">,</span> <span class="str">'zhuan_qiang'</span><span class="op">:</span> <span class="num">5</span><span class="op">,</span> <span class="str">'chang_yu'</span><span class="op">:</span> <span class="num">7</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t180" class="pln"> <span class="str">'jin_zi'</span><span class="op">:</span> <span class="num">6</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t181" class="pln"> <span class="str">'zong_he'</span><span class="op">:</span> <span class="num">7</span><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t182" class="stm run hide_run"> <span class="nam">row3</span> <span class="op">=</span> <span class="op">{</span><span class="str">'ri_qi'</span><span class="op">:</span> <span class="str">'2018-12-22'</span><span class="op">,</span> <span class="str">'zi_jin'</span><span class="op">:</span> <span class="num">8</span><span class="op">,</span> <span class="str">'qiang_du'</span><span class="op">:</span> <span class="num">6</span><span class="op">,</span> <span class="str">'feng_xian'</span><span class="op">:</span> <span class="num">5</span><span class="op">,</span> <span class="str">'zhuan_qiang'</span><span class="op">:</span> <span class="num">4</span><span class="op">,</span> <span class="str">'chang_yu'</span><span class="op">:</span> <span class="num">6</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t183" class="pln"> <span class="str">'jin_zi'</span><span class="op">:</span> <span class="num">5</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t184" class="pln"> <span class="str">'zong_he'</span><span class="op">:</span> <span class="num">8</span><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t185" class="stm run hide_run"> <span class="nam">stock_index</span> <span class="op">=</span> <span class="nam">company</span><span class="op">.</span><span class="nam">stockindex_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">ri_qi</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'ri_qi'</span><span class="op">]</span><span class="op">,</span> <span class="nam">zi_jin</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'zi_jin'</span><span class="op">]</span><span class="op">,</span> <span class="nam">qiang_du</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'qiang_du'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t186" class="pln"> <span class="nam">feng_xian</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'feng_xian'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t187" class="pln"> <span class="nam">zhuan_qiang</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'zhuan_qiang'</span><span class="op">]</span><span class="op">,</span> <span class="nam">chang_yu</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'chang_yu'</span><span class="op">]</span><span class="op">,</span> <span class="nam">jin_zi</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'jin_zi'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t188" class="pln"> <span class="nam">zong_he</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'zong_he'</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t189" class="stm run hide_run"> <span class="nam">company</span><span class="op">.</span><span class="nam">stockindex_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">ri_qi</span><span class="op">=</span><span class="nam">row2</span><span class="op">[</span><span class="str">'ri_qi'</span><span class="op">]</span><span class="op">,</span> <span class="nam">zi_jin</span><span class="op">=</span><span class="nam">row2</span><span class="op">[</span><span class="str">'zi_jin'</span><span class="op">]</span><span class="op">,</span> <span class="nam">qiang_du</span><span class="op">=</span><span class="nam">row2</span><span class="op">[</span><span class="str">'qiang_du'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t190" class="pln"> <span class="nam">feng_xian</span><span class="op">=</span><span class="nam">row2</span><span class="op">[</span><span class="str">'feng_xian'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t191" class="pln"> <span class="nam">zhuan_qiang</span><span class="op">=</span><span class="nam">row2</span><span class="op">[</span><span class="str">'zhuan_qiang'</span><span class="op">]</span><span class="op">,</span> <span class="nam">chang_yu</span><span class="op">=</span><span class="nam">row2</span><span class="op">[</span><span class="str">'chang_yu'</span><span class="op">]</span><span class="op">,</span> <span class="nam">jin_zi</span><span class="op">=</span><span class="nam">row2</span><span class="op">[</span><span class="str">'jin_zi'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t192" class="pln"> <span class="nam">zong_he</span><span class="op">=</span><span class="nam">row2</span><span class="op">[</span><span class="str">'zong_he'</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t193" class="stm run hide_run"> <span class="nam">company</span><span class="op">.</span><span class="nam">stockindex_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">ri_qi</span><span class="op">=</span><span class="nam">row3</span><span class="op">[</span><span class="str">'ri_qi'</span><span class="op">]</span><span class="op">,</span> <span class="nam">zi_jin</span><span class="op">=</span><span class="nam">row3</span><span class="op">[</span><span class="str">'zi_jin'</span><span class="op">]</span><span class="op">,</span> <span class="nam">qiang_du</span><span class="op">=</span><span class="nam">row3</span><span class="op">[</span><span class="str">'qiang_du'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t194" class="pln"> <span class="nam">feng_xian</span><span class="op">=</span><span class="nam">row3</span><span class="op">[</span><span class="str">'feng_xian'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t195" class="pln"> <span class="nam">zhuan_qiang</span><span class="op">=</span><span class="nam">row3</span><span class="op">[</span><span class="str">'zhuan_qiang'</span><span class="op">]</span><span class="op">,</span> <span class="nam">chang_yu</span><span class="op">=</span><span class="nam">row3</span><span class="op">[</span><span class="str">'chang_yu'</span><span class="op">]</span><span class="op">,</span> <span class="nam">jin_zi</span><span class="op">=</span><span class="nam">row3</span><span class="op">[</span><span class="str">'jin_zi'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t196" class="pln"> <span class="nam">zong_he</span><span class="op">=</span><span class="nam">row3</span><span class="op">[</span><span class="str">'zong_he'</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t197" class="stm run hide_run"> <span class="key">return</span> <span class="nam">stock_index</span><span class="strut">&nbsp;</span></p>
<p id="t198" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t199" class="pln"><span class="com"># &#20026;&#32929;&#31080;&#21019;&#36896;&#26368;&#26032;&#30340;&#21382;&#21490;&#19982;&#39044;&#27979;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t200" class="stm run hide_run"><span class="key">def</span> <span class="nam">create_last_hist_predict_data</span><span class="op">(</span><span class="nam">company</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t201" class="stm run hide_run"> <span class="nam">now</span> <span class="op">=</span> <span class="nam">datetime</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t202" class="stm run hide_run"> <span class="nam">hist_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="nam">str</span><span class="op">(</span><span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="op">-</span><span class="num">1</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> <span class="num">10</span><span class="op">]</span><span class="op">,</span> <span class="op">[</span><span class="nam">str</span><span class="op">(</span><span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> <span class="num">10.2</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t203" class="stm run hide_run"> <span class="nam">pred_data</span> <span class="op">=</span> <span class="op">[</span><span class="op">[</span><span class="nam">str</span><span class="op">(</span><span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> <span class="num">10</span><span class="op">]</span><span class="op">,</span> <span class="op">[</span><span class="nam">str</span><span class="op">(</span><span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span> <span class="op">+</span> <span class="nam">timedelta</span><span class="op">(</span><span class="nam">days</span><span class="op">=</span><span class="num">1</span><span class="op">)</span><span class="op">)</span><span class="op">,</span> <span class="num">10.2</span><span class="op">]</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t204" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t205" class="stm run hide_run"> <span class="nam">company</span><span class="op">.</span><span class="nam">historydata_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">data</span><span class="op">=</span><span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="nam">hist_data</span><span class="op">)</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">=</span><span class="nam">hist_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t206" class="stm run hide_run"> <span class="nam">company</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">data</span><span class="op">=</span><span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="nam">pred_data</span><span class="op">)</span><span class="op">,</span> <span class="nam">start_date</span><span class="op">=</span><span class="nam">pred_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t207" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t208" class="stm run hide_run"> <span class="key">return</span> <span class="nam">hist_data</span><span class="op">,</span><span class="nam">pred_data</span><span class="strut">&nbsp;</span></p>
<p id="t209" class="stm run hide_run"><span class="key">class</span> <span class="nam">HomeView</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t210" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_return_data</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t211" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t212" class="pln"><span class="str"> &#27979;&#35797;&#35775;&#38382;&#20027;&#39029;&#26102;&#65292;&#36820;&#22238;&#32929;&#31080;&#20195;&#30721;&#20026;&#65306;600718&#30340;&#25968;&#25454;&#65292;&#21253;&#25324;&#65306;&#21382;&#21490;&#12289;&#39044;&#27979;&#21644;&#25351;&#26631;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t213" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t214" class="pln"> <span class="com"># &#26500;&#36896;&#26368;&#26032;&#21382;&#21490;&#12289;&#39044;&#27979;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t215" class="stm run hide_run"> <span class="nam">cp</span> <span class="op">=</span> <span class="nam">create_company</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="str">"600718"</span><span class="op">,</span> <span class="nam">name</span><span class="op">=</span><span class="str">"&#19996;&#36719;&#38598;&#22242;"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t216" class="stm run hide_run"> <span class="nam">hist_data</span><span class="op">,</span><span class="nam">pred_data</span> <span class="op">=</span> <span class="nam">create_last_hist_predict_data</span><span class="op">(</span><span class="nam">cp</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t217" class="stm run hide_run"> <span class="nam">stock_index</span> <span class="op">=</span> <span class="nam">create_stock_index</span><span class="op">(</span><span class="nam">cp</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t218" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t219" class="stm run hide_run"> <span class="nam">response</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">client</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="nam">reverse</span><span class="op">(</span><span class="str">'stock_predict:home'</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t220" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">response</span><span class="op">.</span><span class="nam">status_code</span><span class="op">,</span><span class="num">200</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t221" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="str">'data'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t222" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">cp</span><span class="op">.</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t223" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">str</span><span class="op">(</span><span class="nam">hist_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t224" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">str</span><span class="op">(</span><span class="nam">pred_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t225" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">stock_index</span><span class="op">.</span><span class="nam">ri_qi</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t226" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">stock_index</span><span class="op">.</span><span class="nam">zi_jin</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t227" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">stock_index</span><span class="op">.</span><span class="nam">jin_zi</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t228" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">stock_index</span><span class="op">.</span><span class="nam">zong_he</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t229" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t230" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t231" class="stm run hide_run"><span class="key">class</span> <span class="nam">PredictStockAction</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t232" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_predict_not_exist_stock</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t233" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t234" class="pln"><span class="str"> &#39044;&#27979;&#19981;&#23384;&#22312;&#30340;&#32929;&#31080;&#20195;&#30721;&#65292;&#36820;&#22238;404</span><span class="strut">&nbsp;</span></p>
<p id="t235" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t236" class="stm run hide_run"> <span class="nam">url</span> <span class="op">=</span> <span class="nam">reverse</span><span class="op">(</span><span class="str">'stock_predict:predict'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t237" class="stm run hide_run"> <span class="nam">response</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">client</span><span class="op">.</span><span class="nam">post</span><span class="op">(</span><span class="nam">url</span><span class="op">,</span><span class="nam">data</span><span class="op">=</span><span class="op">{</span><span class="str">"stock_code"</span><span class="op">:</span><span class="str">"000000"</span><span class="op">}</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t238" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">response</span><span class="op">.</span><span class="nam">status_code</span><span class="op">,</span><span class="num">404</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t239" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t240" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_predict_stock</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t241" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t242" class="pln"><span class="str"> &#27979;&#35797;&#36755;&#20837;&#27491;&#30830;&#30340;&#32929;&#31080;&#20195;&#30721;&#26102;&#65292;&#24212;&#35813;&#36820;&#22238;&#35813;&#32929;&#31080;&#30340;&#21382;&#21490;&#12289;&#39044;&#27979;&#12289;&#25351;&#26631;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t243" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t244" class="stm run hide_run"> <span class="nam">cp</span> <span class="op">=</span> <span class="nam">create_company</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="str">"000651"</span><span class="op">,</span> <span class="nam">name</span><span class="op">=</span><span class="str">"&#26684;&#21147;&#30005;&#22120;"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t245" class="stm run hide_run"> <span class="nam">hist_data</span><span class="op">,</span><span class="nam">pred_data</span> <span class="op">=</span> <span class="nam">create_last_hist_predict_data</span><span class="op">(</span><span class="nam">cp</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t246" class="stm run hide_run"> <span class="nam">stock_index</span> <span class="op">=</span> <span class="nam">create_stock_index</span><span class="op">(</span><span class="nam">cp</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t247" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t248" class="stm run hide_run"> <span class="nam">url</span> <span class="op">=</span> <span class="nam">reverse</span><span class="op">(</span><span class="str">'stock_predict:predict'</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t249" class="stm run hide_run"> <span class="nam">response</span> <span class="op">=</span> <span class="nam">self</span><span class="op">.</span><span class="nam">client</span><span class="op">.</span><span class="nam">post</span><span class="op">(</span><span class="nam">url</span><span class="op">,</span> <span class="nam">data</span><span class="op">=</span><span class="op">{</span><span class="str">"stock_code"</span><span class="op">:</span> <span class="nam">cp</span><span class="op">.</span><span class="nam">stock_code</span><span class="op">}</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t250" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">response</span><span class="op">.</span><span class="nam">status_code</span><span class="op">,</span> <span class="num">200</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t251" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">str</span><span class="op">(</span><span class="nam">hist_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t252" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">str</span><span class="op">(</span><span class="nam">pred_data</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t253" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">stock_index</span><span class="op">.</span><span class="nam">ri_qi</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t254" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">stock_index</span><span class="op">.</span><span class="nam">zi_jin</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t255" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">stock_index</span><span class="op">.</span><span class="nam">jin_zi</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t256" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertContains</span><span class="op">(</span><span class="nam">response</span><span class="op">,</span><span class="nam">stock_index</span><span class="op">.</span><span class="nam">zong_he</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t257" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t258" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t259" class="stm run hide_run"><span class="key">class</span> <span class="nam">FuncGetCrawlSaveData</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t260" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t261" class="pln"><span class="str"> &#27979;&#35797;&#26041;&#27861; get_crawl_save_data</span><span class="strut">&nbsp;</span></p>
<p id="t262" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t263" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_get_crawl_save_data</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t264" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t265" class="pln"><span class="str"> &#27979;&#35797;&#35843;&#29992;&#35813;&#26041;&#27861;&#65292;&#25968;&#25454;&#24211;&#22686;&#21152;&#20102; StockIndex &#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t266" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t267" class="stm run hide_run"> <span class="nam">stock_codes</span> <span class="op">=</span> <span class="op">{</span><span class="str">"600718"</span><span class="op">:</span><span class="str">"&#19996;&#36719;&#38598;&#22242;"</span><span class="op">,</span><span class="str">"000651"</span><span class="op">:</span><span class="str">"&#26684;&#21147;&#30005;&#22120;"</span><span class="op">,</span><span class="str">"600839"</span><span class="op">:</span><span class="str">"&#22235;&#24029;&#38271;&#34425;"</span><span class="op">,</span><span class="str">"600320"</span><span class="op">:</span><span class="str">"&#25391;&#21326;&#37325;&#24037;"</span><span class="op">,</span><span class="str">"601988"</span><span class="op">:</span><span class="str">"&#20013;&#22269;&#38134;&#34892;"</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t268" class="pln"> <span class="str">"000066"</span><span class="op">:</span> <span class="str">"&#20013;&#22269;&#38271;&#22478;"</span><span class="op">,</span><span class="str">"601766"</span><span class="op">:</span><span class="str">"&#20013;&#22269;&#20013;&#36710;"</span><span class="op">,</span><span class="str">"601390"</span><span class="op">:</span><span class="str">"&#20013;&#22269;&#20013;&#38081;"</span><span class="op">,</span><span class="str">"000768"</span><span class="op">:</span><span class="str">"&#20013;&#33322;&#39134;&#26426;"</span><span class="op">,</span><span class="str">"000063"</span><span class="op">:</span><span class="str">"&#20013;&#20852;&#36890;&#35759;"</span><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t269" class="stm run hide_run"> <span class="key">for</span> <span class="nam">code</span><span class="op">,</span><span class="nam">name</span> <span class="key">in</span> <span class="nam">stock_codes</span><span class="op">.</span><span class="nam">items</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t270" class="stm run hide_run"> <span class="nam">create_company</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">code</span><span class="op">,</span><span class="nam">name</span><span class="op">=</span><span class="nam">name</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t271" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">StockIndex</span><span class="op">.</span><span class="nam">objects</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t272" class="stm run hide_run"> <span class="nam">get_crawl_save_data</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t273" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertGreater</span><span class="op">(</span><span class="nam">StockIndex</span><span class="op">.</span><span class="nam">objects</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t274" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t275" class="stm run hide_run"><span class="key">class</span> <span class="nam">TrainAllModel</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t276" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_train_all_models</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t277" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t278" class="pln"><span class="str"> &#27979;&#35797;&#35757;&#32451;&#25152;&#26377;&#30340;&#27169;&#22411;</span><span class="strut">&nbsp;</span></p>
<p id="t279" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t280" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertEquals</span><span class="op">(</span><span class="nam">run</span><span class="op">.</span><span class="nam">train_all_stock</span><span class="op">(</span><span class="op">)</span><span class="op">,</span><span class="num">0</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t281" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t282" class="stm run hide_run"><span class="key">class</span> <span class="nam">PredictAllData</span><span class="op">(</span><span class="nam">TestCase</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t283" class="stm run hide_run"> <span class="key">def</span> <span class="nam">test_predict_all</span><span class="op">(</span><span class="nam">self</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t284" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t285" class="pln"><span class="str"> &#27979;&#35797;&#39044;&#27979;&#25152;&#26377;&#25968;&#25454;&#30340;&#26041;&#27861;</span><span class="strut">&nbsp;</span></p>
<p id="t286" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t287" class="stm run hide_run"> <span class="nam">self</span><span class="op">.</span><span class="nam">assertIsNotNone</span><span class="op">(</span><span class="nam">run</span><span class="op">.</span><span class="nam">predict_all_stock</span><span class="op">(</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t288" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t289" class="pln"><span class="com"># sched = Scheduler()</span><span class="strut">&nbsp;</span></p>
<p id="t290" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t291" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t292" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t293" class="pln"><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 16:41
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,111 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\urls.py: 100%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\urls.py</b> :
<span class="pc_cov">100%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
5 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">5 run</span>
<span class="mis shortkey_m button_toggle_mis">0 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="stm run hide_run"><a href="#n2">2</a></p>
<p id="n3" class="stm run hide_run"><a href="#n3">3</a></p>
<p id="n4" class="pln"><a href="#n4">4</a></p>
<p id="n5" class="pln"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="pln"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="pln"><a href="#n9">9</a></p>
<p id="n10" class="pln"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">contrib</span> <span class="key">import</span> <span class="nam">admin</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">urls</span> <span class="key">import</span> <span class="nam">path</span><span class="op">,</span><span class="nam">include</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="stm run hide_run"><span class="key">from</span> <span class="op">.</span> <span class="key">import</span> <span class="nam">views</span><span class="strut">&nbsp;</span></p>
<p id="t4" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t5" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="nam">app_name</span> <span class="op">=</span> <span class="str">"stock_predict"</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"><span class="nam">urlpatterns</span> <span class="op">=</span> <span class="op">[</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="pln"> <span class="nam">path</span><span class="op">(</span><span class="str">"home/"</span><span class="op">,</span><span class="nam">views</span><span class="op">.</span><span class="nam">home</span><span class="op">,</span><span class="nam">name</span><span class="op">=</span><span class="str">'home'</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="pln"> <span class="nam">path</span><span class="op">(</span><span class="str">"predict/"</span><span class="op">,</span><span class="nam">views</span><span class="op">.</span><span class="nam">predict_stock_action</span><span class="op">,</span><span class="nam">name</span><span class="op">=</span><span class="str">'predict'</span><span class="op">)</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="op">]</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-21 17:21
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,313 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<title>Coverage for stock_predict\views.py: 99%</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.hotkeys.js"></script>
<script type="text/javascript" src="jquery.isonscreen.js"></script>
<script type="text/javascript" src="coverage_html.js"></script>
<script type="text/javascript">
jQuery(document).ready(coverage.pyfile_ready);
</script>
</head>
<body class="pyfile">
<div id="header">
<div class="content">
<h1>Coverage for <b>stock_predict\views.py</b> :
<span class="pc_cov">99%</span>
</h1>
<img id="keyboard_icon" src="keybd_closed.png" alt="Show keyboard shortcuts" />
<h2 class="stats">
73 statements &nbsp;
<span class="run hide_run shortkey_r button_toggle_run">72 run</span>
<span class="mis shortkey_m button_toggle_mis">1 missing</span>
<span class="exc shortkey_x button_toggle_exc">0 excluded</span>
</h2>
</div>
</div>
<div class="help_panel">
<img id="panel_icon" src="keybd_open.png" alt="Hide keyboard shortcuts" />
<p class="legend">Hot-keys on this page</p>
<div>
<p class="keyhelp">
<span class="key">r</span>
<span class="key">m</span>
<span class="key">x</span>
<span class="key">p</span> &nbsp; toggle line displays
</p>
<p class="keyhelp">
<span class="key">j</span>
<span class="key">k</span> &nbsp; next/prev highlighted chunk
</p>
<p class="keyhelp">
<span class="key">0</span> &nbsp; (zero) top of page
</p>
<p class="keyhelp">
<span class="key">1</span> &nbsp; (one) first highlighted chunk
</p>
</div>
</div>
<div id="source">
<table>
<tr>
<td class="linenos">
<p id="n1" class="stm run hide_run"><a href="#n1">1</a></p>
<p id="n2" class="stm run hide_run"><a href="#n2">2</a></p>
<p id="n3" class="pln"><a href="#n3">3</a></p>
<p id="n4" class="stm run hide_run"><a href="#n4">4</a></p>
<p id="n5" class="stm run hide_run"><a href="#n5">5</a></p>
<p id="n6" class="stm run hide_run"><a href="#n6">6</a></p>
<p id="n7" class="stm run hide_run"><a href="#n7">7</a></p>
<p id="n8" class="stm run hide_run"><a href="#n8">8</a></p>
<p id="n9" class="stm run hide_run"><a href="#n9">9</a></p>
<p id="n10" class="stm run hide_run"><a href="#n10">10</a></p>
<p id="n11" class="pln"><a href="#n11">11</a></p>
<p id="n12" class="stm run hide_run"><a href="#n12">12</a></p>
<p id="n13" class="pln"><a href="#n13">13</a></p>
<p id="n14" class="pln"><a href="#n14">14</a></p>
<p id="n15" class="pln"><a href="#n15">15</a></p>
<p id="n16" class="stm run hide_run"><a href="#n16">16</a></p>
<p id="n17" class="stm run hide_run"><a href="#n17">17</a></p>
<p id="n18" class="pln"><a href="#n18">18</a></p>
<p id="n19" class="stm run hide_run"><a href="#n19">19</a></p>
<p id="n20" class="pln"><a href="#n20">20</a></p>
<p id="n21" class="stm run hide_run"><a href="#n21">21</a></p>
<p id="n22" class="stm run hide_run"><a href="#n22">22</a></p>
<p id="n23" class="stm run hide_run"><a href="#n23">23</a></p>
<p id="n24" class="stm run hide_run"><a href="#n24">24</a></p>
<p id="n25" class="stm run hide_run"><a href="#n25">25</a></p>
<p id="n26" class="stm run hide_run"><a href="#n26">26</a></p>
<p id="n27" class="pln"><a href="#n27">27</a></p>
<p id="n28" class="stm run hide_run"><a href="#n28">28</a></p>
<p id="n29" class="stm run hide_run"><a href="#n29">29</a></p>
<p id="n30" class="stm run hide_run"><a href="#n30">30</a></p>
<p id="n31" class="stm run hide_run"><a href="#n31">31</a></p>
<p id="n32" class="stm run hide_run"><a href="#n32">32</a></p>
<p id="n33" class="stm run hide_run"><a href="#n33">33</a></p>
<p id="n34" class="stm run hide_run"><a href="#n34">34</a></p>
<p id="n35" class="stm run hide_run"><a href="#n35">35</a></p>
<p id="n36" class="pln"><a href="#n36">36</a></p>
<p id="n37" class="stm run hide_run"><a href="#n37">37</a></p>
<p id="n38" class="stm run hide_run"><a href="#n38">38</a></p>
<p id="n39" class="pln"><a href="#n39">39</a></p>
<p id="n40" class="stm run hide_run"><a href="#n40">40</a></p>
<p id="n41" class="stm run hide_run"><a href="#n41">41</a></p>
<p id="n42" class="stm run hide_run"><a href="#n42">42</a></p>
<p id="n43" class="stm run hide_run"><a href="#n43">43</a></p>
<p id="n44" class="stm run hide_run"><a href="#n44">44</a></p>
<p id="n45" class="stm run hide_run"><a href="#n45">45</a></p>
<p id="n46" class="pln"><a href="#n46">46</a></p>
<p id="n47" class="stm run hide_run"><a href="#n47">47</a></p>
<p id="n48" class="stm run hide_run"><a href="#n48">48</a></p>
<p id="n49" class="stm run hide_run"><a href="#n49">49</a></p>
<p id="n50" class="stm run hide_run"><a href="#n50">50</a></p>
<p id="n51" class="stm run hide_run"><a href="#n51">51</a></p>
<p id="n52" class="stm run hide_run"><a href="#n52">52</a></p>
<p id="n53" class="stm run hide_run"><a href="#n53">53</a></p>
<p id="n54" class="pln"><a href="#n54">54</a></p>
<p id="n55" class="stm run hide_run"><a href="#n55">55</a></p>
<p id="n56" class="stm run hide_run"><a href="#n56">56</a></p>
<p id="n57" class="pln"><a href="#n57">57</a></p>
<p id="n58" class="stm run hide_run"><a href="#n58">58</a></p>
<p id="n59" class="pln"><a href="#n59">59</a></p>
<p id="n60" class="stm run hide_run"><a href="#n60">60</a></p>
<p id="n61" class="pln"><a href="#n61">61</a></p>
<p id="n62" class="pln"><a href="#n62">62</a></p>
<p id="n63" class="pln"><a href="#n63">63</a></p>
<p id="n64" class="pln"><a href="#n64">64</a></p>
<p id="n65" class="stm run hide_run"><a href="#n65">65</a></p>
<p id="n66" class="stm run hide_run"><a href="#n66">66</a></p>
<p id="n67" class="stm run hide_run"><a href="#n67">67</a></p>
<p id="n68" class="stm run hide_run"><a href="#n68">68</a></p>
<p id="n69" class="stm run hide_run"><a href="#n69">69</a></p>
<p id="n70" class="stm run hide_run"><a href="#n70">70</a></p>
<p id="n71" class="stm run hide_run"><a href="#n71">71</a></p>
<p id="n72" class="stm run hide_run"><a href="#n72">72</a></p>
<p id="n73" class="stm run hide_run"><a href="#n73">73</a></p>
<p id="n74" class="pln"><a href="#n74">74</a></p>
<p id="n75" class="pln"><a href="#n75">75</a></p>
<p id="n76" class="stm run hide_run"><a href="#n76">76</a></p>
<p id="n77" class="pln"><a href="#n77">77</a></p>
<p id="n78" class="pln"><a href="#n78">78</a></p>
<p id="n79" class="pln"><a href="#n79">79</a></p>
<p id="n80" class="stm run hide_run"><a href="#n80">80</a></p>
<p id="n81" class="stm run hide_run"><a href="#n81">81</a></p>
<p id="n82" class="pln"><a href="#n82">82</a></p>
<p id="n83" class="stm mis"><a href="#n83">83</a></p>
<p id="n84" class="pln"><a href="#n84">84</a></p>
<p id="n85" class="stm run hide_run"><a href="#n85">85</a></p>
<p id="n86" class="stm run hide_run"><a href="#n86">86</a></p>
<p id="n87" class="pln"><a href="#n87">87</a></p>
<p id="n88" class="pln"><a href="#n88">88</a></p>
<p id="n89" class="stm run hide_run"><a href="#n89">89</a></p>
<p id="n90" class="stm run hide_run"><a href="#n90">90</a></p>
<p id="n91" class="stm run hide_run"><a href="#n91">91</a></p>
<p id="n92" class="stm run hide_run"><a href="#n92">92</a></p>
<p id="n93" class="stm run hide_run"><a href="#n93">93</a></p>
<p id="n94" class="pln"><a href="#n94">94</a></p>
<p id="n95" class="stm run hide_run"><a href="#n95">95</a></p>
<p id="n96" class="stm run hide_run"><a href="#n96">96</a></p>
<p id="n97" class="pln"><a href="#n97">97</a></p>
<p id="n98" class="stm run hide_run"><a href="#n98">98</a></p>
<p id="n99" class="stm run hide_run"><a href="#n99">99</a></p>
<p id="n100" class="stm run hide_run"><a href="#n100">100</a></p>
<p id="n101" class="stm run hide_run"><a href="#n101">101</a></p>
<p id="n102" class="pln"><a href="#n102">102</a></p>
<p id="n103" class="stm run hide_run"><a href="#n103">103</a></p>
<p id="n104" class="pln"><a href="#n104">104</a></p>
<p id="n105" class="pln"><a href="#n105">105</a></p>
<p id="n106" class="pln"><a href="#n106">106</a></p>
<p id="n107" class="pln"><a href="#n107">107</a></p>
<p id="n108" class="pln"><a href="#n108">108</a></p>
<p id="n109" class="pln"><a href="#n109">109</a></p>
<p id="n110" class="pln"><a href="#n110">110</a></p>
<p id="n111" class="pln"><a href="#n111">111</a></p>
<p id="n112" class="pln"><a href="#n112">112</a></p>
</td>
<td class="text">
<p id="t1" class="stm run hide_run"><span class="key">import</span> <span class="nam">json</span><span class="strut">&nbsp;</span></p>
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut">&nbsp;</span></p>
<p id="t3" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t4" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">http</span> <span class="key">import</span> <span class="nam">HttpResponse</span><span class="strut">&nbsp;</span></p>
<p id="t5" class="stm run hide_run"><span class="key">from</span> <span class="nam">django</span><span class="op">.</span><span class="nam">shortcuts</span> <span class="key">import</span> <span class="nam">render</span><span class="op">,</span> <span class="nam">get_object_or_404</span><span class="strut">&nbsp;</span></p>
<p id="t6" class="stm run hide_run"><span class="key">from</span> <span class="nam">LSTMPredictStock</span> <span class="key">import</span> <span class="nam">run</span><span class="strut">&nbsp;</span></p>
<p id="t7" class="stm run hide_run"><span class="key">from</span> <span class="nam">stock_predict</span> <span class="key">import</span> <span class="nam">models</span><span class="strut">&nbsp;</span></p>
<p id="t8" class="stm run hide_run"><span class="key">from</span> <span class="nam">datetime</span> <span class="key">import</span> <span class="nam">datetime</span> <span class="key">as</span> <span class="nam">dt</span><span class="strut">&nbsp;</span></p>
<p id="t9" class="stm run hide_run"><span class="key">from</span> <span class="nam">apscheduler</span><span class="op">.</span><span class="nam">scheduler</span> <span class="key">import</span> <span class="nam">Scheduler</span><span class="strut">&nbsp;</span></p>
<p id="t10" class="stm run hide_run"><span class="key">from</span> <span class="op">.</span><span class="nam">models</span> <span class="key">import</span> <span class="nam">Company</span><span class="strut">&nbsp;</span></p>
<p id="t11" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t12" class="stm run hide_run"><span class="key">import</span> <span class="nam">pandas</span> <span class="key">as</span> <span class="nam">pd</span><span class="strut">&nbsp;</span></p>
<p id="t13" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t14" class="pln"><span class="com"># LOCAL = False</span><span class="strut">&nbsp;</span></p>
<p id="t15" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t16" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_hist_predict_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t17" class="stm run hide_run"> <span class="nam">recent_data</span><span class="op">,</span><span class="nam">predict_data</span> <span class="op">=</span> <span class="key">None</span><span class="op">,</span><span class="key">None</span><span class="strut">&nbsp;</span></p>
<p id="t18" class="pln"> <span class="com"># company = models.Company.objects.get(stock_code=stock_code)</span><span class="strut">&nbsp;</span></p>
<p id="t19" class="stm run hide_run"> <span class="nam">company</span> <span class="op">=</span> <span class="nam">get_object_or_404</span><span class="op">(</span><span class="nam">Company</span><span class="op">,</span> <span class="nam">stock_code</span><span class="op">=</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t20" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t21" class="stm run hide_run"> <span class="key">if</span> <span class="nam">company</span><span class="op">.</span><span class="nam">historydata_set</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span> <span class="op">&lt;=</span> <span class="num">0</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t22" class="stm run hide_run"> <span class="nam">history_data</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">HistoryData</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t23" class="stm run hide_run"> <span class="nam">history_data</span><span class="op">.</span><span class="nam">company</span> <span class="op">=</span> <span class="nam">company</span><span class="strut">&nbsp;</span></p>
<p id="t24" class="stm run hide_run"> <span class="nam">history_data</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">run</span><span class="op">.</span><span class="nam">get_hist_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">stock_code</span><span class="op">,</span><span class="nam">recent_day</span><span class="op">=</span><span class="num">20</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t25" class="stm run hide_run"> <span class="nam">history_data</span><span class="op">.</span><span class="nam">save</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t26" class="stm run hide_run"> <span class="nam">recent_data</span> <span class="op">=</span> <span class="nam">history_data</span><span class="op">.</span><span class="nam">get_data</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t27" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t28" class="stm run hide_run"> <span class="nam">all_data</span> <span class="op">=</span> <span class="nam">company</span><span class="op">.</span><span class="nam">historydata_set</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t29" class="stm run hide_run"> <span class="key">for</span> <span class="nam">single</span> <span class="key">in</span> <span class="nam">all_data</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t30" class="stm run hide_run"> <span class="nam">now</span> <span class="op">=</span> <span class="nam">dt</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t31" class="stm run hide_run"> <span class="nam">end_date</span> <span class="op">=</span> <span class="nam">single</span><span class="op">.</span><span class="nam">get_data</span><span class="op">(</span><span class="op">)</span><span class="op">[</span><span class="op">-</span><span class="num">1</span><span class="op">]</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t32" class="stm run hide_run"> <span class="nam">end_date</span> <span class="op">=</span> <span class="nam">dt</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">end_date</span><span class="op">,</span><span class="str">"%Y-%m-%d"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t33" class="stm run hide_run"> <span class="key">if</span> <span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span> <span class="op">></span> <span class="nam">end_date</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#26356;&#26032;&#39044;&#27979;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t34" class="stm run hide_run"> <span class="nam">single</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">run</span><span class="op">.</span><span class="nam">get_hist_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">=</span><span class="nam">stock_code</span><span class="op">,</span><span class="nam">recent_day</span><span class="op">=</span><span class="num">20</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t35" class="stm run hide_run"> <span class="nam">single</span><span class="op">.</span><span class="nam">save</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t36" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t37" class="stm run hide_run"> <span class="nam">recent_data</span> <span class="op">=</span> <span class="nam">single</span><span class="op">.</span><span class="nam">get_data</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t38" class="stm run hide_run"> <span class="key">break</span><span class="strut">&nbsp;</span></p>
<p id="t39" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t40" class="stm run hide_run"> <span class="key">if</span> <span class="nam">company</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span> <span class="op">&lt;=</span> <span class="num">0</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t41" class="stm run hide_run"> <span class="nam">predict_data</span> <span class="op">=</span> <span class="nam">models</span><span class="op">.</span><span class="nam">PredictData</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t42" class="stm run hide_run"> <span class="nam">predict_data</span><span class="op">.</span><span class="nam">company</span> <span class="op">=</span> <span class="nam">company</span><span class="strut">&nbsp;</span></p>
<p id="t43" class="stm run hide_run"> <span class="nam">predict_data</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">run</span><span class="op">.</span><span class="nam">prediction</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">,</span><span class="nam">pre_len</span><span class="op">=</span><span class="num">10</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t44" class="stm run hide_run"> <span class="nam">predict_data</span><span class="op">.</span><span class="nam">save</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t45" class="stm run hide_run"> <span class="nam">predict_data</span> <span class="op">=</span> <span class="nam">predict_data</span><span class="op">.</span><span class="nam">get_data</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t46" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t47" class="stm run hide_run"> <span class="nam">all_data</span> <span class="op">=</span> <span class="nam">company</span><span class="op">.</span><span class="nam">predictdata_set</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t48" class="stm run hide_run"> <span class="key">for</span> <span class="nam">single</span> <span class="key">in</span> <span class="nam">all_data</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t49" class="stm run hide_run"> <span class="nam">now</span> <span class="op">=</span> <span class="nam">dt</span><span class="op">.</span><span class="nam">now</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t50" class="stm run hide_run"> <span class="nam">start_date</span> <span class="op">=</span> <span class="nam">dt</span><span class="op">.</span><span class="nam">strptime</span><span class="op">(</span><span class="nam">single</span><span class="op">.</span><span class="nam">start_date</span><span class="op">,</span><span class="str">"%Y-%m-%d"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t51" class="stm run hide_run"> <span class="key">if</span> <span class="nam">now</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span> <span class="op">></span> <span class="nam">start_date</span><span class="op">.</span><span class="nam">date</span><span class="op">(</span><span class="op">)</span><span class="op">:</span> <span class="com"># &#26356;&#26032;&#39044;&#27979;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t52" class="stm run hide_run"> <span class="nam">single</span><span class="op">.</span><span class="nam">set_data</span><span class="op">(</span><span class="nam">run</span><span class="op">.</span><span class="nam">prediction</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">,</span> <span class="nam">pre_len</span><span class="op">=</span><span class="num">10</span><span class="op">)</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t53" class="stm run hide_run"> <span class="nam">single</span><span class="op">.</span><span class="nam">save</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t54" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t55" class="stm run hide_run"> <span class="nam">predict_data</span> <span class="op">=</span> <span class="nam">single</span><span class="op">.</span><span class="nam">get_data</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t56" class="stm run hide_run"> <span class="key">break</span><span class="strut">&nbsp;</span></p>
<p id="t57" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t58" class="stm run hide_run"> <span class="key">return</span> <span class="nam">recent_data</span><span class="op">,</span><span class="nam">predict_data</span><span class="strut">&nbsp;</span></p>
<p id="t59" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t60" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_crawl_save_data</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t61" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t62" class="pln"><span class="str"> &#23558;10&#20010;&#20844;&#21496;&#30340;&#25351;&#26631;&#25968;&#25454;&#29228;&#21462;&#24182;&#20445;&#23384;&#21040;&#25968;&#25454;&#24211;</span><span class="strut">&nbsp;</span></p>
<p id="t63" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t64" class="pln"> <span class="com"># &#27492;&#22788;&#24212;&#26159;&#20174;&#32593;&#19978;&#29228;&#21462;&#25968;&#25454;&#65292;&#24182;&#20445;&#23384;&#20026;csv&#25991;&#20214;</span><span class="strut">&nbsp;</span></p>
<p id="t65" class="stm run hide_run"> <span class="nam">parent_dir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">dirname</span><span class="op">(</span><span class="nam">__file__</span><span class="op">)</span> <span class="com"># "stock_predict/views.py"</span><span class="strut">&nbsp;</span></p>
<p id="t66" class="stm run hide_run"> <span class="nam">file_dir</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">parent_dir</span><span class="op">,</span> <span class="str">"stock_index/"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t67" class="stm run hide_run"> <span class="key">for</span> <span class="nam">file_name</span> <span class="key">in</span> <span class="nam">os</span><span class="op">.</span><span class="nam">listdir</span><span class="op">(</span><span class="nam">file_dir</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t68" class="stm run hide_run"> <span class="nam">file_path</span> <span class="op">=</span> <span class="nam">os</span><span class="op">.</span><span class="nam">path</span><span class="op">.</span><span class="nam">join</span><span class="op">(</span><span class="nam">file_dir</span><span class="op">,</span> <span class="nam">file_name</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t69" class="stm run hide_run"> <span class="nam">data_frame</span> <span class="op">=</span> <span class="nam">pd</span><span class="op">.</span><span class="nam">read_csv</span><span class="op">(</span><span class="nam">file_path</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t70" class="stm run hide_run"> <span class="nam">stock_code</span> <span class="op">=</span> <span class="nam">file_name</span><span class="op">.</span><span class="nam">split</span><span class="op">(</span><span class="str">'.'</span><span class="op">)</span><span class="op">[</span><span class="num">0</span><span class="op">]</span><span class="strut">&nbsp;</span></p>
<p id="t71" class="stm run hide_run"> <span class="nam">company</span> <span class="op">=</span> <span class="nam">get_object_or_404</span><span class="op">(</span><span class="nam">Company</span><span class="op">,</span> <span class="nam">stock_code</span><span class="op">=</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t72" class="stm run hide_run"> <span class="key">for</span> <span class="nam">index</span><span class="op">,</span><span class="nam">row</span> <span class="key">in</span> <span class="nam">data_frame</span><span class="op">.</span><span class="nam">iterrows</span><span class="op">(</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t73" class="stm run hide_run"> <span class="nam">company</span><span class="op">.</span><span class="nam">stockindex_set</span><span class="op">.</span><span class="nam">create</span><span class="op">(</span><span class="nam">ri_qi</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'ri_qi'</span><span class="op">]</span><span class="op">,</span><span class="nam">zi_jin</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'zi_jin'</span><span class="op">]</span><span class="op">,</span><span class="nam">qiang_du</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'qiang_du'</span><span class="op">]</span><span class="op">,</span><span class="nam">feng_xian</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'feng_xian'</span><span class="op">]</span><span class="op">,</span><span class="strut">&nbsp;</span></p>
<p id="t74" class="pln"> <span class="nam">zhuan_qiang</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'zhuan_qiang'</span><span class="op">]</span><span class="op">,</span><span class="nam">chang_yu</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'chang_yu'</span><span class="op">]</span><span class="op">,</span><span class="nam">jin_zi</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'jin_zi'</span><span class="op">]</span><span class="op">,</span><span class="nam">zong_he</span><span class="op">=</span><span class="nam">row</span><span class="op">[</span><span class="str">'zong_he'</span><span class="op">]</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t75" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t76" class="stm run hide_run"><span class="key">def</span> <span class="nam">get_stock_index</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t77" class="pln"> <span class="str">"""</span><span class="strut">&nbsp;</span></p>
<p id="t78" class="pln"><span class="str"> &#33719;&#21462;&#32929;&#31080;&#30340;&#21508;&#39033;&#25351;&#26631;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t79" class="pln"><span class="str"> """</span><span class="strut">&nbsp;</span></p>
<p id="t80" class="stm run hide_run"> <span class="nam">company</span> <span class="op">=</span> <span class="nam">get_object_or_404</span><span class="op">(</span><span class="nam">Company</span><span class="op">,</span> <span class="nam">stock_code</span><span class="op">=</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t81" class="stm run hide_run"> <span class="key">if</span> <span class="nam">company</span><span class="op">.</span><span class="nam">stockindex_set</span><span class="op">.</span><span class="nam">count</span><span class="op">(</span><span class="op">)</span> <span class="op">&lt;=</span> <span class="num">0</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t82" class="pln"> <span class="com"># &#23558;&#29228;&#21462;&#30340;&#25968;&#25454;&#23384;&#20837;&#25968;&#25454;&#24211;</span><span class="strut">&nbsp;</span></p>
<p id="t83" class="stm mis"> <span class="nam">get_crawl_save_data</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t84" class="pln"> <span class="com"># &#20174;&#25968;&#25454;&#24211;&#33719;&#21462;&#36817;&#19977;&#22825;&#30340;&#25968;&#25454;</span><span class="strut">&nbsp;</span></p>
<p id="t85" class="stm run hide_run"> <span class="nam">indexs</span> <span class="op">=</span> <span class="nam">company</span><span class="op">.</span><span class="nam">stockindex_set</span><span class="op">.</span><span class="nam">all</span><span class="op">(</span><span class="op">)</span><span class="op">.</span><span class="nam">order_by</span><span class="op">(</span><span class="str">'-ri_qi'</span><span class="op">)</span><span class="op">[</span><span class="op">:</span><span class="num">3</span><span class="op">]</span><span class="op">.</span><span class="nam">values</span><span class="op">(</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t86" class="stm run hide_run"> <span class="key">return</span> <span class="nam">list</span><span class="op">(</span><span class="nam">indexs</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t87" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t88" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t89" class="stm run hide_run"><span class="key">def</span> <span class="nam">home</span><span class="op">(</span><span class="nam">request</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t90" class="stm run hide_run"> <span class="nam">recent_data</span><span class="op">,</span><span class="nam">predict_data</span> <span class="op">=</span> <span class="nam">get_hist_predict_data</span><span class="op">(</span><span class="str">"600718"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t91" class="stm run hide_run"> <span class="nam">data</span> <span class="op">=</span> <span class="op">{</span><span class="str">"recent_data"</span><span class="op">:</span><span class="nam">recent_data</span><span class="op">,</span><span class="str">"stock_code"</span><span class="op">:</span><span class="str">"600718"</span><span class="op">,</span><span class="str">"predict_data"</span><span class="op">:</span><span class="nam">predict_data</span><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t92" class="stm run hide_run"> <span class="nam">data</span><span class="op">[</span><span class="str">'indexs'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">get_stock_index</span><span class="op">(</span><span class="str">"600718"</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t93" class="stm run hide_run"> <span class="key">return</span> <span class="nam">render</span><span class="op">(</span><span class="nam">request</span><span class="op">,</span><span class="str">"stock_predict/home.html"</span><span class="op">,</span><span class="op">{</span><span class="str">"data"</span><span class="op">:</span><span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="nam">data</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> <span class="com"># json.dumps(list)</span><span class="strut">&nbsp;</span></p>
<p id="t94" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t95" class="stm run hide_run"><span class="key">def</span> <span class="nam">predict_stock_action</span><span class="op">(</span><span class="nam">request</span><span class="op">)</span><span class="op">:</span><span class="strut">&nbsp;</span></p>
<p id="t96" class="stm run hide_run"> <span class="nam">stock_code</span> <span class="op">=</span> <span class="nam">request</span><span class="op">.</span><span class="nam">POST</span><span class="op">.</span><span class="nam">get</span><span class="op">(</span><span class="str">'stock_code'</span><span class="op">,</span><span class="key">None</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t97" class="pln"> <span class="com"># print("stock_code:\n",stock_code)</span><span class="strut">&nbsp;</span></p>
<p id="t98" class="stm run hide_run"> <span class="nam">recent_data</span><span class="op">,</span> <span class="nam">predict_data</span> <span class="op">=</span> <span class="nam">get_hist_predict_data</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t99" class="stm run hide_run"> <span class="nam">data</span> <span class="op">=</span> <span class="op">{</span><span class="str">"recent_data"</span><span class="op">:</span> <span class="nam">recent_data</span><span class="op">,</span> <span class="str">"stock_code"</span><span class="op">:</span> <span class="nam">stock_code</span><span class="op">,</span> <span class="str">"predict_data"</span><span class="op">:</span> <span class="nam">predict_data</span><span class="op">}</span><span class="strut">&nbsp;</span></p>
<p id="t100" class="stm run hide_run"> <span class="nam">data</span><span class="op">[</span><span class="str">'indexs'</span><span class="op">]</span> <span class="op">=</span> <span class="nam">get_stock_index</span><span class="op">(</span><span class="nam">stock_code</span><span class="op">)</span><span class="strut">&nbsp;</span></p>
<p id="t101" class="stm run hide_run"> <span class="key">return</span> <span class="nam">render</span><span class="op">(</span><span class="nam">request</span><span class="op">,</span> <span class="str">"stock_predict/home.html"</span><span class="op">,</span> <span class="op">{</span><span class="str">"data"</span><span class="op">:</span> <span class="nam">json</span><span class="op">.</span><span class="nam">dumps</span><span class="op">(</span><span class="nam">data</span><span class="op">)</span><span class="op">}</span><span class="op">)</span> <span class="com"># json.dumps(list)</span><span class="strut">&nbsp;</span></p>
<p id="t102" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t103" class="stm run hide_run"><span class="str">'''</span><span class="strut">&nbsp;</span></p>
<p id="t104" class="pln"><span class="str">sched = Scheduler()</span><span class="strut">&nbsp;</span></p>
<p id="t105" class="pln"><span class="str"># &#23450;&#26102;&#20219;&#21153;</span><span class="strut">&nbsp;</span></p>
<p id="t106" class="pln"><span class="str"># @sched.interval_schedule(seconds=2) # &#27599;2s&#25191;&#34892;&#19968;&#27425;</span><span class="strut">&nbsp;</span></p>
<p id="t107" class="pln"><span class="str">@sched.cron_schedule(hour=0,minute=0) # &#27599;&#26085;&#20940;&#26216;&#35843;&#24230;&#19968;&#27425;</span><span class="strut">&nbsp;</span></p>
<p id="t108" class="pln"><span class="str">def train_models():</span><span class="strut">&nbsp;</span></p>
<p id="t109" class="pln"><span class="str"> run.train_all_stock()</span><span class="strut">&nbsp;</span></p>
<p id="t110" class="pln"><span class="strut">&nbsp;</span></p>
<p id="t111" class="pln"><span class="str">sched.start()</span><span class="strut">&nbsp;</span></p>
<p id="t112" class="pln"><span class="str">'''</span><span class="strut">&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<div id="footer">
<div class="content">
<p>
<a class="nav" href="index.html">&#xab; index</a> &nbsp; &nbsp; <a class="nav" href="https://coverage.readthedocs.io">coverage.py v4.5.2</a>,
created at 2018-12-22 16:12
</p>
</div>
</div>
</body>
</html>

@ -0,0 +1,375 @@
/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
/* For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt */
/* CSS styles for coverage.py. */
/* Page-wide styles */
html, body, h1, h2, h3, p, table, td, th {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
}
/* Set baseline grid to 16 pt. */
body {
font-family: georgia, serif;
font-size: 1em;
}
html>body {
font-size: 16px;
}
/* Set base font size to 12/16 */
p {
font-size: .75em; /* 12/16 */
line-height: 1.33333333em; /* 16/12 */
}
table {
border-collapse: collapse;
}
td {
vertical-align: top;
}
table tr.hidden {
display: none !important;
}
p#no_rows {
display: none;
font-size: 1.2em;
}
a.nav {
text-decoration: none;
color: inherit;
}
a.nav:hover {
text-decoration: underline;
color: inherit;
}
/* Page structure */
#header {
background: #f8f8f8;
width: 100%;
border-bottom: 1px solid #eee;
}
#source {
padding: 1em;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
}
.indexfile #footer {
margin: 1em 3em;
}
.pyfile #footer {
margin: 1em 1em;
}
#footer .content {
padding: 0;
font-size: 85%;
font-family: verdana, sans-serif;
color: #666666;
font-style: italic;
}
#index {
margin: 1em 0 0 3em;
}
/* Header styles */
#header .content {
padding: 1em 3em;
}
h1 {
font-size: 1.25em;
display: inline-block;
}
#filter_container {
display: inline-block;
float: right;
margin: 0 2em 0 0;
}
#filter_container input {
width: 10em;
}
h2.stats {
margin-top: .5em;
font-size: 1em;
}
.stats span {
border: 1px solid;
padding: .1em .25em;
margin: 0 .1em;
cursor: pointer;
border-color: #999 #ccc #ccc #999;
}
.stats span.hide_run, .stats span.hide_exc,
.stats span.hide_mis, .stats span.hide_par,
.stats span.par.hide_run.hide_par {
border-color: #ccc #999 #999 #ccc;
}
.stats span.par.hide_run {
border-color: #999 #ccc #ccc #999;
}
.stats span.run {
background: #ddffdd;
}
.stats span.exc {
background: #eeeeee;
}
.stats span.mis {
background: #ffdddd;
}
.stats span.hide_run {
background: #eeffee;
}
.stats span.hide_exc {
background: #f5f5f5;
}
.stats span.hide_mis {
background: #ffeeee;
}
.stats span.par {
background: #ffffaa;
}
.stats span.hide_par {
background: #ffffcc;
}
/* Help panel */
#keyboard_icon {
float: right;
margin: 5px;
cursor: pointer;
}
.help_panel {
position: absolute;
background: #ffffcc;
padding: .5em;
border: 1px solid #883;
display: none;
}
.indexfile .help_panel {
width: 20em; height: 4em;
}
.pyfile .help_panel {
width: 16em; height: 8em;
}
.help_panel .legend {
font-style: italic;
margin-bottom: 1em;
}
#panel_icon {
float: right;
cursor: pointer;
}
.keyhelp {
margin: .75em;
}
.keyhelp .key {
border: 1px solid black;
border-color: #888 #333 #333 #888;
padding: .1em .35em;
font-family: monospace;
font-weight: bold;
background: #eee;
}
/* Source file styles */
.linenos p {
text-align: right;
margin: 0;
padding: 0 .5em;
color: #999999;
font-family: verdana, sans-serif;
font-size: .625em; /* 10/16 */
line-height: 1.6em; /* 16/10 */
}
.linenos p.highlight {
background: #ffdd00;
}
.linenos p a {
text-decoration: none;
color: #999999;
}
.linenos p a:hover {
text-decoration: underline;
color: #999999;
}
td.text {
width: 100%;
}
.text p {
margin: 0;
padding: 0 0 0 .5em;
border-left: 2px solid #ffffff;
white-space: pre;
position: relative;
}
.text p.mis {
background: #ffdddd;
border-left: 2px solid #ff0000;
}
.text p.run, .text p.run.hide_par {
background: #ddffdd;
border-left: 2px solid #00ff00;
}
.text p.exc {
background: #eeeeee;
border-left: 2px solid #808080;
}
.text p.par, .text p.par.hide_run {
background: #ffffaa;
border-left: 2px solid #eeee99;
}
.text p.hide_run, .text p.hide_exc, .text p.hide_mis, .text p.hide_par,
.text p.hide_run.hide_par {
background: inherit;
}
.text span.annotate {
font-family: georgia;
color: #666;
float: right;
padding-right: .5em;
}
.text p.hide_par span.annotate {
display: none;
}
.text span.annotate.long {
display: none;
}
.text p:hover span.annotate.long {
display: block;
max-width: 50%;
white-space: normal;
float: right;
position: absolute;
top: 1.75em;
right: 1em;
width: 30em;
height: auto;
color: #333;
background: #ffffcc;
border: 1px solid #888;
padding: .25em .5em;
z-index: 999;
border-radius: .2em;
box-shadow: #cccccc .2em .2em .2em;
}
/* Syntax coloring */
.text .com {
color: green;
font-style: italic;
line-height: 1px;
}
.text .key {
font-weight: bold;
line-height: 1px;
}
.text .str {
color: #000080;
}
/* index styles */
#index td, #index th {
text-align: right;
width: 5em;
padding: .25em .5em;
border-bottom: 1px solid #eee;
}
#index th {
font-style: italic;
color: #333;
border-bottom: 1px solid #ccc;
cursor: pointer;
}
#index th:hover {
background: #eee;
border-bottom: 1px solid #999;
}
#index td.left, #index th.left {
padding-left: 0;
}
#index td.right, #index th.right {
padding-right: 0;
}
#index th.headerSortDown, #index th.headerSortUp {
border-bottom: 1px solid #000;
white-space: nowrap;
background: #eee;
}
#index th.headerSortDown:after {
content: " ↓";
}
#index th.headerSortUp:after {
content: " ↑";
}
#index td.name, #index th.name {
text-align: left;
width: auto;
}
#index td.name a {
text-decoration: none;
color: #000;
}
#index tr.total,
#index tr.total_dynamic {
}
#index tr.total td,
#index tr.total_dynamic td {
font-weight: bold;
border-top: 1px solid #ccc;
border-bottom: none;
}
#index tr.file:hover {
background: #eeeeee;
}
#index tr.file:hover td.name {
text-decoration: underline;
color: #000;
}
/* scroll marker styles */
#scroll_marker {
position: fixed;
right: 0;
top: 0;
width: 16px;
height: 100%;
background: white;
border-left: 1px solid #eee;
}
#scroll_marker .marker {
background: #eedddd;
position: absolute;
min-height: 3px;
width: 100%;
}

@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'WebStockPredict.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

@ -0,0 +1,9 @@
python==3.6.6
django==2.1.4
numpy==1.15.2
pandas==0.23.4
tensorflow-gpu==1.10.0
keras==2.2.2
matplotlib==2.2.2
cudatoolkit==9.0
cudnn==7.1.4

@ -0,0 +1,12 @@
from stock_predict import models
def add_company():
companies = {"600718":"东软集团","000651":"格力电器","600839":"四川长虹","600320":"振华重工","601988":"中国银行",
"000066": "中国长城","601766":"中国中车","601390":"中国中铁","000768":"中航飞机","000063":"中兴通讯"}
for code,name in companies.items():
company = models.Company()
company.stock_code = code
company.name = name
company.save()

@ -0,0 +1,7 @@
from django.contrib import admin
from .models import Company,HistoryData,PredictData
# Register your models here.
admin.site.register(Company)
admin.site.register(HistoryData)
admin.site.register(PredictData)

@ -0,0 +1,5 @@
from django.apps import AppConfig
class StockPredictConfig(AppConfig):
name = 'stock_predict'

@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 19 15:15:35 2018
@author: GRC
"""
import requests
from bs4 import BeautifulSoup
import bs4
import csv
import os
def getHTMLText(url):
try:
#账号密码15520452757
#cookie={'Cookie':'UM_ distinctid= ;PHPSESSID=;CNZZDATA1256448133=; amvid = '}
UM_distinctid = "UM_distinctid=" + "167d4244a665d3-0bc7b9a22f42f1-4313362-144000-167d4244a67440;"
PHPSESSID = "PHPSESSID=" + "3n5tijoru3ac300d06aj1o3ku7;"
CNZZDATA1256448133 = "CNZZDATA1256448133=" + "1846506456-1545449269-%7C1545966443;"
amvid = "amvid=" + "36ea17e34bc1f734cf970e49063d73a6"
cookie={'Cookie':UM_distinctid+PHPSESSID+CNZZDATA1256448133+amvid}
r = requests.get(url, headers=cookie, timeout = 30)
r.raise_for_status()
r.encoding = r.apparent_encoding
return r.text
except:
print("登录数据猫失败!")
return ""
def fillUnivList(ulist, html):
soup = BeautifulSoup(html,"html.parser")
#print(soup.text)
#print(soup.find_all('tbody'))
#print(soup.find_all(id='alldatatablelg')) #alldatatablelg
table = soup.find_all(id='alldatatablelg')[0]
tbody = table.find_all('tbody')[0]
for tr in tbody.find_all('tr'):
if isinstance(tr, bs4.element.Tag):
tds = tr('td')
#print(soup.find_all(tr('td')))
#print(tds)
ulist.append([tds[0].string, tds[4].string, tds[5].string, tds[6].string,tds[8].string, tds[9].string, tds[10].string, tds[11].string])
def printUnivList(ulist, stockcode, num):
#tplt = "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}"
#时间 综合 强度 资金 预期 转强 长预 近资 风险
#print("时间 综合 强度 资金 转强 长预 近资 风险")
shares = []
parent_dir = os.path.dirname(__file__) # 父目录
file_dir = os.path.join(parent_dir,"stock_index/")
if not os.path.exists(file_dir):
os.mkdir(file_dir)
file_path = os.path.join(file_dir,stockcode+'.csv')
with open(file_path, 'w', newline='') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',',
quotechar='\n', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow(['ri_qi', 'zong_he', 'qiang_du', 'zi_jin', 'zhuan_qiang', 'chang_yu', 'jin_zi', 'feng_xian'])
for i in range(num):
u=ulist[i]
#print(tplt.format(u[0], u[1], u[2], u[3], u[4], u[5], u[6], u[7]))
dict = {'ri_qi': u[0], 'zong_he': u[1], 'qiang_du': u[2], 'zi_jin': u[3], 'zhuan_qiang': u[4], 'chang_yu': u[5], 'jin_zi': u[6], 'feng_xian': u[7]}
shares.append(dict)
spamwriter.writerow(u)
print(file_path,"保存!")
def main(stockcode):
uinfo = []
url = 'http://www.gpdatacat.com/index.php?r=stock%2Fview&stockcode=' + stockcode
html = getHTMLText(url)
if html == "":
print("登录数据猫失败")
return
fillUnivList(uinfo, html)
printUnivList(uinfo, stockcode, 10) #10个日期最大取值为50
main('000063')#中兴通讯
main('000066')#中国长城
main('000651')#格力电器
main('000768')#中航飞机
main('600320')#振华重工
main('600718')#东软集团
main('600839')#四川长虹
main('601390')#中国中铁
main('601766')#中国中车
main('601988')#中国银行
# =============================================================================
# def main():
# uinfo = []
# url = 'http://www.gpdatacat.com/index.php?r=stock%2Fview&stockcode=000063'
# html = getHTMLText(url)
# fillUnivList(uinfo, html)
# printUnivList(uinfo, 10) #50个日期
# main()
# =============================================================================

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save