Пример #1
0
from fastai.structured import add_datepart
import tensorflow as tf
from tensorflow.keras import layers
from sklearn import neighbors
from sklearn.model_selection import GridSearchCV
from pandas.util.testing import assert_frame_equal

goog = Stocker('GOOGL')
goog.plot_stock()

# Create model
model, model_data = goog.create_prophet_model(days=90)
goog.evaluate_prediction()

# Optimize the model
goog.changepoint_prior_analysis(changepoint_priors=[0.001, 0.05, 0.1, 0.2])
goog.changepoint_prior_validation(start_date='2016-01-04',
                                  end_date='2017-01-03',
                                  changepoint_priors=[0.001, 0.05, 0.1, 0.2])

# Evaluate the new model
goog.evaluate_prediction()
print(goog.evaluate_prediction(nshares=1000))

# Getting the dataframe of the data
goog_data = goog.make_df('2004-08-19', '2018-03-27')
print(goog_data.head(50))

goog_data = goog_data[[
    'Date', 'Open', 'High', 'Low', 'Close', 'Adj. Close', 'Volume'
]]
Пример #2
0
# -*- coding: utf-8 -*-
# @Author      : Ryan
# @Time        : 2021/9/30 22:09
# @Software    : PyCharm
# @Description :

from stocker import Stocker
import matplotlib.pyplot as plt

amazon = Stocker(ticker='AMZN')
model, model_data = amazon.create_prophet_model(days=90)
amazon.evaluate_prediction()
amazon.changepoint_prior_analysis(changepoint_priors=[0.001, 0.05, 0.1, 0.2])
amazon.changepoint_prior_validation(start_date='2016-01-04',
                                    end_date='2017-01-03',
                                    changepoint_priors=[0.001, 0.05, 0.1, 0.2])