コード例 #1
0
ファイル: run.py プロジェクト: huanjka119/FinanceCenter
 def get_rights_issue_detail_data(provider: Provider, sleep, desc, pc, lock,
                                  region, batch):
     # 配股表
     RightsIssueDetail.record_data(provider=provider,
                                   share_para=(desc, pc, lock, True,
                                               region),
                                   sleeping_time=sleep,
                                   batch_size=batch)
コード例 #2
0
    def on_finish(self):
        last_year = str(now_pd_timestamp().year)
        codes = [item.code for item in self.entities]
        need_filleds = DividendFinancing.query_data(
            provider=self.provider,
            codes=codes,
            return_type="domain",
            session=self.session,
            filters=[DividendFinancing.rights_raising_fund.is_(None)],
            end_timestamp=last_year,
        )

        for item in need_filleds:
            df = RightsIssueDetail.query_data(
                provider=self.provider,
                entity_id=item.entity_id,
                columns=[
                    RightsIssueDetail.timestamp,
                    RightsIssueDetail.rights_raising_fund
                ],
                start_timestamp=item.timestamp,
                end_timestamp="{}-12-31".format(item.timestamp.year),
            )
            if pd_is_not_null(df):
                item.rights_raising_fund = df["rights_raising_fund"].sum()
                self.session.commit()

        super().on_finish()
コード例 #3
0
    def on_finish(self):
        last_year = str(now_pd_timestamp(self.region).year)
        codes = [item.code for item in self.entities]
        need_filleds = DividendFinancing.query_data(region=self.region,
                                                    provider=self.provider,
                                                    codes=codes,
                                                    return_type='domain',
                                                    filters=[DividendFinancing.rights_raising_fund.is_(None)],
                                                    end_timestamp=last_year)

        desc = RightsIssueDetail.__name__ + ": update relevant table"
        with tqdm(total=len(need_filleds), ncols=90, desc=desc, position=2, leave=True) as pbar:
            from sqlalchemy import func

            session = get_db_session(region=self.region,
                                     provider=self.provider,
                                     data_schema=self.data_schema)

            for item in need_filleds:
                result = RightsIssueDetail.query_data(
                                                region=self.region,
                                                provider=self.provider,
                                                entity_id=item.entity_id,
                                                start_timestamp=item.timestamp,
                                                end_timestamp="{}-12-31".format(item.timestamp.year),
                                                return_type='func',
                                                func=func.sum(RightsIssueDetail.rights_raising_fund))

                if isinstance(result, (int, float)):
                    item.rights_raising_fund = result
                    session.commit()
                pbar.update()

        super().on_finish()
コード例 #4
0
def test_000778_rights_issue_detail():
    result = RightsIssueDetail.query_data(
        session=session,
        provider='eastmoney',
        return_type='domain',
        codes=['000778'],
        end_timestamp='2018-09-30',
        order=RightsIssueDetail.timestamp.desc())
    assert len(result) == 2
    latest: RightsIssueDetail = result[0]
    assert latest.timestamp == to_pd_timestamp('2001-09-10')
    assert latest.rights_issues == 43570000
    assert latest.rights_raising_fund == 492300000
    assert latest.rights_issue_price == 11.3
コード例 #5
0
ファイル: test_dividend_financing.py プロジェクト: zvtvz/zvt
def test_000778_rights_issue_detail():
    result = RightsIssueDetail.query_data(
        session=session,
        provider="eastmoney",
        return_type="domain",
        codes=["000778"],
        end_timestamp="2018-09-30",
        order=RightsIssueDetail.timestamp.desc(),
    )
    assert len(result) == 2
    latest: RightsIssueDetail = result[0]
    assert latest.timestamp == to_pd_timestamp("2001-09-10")
    assert latest.rights_issues == 43570000
    assert latest.rights_raising_fund == 492300000
    assert latest.rights_issue_price == 11.3
コード例 #6
0
def test_rights_issue_detail():
    try:
        RightsIssueDetail.record_data(provider='eastmoney',
                                      codes=SAMPLE_STOCK_CODES)
    except:
        assert False