資源簡(jiǎn)介
多因子選股策略
# coding:gbk
'''
策略以HS300為基礎(chǔ)股票池,在日線下運(yùn)行,20個(gè)交易日進(jìn)行一次調(diào)倉(cāng),每次買入在買入備選中因子評(píng)分前10的股票,每支股票各分配當(dāng)前可用資金的10%(權(quán)重可調(diào)整)
擴(kuò)展數(shù)據(jù)需要在補(bǔ)完HS300成分股數(shù)據(jù)之后生成,本模型中擴(kuò)展數(shù)據(jù)暫時(shí)使用VBA指標(biāo)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')
# 設(shè)定基礎(chǔ)股票池為滬深300成分股
ContextInfo.set_universe(ContextInfo.s)
# 策略運(yùn)行天數(shù)
ContextInfo.day = 0
# 持倉(cāng)情況
ContextInfo.holdings = {i: 0 for i in ContextInfo.s}
# 資金權(quán)重
ContextInfo.weight = [0.1] * 10 # 設(shè)置資金分配權(quán)重
# 買入點(diǎn)
ContextInfo.buypoint = {}
代碼片段和文件信息
評(píng)論
共有 條評(píng)論