feat(Model): continued with the keras model scaffolding

This commit is contained in:
Mark Aron Szulyovszky
2021-11-10 14:51:12 +01:00
parent 20aa1474d6
commit 3188aab220
22 changed files with 21751 additions and 21633 deletions
+2 -2
View File
@@ -38,11 +38,11 @@ def get_stock_price_av(symbol: str, start_date: str = None) -> pd.DataFrame:
api_url = f'https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol={symbol}&outputsize=full&apikey={AV_API_KEY}'
raw_df = requests.get(api_url).json()
df = pd.DataFrame(raw_df['Time Series (Daily)']).T
df = df.rename(columns = {'1. open': 'open', '2. high': 'high', '3. low': 'low', '4. close': 'close', '5. adjusted close': 'adj_close', '6. volume': 'volume'})
df = df.rename(columns = {'1. open': 'open', '2. high': 'high', '3. low': 'low', '5. adjusted close': 'close', '6. volume': 'volume'})
for i in df.columns:
df[i] = df[i].astype(float)
df.index = pd.to_datetime(df.index)
df = df.iloc[::-1].drop(['7. dividend amount', '8. split coefficient'], axis = 1)
df = df.iloc[::-1].drop(['4. close', '7. dividend amount', '8. split coefficient'], axis = 1)
if start_date:
df = df[df.index >= start_date]
df.sort_index(inplace = True, ascending= True)
+5
View File
@@ -0,0 +1,5 @@
def normalize(data, train_split):
data_mean = data[:train_split].mean(axis=0)
data_std = data[:train_split].std(axis=0)
return (data - data_mean) / data_std