Beispiel #1
0
 def test_major_industry_constitute():
     set_global_config('config.json')
     provider = '申万'
     level = 2
     name = '景点'
     obj = MajorIndustryConstitutes(provider=provider, level=level)
     print(obj.get_major_constitute(name))
Beispiel #2
0
 def setUp(self) -> None:
     set_global_config('config.json')
     self.target = ContinuousFactor('自合成指数', '收益率')
     self.target.bind_params(ids='ST.IND')
     self.benchmark = ContinuousFactor('自合成指数', '收益率')
     self.benchmark.bind_params(ids='全市场.IND')
     self.start = dt.datetime(2012, 1, 1)
     self.end = dt.datetime(2020, 1, 1)
 def setUp(self) -> None:
     set_global_config('config.json')
     self.db_interface = get_db_interface()
     self.calendar = TradingCalendar()
     self.start_date = dt.datetime(2002, 3, 1)
     self.end_date = dt.datetime(2002, 3, 30)
     self.ids = ['000001.SZ', '000002.SZ']
     self.close = ContinuousFactor('股票日行情', '收盘价', self.db_interface)
     self.adj = CompactFactor('复权因子', self.db_interface)
Beispiel #4
0
 def setUp(self) -> None:
     set_global_config('config.json')
     self.db_interface = get_db_interface()
     self.calendar = TradingCalendar()
     self.start_date = dt.datetime(2020, 12, 1)
     self.end_date = dt.datetime(2020, 12, 18)
     self.ids = ['000001.SZ', '000002.SZ']
     # self.ids = StockTickers().ticker(dt.date(2005, 1, 1))
     self.close = ContinuousFactor('股票日行情', '收盘价', self.db_interface)
     self.adj = CompactFactor('复权因子', self.db_interface)
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()
Beispiel #6
0
    def setUp(self):
        set_global_config('config.json')
        self.data_reader = AShareDataReader()
        forward_return = self.data_reader.forward_return
        factors = self.data_reader.log_cap
        ticker_selector = StockTickerSelector(StockSelectionPolicy())
        market_cap = self.data_reader.stock_free_floating_market_cap
        start_date = dt.datetime(2020, 8, 1)
        end_date = dt.datetime(2021, 2, 1)
        dates = TradingCalendar().first_day_of_month(start_date, end_date)

        self.t = CrossSectionalPortfolioAnalysis(forward_return, factors=factors, dates=dates, market_cap=market_cap,
                                                 ticker_selector=ticker_selector)
        self.t.cache()
Beispiel #7
0
 def test_ff_model():
     set_global_config('config.json')
     date = dt.datetime(2020, 3, 3)
     model = FamaFrench3FactorModel()
     # self = model
     print(model.compute_daily_factor_return(date))
import sys

from AShareData import ConstLimitStockFactorCompositor, set_global_config, TDXData, TushareData

if __name__ == '__main__':
    # set_global_config(sys.argv[1])
    set_global_config("config.json")
    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()
Beispiel #9
0
 def setUp(self):
     set_global_config('config.json')
Beispiel #10
0
 def setUp(self):
     set_global_config('config.json')
     self.portfolio_analysis = ASharePortfolioAnalysis()
     self.data_reader = self.portfolio_analysis.data_reader
Beispiel #11
0
 def setUp(self) -> None:
     set_global_config('config.json')
     self.jq_data = JQData()
Beispiel #12
0
 def setUp(self) -> None:
     set_global_config('config.json')
     self.downloader = TushareData()
 def setUp(self) -> None:
     config_loc = 'config.json'
     set_global_config('config.json')
     self.wind_data = WindData.from_config(config_loc)
Beispiel #14
0
 def setUp(self) -> None:
     set_global_config('config.json')
     db_interface = get_db_interface()
     self.industry_obj = IndustryComparison(index='000905.SH',
                                            industry_provider='中信',
                                            industry_level=2)
Beispiel #15
0
 def test_index_highlighter():
     set_global_config('config.json')
     obj = IndexHighlighter()
     obj.summary()
Beispiel #16
0
import datetime as dt
import sys

from AShareData import AShareDataReader, set_global_config
from AShareData.factor_compositor import FactorPortfolio, FactorPortfolioPolicy
from AShareData.utils import StockSelectionPolicy

if __name__ == '__main__':
    set_global_config(sys.argv[1])

    data_reader = AShareDataReader()
    stock_selection_policy = StockSelectionPolicy()
    stock_selection_policy.ignore_new_stock_period = 244
    stock_selection_policy.ignore_st = True
    stock_selection_policy.ignore_pause = True

    policy = FactorPortfolioPolicy()
    policy.bins = [5, 10]
    policy.stock_selection_policy = stock_selection_policy
    policy.start_date = dt.datetime(2010, 1, 1)
    policy.industry = data_reader.industry('申万', 1)
    policy.weight = data_reader.stock_free_floating_market_cap

    policy.name = data_reader.beta.name
    policy.factor = data_reader.beta

    sub_port = FactorPortfolio(factor_portfolio_policy=policy)
    sub_port.update()
Beispiel #17
0
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()
Beispiel #18
0
 def setUp(self) -> None:
     set_global_config('config.json')