Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions nasdaq_uvoljs.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,23 @@ def build_df(self, ud):
co_name_lj = (re.sub('[\']', '', co_name_lj) ) # remove " ' and strip leading/trailing spaces

price_cl = (re.sub('[ $,]', '', price)) # remove $ sign
price_net_cl = (re.sub(r'[\-+]', '', price_net)) # remove - + signs
price_pct_cl = (re.sub(r'[\-+%]', '', price_pct)) # remove - + % signs
price_net_cl = (re.sub(r'[\+]', '', price_net)) # remove + sign, preserve -
price_pct_cl = (re.sub(r'[\+%]', '', price_pct)) # remove +/% signs, preserve -
vol_abs_cl = (re.sub('[,]', '', vol_abs)) # remove ,
vol_abs_cl = (re.sub('[,]', '', vol_abs)) # remove ,
vol_pct_cl = (re.sub('[%]', '', vol_pct)) # remover %
price_net_clean = round(float(price_net_cl), 2)
price_pct_clean = round(float(price_pct_cl), 2)
if price_net_clean < 0 and price_pct_clean > 0:
price_pct_clean = -price_pct_clean

self.list_data = [[ \
x, \
re.sub('\'', '', co_sym_lj), \
co_name_lj, \
round(float(price_cl), 2), \
round(float(price_net_cl), 2), \
round(float(price_pct_cl), 2), \
price_net_clean, \
price_pct_clean, \
round(float(vol_abs_cl)), \
round(float(vol_pct_cl), 1), \
time_now ]]
Expand Down
8 changes: 5 additions & 3 deletions nasdaq_wrangler.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ def clean_cast(self):
logging.info('%s - Price NET is unchanged' % cmi_debug )
cc_errors += 1
else:
self.price_net_cl = (re.sub(r'[\-+]', '', self.price_net)) # remove - + signs
self.price_net_cl = float(self.price_net)
self.price_net_cl = (re.sub(r'[\+,]', '', self.price_net)) # remove +/, signs, preserve -
self.price_net_cl = float(self.price_net_cl)

if self.price_pct == "N/A":
self.price_pct_cl = float(0)
Expand All @@ -419,8 +419,10 @@ def clean_cast(self):
logging.info('%s - Price pct is bad, field is Null/empty' % cmi_debug )
cc_errors += 1
else:
self.price_pct = (re.sub(r'[\-+%]', '', self.price_pct)) # remove - + % signs
self.price_pct = (re.sub(r'[\+%,]', '', self.price_pct)) # remove +/%/, signs, preserve -
self.price_pct_cl = float(self.price_pct)
if self.price_net_cl < 0 and self.price_pct_cl > 0:
self.price_pct_cl = -self.price_pct_cl

# ################# open price(s) need extra treatment & care...
"""
Expand Down
11 changes: 8 additions & 3 deletions y_daylosers.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,18 @@ def extr_gen():
co_name_lj = (re.sub(r'[\'\"]', '', co_name_lj) ) # remove " ' and strip leading/trailing spaces
price_cl = (re.sub(r'\,', '', price)) # remove ,
price_clean = float(price_cl)
change_clean = float(change_val)
change_sign_multiplier = -1 if change_sign == "-" or str(change_val).strip().startswith("-") else 1
change_cl = re.sub(r'[\+\-,]', "", str(change_val))
change_clean = float(change_cl) * change_sign_multiplier

if pct_val == "N/A":
pct_val = float(0.0) # Bad data. FOund a filed with N/A instead of read num
pct_clean = float(0.0) # Bad data. FOund a filed with N/A instead of read num
else:
pct_sign_multiplier = -1 if pct_sign == "-" or str(pct_val).strip().startswith("-") else 1
pct_cl = re.sub(r'[\%\+\-,]', "", pct_val )
pct_clean = float(pct_cl)
pct_clean = float(pct_cl) * pct_sign_multiplier
if change_clean < 0 and pct_clean > 0:
pct_clean = -pct_clean

################################ 5 ####################################
mktcap = (re.sub(r'[N\/A]', '0', mktcap)) # handle N/A
Expand Down
11 changes: 8 additions & 3 deletions y_smallcaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,18 @@ def extr_gen():
co_name_lj = (re.sub(r'[\'\"]', '', co_name_lj) ) # remove " ' and strip leading/trailing spaces
price_cl = (re.sub(r'\,', '', price)) # remove ,
price_clean = float(price_cl)
change_clean = float(change_val)
change_sign_multiplier = -1 if change_sign == "-" or str(change_val).strip().startswith("-") else 1
change_cl = re.sub(r'[\+\-,]', "", str(change_val))
change_clean = float(change_cl) * change_sign_multiplier

if pct_val == "N/A":
pct_val = float(0.0) # Bad data. FOund a filed with N/A instead of read num
pct_clean = float(0.0) # Bad data. FOund a filed with N/A instead of read num
else:
pct_sign_multiplier = -1 if pct_sign == "-" or str(pct_val).strip().startswith("-") else 1
pct_cl = re.sub(r'[\%\+\-,]', "", pct_val )
pct_clean = float(pct_cl)
pct_clean = float(pct_cl) * pct_sign_multiplier
if change_clean < 0 and pct_clean > 0:
pct_clean = -pct_clean

################################ 5 ####################################
mktcap = (re.sub(r'[N\/A]', '0', mktcap)) # handle N/A
Expand Down
11 changes: 8 additions & 3 deletions y_topgainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,18 @@ def extr_gen():
co_name_lj = (re.sub(r'[\'\"]', '', co_name_lj) ) # remove " ' and strip leading/trailing spaces
price_cl = (re.sub(r'\,', '', price)) # remove ,
price_clean = float(price_cl)
change_clean = float(change_val)
change_sign_multiplier = -1 if change_sign == "-" or str(change_val).strip().startswith("-") else 1
change_cl = re.sub(r'[\+\-,]', "", str(change_val))
change_clean = float(change_cl) * change_sign_multiplier

if pct_val == "N/A":
pct_val = float(0.0) # Bad data. FOund a filed with N/A instead of read num
pct_clean = float(0.0) # Bad data. FOund a filed with N/A instead of read num
else:
pct_sign_multiplier = -1 if pct_sign == "-" or str(pct_val).strip().startswith("-") else 1
pct_cl = re.sub(r'[\%\+\-,]', "", pct_val )
pct_clean = float(pct_cl)
pct_clean = float(pct_cl) * pct_sign_multiplier
if change_clean < 0 and pct_clean > 0:
pct_clean = -pct_clean

################################ 5 ####################################
mktcap = (re.sub(r'[N\/A]', '0', mktcap)) # handle N/A
Expand Down
Loading