How to use the zvt.domain.FinanceFactor function in zvt

To help you get started, we’ve selected a few zvt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zvtvz / zvt / tests / test_finance.py View on Github external
'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-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 == 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
github zvtvz / zvt / tests / api / test_finance.py View on Github external
'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 = get_finance_factor(session=session, provider='eastmoney', return_type='domain',
                                 codes=['000001'], end_timestamp='2018-12-30',
                                 order=FinanceFactor.report_date.desc(), time_field='report_date')
    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
github zvtvz / zvt / tests / api / test_finance.py View on Github external
'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 = get_finance_factor(session=session, provider='eastmoney', return_type='domain',
                                 codes=['000778'], end_timestamp='2018-12-30',
                                 order=FinanceFactor.report_date.desc(), time_field='report_date')
    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 == 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.0408
    assert latest.net_profit_growth_qoq == 0.2143
github zvtvz / zvt / zvt / recorders / eastmoney / finance / base_china_stock_finance_recorder.py View on Github external
provider=self.provider,
                                 entity_id=entity.id,
                                 order=self.data_schema.timestamp.asc(),
                                 return_type='domain',
                                 session=self.session,
                                 filters=[self.data_schema.timestamp == self.data_schema.report_date,
                                          self.data_schema.timestamp >= to_pd_timestamp('2005-01-01')])
        if the_data_list:
            if self.data_schema == FinanceFactor:
                for the_data in the_data_list:
                    self.fill_timestamp_with_jq(entity, the_data)
            else:
                df = get_finance_factor(entity_id=entity.id,
                                        columns=[FinanceFactor.timestamp, FinanceFactor.report_date, FinanceFactor.id],
                                        filters=[FinanceFactor.timestamp != FinanceFactor.report_date,
                                                 FinanceFactor.timestamp >= to_pd_timestamp('2005-01-01'),
                                                 FinanceFactor.report_date >= the_data_list[0].report_date,
                                                 FinanceFactor.report_date <= the_data_list[-1].report_date, ])

                if pd_is_not_null(df):
                    index_df(df, index='report_date')

                for the_data in the_data_list:
                    if (df is not None) and (not df.empty) and the_data.report_date in df.index:
                        the_data.timestamp = df.at[the_data.report_date, 'timestamp']
                        self.logger.info(
                            'db fill {} {} timestamp:{} for report_date:{}'.format(self.data_schema, entity.id,
                                                                                   the_data.timestamp,
                                                                                   the_data.report_date))
                        self.session.commit()
                    else:
                        # self.logger.info(
github zvtvz / zvt / zvt / factors / fundamental_factor.py View on Github external
entity_ids: List[str] = None,
                 entity_type: str = 'stock',
                 exchanges: List[str] = ['sh', 'sz'],
                 codes: List[str] = None,
                 the_timestamp: Union[str, pd.Timestamp] = None,
                 start_timestamp: Union[str, pd.Timestamp] = '2005-01-01',
                 end_timestamp: Union[str, pd.Timestamp] = now_pd_timestamp(),
                 # 高roe,高现金流,低财务杠杆,有增长
                 columns: List = [FinanceFactor.roe,
                                  FinanceFactor.op_income_growth_yoy,
                                  FinanceFactor.net_profit_growth_yoy,
                                  FinanceFactor.report_period,
                                  FinanceFactor.op_net_cash_flow_per_op_income,
                                  FinanceFactor.sales_net_cash_flow_per_op_income,
                                  FinanceFactor.current_ratio,
                                  FinanceFactor.debt_asset_ratio],
                 filters: List = [FinanceFactor.roe >= 0.02,
                                  FinanceFactor.op_income_growth_yoy >= 0.05,
                                  FinanceFactor.net_profit_growth_yoy >= 0.05,
                                  FinanceFactor.op_net_cash_flow_per_op_income >= 0.1,
                                  FinanceFactor.sales_net_cash_flow_per_op_income >= 0.3,
                                  FinanceFactor.current_ratio >= 1,
                                  FinanceFactor.debt_asset_ratio <= 0.5],
                 order: object = None,
                 limit: int = None,
                 provider: str = 'eastmoney',
                 level: Union[str, IntervalLevel] = IntervalLevel.LEVEL_1DAY,
                 category_field: str = 'entity_id',
                 time_field: str = 'timestamp',
                 computing_window: int = None,
                 keep_all_timestamp: bool = True,
                 fill_method: str = 'ffill',
