Пример #1
0
def test_000001_finance_factor():
    correct_timestamps = ['2018-09-30', '2018-06-30', '2018-03-31', '2017-12-31', '2017-09-30', '2017-06-30',
                          '2017-03-31', '2016-12-31', '2016-09-30', '2016-06-30', '2016-03-31', '2015-12-31',
                          '2015-09-30', '2015-06-30', '2015-03-31', '2014-12-31', '2014-09-30', '2014-06-30',
                          '2014-03-31', '2013-12-31', '2013-09-30', '2013-06-30', '2013-03-31', '2012-12-31',
                          '2012-09-30', '2012-06-30', '2012-03-31', '2011-12-31', '2011-09-30', '2011-06-30',
                          '2011-03-31', '2010-12-31', '2010-09-30', '2010-06-30', '2010-03-31', '2009-12-31',
                          '2009-09-30', '2009-06-30', '2009-03-31', '2008-12-31', '2008-09-30', '2008-06-30',
                          '2008-03-31', '2007-12-31', '2007-09-30', '2007-06-30', '2007-03-31', '2006-12-31',
                          '2006-09-30', '2006-06-30', '2006-03-31', '2005-12-31', '2005-09-30', '2005-06-30',
                          '2005-03-31', '2004-12-31', '2004-09-30', '2004-06-30', '2004-03-31', '2003-12-31',
                          '2003-09-30', '2003-06-30', '2003-03-31', '2002-12-31', '2002-09-30', '2002-06-30',
                          '2002-03-31', '2001-12-31', '2001-09-30', '2001-06-30', '2001-03-31', '2000-12-31',
                          '2000-06-30', '1999-12-31', '1999-06-30', '1998-12-31', '1998-06-30', '1997-12-31',
                          '1997-06-30', '1996-12-31', '1996-06-30', '1995-12-31', '1995-06-30', '1994-12-31',
                          '1994-06-30', '1993-12-31', '1993-06-30', '1992-12-31', '1991-12-31', '1990-12-31',
                          '1989-12-31']
    result = fundamental.get_finance_factor(session=session, provider=Provider.EASTMONEY, return_type='domain',
                                            codes=['000001'], end_timestamp='2018-12-30',
                                            order=FinanceFactor.timestamp.desc())
    assert len(correct_timestamps) == len(result)
    timestamps = [to_time_str(item.report_date) for item in result]
    assert set(correct_timestamps) == set(timestamps)
    latest: FinanceFactor = result[0]
    assert latest.basic_eps == 1.14
    assert latest.deducted_eps == 1.13
    assert latest.diluted_eps == 1.14
    assert latest.bps == 12.538
    assert latest.capital_reserve_ps == 3.2886
    assert latest.undistributed_profit_ps == 5.3566
    assert latest.op_cash_flow_ps == -0.6587

    assert latest.total_op_income == 86660000000
    assert latest.net_profit == 20460000000
    assert latest.deducted_net_profit == 20350000000
    assert latest.op_income_growth_yoy == 0.0856
    assert latest.net_profit_growth_yoy == 0.068
    assert latest.deducted_net_profit_growth_yoy == 0.0636
    assert latest.op_income_growth_qoq == 0.0336
    assert latest.net_profit_growth_qoq == 0.0202
    assert latest.deducted_net_profit_growth_qoq == 0.0168

    assert latest.roe == 0.0948
    assert latest.deducted_roe == 0.0943
    assert latest.rota == 0.0062
    assert latest.net_margin == 0.2360

    assert latest.debt_asset_ratio == 0.9298
    assert latest.em == 14.25
    assert latest.equity_ratio == 13.25

    assert latest.fi_total_deposit == 2130000000000
    assert latest.fi_total_loan == 1920000000000
    assert latest.fi_loan_deposit_ratio == 0.9004
    assert latest.fi_npl_ratio == 0.0168
    assert latest.fi_npl_provision_coverage == 1.6914
