#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat May 19 11:55:33 2018

@author: jonas
"""

# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

#stock_id = '00713'
#stock_id = '0050'
stock_id = '0052'

###########################################################
import settings
from util import load_csv, load_weighted_csv
filepath = '{}/tetfp.csv'.format(settings.DATASET_PATH)
history = load_csv(filepath, int(stock_id))

# Extracting/Filtering the training dataset by stock_id
# Taking 收盤價 as a predictor
from util import query_close_price, query_open_price, query_avg_price, query_volume
from util import query_high_price, query_low_price
dataset = query_close_price(history, int(stock_id))

###########################################################
# Visualising the stock price
from util import plot_stock_price
plot_stock_price(dataset)

###########################################################
from util import plot_stock_price
from matplotlib import pyplot
from statsmodels.graphics.tsaplots import plot_acf
from statsmodels.graphics.tsaplots import plot_pacf
lags=30
dataset_1d = pd.DataFrame(dataset).diff(lags).dropna().values
plot_stock_price(dataset)
plot_stock_price(dataset_1d)
plot_acf(dataset_1d, lags=lags)
pyplot.show()
plot_pacf(dataset_1d, lags=lags)
pyplot.show()