-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstock_info_grabber.py
59 lines (40 loc) · 2 KB
/
stock_info_grabber.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from yahoo_finance import Share
import pandas as pd
import numpy as np
symbols = ['RGLS','HRZN','SPWR','PDVW','RMD','LOPE','VRML','BBG','SHO','GHDX','ARC','CGNT','DVA','EXR','STAG','RIGL','IPCC','IPHS','RIBT','FLEX',\
'APTS','ROL','DEI','NFX','OKE','VOYA','KMB','REXR','SEAS','PBA','DSE','GSS','ZTR','FMC','SYX','UIS','ALL','PAG','RHI','RPXC','X','SKT','WAC.BC','VST','FTK']
def get_stock_info(ticker):
temp_share = Share(ticker)
real_price = temp_share.get_price()
adj_price = (float(temp_share.get_open()) + float(temp_share.get_close()) + float(temp_share.get_high()) + float(temp_share.get_low()))/4
real_vol = temp_share.get_volume()
avg_vol = temp_share.get_avg_daily_volume()
avg_50_day = temp_share.get_50day_moving_avg()
avg_200_day = temp_share.get_200day_moving_avg()
return real_price, adj_price, real_vol, avg_vol, avg_50_day, avg_200_day
#%%
get_stock_info('SPWR')
#%%
for symbol in symbols:
get_stock_info(symbol)
#%%
spwr = Share('SPWR')
print(spwr.get_historical('2017-07-21','2017-08-01'))
#%%
from pandas_datareader import data
import matplotlib.pyplot as plt
import pandas as pd
data_source = 'google'
symbols = ['RGLS','HRZN','SPWR','PDVW','RMD','LOPE','VRML','BBG','SHO','GHDX','ARC','CGNT','DVA','EXR','STAG','RIGL','IPCC','IPHS','RIBT','FLEX',\
'APTS','ROL','DEI','NFX','OKE','VOYA','KMB','REXR','SEAS','PBA','DSE','GSS','ZTR','FMC','SYX','UIS','ALL','PAG','RHI','RPXC','X','SKT','WAC.BC','VST','FTK']
symbol = 'SPWR'
start_date = '2017-08-01'
end_date = '2017-08-01'
panel_data = data.DataReader(symbols, data_source, start_date, end_date)
df_data = panel_data.to_frame()
print(df_data.info())
df_data = df_data.apply(pd.to_numeric, errors='ignore')
filtered = df_data[(df_data['Close'] <= 50) & (df_data['Volume'] >= 500000)]
filtered['Gap$'] = filtered['High'] - filtered['Low']
filtered['Gap%'] = (filtered['High'] - filtered['Low']) / filtered['Open']
print(filtered)