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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 布林帶回調系統-日內 > 來源:https://uqer.io/community/share/566929a4f9f06c6c8a91b6e6 ```py import numpy as np import pandas as pd from pandas import DataFrame start = '2014-01-01' # 回測起始時間 end = '2015-01-01' # 回測結束時間 benchmark = 'HS300' # 策略參考標準 universe = set_universe('HS300') # 證券池,支持股票和基金 capital_base = 100000 # 起始資金 freq = 'm' # 策略類型,'d'表示日間策略使用日線回測,'m'表示日內策略使用分鐘線回測 refresh_rate = 239 # 調倉頻率,表示執行handle_data的時間間隔,若freq = 'd'時間間隔的單位為交易日,若freq = 'm'時間間隔為分鐘 period = 10 multiple=1.5 threshold=-0.1 boll=pd.DataFrame(index=universe,columns = ['mean_cp','high_channel','low_channel']) def initialize(account): # 初始化虛擬賬戶狀態 pass def handle_data(account): # 每個交易日的買入賣出指令 if(account.current_minute=='09:30'): close_prices = account.get_daily_attribute_history('closePrice', period) for s in account.universe: mean_cp = close_prices[s].mean() bias = multiple*np.std(close_prices[s]) high_channel = mean_cp + bias low_channel = mean_cp - bias boll.at[s,'high_channel']=high_channel boll.at[s,'low_channel']=low_channel boll.at[s,'mean_cp']=mean_cp elif(account.current_minute=='14:50'): print account.current_date,",",account.valid_secpos else: for s in account.valid_secpos: #清倉 if account.referencePrice[s]>=boll.at[s,'mean_cp'] : order_to(s, 0) buylist=[] c = account.referencePortfolioValue for s in account.universe: if ((account.referencePrice[s]-boll.at[s,'low_channel'])/boll.at[s,'low_channel'])<=threshold: buylist.append(s) if (len(buylist)==0): return else: w=min(0.2,1.0/len(buylist))# 最大倉位1/5 for s in buylist: p=account.referencePrice[s]*1.01 num=int(c * w / p) order(s, num) ```
                  <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>

                              哎呀哎呀视频在线观看