示例#1
0
def add_historical_eps(stock: Stock, stock_storage: StockStorage):
    if not stock_storage.indexStorage.historicalStorage:
        stock.historical_eps_current_year = 0
        stock.historical_eps_next_year = 0
        return

    historical_storage = StockStorage(
        stock_storage.indexStorage.historicalStorage, stock)

    stock.historical_eps_date = historical_storage.indexStorage.date_str

    try:
        historical_storage.load()
        historical_stock = historical_storage.stock

        stock.historical_eps_current_year = historical_stock.eps_current_year
        stock.historical_eps_next_year = historical_stock.eps_next_year

    except FileNotFoundError:
        stock.historical_eps_current_year = 0
        stock.historical_eps_next_year = 0
示例#2
0
def scrap(stock: Stock, stock_storage: StockStorage, util: OnVistaDateUtil = OnVistaDateUtil()):
    with open(stock_storage.getStoragePath("profil", "html"), mode="r") as f:
        soup = BeautifulSoup(f, 'html.parser')

        currencies = scrap_currencies(soup)

        price = scrap_price(soup)
        fundamentals = scrap_fundamentals(soup)
        company_details = scrap_company_details(soup)

    with open(stock_storage.getStoragePath("bilanz_guv", "html"), mode="r") as f:
        soup = BeautifulSoup(f, 'html.parser')

        bilanz_guv = scrap_bilanz_guv(soup)

    with open(stock_storage.getStoragePath("schaetzungen", "html"), mode="r") as f:
        soup = BeautifulSoup(f, 'html.parser')

        schaetzung = scrap_schaetzung(soup)

    with open(stock_storage.getStoragePath("analysen", "html"), mode="r") as f:
        soup = BeautifulSoup(f, 'html.parser')

        stock.ratings = scrap_analysen(soup)

    last_year = util.get_last_year()
    current_year = util.get_current_year(estimated=False)
    next_year = util.get_next_year(estimated=False)

    stock.price = asFloat(price)

    stock.field = company_details["Branchen"]

    GuV = findIn(bilanz_guv, "GuV")
    gewinn = asFloat(GuV["Ergebnis nach Steuer"][last_year])
    ebit = asFloat(GuV["Ergebnis vor Steuern"][last_year])
    erloes = asFloat(GuV["Umsatzerlöse"][last_year])

    bilanz = findIn(bilanz_guv, "Bilanz")
    eigenkapital = asFloat(bilanz["Eigenkapital"][last_year])

    stock.roi = gewinn / eigenkapital * 100
    stock.ebit_margin = ebit / erloes * 100

    unternehmenskennzahlen = findIn(bilanz_guv, "Unternehmenskennzahlen")
    stock.equity_ratio = asFloat(unternehmenskennzahlen["Eigenkapitalquote in %"][last_year])

    stock.per = asFloat(schaetzung["KGV"][current_year])

    hist_pers = unternehmenskennzahlen["KGV (Jahresendkurs)"]

    per_5_years = stock.per
    number_of_year = 1

    for year in list(hist_pers.keys())[-4:]:
        if hist_pers[year] != "-":
            per_5_years += asFloat(hist_pers[year])
            number_of_year += 1

    stock.per_5_years = (per_5_years / number_of_year)

    eps_row_name = "Ergebnis/Aktie (reported)" if ("Ergebnis/Aktie (reported)" in schaetzung) else "Ergebnis/Aktie"
    stock.eps_current_year = asFloat(schaetzung[eps_row_name][current_year])
    stock.eps_next_year = asFloat(schaetzung[eps_row_name][next_year])

    stock.per_fallback = stock.price / stock.eps_current_year if stock.eps_current_year != 0 else 0

    stock.market_capitalization = asFloat(fundamentals["Marktkapitalisierung in Mrd. EUR"]) * 1000000000

    stock_price_today = 0
    stock_price_6month = 0
    stock_price_1year = 0

    stock.history = History(stock_price_today, stock_price_6month, stock_price_1year)

    stock.monthClosings = MonthClosings()

    stock.historical_eps_current_year = 0
    stock.historical_eps_date = 0
    stock.historical_eps_next_year = 0

    stock.reaction_to_quarterly_numbers = ReactionToQuarterlyNumbers(0, 0, 0, 0, "")

    return stock