goldhand 9.0__py3-none-any.whl → 11.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of goldhand might be problematic. Click here for more details.
- goldhand/__init__.py +0 -1
- goldhand/stocks.py +38 -84
- goldhand/tw.py +6 -22
- {goldhand-9.0.dist-info → goldhand-11.3.dist-info}/METADATA +1 -1
- goldhand-11.3.dist-info/RECORD +8 -0
- {goldhand-9.0.dist-info → goldhand-11.3.dist-info}/WHEEL +1 -1
- goldhand/test.py +0 -10
- goldhand/video.py +0 -0
- goldhand-9.0.dist-info/RECORD +0 -10
- {goldhand-9.0.dist-info → goldhand-11.3.dist-info}/top_level.txt +0 -0
goldhand/__init__.py
CHANGED
goldhand/stocks.py
CHANGED
|
@@ -10,29 +10,32 @@ import json
|
|
|
10
10
|
import cloudscraper
|
|
11
11
|
|
|
12
12
|
class GoldHand:
|
|
13
|
-
def __init__(self, ticker,
|
|
13
|
+
def __init__(self, ticker, ad_ticker=True, range='18y', interval='1d'):
|
|
14
14
|
self.scraper = cloudscraper.create_scraper()
|
|
15
|
+
self.ad_ticker = ad_ticker
|
|
16
|
+
self.range = range
|
|
17
|
+
self.interval = interval
|
|
15
18
|
self.ticker = ticker
|
|
16
19
|
self.df = None
|
|
17
|
-
self.static_plot = static_plot
|
|
18
20
|
self.download_historical_data()
|
|
19
21
|
|
|
20
22
|
|
|
21
|
-
def get_olhc(self
|
|
22
|
-
|
|
23
|
+
def get_olhc(self):
|
|
24
|
+
#scraper = cloudscraper.create_scraper()
|
|
25
|
+
response = self.scraper.get(f"https://query1.finance.yahoo.com/v8/finance/chart/{self.ticker}?interval={self.interval}&range={self.range}")
|
|
23
26
|
t= response.json()
|
|
24
27
|
df = pd.DataFrame(t['chart']['result'][0]['indicators']['quote'][0])
|
|
25
28
|
df['date'] = pd.to_datetime(t['chart']['result'][0]['timestamp'], unit='s').date
|
|
26
29
|
df = df[['date', 'open', 'low', 'high', 'close', 'volume']]
|
|
27
|
-
if ad_ticker:
|
|
28
|
-
df['ticker'] = ticker
|
|
30
|
+
if self.ad_ticker:
|
|
31
|
+
df['ticker'] = self.ticker
|
|
29
32
|
return(df)
|
|
30
33
|
|
|
31
34
|
|
|
32
35
|
|
|
33
36
|
def download_historical_data(self):
|
|
34
37
|
# Download historical stock data for the last year
|
|
35
|
-
self.df = self.get_olhc(
|
|
38
|
+
self.df = self.get_olhc()
|
|
36
39
|
self.df.columns = self.df.columns.str.lower()
|
|
37
40
|
|
|
38
41
|
# Rsi
|
|
@@ -102,50 +105,30 @@ class GoldHand:
|
|
|
102
105
|
|
|
103
106
|
states = self.df[self.df['local']!='']['local'].index.to_list()
|
|
104
107
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
self.df.loc[states[i], 'local_text'] = f'Up:{round(((rise+100)/100), 2)}x<br>${round(current_high, 2)}'
|
|
119
|
-
else:
|
|
120
|
-
self.df.loc[states[i], 'local_text'] = f'Up:{round(rise, 2)}%<br>${round(current_high, 2)}'
|
|
108
|
+
|
|
109
|
+
for i in range(1,len(states)):
|
|
110
|
+
prev = self.df.loc[states[i-1], 'local']
|
|
111
|
+
current= self.df.loc[states[i], 'local']
|
|
112
|
+
prev_high = self.df.loc[states[i-1], 'high']
|
|
113
|
+
prev_low = self.df.loc[states[i-1], 'low']
|
|
114
|
+
current_high = self.df.loc[states[i], 'high']
|
|
115
|
+
current_low = self.df.loc[states[i], 'low']
|
|
116
|
+
if current == 'maximum':
|
|
117
|
+
# rise
|
|
118
|
+
rise = (current_high/ prev_low -1)*100
|
|
119
|
+
if rise>100:
|
|
120
|
+
self.df.loc[states[i], 'local_text'] = f'🚀🌌{round(((rise+100)/100), 2)}x<br>${round(current_high, 2)}'
|
|
121
121
|
else:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
prev_high = self.df.loc[states[i-1], 'high']
|
|
130
|
-
prev_low = self.df.loc[states[i-1], 'low']
|
|
131
|
-
current_high = self.df.loc[states[i], 'high']
|
|
132
|
-
current_low = self.df.loc[states[i], 'low']
|
|
133
|
-
if current == 'maximum':
|
|
134
|
-
# rise
|
|
135
|
-
rise = (current_high/ prev_low -1)*100
|
|
136
|
-
if rise>100:
|
|
137
|
-
self.df.loc[states[i], 'local_text'] = f'🚀🌌{round(((rise+100)/100), 2)}x<br>${round(current_high, 2)}'
|
|
138
|
-
else:
|
|
139
|
-
self.df.loc[states[i], 'local_text'] = f'🚀{round(rise, 2)}%<br>${round(current_high, 2)}'
|
|
122
|
+
self.df.loc[states[i], 'local_text'] = f'🚀{round(rise, 2)}%<br>${round(current_high, 2)}'
|
|
123
|
+
else:
|
|
124
|
+
fall = round((1-(current_low / prev_high))*100, 2)
|
|
125
|
+
if fall < 30:
|
|
126
|
+
temj = '💸'
|
|
127
|
+
elif fall < 50:
|
|
128
|
+
temj = '💸'
|
|
140
129
|
else:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
temj = '🪂'
|
|
144
|
-
elif fall < 50:
|
|
145
|
-
temj = '💸'
|
|
146
|
-
else:
|
|
147
|
-
temj = '😭💔'
|
|
148
|
-
self.df.loc[states[i], 'local_text'] = f'{temj}{fall}%<br>${round(current_low, 2)}'
|
|
130
|
+
temj = '😭💔'
|
|
131
|
+
self.df.loc[states[i], 'local_text'] = f'{temj}{fall}%<br>${round(current_low, 2)}'
|
|
149
132
|
|
|
150
133
|
|
|
151
134
|
def plotly_last_year(self, plot_title, plot_height=900):
|
|
@@ -160,45 +143,15 @@ class GoldHand:
|
|
|
160
143
|
min_price = row['low']
|
|
161
144
|
max_price = row['high']
|
|
162
145
|
if direction == 'maximum':
|
|
163
|
-
fig.add_annotation( x=tdate, y=max_price, text=local_text, showarrow=True,
|
|
164
|
-
align="center", bordercolor="#c7c7c7",
|
|
165
|
-
font=dict(family="Courier New, monospace", size=16, color="#214e34" ), borderwidth=2,
|
|
166
|
-
borderpad=4,
|
|
167
|
-
bgcolor="#f4fdff",
|
|
168
|
-
opacity=0.8,
|
|
169
|
-
arrowhead=2,
|
|
170
|
-
arrowsize=1,
|
|
171
|
-
arrowwidth=1,
|
|
172
|
-
ax=-45,ay=-45)
|
|
146
|
+
fig.add_annotation( x=tdate, y=max_price, text=local_text, showarrow=True, align="center", bordercolor="#c7c7c7", font=dict(family="Courier New, monospace", size=16, color="#214e34" ), borderwidth=2, borderpad=4, bgcolor="#f4fdff", opacity=0.8, arrowhead=2, arrowsize=1, arrowwidth=1, ax=-45,ay=-45)
|
|
173
147
|
|
|
174
148
|
if direction == 'minimum':
|
|
175
|
-
fig.add_annotation( x=tdate, y=min_price, text=local_text, showarrow=True,
|
|
176
|
-
align="center", bordercolor="#c7c7c7",
|
|
177
|
-
font=dict(family="Courier New, monospace", size=16, color="red" ), borderwidth=2,
|
|
178
|
-
borderpad=4,
|
|
179
|
-
bgcolor="#f4fdff",
|
|
180
|
-
opacity=0.8,
|
|
181
|
-
arrowhead=2,
|
|
182
|
-
arrowsize=1,
|
|
183
|
-
arrowwidth=1,
|
|
184
|
-
ax=45,ay=45)
|
|
149
|
+
fig.add_annotation( x=tdate, y=min_price, text=local_text, showarrow=True, align="center", bordercolor="#c7c7c7", font=dict(family="Courier New, monospace", size=16, color="red" ), borderwidth=2, borderpad=4, bgcolor="#f4fdff", opacity=0.8, arrowhead=2, arrowsize=1, arrowwidth=1, ax=45,ay=45)
|
|
185
150
|
|
|
186
151
|
fig.update_layout(showlegend=False, plot_bgcolor='white', height=plot_height, title= plot_title)
|
|
187
152
|
|
|
188
|
-
fig.update_xaxes(
|
|
189
|
-
|
|
190
|
-
ticks='outside',
|
|
191
|
-
showline=True,
|
|
192
|
-
linecolor='black',
|
|
193
|
-
gridcolor='lightgrey'
|
|
194
|
-
)
|
|
195
|
-
fig.update_yaxes(
|
|
196
|
-
mirror=True,
|
|
197
|
-
ticks='outside',
|
|
198
|
-
showline=True,
|
|
199
|
-
linecolor='black',
|
|
200
|
-
gridcolor='lightgrey'
|
|
201
|
-
)
|
|
153
|
+
fig.update_xaxes( mirror=True, ticks='outside', showline=True, linecolor='black', gridcolor='lightgrey' )
|
|
154
|
+
fig.update_yaxes( mirror=True, ticks='outside', showline=True, linecolor='black', gridcolor='lightgrey')
|
|
202
155
|
fig.update(layout_xaxis_rangeslider_visible=False)
|
|
203
156
|
fig.add_trace( go.Scatter(x=tdf['date'], y=tdf['sma_50'], opacity =0.5, line=dict(color='lightblue', width = 2) , name = 'SMA 50') )
|
|
204
157
|
fig.add_trace( go.Scatter(x=tdf['date'], y=tdf['sma_200'], opacity =0.7, line=dict(color='red', width = 2.5) , name = 'SMA 200') )
|
|
@@ -207,4 +160,5 @@ class GoldHand:
|
|
|
207
160
|
|
|
208
161
|
# https://stackoverflow.com/questions/71411995/pandas-plotly-secondary-graph-needs-to-be-to-rsi
|
|
209
162
|
|
|
210
|
-
#https://wire.insiderfinance.io/plot-candlestick-rsi-bollinger-bands-and-macd-charts-using-yfinance-python-api-1c2cb182d147
|
|
163
|
+
#https://wire.insiderfinance.io/plot-candlestick-rsi-bollinger-bands-and-macd-charts-using-yfinance-python-api-1c2cb182d147
|
|
164
|
+
|
goldhand/tw.py
CHANGED
|
@@ -16,7 +16,7 @@ class Tw:
|
|
|
16
16
|
self.get_all_crypto()
|
|
17
17
|
|
|
18
18
|
def get_all_stock(self):
|
|
19
|
-
data_query = '{"filter":[{"left":"type","operation":"in_range","right":["stock","dr","fund"]},{"left":"subtype","operation":"in_range","right":["common","foreign-issuer","","etf","etf,odd","etf,otc","etf,cfd"]},{"left":"exchange","operation":"in_range","right":["AMEX","NASDAQ","NYSE"]},{"left":"is_primary","operation":"equal","right":true},{"left":"active_symbol","operation":"equal","right":true}],"options":{"lang":"en"},"markets":["america"],"symbols":{"query":{"types":[]},"tickers":[]},"columns":["logoid","name","close","change","change_abs","Recommend.All","volume","Value.Traded","market_cap_basic","price_earnings_ttm","earnings_per_share_basic_ttm","number_of_employees","sector","
|
|
19
|
+
data_query = '{"filter":[{"left":"type","operation":"in_range","right":["stock","dr","fund"]},{"left":"subtype","operation":"in_range","right":["common","foreign-issuer","","etf","etf,odd","etf,otc","etf,cfd"]},{"left":"exchange","operation":"in_range","right":["AMEX","NASDAQ","NYSE"]},{"left":"is_primary","operation":"equal","right":true},{"left":"active_symbol","operation":"equal","right":true}],"options":{"lang":"en"},"markets":["america"],"symbols":{"query":{"types":[]},"tickers":[]},"columns":["logoid","name","close","change","change_abs","Recommend.All","volume","Value.Traded","market_cap_basic","price_earnings_ttm","earnings_per_share_basic_ttm","number_of_employees","sector","High.3M","Low.3M","Perf.3M","Perf.5Y","High.1M","Low.1M","High.6M","Low.6M","Perf.6M","beta_1_year","price_52_week_high","price_52_week_low","High.All","Low.All","BB.lower","BB.upper","change|1M","change_abs|1M","change|1W","change_abs|1W","change|240","country","EMA50","EMA100","EMA200","MACD.macd","MACD.signal","Mom","Perf.1M","RSI7","SMA50","SMA100","SMA200","Stoch.RSI.K","Stoch.RSI.D","Perf.W","Perf.Y","Perf.YTD","industry","Perf.All","description","type","subtype","update_mode","pricescale","minmov","fractional","minmove2","Mom[1]","RSI7[1]","Rec.Stoch.RSI","currency","fundamental_currency_code"],"sort":{"sortBy":"market_cap_basic","sortOrder":"desc"},"range":[0,8000]}'
|
|
20
20
|
response = requests.post('https://scanner.tradingview.com/america/scan', data=data_query)
|
|
21
21
|
data = response.json()
|
|
22
22
|
list_elements = list(map(lambda x:x['d'], data['data'] ))
|
|
@@ -94,16 +94,7 @@ class Tw:
|
|
|
94
94
|
|
|
95
95
|
fig = px.bar(secdf, x='name', y='market_cap_basic', title = f"{row_df['Company'].iloc[0]} ({row_df['name'].iloc[0]})<br>{row_df['sector'].iloc[0]} | {row_df['industry'].iloc[0]}", labels={'market_cap_basic':'Market kapitalization'}, text='Company')
|
|
96
96
|
|
|
97
|
-
fig.add_annotation( x=row_df['name'].iloc[0], y=row_df['market_cap_basic'].iloc[0], text= f"{market_cap}", showarrow=True,
|
|
98
|
-
align="center", bordercolor="#c7c7c7",
|
|
99
|
-
font=dict(family="Courier New, monospace", size=16, color="#214e34" ), borderwidth=2,
|
|
100
|
-
borderpad=4,
|
|
101
|
-
bgcolor="#f4fdff",
|
|
102
|
-
opacity=0.8,
|
|
103
|
-
arrowhead=2,
|
|
104
|
-
arrowsize=1,
|
|
105
|
-
arrowwidth=1,
|
|
106
|
-
ax=65,ay=-45)
|
|
97
|
+
fig.add_annotation( x=row_df['name'].iloc[0], y=row_df['market_cap_basic'].iloc[0], text= f"{market_cap}", showarrow=True, align="center", bordercolor="#c7c7c7", font=dict(family="Courier New, monospace", size=16, color="#214e34" ), borderwidth=2, borderpad=4, bgcolor="#f4fdff", opacity=0.8, arrowhead=2, arrowsize=1, arrowwidth=1, ax=65,ay=-45)
|
|
107
98
|
fig.update_layout(showlegend=False, plot_bgcolor='white', height=600)
|
|
108
99
|
fig.show()
|
|
109
100
|
|
|
@@ -122,19 +113,12 @@ class Tw:
|
|
|
122
113
|
fig = px.bar(inddf, x='name', y='market_cap_basic', title = f"{row_df['Company'].iloc[0]} ({row_df['name'].iloc[0]})<br>{row_df['sector'].iloc[0]} | {row_df['industry'].iloc[0]}", labels={'market_cap_basic':'Market kapitalization'}, text='Company')
|
|
123
114
|
|
|
124
115
|
|
|
125
|
-
fig.add_annotation( x=row_df['name'].iloc[0], y=row_df['market_cap_basic'].iloc[0], text= f"{market_cap}", showarrow=True,
|
|
126
|
-
align="center", bordercolor="#c7c7c7",
|
|
127
|
-
font=dict(family="Courier New, monospace", size=16, color="#214e34" ), borderwidth=2,
|
|
128
|
-
borderpad=4,
|
|
129
|
-
bgcolor="#f4fdff",
|
|
130
|
-
opacity=0.8,
|
|
131
|
-
arrowhead=2,
|
|
132
|
-
arrowsize=1,
|
|
133
|
-
arrowwidth=1,
|
|
134
|
-
ax=65,ay=-45)
|
|
116
|
+
fig.add_annotation( x=row_df['name'].iloc[0], y=row_df['market_cap_basic'].iloc[0], text= f"{market_cap}", showarrow=True, align="center", bordercolor="#c7c7c7", font=dict(family="Courier New, monospace", size=16, color="#214e34" ), borderwidth=2, borderpad=4, bgcolor="#f4fdff", opacity=0.8, arrowhead=2, arrowsize=1, arrowwidth=1, ax=65,ay=-45)
|
|
135
117
|
fig.update_layout(showlegend=False, plot_bgcolor='white', height=600)
|
|
136
118
|
fig.show()
|
|
137
119
|
|
|
138
120
|
|
|
139
121
|
|
|
140
|
-
tw = Tw()
|
|
122
|
+
#tw = Tw()
|
|
123
|
+
#print(tw.stock.head(1).T)
|
|
124
|
+
#print(tw.crypto.head(1).T)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
goldhand/__init__.py,sha256=ihEkhO-z6MG_h27u4Mf6dAldHfhFpz55Zc3b8l96baE,64
|
|
2
|
+
goldhand/helpers.py,sha256=l9yn0kVTiwfUR8sI5nH1QFx6dYikaUQgRA227Ox7hs0,6130
|
|
3
|
+
goldhand/stocks.py,sha256=O3h0ifn_bIwTfGOK9PpOOIlqjsYZHRRhG9THqUzW5I0,7547
|
|
4
|
+
goldhand/tw.py,sha256=K8MwMDkW5JtBFBG0qcPzj8OVx2OhDjrOH2UGo6nwtSs,8375
|
|
5
|
+
goldhand-11.3.dist-info/METADATA,sha256=Zfr9ei3Tthr9FvilaMTFQ4CySHFVx34K0RcWt1mTBJw,1952
|
|
6
|
+
goldhand-11.3.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
7
|
+
goldhand-11.3.dist-info/top_level.txt,sha256=siEJ2_a_Fx_7hqRI4Ms6SzCelbXrK_1H_eOF8KAaMdA,9
|
|
8
|
+
goldhand-11.3.dist-info/RECORD,,
|
goldhand/test.py
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
from tw import *
|
|
2
|
-
from stocks import *
|
|
3
|
-
from video import *
|
|
4
|
-
|
|
5
|
-
tw =Tw()
|
|
6
|
-
# stock_ticker = "AMD"
|
|
7
|
-
# t = GoldHand(stock_ticker)
|
|
8
|
-
# p = t.plotly_last_year(tw.get_plotly_title(stock_ticker))
|
|
9
|
-
# p.update_layout(height=1080, width=1920)
|
|
10
|
-
# p.write_image("fig2.png", )
|
goldhand/video.py
DELETED
|
File without changes
|
goldhand-9.0.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
goldhand/__init__.py,sha256=emyQ10OQsNR6j0i7vSedLP2c-3SXr4tZKK9Xz0twW9s,85
|
|
2
|
-
goldhand/helpers.py,sha256=l9yn0kVTiwfUR8sI5nH1QFx6dYikaUQgRA227Ox7hs0,6130
|
|
3
|
-
goldhand/stocks.py,sha256=hmQMdkAqC9bE0Dwx5O5lf7RiwBssLIPDBxO81HOPWMs,9085
|
|
4
|
-
goldhand/test.py,sha256=zXeBIeaBU5GCypO1NpcqitImCBTII2xVDGmBcbYNzns,253
|
|
5
|
-
goldhand/tw.py,sha256=U6B-DRLjlFN-cWvnBsEuw4o5XMLynhycg0c5de76uqI,8466
|
|
6
|
-
goldhand/video.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
goldhand-9.0.dist-info/METADATA,sha256=5u6bk-xEvOXW06KLq_VuYrlnrOPtxw3zicZo1OMYNZQ,1951
|
|
8
|
-
goldhand-9.0.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
|
9
|
-
goldhand-9.0.dist-info/top_level.txt,sha256=siEJ2_a_Fx_7hqRI4Ms6SzCelbXrK_1H_eOF8KAaMdA,9
|
|
10
|
-
goldhand-9.0.dist-info/RECORD,,
|
|
File without changes
|