Example #1
0
 def get_stock_detail_data(region: Region, provider: Provider, sleep,
                           process, desc, mode):
     # 个股详情
     from zvt.domain.meta.stock_meta import StockDetail
     StockDetail.record_data(region=region,
                             provider=provider,
                             share_para=(process, desc, mode),
                             sleeping_time=sleep)
                json=param)
            resp.encoding = 'utf8'

            resp_json = resp.json()['Result']['FaXingXiangGuan']

            security_item.issue_pe = to_float(resp_json['PEIssued'])
            security_item.price = to_float(resp_json['IssuePrice'])
            security_item.issues = to_float(resp_json['ShareIssued'])
            security_item.raising_fund = to_float((resp_json['NetCollection']))
            security_item.net_winning_rate = pct_to_float(
                resp_json['LotRateOn'])

            self.session.commit()

            self.logger.info('finish recording stock meta for:{}'.format(
                security_item.code))

            self.sleep()


__all__ = [
    'EastmoneyChinaStockListRecorder', 'EastmoneyChinaStockDetailRecorder'
]

if __name__ == '__main__':
    # init_log('china_stock_meta.log')

    # recorder = EastmoneyChinaStockDetailRecorder()
    # recorder.run()
    StockDetail.record_data(codes=['000338', '000777'], provider='eastmoney')
                security_item.issue_pe = to_float(resp_json['PEIssued'])
                security_item.price = to_float(resp_json['IssuePrice'])
                security_item.issues = to_float(resp_json['ShareIssued'])
                security_item.raising_fund = to_float(
                    (resp_json['NetCollection']))
                security_item.net_winning_rate = pct_to_float(
                    resp_json['LotRateOn'])

                self.session.commit()
                self.logger.info('finish recording stock meta for: {}'.format(
                    security_item.code))

                self.share_para[2].acquire()
                pbar.update()
                self.share_para[2].release()

                self.sleep()


__all__ = [
    'EastmoneyChinaStockListRecorder', 'EastmoneyChinaStockDetailRecorder'
]

if __name__ == '__main__':
    # init_log('china_stock_meta.log')

    # recorder = EastmoneyChinaStockDetailRecorder()
    # recorder.run()
    StockDetail.record_data(codes=['000338', '000777'],
                            provider=Provider.EastMoney)
Example #4
0
        if not entity.industry:
            entity.industry = info.get('industry', None)

        if not entity.market_cap or entity.market_cap == 0:
            entity.market_cap = info.get('market_cap', 0)

        entity.profile = info.get('longBusinessSummary', None)
        entity.state = info.get('state', None)
        entity.city = info.get('city', None)
        entity.zip_code = info.get('zip', None)

        entity.last_sale = info.get('previousClose', None)

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

        self.sleep()


__all__ = ['YahooUsStockListRecorder', 'YahooUsStockDetailRecorder']

if __name__ == '__main__':
    # init_log('china_stock_meta.log')

    # recorder = EastmoneyChinaStockDetailRecorder()
    # recorder.run()
    StockDetail.record_data(codes=['A'], provider=Provider.Yahoo)
            resp = requests.post(
                "https://emh5.eastmoney.com/api/GongSiGaiKuang/GetFaXingXiangGuan",
                json=param)
            resp.encoding = "utf8"

            resp_json = resp.json()["Result"]["FaXingXiangGuan"]

            security_item.issue_pe = to_float(resp_json["PEIssued"])
            security_item.price = to_float(resp_json["IssuePrice"])
            security_item.issues = to_float(resp_json["ShareIssued"])
            security_item.raising_fund = to_float((resp_json["NetCollection"]))
            security_item.net_winning_rate = pct_to_float(
                resp_json["LotRateOn"])

            self.session.commit()

            self.logger.info("finish recording stock meta for:{}".format(
                security_item.code))

            self.sleep()


if __name__ == "__main__":
    # init_log('china_stock_meta.log')

    recorder = EastmoneyStockRecorder()
    recorder.run()
    StockDetail.record_data(codes=["000338", "000777"], provider="eastmoney")
# the __all__ is generated
__all__ = ["EastmoneyStockRecorder", "EastmoneyStockDetailRecorder"]