Skip to content
All library documents

Equal-Weighting the Five Smallest CSI 300 Stocks by Market Capitalization

Article Strategy library · Author: Myquant

Summary

This document sketches a periodic stock-selection and execution process focused on the five smallest companies by market capitalization in the CSI 300 universe. On the first incoming market bar, the strategy selects the target basket and compares it with current holdings. If there are no holdings, it buys the basket with equal weights; otherwise, it sells positions outside the new basket and waits for all sell fills before using returned cash to buy the replacements.

The source shows an event-driven order-fill workflow and calculates share quantities in board-lot units, allocating most available cash across the target names. It does not provide the selection code, explain how or when market capitalizations are sourced, or describe rebalance frequency beyond the initial bar-triggered process. There are no backtest settings or performance results, and the brief outline does not address transaction costs, liquidity, corporate actions, or the risks of concentrating in smaller constituents.

Key ideas

  • The proposed universe is the CSI 300, from which the five smallest stocks by market capitalization are selected.
  • Target holdings are equally weighted when the strategy starts without positions.
  • Stocks outside the selected basket are sold before replacement purchases begin.
  • The implementation waits for sell fills before allocating available cash to new positions.
  • The document provides no backtest results or details on selection data and rebalance timing.

Tags

Full text
# Alpha


# Alpha









始终买入沪深300中市值最小的5只
    先订阅000300分钟行情(也可订阅其他symbol,只是用来作行情触发)
    第一个bar行情到来时在md_init中选股
    选出股票池与持仓作对比
    无持仓时直接按照股票池等权买入
    有持仓时,不在股票池中的股票卖出
    在成交回报on_order_filled中判断是否都已卖出,卖出仓位都成交以后再买入

## Source (Apache-2.0)

```python
# !/usr/bin/env python
# -*- coding: utf-8 -*-
from gmsdk.api import StrategyBase


class Alpha(StrategyBase):
    '''
    始终买入沪深300中市值最小的5只
    先订阅000300分钟行情(也可订阅其他symbol,只是用来作行情触发)
    第一个bar行情到来时在md_init中选股
    选出股票池与持仓作对比
    无持仓时直接按照股票池等权买入
    有持仓时,不在股票池中的股票卖出
    在成交回报on_order_filled中判断是否都已卖出,卖出仓位都成交以后再买入
    '''

    def __init__(self, *args, **kwargs):
        super(Alpha, self).__init__(*args, **kwargs)
        self.buy_dict = {}
        self.sell_dict = {}
        self.is_traded = False

    def initialize(self):
        pass

    # 收到第一根Bar后交易
    def on_bar(self, bar):
        print(bar.strtime)
        if self.is_traded:
            return
        self.is_traded = True
        self.initialize()
        self.handle_data()

    def handle_data(self):
        pass

    def on_order_filled(self, order):
        if order.sec_id in self.sell_dict and order.strategy_id == self.strategy_id:
            self.sell_dict.pop(order.sec_id)
            if len(self.sell_dict) == 0:  # 由于资金每次都开满,等卖盘全部成交资金回流时再买入
                cash = self.get_cash()
                for bar in self.buy_dict.values():
                    vol = int(cash.available * 0.95 / len(self.buy_dict) / bar.close / 100) * 100
                    self.open_long(bar.exchange, bar.sec_id, 0, vol)


```

Shown in full with attribution under the source's licence. Licence: Apache-2.0

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.