金字塔的橫向統計功能 自定義數據橫向排名統計功能實現策略回測的方法和步驟[金字塔模型]
: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">金字塔的橫向統計功能是一個十分強大的功能,尤其是針對股票市場品種數據大的特點,更是在我們的量化交易統計過程中發揮巨大的優勢。舉例來說:: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">? 我們的策略實現如下功能:尋找漲幅排名在30名之前,并且MA均線處于金叉位置的股票,實現買進,出現死叉的持倉股票,賣出。: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">? 為了實現上述策略,我們要將策略分成2個部分來完成,第一要完成股票在市場當中的漲跌幅排名,第二就是要判斷是否金叉和死叉。: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">? 排名統計就需要借助橫向統計功能,先為我們統計出來個股在整個市場的漲跌幅排名情況。雖然我們可以在公式中自行完成統計工作,但是計算量是十分巨大的,這樣的公式編寫出來也幾乎是沒法正常使用的,幸好金字塔為我們提供了非常有價值的橫向統計自定義數據的功能,有了這個功能,再復雜的統計工作,我們都可以非常輕松的來完成,而且是效率非常高的。并且自定義數據不僅僅可以用來做統計,像類似跨周期數據引用這樣的工作,我們也都可以用他來幫我們完成,喜歡使用跨周期引用的朋友可以自定嘗試,使用自定義數據和你自己在公式中使用STKINDI他們的效率差別。好了言歸正傳,下面來介紹統計橫向排名的步驟:: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">??第一步,建立一個技術指標公式,用來統計漲跌幅,名稱為 Formula2,代碼為:: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">? 第二步,我們進行橫向排名統計,分析菜單->自定義數據,打開自定義數據窗口,本例中我們以日線數據做統計,: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">
: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">? 新建一個“證券相關序列”,名稱為“漲幅排”的自定義數據序列,選擇我們前面建立的公式指標,統計周期選擇日線,如果你除了測評外還需要盤中做后臺程序化交易,那么你還需要勾選“自動更新”這個選項,這里的重點選項是需要你勾選“生成橫向排名數據”,只有你勾選了這個選項后,才可以對漲跌幅這個數據做排名的哦。最后確認你的計算范圍,要選擇對“上海A股”整個市場板塊進行統計。: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">? 設置完畢后,我們需要點“刷新”按鈕進行刷新,: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">? 這里重點提醒的是,如果你需要測評,那么你應該選擇刷新指定數量的數據,如果你是做實盤程序化使用,那么這個數量應該盡可能設小,以加快橫向統計的處理速度。: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">??刷新完畢后,我們可以人工打開一個品種看一下刷新的數據是否正確,比如我們以浦發銀行為例:: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">
: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?接下來最后一步就是進行程序化交易測評的公式編寫部分了,按照上述的要求編寫的程序化交易的代碼如下:: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?這里重點介紹的函數SELFDATA,用這個函數可以直接讀取我們之前設定的自定義數據。用法非常簡單,我想通過上述的代碼用戶應該不難理解他的使用。: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?上述代碼編寫完畢后,我們就可以進行我們的測試工作啦,下面是測試報告。: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">==========================================================================: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">有關自定義數據的屬性類型的說明:: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">?: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">
: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">
: none; color: rgb(85,85,85); font-style: normal; widows: 1; letter-spacing: normal; line-height: 18px; background-color: rgb(246,249,251); text-indent: 0px; -webkit-text-stroke-width: 0px">
橫向統計序列:將所有的品種進行統計,統計結果擬合到一個結果中,例如我們可以統計滬深A股的上漲,下跌家數,以及指標值的累加,例如統計滬深A股出現MA均線金叉的家數等等。
?
{別忘了將本網告訴您身邊的朋友,向朋友傳達有用資料,也是一種人情,你朋友會感謝你的。}
?
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 511411198 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容