def daily_routine(config_loc: str): set_global_config(config_loc) with TushareData() as tushare_crawler: tushare_crawler.update_base_info() tushare_crawler.get_shibor() tushare_crawler.get_ipo_info() tushare_crawler.get_company_info() tushare_crawler.update_hs_holding() tushare_crawler.get_hs_constitute() tushare_crawler.update_stock_names() tushare_crawler.update_dividend() tushare_crawler.update_index_daily() tushare_crawler.update_hk_stock_daily() tushare_crawler.update_fund_daily() tushare_crawler.update_fund_dividend() tushare_crawler.update_financial_data() with WindData() as wind_data: wind_data.update_stock_daily_data() wind_data.update_stock_adj_factor() wind_data.update_stock_units() wind_data.update_industry() wind_data.update_pause_stock_info() wind_data.update_convertible_bond_daily_data() wind_data.update_cb_convertible_price() wind_data.update_future_daily_data() wind_data.update_fund_extra_info() wind_data.update_fund_info() wind_data.update_stock_option_daily_data() with JQData() as jq_data: jq_data.update_stock_morning_auction_data() with TDXData() as tdx_data: tdx_data.update_stock_minute() tdx_data.update_convertible_bond_minute() # compute data ConstLimitStockFactorCompositor().update() NegativeBookEquityListingCompositor().update() IndexUpdater().update() # model data SMBandHMLCompositor().update() UMDCompositor().update()
import sys from AShareData import generate_db_interface_from_config, set_global_config, TushareData from AShareData.model import FamaFrench3FactorModel, FamaFrenchCarhart4FactorModel, SMBandHMLCompositor, UMDCompositor from update_routine import daily_routine if __name__ == '__main__': config_loc = sys.argv[1] db_interface = generate_db_interface_from_config(config_loc, init=True) set_global_config(config_loc) with TushareData() as tushare_data: tushare_data.init_db() tushare_data.init_accounting_data() daily_routine(config_loc) SMBandHMLCompositor(FamaFrench3FactorModel()).update() UMDCompositor(FamaFrenchCarhart4FactorModel()).update()
import sys from AShareData import ConstLimitStockFactorCompositor, JQData, set_global_config, TushareData, WindData if __name__ == '__main__': set_global_config(sys.argv[1]) tushare_crawler = TushareData() tushare_crawler.update_base_info() tushare_crawler.get_shibor() tushare_crawler.get_ipo_info() tushare_crawler.get_company_info() tushare_crawler.update_hs_holding() tushare_crawler.get_hs_constitute() tushare_crawler.update_stock_names() tushare_crawler.update_dividend() tushare_crawler.update_index_daily() tushare_crawler.update_hk_stock_daily() tushare_crawler.update_fund_daily() tushare_crawler.update_fund_dividend() with WindData() as wind_data: wind_data.update_stock_daily_data() wind_data.update_stock_adj_factor() wind_data.update_stock_units() wind_data.update_industry()
import datetime as dt import json import sys from DingTalkMessageBot import DingTalkMessageBot from AShareData import JQData, MySQLInterface, prepare_engine, TushareData if __name__ == '__main__': config_loc = sys.argv[1] date = dt.date.today() with open(config_loc, 'r') as f: config = json.load(f) engine = prepare_engine(config_loc) db_interface = MySQLInterface(engine) tushare_crawler = TushareData(config['tushare_token'], db_interface=db_interface) tushare_crawler.get_ipo_info() token = '076314e3a582ce36705d53dc0b822493c046447b82e3cfb1571850debe500b15' secret = 'SEC2931f95f8d27145c579b8f37eb479fc587a3caec441829b5a4999b90271286c4' messenger = DingTalkMessageBot(token, secret) try: with JQData(db_interface, config['jq_mobile'], config['jq_password']) as jq_data: jq_data.stock_open_auction_data(date) messenger.send_message(f'{date} 集合竞价数据已下载.') except: messenger.send_message(f'{date} 集合竞价数据下载失败.')
import json import sys from AShareData import ConstLimitStockFactorCompositor, MySQLInterface, prepare_engine, TushareData, WindData if __name__ == '__main__': config_loc = sys.argv[1] with open(config_loc, 'r') as f: config = json.load(f) tushare_token = config['tushare_token'] engine = prepare_engine(config_loc) db_interface = MySQLInterface(engine, init=True) tushare_crawler = TushareData(tushare_token, db_interface=db_interface) tushare_crawler.update_base_info() tushare_crawler.get_shibor() tushare_crawler.get_ipo_info() tushare_crawler.get_company_info() tushare_crawler.update_hs_holding() tushare_crawler.get_hs_constitute() tushare_crawler.update_stock_names() tushare_crawler.update_dividend() tushare_crawler.update_index_daily() tushare_crawler.update_hk_stock_daily() tushare_crawler.update_fund_daily()
def setUp(self) -> None: set_global_config('config.json') self.downloader = TushareData()