Пример #2
0
def test_000778_finance_factor():
    correct_timestamps = [
        '2018-09-30', '2018-06-30', '2018-03-31', '2017-12-31', '2017-09-30',
        '2017-06-30', '2017-03-31', '2016-12-31', '2016-09-30', '2016-06-30',
        '2016-03-31', '2015-12-31', '2015-09-30', '2015-06-30', '2015-03-31',
        '2014-12-31', '2014-09-30', '2014-06-30', '2014-03-31', '2013-12-31',
        '2013-09-30', '2013-06-30', '2013-03-31', '2012-12-31', '2012-09-30',
        '2012-06-30', '2012-03-31', '2011-12-31', '2011-09-30', '2011-06-30',
        '2011-03-31', '2010-12-31', '2010-09-30', '2010-06-30', '2010-03-31',
        '2009-12-31', '2009-09-30', '2009-06-30', '2009-03-31', '2008-12-31',
        '2008-09-30', '2008-06-30', '2008-03-31', '2007-12-31', '2007-09-30',
        '2007-06-30', '2007-03-31', '2006-12-31', '2006-09-30', '2006-06-30',
        '2006-03-31', '2005-12-31', '2005-09-30', '2005-06-30', '2005-03-31',
        '2004-12-31', '2004-09-30', '2004-06-30', '2004-03-31', '2003-12-31',
        '2003-09-30', '2003-06-30', '2003-03-31', '2002-12-31', '2002-09-30',
        '2002-06-30', '2002-03-31', '2001-12-31', '2001-06-30', '2000-12-31',
        '2000-06-30', '1999-12-31', '1999-06-30', '1998-12-31', '1998-06-30',
        '1997-12-31', '1997-06-30', '1996-12-31', '1995-12-31', '1994-12-31'
    ]
    result = fundamental.get_finance_factor(
        session=session,
        provider=Provider.EASTMONEY,
        return_type='domain',
        codes=['000778'],
        end_timestamp='2018-09-30',
        order=FinanceFactor.timestamp.desc())
    assert len(correct_timestamps) == len(result)
    timestamps = [to_time_str(item.timestamp) for item in result]
    assert set(correct_timestamps) == set(timestamps)
    latest: FinanceFactor = result[0]

    assert latest.basic_eps == 0.4537
    assert latest.diluted_eps == 0.4537
    assert latest.bps == 5.0919
    assert latest.capital_reserve_ps == 2.1769
    assert latest.undistributed_profit_ps == 1.8132
    assert latest.op_cash_flow_ps == 1.0148
    assert latest.total_op_income == 31710000000
    assert latest.gross_profit == 5491000000
    assert latest.net_profit == 1811000000
    assert latest.deducted_net_profit == 1897000000
    assert latest.op_income_growth_yoy == -0.1024
    assert latest.net_profit_growth_yoy == 1.2404
    assert latest.deducted_net_profit_growth_yoy == 1.4813
    assert latest.op_income_growth_qoq == 0.0409
    assert latest.net_profit_growth_qoq == 0.2139
    assert latest.deducted_net_profit_growth_qoq == 0.2945

    assert latest.roe == 0.0882
    assert latest.rota == 0.0377
    assert latest.gross_profit_margin == 0.1731
    assert latest.net_margin == 0.0591

    assert latest.advance_receipts_per_op_income == 0.1
    assert latest.sales_net_cash_flow_per_op_income == 0.88
    assert latest.op_net_cash_flow_per_op_income == 0.13
    assert latest.actual_tax_rate == 0.2362

    assert latest.current_ratio == 1
    assert latest.quick_ratio == 0.84
    assert latest.cash_flow_ratio == 0.17
    assert latest.debt_asset_ratio == 0.5766
    assert latest.em == 2.36
    assert latest.equity_ratio == 1.43

    assert latest.total_assets_turnover_days == 423.09
    assert latest.inventory_turnover_days == 32.77
    assert latest.receivables_turnover_days == 51.84
    assert latest.total_assets_turnover == 0.64
    assert latest.inventory_turnover == 8.24
    assert latest.receivables_turnover == 5.21