Esempio n. 1
0
 def test_ticker_selection(self):
     policy = StockSelectionPolicy()
     policy.ignore_new_stock_period = dt.timedelta(days=360)
     policy.select_st = False
     selector = StockTickerSelector(policy=policy)
     dates = [dt.datetime(2020, 1, 7), dt.datetime(2020, 12, 28)]
     ret = selector.generate_index(dates)
     print(ret)
Esempio n. 2
0
 def test_new_ticker_selection(self):
     policy = StockSelectionPolicy()
     policy.ignore_new_stock_period = 60
     policy.select_new_stock_period = 90
     policy.select_st = False
     selector = StockTickerSelector(policy=policy, db_interface=self.db_interface)
     dates = [dt.datetime(2020, 1, 7), dt.datetime(2020, 12, 28)]
     ret = selector.generate_index(dates=dates)
     print(ret)
Esempio n. 3
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()