Ejemplo n.º 1
0
class DividendPolicyAnalyzer():
    def __init__(self, stock_symbol):
        param = {
            'stock_symbol' : stock_symbol,
            'account_list' : [
                'CashDividends', 
                'StockDividendsFromRetainedEarnings',
                'StockDividendsFromCapitalReserve',
                'EmployeeStockBonusRatio',
            ]
        }
        self.time_series = AccountTimeSeries(param)

    def get_cash_dividends(self):
        return self.time_series.get('CashDividends')

    def get_stock_dividends_from_retained_earnings(self):
        return self.time_series.get('StockDividendsFromRetainedEarnings')

    def get_stock_dividends_from_capital_reserve(self):
        return self.time_series.get('StockDividendsFromCapitalReserve')

    def get_stock_dividends(self):
        # StockDividends = StockDividendsFromRetainedEarnings + StockDividendsFromCapitalReserve
        stock_dividends_from_retained_earnings = self.get_stock_dividends_from_retained_earnings()
        stock_dividends_from_capital_reserve = self.get_stock_dividends_from_capital_reserve()
        return stock_dividends_from_retained_earnings + stock_dividends_from_capital_reserve

    def get_employee_stock_bonus_ratio(self):
        return self.time_series.get('EmployeeStockBonusRatio')
Ejemplo n.º 2
0
class DividendPolicyAnalyzer():
    def __init__(self, stock_symbol):
        param = {
            'stock_symbol':
            stock_symbol,
            'account_list': [
                'CashDividends',
                'StockDividendsFromRetainedEarnings',
                'StockDividendsFromCapitalReserve',
                'EmployeeStockBonusRatio',
            ]
        }
        self.time_series = AccountTimeSeries(param)

    def get_cash_dividends(self):
        return self.time_series.get('CashDividends')

    def get_stock_dividends_from_retained_earnings(self):
        return self.time_series.get('StockDividendsFromRetainedEarnings')

    def get_stock_dividends_from_capital_reserve(self):
        return self.time_series.get('StockDividendsFromCapitalReserve')

    def get_stock_dividends(self):
        # StockDividends = StockDividendsFromRetainedEarnings + StockDividendsFromCapitalReserve
        stock_dividends_from_retained_earnings = self.get_stock_dividends_from_retained_earnings(
        )
        stock_dividends_from_capital_reserve = self.get_stock_dividends_from_capital_reserve(
        )
        return stock_dividends_from_retained_earnings + stock_dividends_from_capital_reserve

    def get_employee_stock_bonus_ratio(self):
        return self.time_series.get('EmployeeStockBonusRatio')
