@ -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":[]}}
|
@ -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,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))
|
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 83 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 114 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 20 KiB |
@ -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()
|
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 144 KiB |
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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </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"> </span></p>
|
||||
<p id="t3" class="pln"><span class="com"># as is with no warranties or support.</span><span class="strut"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t9" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t10" class="stm run hide_run"><span class="key">import</span> <span class="nam">warnings</span><span class="strut"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </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"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t9" class="pln"> <span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t10" class="pln"><span class="str"> filename:数据所在文件名, '.csv'格式文件</span><span class="strut"> </span></p>
|
||||
<p id="t11" class="pln"><span class="str"> split:训练与测试数据分割变量</span><span class="strut"> </span></p>
|
||||
<p id="t12" class="pln"><span class="str"> cols:选择data的一列或者多列进行分析,如 Close 和 Volume</span><span class="strut"> </span></p>
|
||||
<p id="t13" class="pln"><span class="str"> '''</span><span class="strut"> </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"> </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"> </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">#选择指定的列 进行分割 得到 未处理的训练数据</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t21" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t22" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t24" class="pln"> <span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t25" class="pln"><span class="str"> Create x, y test data windows</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t27" class="pln"><span class="str"> load data, otherwise reduce size of the training split.</span><span class="strut"> </span></p>
|
||||
<p id="t28" class="pln"><span class="str"> '''</span><span class="strut"> </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"> </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"> </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">#每一个元素是长度为seq_len的 list即一个window</span><span class="strut"> </span></p>
|
||||
<p id="t32" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t35" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t38" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t40" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t42" class="pln"> <span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t43" class="pln"><span class="str"> Create x, y train data windows</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t45" class="pln"><span class="str"> load data, otherwise use generate_training_window() method.</span><span class="strut"> </span></p>
|
||||
<p id="t46" class="pln"><span class="str"> '''</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t53" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t55" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t59" class="stm run hide_run"> <span class="key">while</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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t71" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"># 最后一行的 0个元素 组成array类型,若是[0,2]则取第0个和第2个元素组成array,[-1, 0]:则是取最后一行第0个元素,</span><span class="strut"> </span></p>
|
||||
<p id="t78" class="pln"> <span class="com"># 只返回该元素的值[]和()用于索引都是切片操作,所以这里的y即label是 第一列Close列</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t80" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t82" class="pln"> <span class="str">'''Normalise window with a base value of zero'''</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"># 获取国内股票历史数据</span><span class="strut"> </span></p>
|
||||
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">json</span><span class="strut"> </span></p>
|
||||
<p id="t3" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut"> </span></p>
|
||||
<p id="t4" class="stm run hide_run"><span class="key">import</span> <span class="nam">requests</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t6" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t8" class="pln"> <span class="com"># 从网易接口获取数据</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t11" class="pln"><span class="strut"> </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"># 上海证券</span><span class="strut"> </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"> </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"># 深圳证券</span><span class="strut"> </span></p>
|
||||
<p id="t15" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t18" class="pln"><span class="strut"> </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"> </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二进制数据 r.text 文本数据</span><span class="strut"> </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"> </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"># 列名替换开头的空字符</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t26" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"># 去除无效数据</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t34" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t35" class="pln"><span class="strut"> </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"># 得到从start_date至今日 所有最新数据</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t39" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t42" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t43" class="pln"> <span class="com"># start_date = '2010-06-21' # 只能按整年获取至今日数据</span><span class="strut"> </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"> </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"> </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"># 在当前日期上加一年</span><span class="strut"> </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"># 获取今年最新数据</span><span class="strut"> </span></p>
|
||||
<p id="t48" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t51" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t53" class="pln"> <span class="com"># start_date = '2010-06-21' # 只能按整年获取至今日数据</span><span class="strut"> </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"> </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"> </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"># 在当前日期上加一年</span><span class="strut"> </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"># 获取今年最新数据</span><span class="strut"> </span></p>
|
||||
<p id="t58" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t60" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t61" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </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"> </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"> </span></p>
|
||||
<p id="t4" class="stm mis"><span class="key">import</span> <span class="nam">time</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t6" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t8" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t9" class="pln"><span class="str"> Gets historical stock data of given tickers between dates</span><span class="strut"> </span></p>
|
||||
<p id="t10" class="pln"><span class="str"> :param ticker: company, or companies whose data is to fetched</span><span class="strut"> </span></p>
|
||||
<p id="t11" class="pln"><span class="str"> :type ticker: string or list of strings</span><span class="strut"> </span></p>
|
||||
<p id="t12" class="pln"><span class="str"> :param start_date: starting date for stock prices</span><span class="strut"> </span></p>
|
||||
<p id="t13" class="pln"><span class="str"> :type start_date: string of date "YYYY-mm-dd"</span><span class="strut"> </span></p>
|
||||
<p id="t14" class="pln"><span class="str"> :param end_date: end date for stock prices</span><span class="strut"> </span></p>
|
||||
<p id="t15" class="pln"><span class="str"> :type end_date: string of date "YYYY-mm-dd"</span><span class="strut"> </span></p>
|
||||
<p id="t16" class="pln"><span class="str"> :return: stock_data.csv</span><span class="strut"> </span></p>
|
||||
<p id="t17" class="pln"><span class="str"> """</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t19" class="stm mis"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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">#数据列包括:Date Open High Low Close Adj Close Volume</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t24" class="stm mis"> <span class="key">if</span> <span class="nam">i</span> <span class="op"><</span> <span class="num">5</span><span class="op">:</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t27" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t31" class="pln"> <span class="com"># print("date:%s - %s" % (start_date,end_date))</span><span class="strut"> </span></p>
|
||||
<p id="t32" class="pln"> <span class="com"># print("all_data:\n",all_data)</span><span class="strut"> </span></p>
|
||||
<p id="t33" class="pln"> <span class="com"># all_data.to_csv("stock_all_prices.csv")</span><span class="strut"> </span></p>
|
||||
<p id="t34" class="pln"> <span class="com"># stock_data = all_data["Adj Close"]</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t38" class="pln"> <span class="com"># insert_date_close_col(filename)</span><span class="strut"> </span></p>
|
||||
<p id="t39" class="pln"><span class="strut"> </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"> </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只读,r+读写,不创建。文件不存在则报错</span><span class="strut"> </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"># 读取原来所有内容</span><span class="strut"> </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"># 将文件索引重定位到文件头</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t46" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t47" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">math</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t10" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t12" class="pln"> <span class="str">"""A class for an building and inferencing an lstm model"""</span><span class="strut"> </span></p>
|
||||
<p id="t13" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t16" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t18" class="pln"> <span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t19" class="pln"><span class="str"> 从本地保存的模型参数来加载模型</span><span class="strut"> </span></p>
|
||||
<p id="t20" class="pln"><span class="str"> filepath: .h5 格式文件</span><span class="strut"> </span></p>
|
||||
<p id="t21" class="pln"><span class="str"> '''</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t24" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t26" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t27" class="pln"><span class="str"> 新建一个模型</span><span class="strut"> </span></p>
|
||||
<p id="t28" class="pln"><span class="str"> configs:配置文件</span><span class="strut"> </span></p>
|
||||
<p id="t29" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t32" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t40" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t47" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t49" class="pln"><span class="strut"> </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"> </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">#输出构建一个模型耗时</span><span class="strut"> </span></p>
|
||||
<p id="t52" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t58" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t60" class="stm mis"> <span class="nam">callbacks</span> <span class="op">=</span> <span class="op">[</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t63" class="pln"> <span class="op">]</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t65" class="pln"> <span class="nam">x</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t66" class="pln"> <span class="nam">y</span><span class="op">,</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t69" class="pln"> <span class="nam">callbacks</span><span class="op">=</span><span class="nam">callbacks</span><span class="strut"> </span></p>
|
||||
<p id="t70" class="pln"> <span class="op">)</span><span class="strut"> </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">#保存训练好的模型</span><span class="strut"> </span></p>
|
||||
<p id="t72" class="pln"><span class="strut"> </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"> </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">#输出训练耗时</span><span class="strut"> </span></p>
|
||||
<p id="t75" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t77" class="pln"> <span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t78" class="pln"><span class="str"> 由data_gen数据产生器来,逐步产生训练数据,而不是一次性将数据读入到内存</span><span class="strut"> </span></p>
|
||||
<p id="t79" class="pln"><span class="str"> '''</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t84" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t89" class="pln"> <span class="op">]</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t91" class="pln"> <span class="nam">data_gen</span><span class="op">,</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t95" class="pln"> <span class="nam">workers</span><span class="op">=</span><span class="num">1</span><span class="strut"> </span></p>
|
||||
<p id="t96" class="pln"> <span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t97" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t100" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t101" class="pln"> <span class="com"># data必须是三维数据,即shape:(a,b,c)</span><span class="strut"> </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"> </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"> </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有多少行就输出多少个预测值,返回的预测值是一个2维数组:(a,1) a:为data的行数</span><span class="strut"> </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"># 这里将二维数组,变成一维数组</span><span class="strut"> </span></p>
|
||||
<p id="t106" class="stm mis"> <span class="key">return</span> <span class="nam">predicted</span> <span class="com"># 返回一维数组,元素个数与data的a相同</span><span class="strut"> </span></p>
|
||||
<p id="t107" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t108" class="pln"> <span class="com"># 对data进行多段预测,每段预测基于一个窗口大小(window_size)的数据,然后输出prediction_len长的预测值(一维数组)</span><span class="strut"> </span></p>
|
||||
<p id="t109" class="pln"> <span class="com"># 再从上一个窗口移动prediction_len的长度,得到下一个窗口的数据,并基于该数据再预测prediction_len长的预测值</span><span class="strut"> </span></p>
|
||||
<p id="t110" class="pln"> <span class="com"># 所以prediction_len决定了窗口的移位步数,每次的窗口大小是一样的,所以最后预测的段数 = 窗口个数/预测长度</span><span class="strut"> </span></p>
|
||||
<p id="t111" class="pln"> <span class="com"># 相当于多次调用predict_1_win_sequence方法</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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:增加新轴,使得curr_frame变成(1,x,x)三维数据</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t123" class="stm mis"> <span class="key">return</span> <span class="nam">prediction_seqs</span><span class="strut"> </span></p>
|
||||
<p id="t124" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t125" class="pln"> <span class="com"># 输入一个窗口的数据,指定预测的长度,data:依旧是三维数组(1,win_len,fea_len)</span><span class="strut"> </span></p>
|
||||
<p id="t126" class="pln"> <span class="com"># 返回预测数组</span><span class="strut"> </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:为输入数据的长度</span><span class="strut"> </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"> </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"># 基于data[0]一个窗口的数据,来预测len(data)个输出</span><span class="strut"> </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"> </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"> </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了一个预测值(标量)</span><span class="strut"> </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"> </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"># 插入位置[window_size-2]:curr_frame的末尾,predicted[-1]:插入值</span><span class="strut"> </span></p>
|
||||
<p id="t135" class="stm mis"> <span class="key">return</span> <span class="nam">predicted</span><span class="strut"> </span></p>
|
||||
<p id="t136" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t137" class="pln"> <span class="com"># 输入一个窗口的数据,指定预测的长度,data:依旧是三维数组(1,win_len,fea_len)</span><span class="strut"> </span></p>
|
||||
<p id="t138" class="pln"> <span class="com"># 返回预测数组</span><span class="strut"> </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:data的窗口大小</span><span class="strut"> </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"> </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"> </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"> </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"> </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了一个预测值(标量)</span><span class="strut"> </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"> </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"># 插入位置[window_size-2]:curr_frame的末尾,predicted[-1]:插入值</span><span class="strut"> </span></p>
|
||||
<p id="t147" class="stm run hide_run"> <span class="key">return</span> <span class="nam">predicted</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t10" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t8" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut"> </span></p>
|
||||
<p id="t9" class="stm run hide_run"><span class="key">import</span> <span class="nam">json</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t11" class="stm run hide_run"><span class="key">import</span> <span class="nam">math</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t19" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t20" class="pln"><span class="strut"> </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与true_data:同长度一维数组</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t28" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t29" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t30" class="pln"><span class="com"># predicted_data每个元素的长度必须为prediction_len</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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为一维数组,长度为prediction_len。predicted_data:二维数组,每个元素为list</span><span class="strut"> </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"> </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:list拼接操作</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t41" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t42" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t43" class="pln"><span class="com"># 只用于训练模型,但同时可根据参数进行模型的评估</span><span class="strut"> </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"># 训练指定股票代码的模型</span><span class="strut"> </span></p>
|
||||
<p id="t45" class="pln"> <span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t46" class="pln"><span class="str"> 训练并保存模型,同时根据测试数据对模型进行评估(绘图方式)</span><span class="strut"> </span></p>
|
||||
<p id="t47" class="pln"><span class="str"> '''</span><span class="strut"> </span></p>
|
||||
<p id="t48" class="pln"><span class="strut"> </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"> </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"> </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"># 创建保存模型的目录</span><span class="strut"> </span></p>
|
||||
<p id="t52" class="pln"><span class="strut"> </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"> </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"> </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"># 若不评估模型准确度,则将全部历史数据用于训练</span><span class="strut"> </span></p>
|
||||
<p id="t56" class="pln"><span class="strut"> </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"># 从本地加载训练和测试数据</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t59" class="pln"> <span class="nam">split</span><span class="op">,</span><span class="strut"> </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"># 选择某些列的数据进行训练</span><span class="strut"> </span></p>
|
||||
<p id="t61" class="pln"> <span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t62" class="pln"><span class="strut"> </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"> </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"># 根据配置文件新建模型</span><span class="strut"> </span></p>
|
||||
<p id="t65" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t66" class="pln"> <span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t67" class="pln"><span class="str"> # in-memory training</span><span class="strut"> </span></p>
|
||||
<p id="t68" class="pln"><span class="str"> model.train(</span><span class="strut"> </span></p>
|
||||
<p id="t69" class="pln"><span class="str"> x,</span><span class="strut"> </span></p>
|
||||
<p id="t70" class="pln"><span class="str"> y,</span><span class="strut"> </span></p>
|
||||
<p id="t71" class="pln"><span class="str"> epochs = configs['training']['epochs'],</span><span class="strut"> </span></p>
|
||||
<p id="t72" class="pln"><span class="str"> batch_size = configs['training']['batch_size'],</span><span class="strut"> </span></p>
|
||||
<p id="t73" class="pln"><span class="str"> save_dir = configs['model']['save_dir']</span><span class="strut"> </span></p>
|
||||
<p id="t74" class="pln"><span class="str"> )</span><span class="strut"> </span></p>
|
||||
<p id="t75" class="pln"><span class="str"> '''</span><span class="strut"> </span></p>
|
||||
<p id="t76" class="pln"> <span class="com"># 训练模型:</span><span class="strut"> </span></p>
|
||||
<p id="t77" class="pln"> <span class="com"># out-of memory generative training</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t85" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t91" class="pln"> <span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t92" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t93" class="pln"> <span class="com"># 预测</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t98" class="pln"> <span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t99" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t102" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">"训练:\n"</span><span class="op">,</span> <span class="nam">predictions</span><span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t103" class="pln"> <span class="com"># plot_results_multiple(predictions, y_test, configs['data']['sequence_length'])</span><span class="strut"> </span></p>
|
||||
<p id="t104" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t105" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t106" class="pln"><span class="com"># 对指定公司的股票进行预测</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t108" class="pln"> <span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t109" class="pln"><span class="str"> 使用保存的模型,对输入数据进行预测</span><span class="strut"> </span></p>
|
||||
<p id="t110" class="pln"><span class="str"> '''</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t117" class="pln"> <span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t118" class="pln"><span class="strut"> </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"> </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"> </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"> </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"># 根据配置文件新建模型</span><span class="strut"> </span></p>
|
||||
<p id="t123" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t124" class="pln"> <span class="com"># predict_length = configs['data']['sequence_length'] # 预测长度</span><span class="strut"> </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"> </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"># 用最近一个窗口的数据进行预测,没有对比数据</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t128" class="pln"> <span class="key">else</span><span class="op">:</span> <span class="com"># 用指定位置的一个窗口数据进行预测,有对比真实数据(用于绘图对比)</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t130" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t133" class="pln"> <span class="nam">normalise</span><span class="op">=</span><span class="key">False</span><span class="strut"> </span></p>
|
||||
<p id="t134" class="pln"> <span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t135" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t140" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t143" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t147" class="pln"> <span class="op">)</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t150" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t152" class="pln"> <span class="com"># predict_length)</span><span class="strut"> </span></p>
|
||||
<p id="t153" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t155" class="pln"> <span class="com"># 反归一化</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t159" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t160" class="pln"> <span class="com"># print("预测数据:\n", predictions)</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t162" class="stm mis"> <span class="nam">print</span><span class="op">(</span><span class="str">"真实数据:\n"</span><span class="op">,</span> <span class="nam">y_test_real</span><span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t163" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t164" class="pln"> <span class="com"># plot_results_multiple(predictions, y_test, predict_length)</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t168" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t170" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t172" class="pln"><span class="strut"> </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"># 给预测数据添加对应日期</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t178" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t179" class="stm run hide_run"> <span class="key">while</span> <span class="nam">counter</span> <span class="op"><</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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t187" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t188" class="stm run hide_run"> <span class="key">return</span> <span class="nam">date_predict</span><span class="strut"> </span></p>
|
||||
<p id="t189" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t190" class="pln"><span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t191" class="pln"><span class="str">def main(stock_code, train=False, predict=False):</span><span class="strut"> </span></p>
|
||||
<p id="t192" class="pln"><span class="str"> configs = json.load(open(get_config_path(), 'r'))</span><span class="strut"> </span></p>
|
||||
<p id="t193" class="pln"><span class="str"> companies = configs['companies']</span><span class="strut"> </span></p>
|
||||
<p id="t194" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t195" class="pln"><span class="str"> if stock_code not in companies.keys():</span><span class="strut"> </span></p>
|
||||
<p id="t196" class="pln"><span class="str"> print("该公司不在指定范围内")</span><span class="strut"> </span></p>
|
||||
<p id="t197" class="pln"><span class="str"> return -1</span><span class="strut"> </span></p>
|
||||
<p id="t198" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t199" class="pln"><span class="str"> if train:</span><span class="strut"> </span></p>
|
||||
<p id="t200" class="pln"><span class="str"> train_model(stock_code)</span><span class="strut"> </span></p>
|
||||
<p id="t201" class="pln"><span class="str"> return 0 # 训练完成</span><span class="strut"> </span></p>
|
||||
<p id="t202" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t203" class="pln"><span class="str"> if predict:</span><span class="strut"> </span></p>
|
||||
<p id="t204" class="pln"><span class="str"> # for root, dirs, files in os.walk('saved_models'):</span><span class="strut"> </span></p>
|
||||
<p id="t205" class="pln"><span class="str"> # root:当前目录路径 dirs: 当前路径下所有子目录 files:当前路径下所有非目录子文件</span><span class="strut"> </span></p>
|
||||
<p id="t206" class="pln"><span class="str"> if stock_code + ".h5" in os.listdir("saved_models"): # os.listdir:获得当前目录下的所有文件名。不包括子目录</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t208" class="pln"><span class="str"> else:</span><span class="strut"> </span></p>
|
||||
<p id="t209" class="pln"><span class="str"> return -2 # 该公司还没有训练模型</span><span class="strut"> </span></p>
|
||||
<p id="t210" class="pln"><span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t211" class="pln"> <span class="com"># 二维数组:[[data,value],[...]]</span><span class="strut"> </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"># 获取某股票,指定天数的历史close数据,包含日期</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t220" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t221" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t228" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t229" class="stm run hide_run"> <span class="key">return</span> <span class="num">0</span><span class="strut"> </span></p>
|
||||
<p id="t230" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t231" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t239" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t240" class="stm run hide_run"> <span class="key">return</span> <span class="nam">predict_list</span><span class="strut"> </span></p>
|
||||
<p id="t241" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t242" class="pln"><span class="strut"> </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的绝对路径</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t246" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t247" class="pln"><span class="strut"> </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目录的绝对路径</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t251" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t252" class="pln"><span class="strut"> </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"># 当前文件的父目录绝对路径</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t255" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t256" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t257" class="pln"><span class="com"># if __name__ == '__main__':</span><span class="strut"> </span></p>
|
||||
<p id="t258" class="pln"><span class="com"># # get_all_last_data("2010-01-01") # 先获得最新数据</span><span class="strut"> </span></p>
|
||||
<p id="t259" class="pln"><span class="com"># train_all_stock()</span><span class="strut"> </span></p>
|
||||
<p id="t260" class="pln"><span class="com"># # predict_all_stock()</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="str">Django settings for WebStockPredict project.</span><span class="strut"> </span></p>
|
||||
<p id="t3" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t4" class="pln"><span class="str">Generated by 'django-admin startproject' using Django 2.1.4.</span><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t6" class="pln"><span class="str">For more information on this file, see</span><span class="strut"> </span></p>
|
||||
<p id="t7" class="pln"><span class="str">https://docs.djangoproject.com/en/2.1/topics/settings/</span><span class="strut"> </span></p>
|
||||
<p id="t8" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t9" class="pln"><span class="str">For the full list of settings and their values, see</span><span class="strut"> </span></p>
|
||||
<p id="t10" class="pln"><span class="str">https://docs.djangoproject.com/en/2.1/ref/settings/</span><span class="strut"> </span></p>
|
||||
<p id="t11" class="pln"><span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t12" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t13" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut"> </span></p>
|
||||
<p id="t14" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t17" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t18" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t19" class="pln"><span class="com"># Quick-start development settings - unsuitable for production</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t21" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t22" class="pln"><span class="com"># SECURITY WARNING: keep the secret key used in production secret!</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t24" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t27" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t29" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t30" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t31" class="pln"><span class="com"># Application definition</span><span class="strut"> </span></p>
|
||||
<p id="t32" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t34" class="pln"> <span class="str">'django.contrib.admin'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t35" class="pln"> <span class="str">'django.contrib.auth'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t36" class="pln"> <span class="str">'django.contrib.contenttypes'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t37" class="pln"> <span class="str">'django.contrib.sessions'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t38" class="pln"> <span class="str">'django.contrib.messages'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t39" class="pln"> <span class="str">'django.contrib.staticfiles'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t40" class="pln"> <span class="str">'stock_predict.apps.StockPredictConfig'</span><span class="strut"> </span></p>
|
||||
<p id="t41" class="pln"><span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t42" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t44" class="pln"> <span class="str">'django.middleware.security.SecurityMiddleware'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t45" class="pln"> <span class="str">'django.contrib.sessions.middleware.SessionMiddleware'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t46" class="pln"> <span class="str">'django.middleware.common.CommonMiddleware'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t47" class="pln"> <span class="str">'django.middleware.csrf.CsrfViewMiddleware'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t48" class="pln"> <span class="str">'django.contrib.auth.middleware.AuthenticationMiddleware'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t49" class="pln"> <span class="str">'django.contrib.messages.middleware.MessageMiddleware'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t50" class="pln"> <span class="str">'django.middleware.clickjacking.XFrameOptionsMiddleware'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t51" class="pln"><span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t52" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t54" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t56" class="pln"> <span class="op">{</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t60" class="pln"> <span class="str">'OPTIONS'</span><span class="op">:</span> <span class="op">{</span><span class="strut"> </span></p>
|
||||
<p id="t61" class="pln"> <span class="str">'context_processors'</span><span class="op">:</span> <span class="op">[</span><span class="strut"> </span></p>
|
||||
<p id="t62" class="pln"> <span class="str">'django.template.context_processors.debug'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t63" class="pln"> <span class="str">'django.template.context_processors.request'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t64" class="pln"> <span class="str">'django.contrib.auth.context_processors.auth'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t65" class="pln"> <span class="str">'django.contrib.messages.context_processors.messages'</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t66" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t67" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t68" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t69" class="pln"><span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t70" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t72" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t73" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t74" class="pln"><span class="com"># Database</span><span class="strut"> </span></p>
|
||||
<p id="t75" class="pln"><span class="com"># https://docs.djangoproject.com/en/2.1/ref/settings/#databases</span><span class="strut"> </span></p>
|
||||
<p id="t76" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t78" class="pln"> <span class="str">'default'</span><span class="op">:</span> <span class="op">{</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t81" class="pln"> <span class="op">}</span><span class="strut"> </span></p>
|
||||
<p id="t82" class="pln"><span class="op">}</span><span class="strut"> </span></p>
|
||||
<p id="t83" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t84" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t85" class="pln"><span class="com"># Password validation</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t87" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t89" class="pln"> <span class="op">{</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t91" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t92" class="pln"> <span class="op">{</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t94" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t95" class="pln"> <span class="op">{</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t97" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t98" class="pln"> <span class="op">{</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t100" class="pln"> <span class="op">}</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t101" class="pln"><span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t102" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t103" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t104" class="pln"><span class="com"># Internationalization</span><span class="strut"> </span></p>
|
||||
<p id="t105" class="pln"><span class="com"># https://docs.djangoproject.com/en/2.1/topics/i18n/</span><span class="strut"> </span></p>
|
||||
<p id="t106" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t108" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t110" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t112" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t114" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t116" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t117" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t118" class="pln"><span class="com"># Static files (CSS, JavaScript, Images)</span><span class="strut"> </span></p>
|
||||
<p id="t119" class="pln"><span class="com"># https://docs.djangoproject.com/en/2.1/howto/static-files/</span><span class="strut"> </span></p>
|
||||
<p id="t120" class="pln"><span class="strut"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="str"> https://docs.djangoproject.com/en/2.1/topics/http/urls/</span><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"><span class="str">Examples:</span><span class="strut"> </span></p>
|
||||
<p id="t6" class="pln"><span class="str">Function views</span><span class="strut"> </span></p>
|
||||
<p id="t7" class="pln"><span class="str"> 1. Add an import: from my_app import views</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t9" class="pln"><span class="str">Class-based views</span><span class="strut"> </span></p>
|
||||
<p id="t10" class="pln"><span class="str"> 1. Add an import: from other_app.views import Home</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t12" class="pln"><span class="str">Including another URLconf</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t15" class="pln"><span class="str">"""</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t18" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t22" class="pln"><span class="op">]</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="str">WSGI config for WebStockPredict project.</span><span class="strut"> </span></p>
|
||||
<p id="t3" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t6" class="pln"><span class="str">For more information on this file, see</span><span class="strut"> </span></p>
|
||||
<p id="t7" class="pln"><span class="str">https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/</span><span class="strut"> </span></p>
|
||||
<p id="t8" class="pln"><span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t9" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t10" class="stm mis"><span class="key">import</span> <span class="nam">os</span><span class="strut"> </span></p>
|
||||
<p id="t11" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t13" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t15" class="pln"><span class="strut"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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'> </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> 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);
|
After Width: | Height: | Size: 112 B |
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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut"> </span></p>
|
||||
<p id="t3" class="stm run hide_run"><span class="key">import</span> <span class="nam">sys</span><span class="strut"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t7" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t12" class="pln"> <span class="str">"available on your PYTHONPATH environment variable? Did you "</span><span class="strut"> </span></p>
|
||||
<p id="t13" class="pln"> <span class="str">"forget to activate a virtual environment?"</span><span class="strut"> </span></p>
|
||||
<p id="t14" class="pln"> <span class="op">)</span> <span class="key">from</span> <span class="nam">exc</span><span class="strut"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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,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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </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">"东软集团"</span><span class="op">,</span><span class="str">"000651"</span><span class="op">:</span><span class="str">"格力电器"</span><span class="op">,</span><span class="str">"600839"</span><span class="op">:</span><span class="str">"四川长虹"</span><span class="op">,</span><span class="str">"600320"</span><span class="op">:</span><span class="str">"振华重工"</span><span class="op">,</span><span class="str">"601988"</span><span class="op">:</span><span class="str">"中国银行"</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"> <span class="str">"000066"</span><span class="op">:</span> <span class="str">"中国长城"</span><span class="op">,</span><span class="str">"601766"</span><span class="op">:</span><span class="str">"中国中车"</span><span class="op">,</span><span class="str">"601390"</span><span class="op">:</span><span class="str">"中国中铁"</span><span class="op">,</span><span class="str">"000768"</span><span class="op">:</span><span class="str">"中航飞机"</span><span class="op">,</span><span class="str">"000063"</span><span class="op">:</span><span class="str">"中兴通讯"</span><span class="op">}</span><span class="strut"> </span></p>
|
||||
<p id="t6" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t12" class="pln"><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </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"> </span></p>
|
||||
<p id="t3" class="pln"><span class="com"># Register your models here.</span><span class="strut"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t3" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t6" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t8" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t10" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t12" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t13" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t17" class="pln"> <span class="nam">fields</span><span class="op">=</span><span class="op">[</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t21" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t22" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t25" class="pln"> <span class="nam">fields</span><span class="op">=</span><span class="op">[</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t29" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t30" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t33" class="pln"> <span class="nam">fields</span><span class="op">=</span><span class="op">[</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t37" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t38" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t39" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t10" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t11" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t17" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t22" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t23" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t10" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t11" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t17" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t22" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t23" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t10" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t11" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t17" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t22" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t23" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t6" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t8" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t11" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t12" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t16" class="pln"> <span class="nam">fields</span><span class="op">=</span><span class="op">[</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t26" class="pln"> <span class="op">]</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t27" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t28" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t10" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
<p id="t11" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t17" class="pln"> <span class="op">)</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t18" class="pln"> <span class="op">]</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t6" class="pln"><span class="com"># Create your models here.</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t10" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t21" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t22" class="pln"><span class="strut"> </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"> </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"> </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"># 字符串类型</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t27" class="pln"><span class="strut"> </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"># 将list类型数据,转为字符串存储</span><span class="strut"> </span></p>
|
||||
<p id="t29" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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"># 记录第一条数据的日期</span><span class="strut"> </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"># 可以将list或dict类型 转为字符串</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t34" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t37" class="pln"><span class="strut"> </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"> </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"># 可以将字符串 转为list或dict类型</span><span class="strut"> </span></p>
|
||||
<p id="t40" class="pln"><span class="strut"> </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"> </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"> </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"># 字符串类型</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t45" class="pln"><span class="strut"> </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"># 将list类型数据,转为字符串存储</span><span class="strut"> </span></p>
|
||||
<p id="t47" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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"># 记录第一条数据的日期</span><span class="strut"> </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"># 可以将list或dict类型 转为字符串</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t52" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t55" class="pln"><span class="strut"> </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"> </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"># 可以将字符串 转为list或dict类型</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </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"> </span></p>
|
||||
<p id="t3" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t13" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t16" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t17" class="pln"><span class="str"> 测试使用非list类型传入set_data,应该抛出异常</span><span class="strut"> </span></p>
|
||||
<p id="t18" class="pln"><span class="str"> """</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t20" class="pln"> <span class="com"># 测试函数hd.set_data(list_data=data)Raises Exception,并且包含指定报错msg</span><span class="strut"> </span></p>
|
||||
<p id="t21" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t25" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t29" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t30" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t32" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t33" class="pln"><span class="str"> 测试正确调用set_data方法,验证HistoryData对象的属性data与start_date被修改</span><span class="strut"> </span></p>
|
||||
<p id="t34" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t40" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t42" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t43" class="pln"><span class="str"> 测试test_get_data返回 list对象</span><span class="strut"> </span></p>
|
||||
<p id="t44" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t49" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t52" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t53" class="pln"><span class="str"> 测试使用非list类型传入set_data,应该抛出异常</span><span class="strut"> </span></p>
|
||||
<p id="t54" class="pln"><span class="str"> """</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t56" class="pln"> <span class="com"># 测试函数hd.set_data(list_data=data)Raises Exception,并且包含指定报错msg</span><span class="strut"> </span></p>
|
||||
<p id="t57" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t61" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t65" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t66" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t68" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t69" class="pln"><span class="str"> 测试正确调用set_data方法,验证HistoryData对象的属性data与start_date被正确修改</span><span class="strut"> </span></p>
|
||||
<p id="t70" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t76" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t78" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t79" class="pln"><span class="str"> 测试test_get_data返回的是list对象</span><span class="strut"> </span></p>
|
||||
<p id="t80" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t85" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t86" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t89" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t91" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t92" class="pln"><span class="str"> 测试 get_hist_predict_data 方法</span><span class="strut"> </span></p>
|
||||
<p id="t93" class="pln"><span class="str"> """</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t95" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t96" class="pln"><span class="str"> 传入未知的stock_code, 返回404错误</span><span class="strut"> </span></p>
|
||||
<p id="t97" class="pln"><span class="str"> """</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t99" class="stm run hide_run"> <span class="key">try</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t103" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t105" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t106" class="pln"><span class="str"> 当数据库存在数据且为最新数据时,返回数据库中的数据</span><span class="strut"> </span></p>
|
||||
<p id="t107" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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">"格力集团"</span><span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t110" class="pln"> <span class="com"># 构造最新历史、预测数据</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t114" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t117" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t121" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t123" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t124" class="pln"><span class="str"> 测试当指定股票代码的历史数据和预测数据,在数据库中没有记录时,则从API获取历史数据,使用模型预测数据,然后保存到数据库</span><span class="strut"> </span></p>
|
||||
<p id="t125" class="pln"><span class="str"> """</span><span class="strut"> </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">"中兴通讯"</span><span class="op">)</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t132" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t138" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t140" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t141" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t143" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t144" class="pln"><span class="str"> 测试当数据库所存数据不是最新时,应该将数据更新</span><span class="strut"> </span></p>
|
||||
<p id="t145" class="pln"><span class="str"> """</span><span class="strut"> </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">"中兴通讯"</span><span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t147" class="pln"> <span class="com"># 构造过时历史、预测数据</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t150" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t154" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t161" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t164" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t165" class="pln"><span class="str"> 测试调用该方法,数据库成功添加了股票公司数据</span><span class="strut"> </span></p>
|
||||
<p id="t166" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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">'东软集团'</span><span class="op">)</span><span class="strut"> </span></p>
|
||||
<p id="t173" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t174" class="pln"><span class="com"># 为公司创造指标数据</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t197" class="stm run hide_run"> <span class="key">return</span> <span class="nam">stock_index</span><span class="strut"> </span></p>
|
||||
<p id="t198" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t199" class="pln"><span class="com"># 为股票创造最新的历史与预测数据</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t204" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t207" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t211" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t212" class="pln"><span class="str"> 测试访问主页时,返回股票代码为:600718的数据,包括:历史、预测和指标数据</span><span class="strut"> </span></p>
|
||||
<p id="t213" class="pln"><span class="str"> """</span><span class="strut"> </span></p>
|
||||
<p id="t214" class="pln"> <span class="com"># 构造最新历史、预测数据</span><span class="strut"> </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">"东软集团"</span><span class="op">)</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t218" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t229" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t230" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t233" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t234" class="pln"><span class="str"> 预测不存在的股票代码,返回404</span><span class="strut"> </span></p>
|
||||
<p id="t235" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t239" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t241" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t242" class="pln"><span class="str"> 测试输入正确的股票代码时,应该返回该股票的历史、预测、指标数据</span><span class="strut"> </span></p>
|
||||
<p id="t243" class="pln"><span class="str"> """</span><span class="strut"> </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">"格力电器"</span><span class="op">)</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t247" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t257" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t258" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t260" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t261" class="pln"><span class="str"> 测试方法 get_crawl_save_data</span><span class="strut"> </span></p>
|
||||
<p id="t262" class="pln"><span class="str"> """</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t264" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t265" class="pln"><span class="str"> 测试调用该方法,数据库增加了 StockIndex 数据</span><span class="strut"> </span></p>
|
||||
<p id="t266" class="pln"><span class="str"> """</span><span class="strut"> </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">"东软集团"</span><span class="op">,</span><span class="str">"000651"</span><span class="op">:</span><span class="str">"格力电器"</span><span class="op">,</span><span class="str">"600839"</span><span class="op">:</span><span class="str">"四川长虹"</span><span class="op">,</span><span class="str">"600320"</span><span class="op">:</span><span class="str">"振华重工"</span><span class="op">,</span><span class="str">"601988"</span><span class="op">:</span><span class="str">"中国银行"</span><span class="op">,</span><span class="strut"> </span></p>
|
||||
<p id="t268" class="pln"> <span class="str">"000066"</span><span class="op">:</span> <span class="str">"中国长城"</span><span class="op">,</span><span class="str">"601766"</span><span class="op">:</span><span class="str">"中国中车"</span><span class="op">,</span><span class="str">"601390"</span><span class="op">:</span><span class="str">"中国中铁"</span><span class="op">,</span><span class="str">"000768"</span><span class="op">:</span><span class="str">"中航飞机"</span><span class="op">,</span><span class="str">"000063"</span><span class="op">:</span><span class="str">"中兴通讯"</span><span class="op">}</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t274" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t277" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t278" class="pln"><span class="str"> 测试训练所有的模型</span><span class="strut"> </span></p>
|
||||
<p id="t279" class="pln"><span class="str"> """</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t281" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t284" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t285" class="pln"><span class="str"> 测试预测所有数据的方法</span><span class="strut"> </span></p>
|
||||
<p id="t286" class="pln"><span class="str"> """</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t288" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t289" class="pln"><span class="com"># sched = Scheduler()</span><span class="strut"> </span></p>
|
||||
<p id="t290" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t291" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t292" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t293" class="pln"><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </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"> </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"> </span></p>
|
||||
<p id="t4" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t5" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t7" class="pln"><span class="strut"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t11" class="pln"><span class="op">]</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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
|
||||
<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> toggle line displays
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">j</span>
|
||||
<span class="key">k</span> next/prev highlighted chunk
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">0</span> (zero) top of page
|
||||
</p>
|
||||
<p class="keyhelp">
|
||||
<span class="key">1</span> (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"> </span></p>
|
||||
<p id="t2" class="stm run hide_run"><span class="key">import</span> <span class="nam">os</span><span class="strut"> </span></p>
|
||||
<p id="t3" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t11" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t13" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t14" class="pln"><span class="com"># LOCAL = False</span><span class="strut"> </span></p>
|
||||
<p id="t15" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t18" class="pln"> <span class="com"># company = models.Company.objects.get(stock_code=stock_code)</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t20" class="pln"><span class="strut"> </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"><=</span> <span class="num">0</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t27" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"># 更新预测数据</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t36" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t38" class="stm run hide_run"> <span class="key">break</span><span class="strut"> </span></p>
|
||||
<p id="t39" class="pln"><span class="strut"> </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"><=</span> <span class="num">0</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t46" class="pln"> <span class="key">else</span><span class="op">:</span><span class="strut"> </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"> </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"> </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"> </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"> </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"># 更新预测数据</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t54" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t56" class="stm run hide_run"> <span class="key">break</span><span class="strut"> </span></p>
|
||||
<p id="t57" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t59" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t61" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t62" class="pln"><span class="str"> 将10个公司的指标数据爬取并保存到数据库</span><span class="strut"> </span></p>
|
||||
<p id="t63" class="pln"><span class="str"> """</span><span class="strut"> </span></p>
|
||||
<p id="t64" class="pln"> <span class="com"># 此处应是从网上爬取数据,并保存为csv文件</span><span class="strut"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t75" class="pln"><span class="strut"> </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"> </span></p>
|
||||
<p id="t77" class="pln"> <span class="str">"""</span><span class="strut"> </span></p>
|
||||
<p id="t78" class="pln"><span class="str"> 获取股票的各项指标数据</span><span class="strut"> </span></p>
|
||||
<p id="t79" class="pln"><span class="str"> """</span><span class="strut"> </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"> </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"><=</span> <span class="num">0</span><span class="op">:</span><span class="strut"> </span></p>
|
||||
<p id="t82" class="pln"> <span class="com"># 将爬取的数据存入数据库</span><span class="strut"> </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"> </span></p>
|
||||
<p id="t84" class="pln"> <span class="com"># 从数据库获取近三天的数据</span><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t87" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t88" class="pln"><span class="strut"> </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"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t94" class="pln"><span class="strut"> </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"> </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"> </span></p>
|
||||
<p id="t97" class="pln"> <span class="com"># print("stock_code:\n",stock_code)</span><span class="strut"> </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"> </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"> </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"> </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"> </span></p>
|
||||
<p id="t102" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t103" class="stm run hide_run"><span class="str">'''</span><span class="strut"> </span></p>
|
||||
<p id="t104" class="pln"><span class="str">sched = Scheduler()</span><span class="strut"> </span></p>
|
||||
<p id="t105" class="pln"><span class="str"># 定时任务</span><span class="strut"> </span></p>
|
||||
<p id="t106" class="pln"><span class="str"># @sched.interval_schedule(seconds=2) # 每2s执行一次</span><span class="strut"> </span></p>
|
||||
<p id="t107" class="pln"><span class="str">@sched.cron_schedule(hour=0,minute=0) # 每日凌晨调度一次</span><span class="strut"> </span></p>
|
||||
<p id="t108" class="pln"><span class="str">def train_models():</span><span class="strut"> </span></p>
|
||||
<p id="t109" class="pln"><span class="str"> run.train_all_stock()</span><span class="strut"> </span></p>
|
||||
<p id="t110" class="pln"><span class="strut"> </span></p>
|
||||
<p id="t111" class="pln"><span class="str">sched.start()</span><span class="strut"> </span></p>
|
||||
<p id="t112" class="pln"><span class="str">'''</span><span class="strut"> </span></p>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="content">
|
||||
<p>
|
||||
<a class="nav" href="index.html">« index</a> <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'
|