@@ -56,7 +56,7 @@ def image_scrap(url, ticker, out_dir):
56
56
out_dir(str): output directory
57
57
"""
58
58
try :
59
- r = session .get (url , stream = True , headers = headers , timeout = 10 )
59
+ r = session .get (url , stream = True , headers = headers , timeout = 10 , proxies = proxy_dict )
60
60
r .raise_for_status ()
61
61
r .raw .decode_content = True
62
62
if len (out_dir ) != 0 :
@@ -136,16 +136,17 @@ def image_scrap_function(url, chart, timeframe, urlonly):
136
136
137
137
138
138
def number_covert (num ):
139
- """covert number(str) to number(float)
139
+ """Convert number(str) to number(float)
140
140
141
141
Args:
142
- num(str): number of string
142
+ num(str): number as a string
143
143
Return:
144
- num(float): number of string
144
+ num(float or None ): number converted to float or None
145
145
"""
146
- if num == "-" :
146
+ if not num or num == "-" : # Check if the string is empty or is "-"
147
147
return None
148
- elif num [- 1 ] == "%" :
148
+ num = num .strip () # Remove any surrounding whitespace
149
+ if num [- 1 ] == "%" :
149
150
return float (num [:- 1 ]) / 100
150
151
elif num [- 1 ] == "B" :
151
152
return float (num [:- 1 ]) * 1000000000
@@ -154,7 +155,7 @@ def number_covert(num):
154
155
elif num [- 1 ] == "K" :
155
156
return float (num [:- 1 ]) * 1000
156
157
else :
157
- return float ("" . join ( num .split ("," )))
158
+ return float (num .replace ("," , "" )) # Remove commas and convert to float
158
159
159
160
160
161
def format_datetime (date_str ):
0 commit comments