This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import quandl | |
import pandas as pd | |
class MeanReversion: | |
def __init__(self, security, start_date, end_date, sma_, lma_): | |
self.security = security | |
self.start_date = start_date | |
self.end_date = end_date | |
self.sma_ = sma_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@application.route('/meanreversion/result/<security>/<start_date>/<end_date>/<int:sma_>/<int:lma_>') | |
def meanreversion_result(security,start_date,end_date,sma_,lma_): | |
m = MeanReversion(security, start_date, end_date, sma_, lma_) | |
smadf = m.moving_average_df(m.sma_) | |
lmadf = m.moving_average_df(m.lma_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask_wtf import FlaskForm | |
from wtforms import StringField, DateField, validators | |
class CorrelationForm(FlaskForm): | |
stock1 = StringField('Stock 1', | |
[validators.Required('Start typing ticker symbol and select'), | |
validators.Length(min=1, max=5)], id = "ticker1") | |
stock2 = StringField('Stock 2', | |
[validators.Required('Start typing ticker symbol and select'), | |
validators.Length(min=1, max=5)], id = "ticker2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@application.route('/correlation', methods=['GET', 'POST']) | |
def correlation(): | |
form = CorrelationForm() | |
if request.method == 'POST' and form.validate(): | |
security1 = request.form['stock1'] | |
security2 = request.form['stock2'] | |
start_date = request.form['date_start'] | |
end_date = request.form['date_end'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method=”post” action=”{{ url_for(‘correlation’) }}”> | |
{{ form.hidden_tag() }} | |
<div class=”form-group row”> | |
<div class=”col-sm-10 col-lg-10"> | |
{{ form.stock1.label |safe }} {{ form.stock1(placeholder=”e.g., GOOG”, class=”form-control”)|safe }} {% if form.stock1.errors %} | |
<ul class=”alert alert-info alert-dismissible” role=”alert”> | |
<button type=”button” class=”close” data-dismiss=”alert” aria-label=”Close” <span aria-hidden=”true”>×</span> | |
</button> | |
{% for error in form.stock1.errors %} | |
<strong>{{ error }}</strong> {% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<div class="col-lg-4 col-md-4 col-sm-6"> | |
<div class="panel panel-primary"> | |
<div class="panel-heading"> | |
<div class="row"> | |
<div class="col-xs-3"> | |
<i class="fa fa-institution fa-4x"></i> | |
</div> | |
<div class="col-xs-9 text-right"> | |
<div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# “404 Page Not Found” | |
@application.errorhandler(404) | |
def page_not_found(e): | |
return render_template('404.html'), 404 | |
# “500 Internal Server Error” | |
@application.errorhandler(500) | |
def page_not_found(e): | |
return render_template('500.html'), 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for message in get_flashed_messages() %} | |
<div class="alert alert-warning alert-dismissible" role="alert"> | |
<button type="button" class="close" data-dismiss="alert" aria-label="Close" | |
<span | |
aria-hidden="true">×</span></button> | |
{{ message }} | |
</div> | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@application.route('/correlation/result/<security1>/<security2>/<start_date>/<end_date>') | |
def correlation_result(security1,security2,start_date,end_date): | |
try: | |
c = Correlation(security1, security2, start_date, end_date) | |
except: | |
if start_date > end_date: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
packages: | |
yum: | |
gcc-c++: [] | |
python34-devel: [] |
OlderNewer