Ejemplo n.º 3
0
class RevenueIndexAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol' : stock_symbol,
            'period' : period, 
            'account_list' : [
                'Inventories',
                'Sales', 
                'AccountsReceivable',
                'GrossProfit',
                'SellingExpenses',
                'AdministrativeExpenses',
                'AccountsPayable',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_inventory_index(self):
        # InventoryIndex = InventoryGrowthRate - SalesGrowthRate
        inventory_growth_rate = self.__get_growth_rate('Inventories')
        sales_growth_rate = self.__get_growth_rate('Sales')
        return inventory_growth_rate - sales_growth_rate

    def get_accounts_receivable_index(self):
        # AccountsReceivableIndex = AccountsReceivableGrowthRate - SalesGrowthRate
        accounts_receivable_growth_rate = self.__get_growth_rate('AccountsReceivable')
        sales_growth_rate = self.__get_growth_rate('Sales')
        return accounts_receivable_growth_rate - sales_growth_rate

    def get_gross_profit_index(self):
        # GrossProfitIndex = SalesGrowthRate - GrossProfitGrowthRate
        sales_growth_rate = self.__get_growth_rate('Sales')
        gross_profit_growth_rate = self.__get_growth_rate('GrossProfit')
        return sales_growth_rate - gross_profit_growth_rate

    def get_selling_and_administrative_expenses_index(self):
        # SellingAndAdministrativeExpensesIndex = SellingAndAdministrativeExpensesGrowthRate - SalesGrowthRate
        selling_expenses = self.time_series.get('SellingExpenses')
        administrative_expenses = self.time_series.get('AdministrativeExpenses')
        selling_and_administrative_expenses = selling_expenses + administrative_expenses
        selling_and_administrative_expenses_growth_rate \
                = self.__get_growth_rate_by_curr_time_series(selling_and_administrative_expenses)
        sales_growth_rate = self.__get_growth_rate('Sales')
        return selling_and_administrative_expenses_growth_rate - sales_growth_rate

    def get_accounts_payable_index(self):
        # AccountsPayableIndex = SalesGrowthRate - AccountsPayableGrowthRate
        sales_growth_rate = self.__get_growth_rate('Sales')
        accounts_payable_growth_rate = self.__get_growth_rate('AccountsPayable')
        return sales_growth_rate - accounts_payable_growth_rate

    def __get_growth_rate(self, account):
        curr_time_series = self.time_series.get(account)
        return self.__get_growth_rate_by_curr_time_series(curr_time_series)

    def __get_growth_rate_by_curr_time_series(self, curr_time_series):
        prev_time_series = curr_time_series.get_average().shift()
        return (curr_time_series - prev_time_series) / prev_time_series
 def __init__(self, stock_symbol):
     param = {
         'stock_symbol' : stock_symbol,
         'account_list' : [
             'OperatingRevenue',
         ]
     }
     self.time_series = AccountTimeSeries(param)
Ejemplo n.º 5
0
 def __init__(self, stock_symbol):
     param = {
         'stock_symbol':
         stock_symbol,
         'account_list': [
             'CapitalIncreaseByCash',
             'CapitalIncreaseByEarnings',
             'CapitalIncreaseBySurplus',
         ]
     }
     self.time_series = AccountTimeSeries(param)
Ejemplo n.º 6
0
 def __init__(self, stock_symbol):
     param = {
         'stock_symbol':
         stock_symbol,
         'account_list': [
             'CashDividends',
             'StockDividendsFromRetainedEarnings',
             'StockDividendsFromCapitalReserve',
             'EmployeeStockBonusRatio',
         ]
     }
     self.time_series = AccountTimeSeries(param)
Ejemplo n.º 7
0
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol': stock_symbol,
         'period': period,
         'account_list': [
             'NetProfit',
             'Equity',
             'StockPrice',
             'BookValue',
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol' : stock_symbol,
         'period' : period, 
         'account_list' : [
             'Assets',
             'Liabilities',  
             'Equity',
             'LongTermLiabilities',
             'CurrentLiabilities',
             'FixedAssets',
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
class CapitalStructureAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol' : stock_symbol,
            'period' : period, 
            'account_list' : [
                'Assets',
                'Liabilities',  
                'Equity',
                'LongTermLiabilities',
                'CurrentLiabilities',
                'FixedAssets',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_equity_ratio(self):
        # EquityRatio = Equity / Assets
        equity = self.time_series.get('Equity')
        assets = self.time_series.get('Assets')
        return equity / assets

    def get_liabilities_ratio(self):
        # LiabilitiesRatio = Liabilities / Assets
        liabilities = self.time_series.get('Liabilities')
        assets = self.time_series.get('Assets')
        return liabilities / assets

    def get_equity_multiplier(self):
        # EquityMultiplier = Assets / Equity
        assets = self.time_series.get('Assets')
        equity = self.time_series.get('Equity')
        return assets / equity

    def get_true_liabilities_ratio(self):
        # TrueLiabilitiesRatio = LongTermLiabilities / (Assets - CurrentLiabilities)
        long_term_liabilities = self.time_series.get('LongTermLiabilities')
        assets = self.time_series.get('Assets')
        current_liabilities = self.time_series.get('CurrentLiabilities')
        return long_term_liabilities / (assets - current_liabilities)

    def get_long_term_capital_to_fixed_assets_ratio(self):
        # LongTermCapitalToFixedAssetsRatio = (LongTermLiabilities + Equity) / FixedAssets
        long_term_liabilities = self.time_series.get('LongTermLiabilities')
        equity = self.time_series.get('Equity')
        fixed_assets = self.time_series.get('FixedAssets')
        return (long_term_liabilities + equity) / fixed_assets
class OperatingRevenueAnalyzer():
    def __init__(self, stock_symbol):
        param = {
            'stock_symbol' : stock_symbol,
            'account_list' : [
                'OperatingRevenue',
            ]
        }
        self.time_series = AccountTimeSeries(param)

    def get_operating_revenue(self):
        operating_revenue = self.time_series.get('OperatingRevenue')
        return operating_revenue

    def get_accumulated_operating_revenue(self):
        return self.get_operating_revenue().accumulate_annually()

    def get_accumulated_operating_revenue_yoy(self):
        return self.get_accumulated_operating_revenue().get_yoy()

    def get_long_term_average(self):
        return self.get_operating_revenue().get_moving_average(12)

    def get_short_term_average(self):
        return self.get_operating_revenue().get_moving_average(3)
Ejemplo n.º 11
0
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol' : stock_symbol,
         'period' : period, 
         'account_list' : [
             'Inventories',
             'Sales', 
             'AccountsReceivable',
             'GrossProfit',
             'SellingExpenses',
             'AdministrativeExpenses',
             'AccountsPayable',
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
Ejemplo n.º 12
0
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol':
         stock_symbol,
         'period':
         period,
         'account_list': [
             'CurrentAssets',
             'CurrentLiabilities',
             'Inventories',
             'PrepaidAccounts',
             'IncomeBeforeTax',
             'InterestExpense',
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
Ejemplo n.º 13
0
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol':
         stock_symbol,
         'period':
         period,
         'account_list': [
             'NetProfit',
             'CashFlowFromOperatingActivities',
             'CashFlowFromInvestingActivities',
             'CashFlowFromFinancingActivities',
             'LongTermInvestments',
             'Assets',
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
Ejemplo n.º 14
0
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol' : stock_symbol,
         'period' : period, 
         'account_list' : [
             'Sales',
             'GrossProfit',
             'OperatingProfit',
             'NetProfit',
             'IncomeBeforeTax',
             'CostOfGoodsSold',
             'Inventories',
             'AccountsReceivable',
             'AccountsPayable',
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
 def __init__(self, stock_symbol):
     param = {
         'stock_symbol' : stock_symbol,
         'account_list' : [
             'CapitalIncreaseByCash', 
             'CapitalIncreaseByEarnings',
             'CapitalIncreaseBySurplus',
         ]
     }
     self.time_series = AccountTimeSeries(param)
Ejemplo n.º 16
0
 def __init__(self, stock_symbol):
     param = {
         'stock_symbol' : stock_symbol,
         'account_list' : [
             'CashDividends', 
             'StockDividendsFromRetainedEarnings',
             'StockDividendsFromCapitalReserve',
             'EmployeeStockBonusRatio',
         ]
     }
     self.time_series = AccountTimeSeries(param)
class CapitalIncreaseHistoryAnalyzer():
    def __init__(self, stock_symbol):
        param = {
            'stock_symbol' : stock_symbol,
            'account_list' : [
                'CapitalIncreaseByCash', 
                'CapitalIncreaseByEarnings',
                'CapitalIncreaseBySurplus',
            ]
        }
        self.time_series = AccountTimeSeries(param)

    def get_capital_increase_by_cash(self):
        return self.time_series.get('CapitalIncreaseByCash')

    def get_capital_increase_by_earnings(self):
        return self.time_series.get('CapitalIncreaseByEarnings')

    def get_capital_increase_by_surplus(self):
        return self.time_series.get('CapitalIncreaseBySurplus')
Ejemplo n.º 18
0
class CashFlowAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol':
            stock_symbol,
            'period':
            period,
            'account_list': [
                'NetProfit',
                'CashFlowFromOperatingActivities',
                'CashFlowFromInvestingActivities',
                'CashFlowFromFinancingActivities',
                'LongTermInvestments',
                'Assets',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_net_profit(self):
        net_profit = self.time_series.get('NetProfit')
        return net_profit

    def get_cash_flow_from_operating_activities(self):
        cash_flow = self.time_series.get('CashFlowFromOperatingActivities')
        return cash_flow

    def get_cash_flow_from_investing_activities(self):
        cash_flow = self.time_series.get('CashFlowFromInvestingActivities')
        return cash_flow

    def get_cash_flow_from_financing_activities(self):
        cash_flow = self.time_series.get('CashFlowFromFinancingActivities')
        return cash_flow

    def get_free_cash_flow(self):
        # FreeCashFlow = CashFlowFromOperatingActivities + CashFlowFromInvestingActivities
        cash_flow_from_operating_activities = self.time_series.get(
            'CashFlowFromOperatingActivities')
        cash_flow_from_investing_activities = self.time_series.get(
            'CashFlowFromInvestingActivities')
        return cash_flow_from_operating_activities + cash_flow_from_investing_activities

    def get_accumulated_free_cash_flow(self):
        free_cash_flow = self.get_free_cash_flow()
        return free_cash_flow.accumulate()

    def get_long_term_investments_to_assets_ratio(self):
        long_term_investments = self.time_series.get('LongTermInvestments')
        assets = self.time_series.get('Assets')
        return long_term_investments / assets
Ejemplo n.º 19
0
class CapitalIncreaseHistoryAnalyzer():
    def __init__(self, stock_symbol):
        param = {
            'stock_symbol':
            stock_symbol,
            'account_list': [
                'CapitalIncreaseByCash',
                'CapitalIncreaseByEarnings',
                'CapitalIncreaseBySurplus',
            ]
        }
        self.time_series = AccountTimeSeries(param)

    def get_capital_increase_by_cash(self):
        return self.time_series.get('CapitalIncreaseByCash')

    def get_capital_increase_by_earnings(self):
        return self.time_series.get('CapitalIncreaseByEarnings')

    def get_capital_increase_by_surplus(self):
        return self.time_series.get('CapitalIncreaseBySurplus')
Ejemplo n.º 20
0
class DupontAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol' : stock_symbol,
            'period' : period, 
            'account_list' : [
                'NetProfit',
                'Equity',
                'Assets',
                'Sales', 
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_roe(self):
        # ROE = NetProfit / Equity
        net_profit = self.time_series.get('NetProfit')
        equity = self.time_series.get('Equity').get_average()
        return net_profit / equity

    def get_roa(self):
        # ROE = NetProfit / Assets
        net_profit = self.time_series.get('NetProfit')
        assets = self.time_series.get('Assets').get_average()
        return net_profit / assets

    def get_ros(self):
        # ROS (returns on sales) = NetProfit / Sales
        net_profit = self.time_series.get('NetProfit')
        sales = self.time_series.get('Sales') 
        return net_profit / sales

    def get_ato(self):
        # ATO (asset turnover) = Sales / Assets
        sales = self.time_series.get('Sales') 
        assets = self.time_series.get('Assets').get_average()
        return sales / assets        

    def get_equity_multiplier(self):
        # EquityMultiplier = Assets / Equity
        assets = self.time_series.get('Assets').get_average()
        equity = self.time_series.get('Equity').get_average()
        return assets / equity
Ejemplo n.º 21
0
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol' : stock_symbol,
         'period' : period, 
         'account_list' : [
             'NetProfit',
             'Equity',
             'Assets',
             'Sales', 
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
Ejemplo n.º 22
0
class DupontAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol': stock_symbol,
            'period': period,
            'account_list': [
                'NetProfit',
                'Equity',
                'Assets',
                'Sales',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_roe(self):
        # ROE = NetProfit / Equity
        net_profit = self.time_series.get('NetProfit')
        equity = self.time_series.get('Equity').get_average()
        return net_profit / equity

    def get_roa(self):
        # ROE = NetProfit / Assets
        net_profit = self.time_series.get('NetProfit')
        assets = self.time_series.get('Assets').get_average()
        return net_profit / assets

    def get_ros(self):
        # ROS (returns on sales) = NetProfit / Sales
        net_profit = self.time_series.get('NetProfit')
        sales = self.time_series.get('Sales')
        return net_profit / sales

    def get_ato(self):
        # ATO (asset turnover) = Sales / Assets
        sales = self.time_series.get('Sales')
        assets = self.time_series.get('Assets').get_average()
        return sales / assets

    def get_equity_multiplier(self):
        # EquityMultiplier = Assets / Equity
        assets = self.time_series.get('Assets').get_average()
        equity = self.time_series.get('Equity').get_average()
        return assets / equity
Ejemplo n.º 23
0
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol' : stock_symbol,
         'period' : period, 
         'account_list' : [
             'CurrentAssets',
             'CurrentLiabilities',  
             'Inventories',
             'PrepaidAccounts',
             'IncomeBeforeTax',
             'InterestExpense',
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
Ejemplo n.º 24
0
 def __init__(self, stock_symbol, period):
     param = {
         'stock_symbol' : stock_symbol,
         'period' : period, 
         'account_list' : [
             'NetProfit',
             'CashFlowFromOperatingActivities',
             'CashFlowFromInvestingActivities',
             'CashFlowFromFinancingActivities',
             'LongTermInvestments',
             'Assets',
         ]
     }
     self.time_series = AccountTimeSeries(param)
     self.period = period
Ejemplo n.º 25
0
class CashFlowAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol' : stock_symbol,
            'period' : period, 
            'account_list' : [
                'NetProfit',
                'CashFlowFromOperatingActivities',
                'CashFlowFromInvestingActivities',
                'CashFlowFromFinancingActivities',
                'LongTermInvestments',
                'Assets',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_net_profit(self):
        net_profit = self.time_series.get('NetProfit')
        return net_profit

    def get_cash_flow_from_operating_activities(self):
        cash_flow = self.time_series.get('CashFlowFromOperatingActivities')
        return cash_flow

    def get_cash_flow_from_investing_activities(self):
        cash_flow = self.time_series.get('CashFlowFromInvestingActivities')
        return cash_flow

    def get_cash_flow_from_financing_activities(self):
        cash_flow = self.time_series.get('CashFlowFromFinancingActivities')
        return cash_flow

    def get_free_cash_flow(self):
        # FreeCashFlow = CashFlowFromOperatingActivities + CashFlowFromInvestingActivities
        cash_flow_from_operating_activities = self.time_series.get('CashFlowFromOperatingActivities')
        cash_flow_from_investing_activities = self.time_series.get('CashFlowFromInvestingActivities')
        return cash_flow_from_operating_activities + cash_flow_from_investing_activities

    def get_accumulated_free_cash_flow(self):
        free_cash_flow = self.get_free_cash_flow()
        return free_cash_flow.accumulate()

    def get_long_term_investments_to_assets_ratio(self):
        long_term_investments = self.time_series.get('LongTermInvestments')
        assets = self.time_series.get('Assets')
        return long_term_investments / assets
Ejemplo n.º 26
0
class LiquidityAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol':
            stock_symbol,
            'period':
            period,
            'account_list': [
                'CurrentAssets',
                'CurrentLiabilities',
                'Inventories',
                'PrepaidAccounts',
                'IncomeBeforeTax',
                'InterestExpense',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_current_ratio(self):
        # CurrentRatio = CurrentAssets / CurrentLiabilities
        current_assets = self.time_series.get('CurrentAssets')
        current_liabilities = self.time_series.get('CurrentLiabilities')
        return current_assets / current_liabilities

    def get_quick_ratio(self):
        # QuickAssets = CurrentAssets - Inventories - PrepaidAccounts
        current_assets = self.time_series.get('CurrentAssets')
        inventories = self.time_series.get('Inventories')
        prepaid_accounts = self.time_series.get('PrepaidAccounts')
        quick_assets = current_assets - inventories - prepaid_accounts

        # QuickRatio = QuickAssets / CurrentLiabilities
        current_liabilities = self.time_series.get('CurrentLiabilities')
        return quick_assets / current_liabilities

    def get_interest_protection_multiples(self):
        # InterestProtectionMultiples = EBDIT / InterestExpense
        # EBDIT = IncomeBeforeTax + InterestExpense
        income_before_tax = self.time_series.get('IncomeBeforeTax')
        interest_expense = self.time_series.get('InterestExpense')
        return (income_before_tax + interest_expense) / interest_expense
Ejemplo n.º 27
0
class LiquidityAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol' : stock_symbol,
            'period' : period, 
            'account_list' : [
                'CurrentAssets',
                'CurrentLiabilities',  
                'Inventories',
                'PrepaidAccounts',
                'IncomeBeforeTax',
                'InterestExpense',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_current_ratio(self):
        # CurrentRatio = CurrentAssets / CurrentLiabilities
        current_assets = self.time_series.get('CurrentAssets')
        current_liabilities = self.time_series.get('CurrentLiabilities')
        return current_assets / current_liabilities

    def get_quick_ratio(self):
        # QuickAssets = CurrentAssets - Inventories - PrepaidAccounts
        current_assets = self.time_series.get('CurrentAssets')
        inventories = self.time_series.get('Inventories')
        prepaid_accounts = self.time_series.get('PrepaidAccounts')
        quick_assets = current_assets - inventories - prepaid_accounts

        # QuickRatio = QuickAssets / CurrentLiabilities
        current_liabilities = self.time_series.get('CurrentLiabilities')
        return quick_assets / current_liabilities

    def get_interest_protection_multiples(self):
        # InterestProtectionMultiples = EBDIT / InterestExpense
        # EBDIT = IncomeBeforeTax + InterestExpense
        income_before_tax = self.time_series.get('IncomeBeforeTax')
        interest_expense = self.time_series.get('InterestExpense')
        return (income_before_tax + interest_expense) / interest_expense
Ejemplo n.º 28
0
class KnAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol': stock_symbol,
            'period': period,
            'account_list': [
                'NetProfit',
                'Equity',
                'StockPrice',
                'BookValue',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_roe(self):
        # ROE = NetProfit / Equity
        net_profit = self.time_series.get('NetProfit')
        assets = self.time_series.get('Equity').get_average()
        return net_profit / assets

    def get_max_pbr(self):
        # max(PBR) = max(StockPrice) / BookValue
        stock_price = self.time_series.get('StockPrice')
        book_value = self.time_series.get('BookValue')
        return stock_price.get_max_by_period(self.period) / book_value

    def get_min_pbr(self):
        # min(PBR) = min(StockPrice) / BookValue
        stock_price = self.time_series.get('StockPrice')
        book_value = self.time_series.get('BookValue')
        return stock_price.get_min_by_period(self.period) / book_value

    def get_max_kn(self):
        # max(Kn) = ROE / min(PBR)
        roe = self.get_roe().annualize(self.period)
        min_pbr = self.get_min_pbr()
        return roe / min_pbr

    def get_min_kn(self):
        # min(Kn) = ROE / max(PBR)
        roe = self.get_roe().annualize(self.period)
        max_pbr = self.get_max_pbr()
        return roe / max_pbr
Ejemplo n.º 29
0
class KnAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol' : stock_symbol,
            'period' : period, 
            'account_list' : [
                'NetProfit',
                'Equity',
                'StockPrice',
                'BookValue',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_roe(self):
        # ROE = NetProfit / Equity
        net_profit = self.time_series.get('NetProfit')
        assets = self.time_series.get('Equity').get_average()
        return net_profit / assets

    def get_max_pbr(self):
        # max(PBR) = max(StockPrice) / BookValue
        stock_price = self.time_series.get('StockPrice')
        book_value = self.time_series.get('BookValue')
        return stock_price.get_max_by_period(self.period) / book_value

    def get_min_pbr(self):
        # min(PBR) = min(StockPrice) / BookValue
        stock_price = self.time_series.get('StockPrice')
        book_value = self.time_series.get('BookValue')
        return stock_price.get_min_by_period(self.period) / book_value

    def get_max_kn(self):
        # max(Kn) = ROE / min(PBR)
        roe = self.get_roe().annualize(self.period)
        min_pbr = self.get_min_pbr()
        return roe / min_pbr

    def get_min_kn(self):
        # min(Kn) = ROE / max(PBR)        
        roe = self.get_roe().annualize(self.period)
        max_pbr = self.get_max_pbr()
        return roe / max_pbr
Ejemplo n.º 30
0
class ProfitabilityAnalyzer():
    def __init__(self, stock_symbol, period):
        param = {
            'stock_symbol' : stock_symbol,
            'period' : period, 
            'account_list' : [
                'Sales',
                'GrossProfit',
                'OperatingProfit',
                'NetProfit',
                'IncomeBeforeTax',
                'CostOfGoodsSold',
                'Inventories',
                'AccountsReceivable',
                'AccountsPayable',
            ]
        }
        self.time_series = AccountTimeSeries(param)
        self.period = period

    def get_gross_profit_margin(self):
        # GrossProfitMargin = GrossProfit / Sales
        gross_profit = self.time_series.get('GrossProfit')
        sales = self.time_series.get('Sales')
        return gross_profit / sales

    def get_operating_profit_margin(self):
        # OperatingProfitMargin = OperatingProfit / Sales
        operating_profit = self.time_series.get('OperatingProfit')
        sales = self.time_series.get('Sales')
        return operating_profit / sales
    
    def get_net_profit_before_tax_margin(self):
        # NetProfitBeforeTaxMargin = NetProfit / Sales
        net_profit_before_tax = self.time_series.get('IncomeBeforeTax')
        sales = self.time_series.get('Sales')
        return net_profit_before_tax / sales

    def get_net_profit_margin(self):
        # NetProfitMargin = NetProfit / Sales
        net_profit = self.time_series.get('NetProfit')
        sales = self.time_series.get('Sales')
        return net_profit / sales

    def get_dio(self):
        # Inventory Turnover Ratio = Cost of goods sold / Inventory
        # DIO = 365 / Inventory Turnover Ratio 
        cost_of_goods_sold = self.time_series.get('CostOfGoodsSold')
        inventories = self.time_series.get('Inventories')
        inventory_turnover_ratio = cost_of_goods_sold / inventories.get_average()
        dio = inventory_turnover_ratio.get_inverse().scalar(365.0)
        return self.__annualize(dio)

    def get_dso(self):
        # Receivables Turnover Ratio = Sales / Accounts receivable
        # DSO = 365 / Receivables Turnover Ratio
        sales = self.time_series.get('Sales')
        accounts_receivable = self.time_series.get('AccountsReceivable')
        receivables_turnover_ratio = sales / accounts_receivable.get_average()
        dso = receivables_turnover_ratio.get_inverse().scalar(365.0)
        return self.__annualize(dso)

    def get_dpo(self):
        # AccountsPayableTurnoverRatio = Cost of goods sold / Accounts payable
        # DPO = 365 / AccountsPayableTurnoverRatio
        cost_of_goods_sold = self.time_series.get('CostOfGoodsSold')
        accounts_payable = self.time_series.get('AccountsPayable')
        accounts_payable_turnover_ratio = cost_of_goods_sold / accounts_payable.get_average()
        dpo = accounts_payable_turnover_ratio.get_inverse().scalar(365.0)
        return self.__annualize(dpo)

    def get_cash_conversion_cycle(self):
        # CCC = DIO + DSO - DPO
        dio = self.get_dio()
        dso = self.get_dso()
        dpo = self.get_dpo()
        return dio + dso - dpo

    def __annualize(self, time_series):
        if self.period == 'Y':
            return time_series
        elif self.period == 'Q':
            return time_series.scalar(0.25)