Exemple #1
0
    def test_calc_profit_margin(self):
        income_statement_data = {
            "Gross Income": [62, 50, 36],
            "Sales/Revenue": [3.1, 2.0, 1.2]
        }
        income_statement_index = pd.to_datetime(["2012-01-01", "2012-01-02", "2012-01-03"])

        dated_metric = DatedMetric(
            pd.Timestamp("2012-01-03"),
            income_statement=pd.DataFrame(income_statement_data, index=income_statement_index),
            financial_report_preparation_lag=np.timedelta64(1, 'D')
        )

        gross_profit_margin = dated_metric.calc_profit_margin("gross")

        # because of 1 day financial_report_preparation_lag
        self.assertEqual(gross_profit_margin, 25)