10% smallest cap stock
来源:https://uqer.io/community/share/5663e2f4f9f06c6c8a91b391
import numpy as np
start = '2011-01-05'
end = '2015-12-01'
benchmark = 'HS300'
universe = StockScreener(Factor.LCAP.nsmall(40))
capital_base = 100000
freq = 'd'
refresh_rate = 1
def initialize(account):
account.empty = True
def handle_data(account):
today = account.current_date
if today.month == 12 and account.empty:
account.empty = False
for stock in account.universe:
p = account.referencePrice.get(stock, 0)
if np.isnan(p) or p == 0:
continue
order_pct_to(stock, 0.025)
elif today.month == 4 and not account.empty:
account.empty = True
for stock in account.universe:
if stock in account.valid_secpos:
order_to(stock,0)