<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 8.1 大小盤輪動 · 新手上路 -- 二八ETF擇時輪動策略2.0 ```py start = '2013-05-01' # 回測起始時間 end = '2015-09-01' # 回測結束時間 benchmark = 'HS300' # 策略參考標準 universe = ['510300.XSHG','510500.XSHG'] # 證券池,支持股票和基金 HS300,SZ500=universe capital_base = 100000 # 起始資金 freq = 'd' # 策略類型,'d'表示日間策略使用日線回測 refresh_rate =1 # 調倉頻率,表示執行handle_data的時間間隔,由于freq = 'd',時間間隔的單位為交易日 max_retracement = 0.01 # 最大回撤比例 def initialize(account): # 初始化虛擬賬戶狀態 pass def handle_data(account): # 每個交易日的買入賣出指令 # 周末進行交換 if account.current_date.weekday() != 4 : return # 有停牌的話,今天就跳過。 if len(account.universe) < 2: return hist = account.get_attribute_history('closePrice', 19) if len(hist) < 2: return # 如果HS300四周內漲幅大于SZ500 if hist[HS300][-1]/hist[HS300][0] > hist[SZ500][-1]/hist[ SZ500][0]: # 且為正收益 if hist[HS300][-1]/hist[HS300][0] > 1: if account.avail_secpos.has_key(SZ500): order_pct_to(SZ500, 0) order_pct_to(HS300, 0.99) elif hist[HS300][-1]/hist[HS300][0] < 1- max_retracement: # 負收益,清盤 if account.avail_secpos.has_key(SZ500): order_pct_to(SZ500, 0) if account.avail_secpos.has_key(HS300): order_pct_to(HS300, 0) # 如果HS300四周內漲幅小于SZ500 elif hist[HS300][-1]/hist[HS300][0] < hist[SZ500][-1]/hist[ SZ500][0]: # 且為正收益 if hist[SZ500][-1]/hist[SZ500][0] > 1: if account.avail_secpos.has_key(HS300): order_pct_to(HS300, 0) order_pct_to(SZ500, 0.99) elif hist[SZ500][-1]/hist[SZ500][0] < 1- max_retracement: # 負收益,清盤 if account.avail_secpos.has_key(SZ500): order_pct_to(SZ500, 0) if account.avail_secpos.has_key(HS300): order_pct_to(HS300, 0) ``` ![](https://box.kancloud.cn/2016-07-30_579cbdb24decb.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看