資源簡介
多因子選股策略
# coding:gbk
'''
策略以HS300為基礎股票池,在日線下運行,20個交易日進行一次調倉,每次買入在買入備選中因子評分前10的股票,每支股票各分配當前可用資金的10%(權重可調整)
擴展數(shù)據(jù)需要在補完HS300成分股數(shù)據(jù)之后生成,本模型中擴展數(shù)據(jù)暫時使用VBA指標ATR和ADTM生成,命名為atr和adtm
'''
import pandas as pd
import numpy as np
import time
import datetime
#1. =============================初始化部分=============================================
def init(ContextInfo):
# 獲取滬深300成分股
ContextInfo.s = ContextInfo.get_sector('000300.SH')
# 設定基礎股票池為滬深300成分股
ContextInfo.set_universe(ContextInfo.s)
# 策略運行天數(shù)
ContextInfo.day = 0
# 持倉情況
ContextInfo.holdings = {i: 0 for i in ContextInfo.s}
# 資金權重
ContextInfo.weight = [0.1] * 10 # 設置資金分配權重
# 買入點
ContextInfo.buypoint = {}
代碼片段和文件信息
評論
共有 條評論