github zvtvz / zvt / zvt / factors / finance_factor.py View on Github external
def __init__(self,
                 entity_ids: List[str] = None,
                 entity_type: str = 'stock',
                 exchanges: List[str] = ['sh', 'sz'],
                 codes: List[str] = None,
                 the_timestamp: Union[str, pd.Timestamp] = None,
                 start_timestamp: Union[str, pd.Timestamp] = None,
                 end_timestamp: Union[str, pd.Timestamp] = None,
                 columns: List = [FinanceFactor.op_income_growth_yoy, FinanceFactor.net_profit_growth_yoy,
                                  FinanceFactor.rota,
                                  FinanceFactor.roe],
                 filters: List = None,
                 order: object = None,
                 limit: int = None,
                 provider: str = 'eastmoney',
                 level: Union[str, IntervalLevel] = IntervalLevel.LEVEL_1DAY,

                 category_field: str = 'entity_id',
                 time_field: str = 'report_date',
                 trip_timestamp: bool = True,
                 auto_load: bool = True,
                 keep_all_timestamp: bool = False,
                 fill_method: str = 'ffill',
                 effective_number: int = 10,
                 depth_computing_method='ma',
github zvtvz / zvt / zvt / factors / fundamental_factor.py View on Github external
start_timestamp: Union[str, pd.Timestamp] = '2005-01-01',
                 end_timestamp: Union[str, pd.Timestamp] = now_pd_timestamp(),
                 # 高roe,高现金流,低财务杠杆,有增长
                 columns: List = [FinanceFactor.roe,
                                  FinanceFactor.op_income_growth_yoy,
                                  FinanceFactor.net_profit_growth_yoy,
                                  FinanceFactor.report_period,
                                  FinanceFactor.op_net_cash_flow_per_op_income,
                                  FinanceFactor.sales_net_cash_flow_per_op_income,
                                  FinanceFactor.current_ratio,
                                  FinanceFactor.debt_asset_ratio],
                 filters: List = [FinanceFactor.roe >= 0.02,
                                  FinanceFactor.op_income_growth_yoy >= 0.05,
                                  FinanceFactor.net_profit_growth_yoy >= 0.05,
                                  FinanceFactor.op_net_cash_flow_per_op_income >= 0.1,
                                  FinanceFactor.sales_net_cash_flow_per_op_income >= 0.3,
                                  FinanceFactor.current_ratio >= 1,
                                  FinanceFactor.debt_asset_ratio <= 0.5],
                 order: object = None,
                 limit: int = None,
                 provider: str = 'eastmoney',
                 level: Union[str, IntervalLevel] = IntervalLevel.LEVEL_1DAY,
                 category_field: str = 'entity_id',
                 time_field: str = 'timestamp',
                 computing_window: int = None,
                 keep_all_timestamp: bool = True,
                 fill_method: str = 'ffill',
                 effective_number: int = None,
                 transformer: Transformer = None,
                 accumulator: Accumulator = None,
                 persist_factor: bool = False,
                 dry_run: bool = False,
github zvtvz / zvt / zvt / factors / fundamental_factor.py View on Github external
def __init__(self,
                 data_schema=FinanceFactor,
                 entity_ids: List[str] = None,
                 entity_type: str = 'stock',
                 exchanges: List[str] = ['sh', 'sz'],
                 codes: List[str] = None,
                 the_timestamp: Union[str, pd.Timestamp] = None,
                 start_timestamp: Union[str, pd.Timestamp] = None,
                 end_timestamp: Union[str, pd.Timestamp] = None,
                 columns: List = None, filters: List = None,
                 order: object = None,
                 limit: int = None,
                 provider: str = 'eastmoney',
                 level: Union[str, IntervalLevel] = IntervalLevel.LEVEL_1DAY,
                 category_field: str = 'entity_id',
                 time_field: str = 'timestamp',
                 computing_window: int = None,
                 keep_all_timestamp: bool = False,
github zvtvz / zvt / zvt / factors / fundamental_factor.py View on Github external
def __init__(self, data_schema=FinanceFactor,
                 entity_ids: List[str] = None,
                 entity_type: str = 'stock',
                 exchanges: List[str] = ['sh', 'sz'],
                 codes: List[str] = None,
                 the_timestamp: Union[str, pd.Timestamp] = None,
                 start_timestamp: Union[str, pd.Timestamp] = '2005-01-01',
                 end_timestamp: Union[str, pd.Timestamp] = now_pd_timestamp(),
                 # 高roe,高现金流,低财务杠杆,有增长
                 columns: List = [FinanceFactor.roe,
                                  FinanceFactor.op_income_growth_yoy,
                                  FinanceFactor.net_profit_growth_yoy,
                                  FinanceFactor.report_period,
                                  FinanceFactor.op_net_cash_flow_per_op_income,
                                  FinanceFactor.sales_net_cash_flow_per_op_income,
                                  FinanceFactor.current_ratio,
                                  FinanceFactor.debt_asset_ratio],
                 filters: List = [FinanceFactor.roe >= 0.02,
                                  FinanceFactor.op_income_growth_yoy >= 0.05,
                                  FinanceFactor.net_profit_growth_yoy >= 0.05,
                                  FinanceFactor.op_net_cash_flow_per_op_income >= 0.1,
                                  FinanceFactor.sales_net_cash_flow_per_op_income >= 0.3,
                                  FinanceFactor.current_ratio >= 1,
                                  FinanceFactor.debt_asset_ratio <= 0.5],
                 order: object = None,
                 limit: int = None,
github zvtvz / zvt / zvt / factors / fundamental_factor.py View on Github external
def __init__(self, data_schema=FinanceFactor,
                 entity_ids: List[str] = None,
                 entity_type: str = 'stock',
                 exchanges: List[str] = ['sh', 'sz'],
                 codes: List[str] = None,
                 the_timestamp: Union[str, pd.Timestamp] = None,
                 start_timestamp: Union[str, pd.Timestamp] = '2005-01-01',
                 end_timestamp: Union[str, pd.Timestamp] = now_pd_timestamp(),
                 # 高roe,高现金流,低财务杠杆,有增长
                 columns: List = [FinanceFactor.roe,
                                  FinanceFactor.op_income_growth_yoy,
                                  FinanceFactor.net_profit_growth_yoy,
                                  FinanceFactor.report_period,
                                  FinanceFactor.op_net_cash_flow_per_op_income,
                                  FinanceFactor.sales_net_cash_flow_per_op_income,
                                  FinanceFactor.current_ratio,
                                  FinanceFactor.debt_asset_ratio],
                 filters: List = [FinanceFactor.roe >= 0.02,
                                  FinanceFactor.op_income_growth_yoy >= 0.05,
                                  FinanceFactor.net_profit_growth_yoy >= 0.05,
                                  FinanceFactor.op_net_cash_flow_per_op_income >= 0.1,
                                  FinanceFactor.sales_net_cash_flow_per_op_income >= 0.3,
                                  FinanceFactor.current_ratio >= 1,
                                  FinanceFactor.debt_asset_ratio <= 0.5],
                 order: object = None,
                 limit: int = None,
                 provider: str = 'eastmoney',