Initial import
git-svn-id: http://moon:8086/svn/projects/Stock@291 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
2019-12-06,270.71
|
||||
2019-12-05,265.58
|
||||
2019-12-04,261.74
|
||||
2019-12-03,259.45
|
||||
2019-12-02,264.16
|
||||
2019-11-29,267.25
|
||||
2019-11-27,267.84
|
||||
2019-11-26,264.29
|
||||
2019-11-25,266.37
|
||||
2019-11-22,261.78
|
||||
2019-11-21,262.01
|
||||
2019-11-20,263.19
|
||||
2019-11-19,266.29
|
||||
2019-11-18,267.1
|
||||
2019-11-15,265.76
|
||||
2019-11-14,262.64
|
||||
2019-11-13,264.47
|
||||
2019-11-12,261.96
|
||||
2019-11-11,262.2
|
||||
2019-11-08,260.14
|
||||
2019-11-07,259.43
|
||||
2019-11-06,257.24
|
||||
2019-11-05,257.13
|
||||
2019-11-04,257.5
|
||||
2019-11-01,255.82
|
||||
2019-10-31,248.76
|
||||
2019-10-30,243.26
|
||||
2019-10-29,243.29
|
||||
2019-10-28,249.05
|
||||
2019-10-25,246.58
|
||||
2019-10-24,243.58
|
||||
2019-10-23,243.18
|
||||
2019-10-22,239.96
|
||||
2019-10-21,240.51
|
||||
2019-10-18,236.41
|
||||
2019-10-17,235.28
|
||||
2019-10-16,234.37
|
||||
2019-10-15,235.32
|
||||
2019-10-14,235.87
|
||||
2019-10-11,236.21
|
||||
2019-10-10,230.09
|
||||
2019-10-09,227.03
|
||||
2019-10-08,224.4
|
||||
2019-10-07,227.06
|
||||
2019-10-04,227.01
|
||||
2019-10-03,220.82
|
||||
2019-10-02,218.96
|
||||
2019-10-01,224.59
|
||||
2019-09-30,223.97
|
||||
2019-09-27,218.82
|
||||
2019-09-26,219.89
|
||||
2019-09-25,221.03
|
||||
2019-09-24,217.68
|
||||
2019-09-23,218.72
|
||||
2019-09-20,217.73
|
||||
2019-09-19,220.96
|
||||
2019-09-18,222.77
|
||||
2019-09-17,220.7
|
||||
2019-09-16,219.9
|
||||
2019-09-13,218.75
|
||||
2019-09-12,223.085
|
||||
2019-09-11,223.59
|
||||
2019-09-10,216.7
|
||||
2019-09-09,214.17
|
||||
2019-09-06,213.26
|
||||
2019-09-05,213.28
|
||||
2019-09-04,209.19
|
||||
2019-09-03,205.7
|
||||
2019-08-30,208.74
|
||||
2019-08-29,209.01
|
||||
2019-08-28,205.53
|
||||
2019-08-27,204.16
|
||||
2019-08-26,206.49
|
||||
2019-08-23,202.64
|
||||
2019-08-22,212.46
|
||||
2019-08-21,212.64
|
||||
2019-08-20,210.36
|
||||
2019-08-19,210.35
|
||||
2019-08-16,206.5
|
||||
2019-08-15,201.74
|
||||
2019-08-14,202.75
|
||||
2019-08-13,208.97
|
||||
2019-08-12,200.48
|
||||
2019-08-09,200.99
|
||||
2019-08-08,203.43
|
||||
2019-08-07,199.04
|
||||
2019-08-06,197.0
|
||||
2019-08-05,193.34
|
||||
2019-08-02,204.02
|
||||
2019-08-01,208.43
|
||||
2019-07-31,213.04
|
||||
2019-07-30,208.78
|
||||
2019-07-29,209.68
|
||||
2019-07-26,207.74
|
||||
2019-07-25,207.02
|
||||
2019-07-24,208.67
|
||||
2019-07-23,208.84
|
||||
2019-07-22,207.22
|
||||
2019-07-19,202.59
|
||||
2019-07-18,205.66
|
||||
|
+35
@@ -0,0 +1,35 @@
|
||||
'''
|
||||
On your terminal run:
|
||||
pip install alpha_vantage
|
||||
|
||||
This also uses the pandas dataframe, and matplotlib, commonly used python packages
|
||||
pip install pandas
|
||||
pip install matplotlib
|
||||
|
||||
For the develop version run:
|
||||
pip install git+https://github.com/RomelTorres/alpha_vantage.git@develop
|
||||
'''
|
||||
|
||||
from alpha_vantage.timeseries import TimeSeries
|
||||
from alpha_vantage.techindicators import TechIndicators
|
||||
|
||||
from matplotlib.pyplot import figure
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Your key here
|
||||
key = '0UO7Z2MVZ2YSQSVE'
|
||||
# Chose your output format, or default to JSON (python dict)
|
||||
ts = TimeSeries(key, output_format='pandas')
|
||||
|
||||
# Get the data, returns a tuple
|
||||
# aapl_data is a pandas dataframe, aapl_meta_data is a dict
|
||||
aapl_data, aapl_meta_data = ts.get_daily(symbol='AAPL')
|
||||
|
||||
|
||||
# Visualization
|
||||
figure(num=None, figsize=(15, 6), dpi=80, facecolor='w', edgecolor='k')
|
||||
aapl_data['4. close'].plot()
|
||||
dataArray = aapl_data['4. close'].to_numpy()
|
||||
plt.tight_layout()
|
||||
plt.grid()
|
||||
plt.show()
|
||||
@@ -0,0 +1,41 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import math
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# https://www.fmlabs.com/reference/default.htm?url=SimpleMA.htm
|
||||
|
||||
def sin(f, a, N):
|
||||
result = np.empty(0)
|
||||
for n in range(0, N):
|
||||
v = a*math.sin(2*math.pi*f*n/N)
|
||||
result = np.append(result, v)
|
||||
|
||||
return result
|
||||
|
||||
def ema(data, alpha=0.75):
|
||||
result = np.empty(0)
|
||||
r = data[0]
|
||||
|
||||
for v in data:
|
||||
r = alpha*r + (1-alpha)*v
|
||||
result = np.append(result, r)
|
||||
|
||||
return result
|
||||
|
||||
def macd(data):
|
||||
ema_short = ema(data, alpha=0.85)
|
||||
ema_long = ema(data, alpha=0.925)
|
||||
|
||||
return ema_short - ema_long
|
||||
|
||||
pd_data = pd.read_csv("aapl.csv", names=['Dates', 'Price'])
|
||||
np_data = np.flip(pd_data['Price'].to_numpy())
|
||||
a = sin(2, 1, 100)
|
||||
|
||||
plt.plot(np_data, label='Price')
|
||||
plt.plot(ema(np_data), label='EMA')
|
||||
plt.plot(macd(np_data), label='MACD')
|
||||
plt.legend()
|
||||
plt.grid()
|
||||
plt.show()
|
||||
@@ -0,0 +1,40 @@
|
||||
'''
|
||||
On your terminal run:
|
||||
pip install alpha_vantage
|
||||
|
||||
This also uses the pandas dataframe, and matplotlib, commonly used python packages
|
||||
pip install pandas
|
||||
pip install matplotlib
|
||||
|
||||
For the develop version run:
|
||||
pip install git+https://github.com/RomelTorres/alpha_vantage.git@develop
|
||||
'''
|
||||
|
||||
from alpha_vantage.timeseries import TimeSeries
|
||||
from alpha_vantage.techindicators import TechIndicators
|
||||
|
||||
from matplotlib.pyplot import figure
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Your key here
|
||||
key = '0UO7Z2MVZ2YSQSVE'
|
||||
# Chose your output format, or default to JSON (python dict)
|
||||
ts = TimeSeries(key, output_format='pandas')
|
||||
ti = TechIndicators(key, output_format='pandas')
|
||||
|
||||
# Get the data, returns a tuple
|
||||
# aapl_data is a pandas dataframe, aapl_meta_data is a dict
|
||||
aapl_data, aapl_meta_data = ts.get_daily(symbol='AAPL')
|
||||
# aapl_sma is a dict, aapl_meta_sma also a dict
|
||||
aapl_sma, aapl_meta_sma = ti.get_sma(symbol='AAPL')
|
||||
|
||||
aapl_data['4. close'].to_csv("aapl.csv")
|
||||
|
||||
# Visualization
|
||||
figure(num=None, figsize=(15, 6), dpi=80, facecolor='w', edgecolor='k')
|
||||
aapl_data['4. close'].plot()
|
||||
#aapl_sma['SMA'].plot()
|
||||
|
||||
plt.tight_layout()
|
||||
plt.grid()
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user