mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-13 04:41:24 +00:00
Fixing low_float
This commit is contained in:
@@ -44,11 +44,6 @@ def high_short_interest(l_args):
|
||||
requests.get(url_high_short_interested_stocks).text, "lxml"
|
||||
)
|
||||
|
||||
# print(text_soup_high_short_interested_stocks.text)
|
||||
# html = text_soup_high_short_interested_stocks.prettify("utf-8")
|
||||
# stock_list = text_soup_high_short_interested_stocks.find_all("td")
|
||||
# stock_list_tr = text_soup_high_short_interested_stocks.find_all("tr")
|
||||
|
||||
a_high_short_interest_header = list()
|
||||
for high_short_interest_header in text_soup_high_short_interested_stocks.findAll(
|
||||
"td", {"class": "tblhdr"}
|
||||
@@ -86,12 +81,13 @@ def high_short_interest(l_args):
|
||||
def low_float(l_args):
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="low_float",
|
||||
description="""Print top stocks with lowest float. LowFloat.com provides a convenient
|
||||
sorted database of stocks which have a float of under 10 million shares. Additional key
|
||||
data such as the number of outstanding shares, short interest, and company industry is
|
||||
displayed. Data is presented for the Nasdaq Stock Market, the New York Stock Exchange,
|
||||
the American Stock Exchange, and the Over the Counter Bulletin Board.
|
||||
[Source: www.lowfloat.com]""",
|
||||
description="""
|
||||
Print top stocks with lowest float. LowFloat.com provides a convenient
|
||||
sorted database of stocks which have a float of under 10 million shares. Additional key
|
||||
data such as the number of outstanding shares, short interest, and company industry is
|
||||
displayed. Data is presented for the Nasdaq Stock Market, the New York Stock Exchange,
|
||||
the American Stock Exchange, and the Over the Counter Bulletin Board. [Source: www.lowfloat.com]
|
||||
""",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
@@ -126,26 +122,21 @@ def low_float(l_args):
|
||||
df_low_float = pd.DataFrame(columns=a_low_float_header)
|
||||
df_low_float.loc[0] = ["", "", "", "", "", "", ""]
|
||||
|
||||
a_low_float_stocks = re.sub(
|
||||
"<!--.*?//-->",
|
||||
"",
|
||||
text_soup_low_float_stocks.find_all("td")[3].text,
|
||||
flags=re.DOTALL,
|
||||
).split("\n")[2:]
|
||||
a_low_float_stocks[0] = a_low_float_stocks[0].replace(
|
||||
"TickerCompanyExchangeFloatOutstdShortIntIndustry", ""
|
||||
)
|
||||
stock_list_tr = text_soup_low_float_stocks.find_all("tr")
|
||||
|
||||
l_stock_info = list()
|
||||
for elem in a_low_float_stocks:
|
||||
if elem is "":
|
||||
low_float_data = list()
|
||||
for a_stock in stock_list_tr:
|
||||
a_stock_txt = a_stock.text
|
||||
|
||||
if a_stock_txt == "":
|
||||
continue
|
||||
|
||||
l_stock_info.append(elem)
|
||||
low_float_data = a_stock_txt.split("\n")
|
||||
|
||||
if len(l_stock_info) == 7:
|
||||
df_low_float.loc[len(df_low_float.index)] = l_stock_info
|
||||
l_stock_info = list()
|
||||
if len(low_float_data) == 8:
|
||||
df_low_float.loc[len(df_low_float.index)] = low_float_data[:-1]
|
||||
|
||||
low_float_data = list()
|
||||
|
||||
pd.set_option("display.max_colwidth", -1)
|
||||
print(df_low_float.head(n=ns_parser.n_num).to_string(index=False))
|
||||
|
||||
@@ -5,9 +5,15 @@ import unittest
|
||||
# pylint: disable=unused-import
|
||||
import pytest
|
||||
|
||||
from gamestonk_terminal.discovery.short_interest_api import high_short_interest
|
||||
from gamestonk_terminal.discovery.short_interest_api import (
|
||||
high_short_interest,
|
||||
low_float,
|
||||
)
|
||||
|
||||
|
||||
class TestDiscoveryShortInterestApi(unittest.TestCase):
|
||||
def test_high_short_interest(self):
|
||||
high_short_interest(["-n", "10"])
|
||||
|
||||
def test_low_float(self):
|
||||
low_float(["-n", "10"])
|
||||
|
||||
Reference in New Issue
Block a user