- improved
git-svn-id: http://moon:8086/svn/projects/Stock@294 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
+11
-1
@@ -1,7 +1,9 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
import pandas_datareader.data as web
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import math
|
import math
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
import datetime
|
||||||
|
|
||||||
# Stock Investors Financial Math
|
# Stock Investors Financial Math
|
||||||
# https://www.fmlabs.com/reference/default.htm?url=SimpleMA.htm
|
# https://www.fmlabs.com/reference/default.htm?url=SimpleMA.htm
|
||||||
@@ -14,6 +16,8 @@ import matplotlib.pyplot as plt
|
|||||||
|
|
||||||
# Knowledge
|
# Knowledge
|
||||||
# https://www.investopedia.com/articles/technical/02/050602.asp
|
# https://www.investopedia.com/articles/technical/02/050602.asp
|
||||||
|
key = '0UO7Z2MVZ2YSQSVE'
|
||||||
|
|
||||||
|
|
||||||
def sin(f, a, N):
|
def sin(f, a, N):
|
||||||
result = np.empty(0)
|
result = np.empty(0)
|
||||||
@@ -39,9 +43,15 @@ def macd(data):
|
|||||||
|
|
||||||
return ema_short - ema_long
|
return ema_short - ema_long
|
||||||
|
|
||||||
|
# Get stock price via data reader
|
||||||
|
if 0:
|
||||||
|
start = datetime.datetime(2016,1,1)
|
||||||
|
end = datetime.date.today()
|
||||||
|
apple = web.DataReader("AAPL", "av-monthly", start, end, api_key=key)
|
||||||
|
type(apple)
|
||||||
|
|
||||||
pd_data = pd.read_csv("aapl.csv", names=['Dates', 'Price'])
|
pd_data = pd.read_csv("aapl.csv", names=['Dates', 'Price'])
|
||||||
np_data = np.flip(pd_data['Price'].to_numpy())
|
np_data = np.flip(pd_data['Price'].to_numpy())
|
||||||
a = sin(2, 1, 100)
|
|
||||||
|
|
||||||
plt.plot(np_data, label='Price')
|
plt.plot(np_data, label='Price')
|
||||||
plt.plot(ema(np_data), label='EMA')
|
plt.plot(ema(np_data), label='EMA')
|
||||||
|
|||||||
Reference in New Issue
Block a user