<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 5.7 5217 策略 · 白龍馬的新手策略 > 來源:https://uqer.io/community/share/56458dbcf9f06c4446b480ec + 買入信號 :價格創出60個交易日新高,第二天買入 + 賣出信號 :價格從最高點下跌17%,則第二天賣出 + 賣出金額平均分配到新高的股價上 ```py import numpy as np from datetime import datetime, timedelta start = '20120101' # 回測起始時間 end = (datetime.today() - timedelta(days=1)).strftime('%Y%m%d') # 截止日期 benchmark = 'HS300' # 策略參考標準 universe = set_universe('HS300') capital_base = 1000000 # 起始資金 freq = 'd' # 策略類型,'d'表示日間策略使用日線回測,'m'表示日內策略使用分鐘線回測 refresh_rate = 1 # 調倉頻率,表示執行handle_data的時間間隔,若freq = 'd'時間間隔的單位為交易日,若freq = 'm'時間間隔為分鐘 MAX_PRICE = {} def initialize(account): # 初始化虛擬賬戶狀態 pass def handle_data(account): # 每個交易日的買入賣出指令 today = account.current_date.strftime('%Y%m%d') hist = account.get_attribute_history('closePrice' , 60) cash = account.cash buylist = [] #記錄持倉股票的最高價(賣出判斷指標) for s in account.valid_secpos : MAX_PRICE[s] = max(MAX_PRICE[s],np.max(hist[s])) # 備選買入股票,已經在股票池的股票不再重復購買,創60日新高則入選購買 option = [x for x in account.universe if x not in account.valid_secpos] for s in option : if np.max(hist[s]) == hist[s][-1] : buylist.append(s) MAX_PRICE[s] = hist[s][-1] # 從最高點下跌17%,賣出 for s in account.valid_secpos : if hist[s][-1] <= MAX_PRICE[s] * (1 - 0.17) : cash += hist[s][-1] * account.valid_secpos.get(s) order_to(s , 0) # 最高價清零 MAX_PRICE[s] = 0 # 買入 for s in buylist : order( s, cash / len(buylist) / hist[s][-1] ) ``` ![](https://box.kancloud.cn/2016-07-30_579cbdace4485.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>

                              哎呀哎呀视频在线观看