<h2>数量序幕:</h2>
<blockquote>
<p><a href="http://wiki.quantsoftware.org/index.php?title=QuantSoftware_ToolKit#Contributors" rel="nofollow noreferrer">Many thanks to <strong>prof. Tucker BALCH</strong>, GA-TECH [GA], and his team, for <strong><code>QSTK</code></strong>-initiative</a> and the innovative approaches to Quantitative Finance Modelling.
<a href="https://i.stack.imgur.com/6u5xh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6u5xh.png" alt="enter image description here"/></a></p>
<h2>How the <code>eventprofiler</code> takes in data?</h2>
</blockquote>
<p>简单地说,它在^{<cd2><strong><code>feed</code></strong>中接收对完整<strong><code>feed</code></strong><code>, ... )</code>的访问,同时也是一个<code>eventprofiler.Predicate</code>-wrapped<strong><code>feed</code></strong>实例的访问权,其中通过一个类参数将所有提要的详细信息直接访问<strong><code>.Predicate</code></strong>实例中,从而能够计算出实现策略演算所需的所有细节。聪明,不是吗?</strong></p>
<p>其余的是通过重用它们的类方法来完成的。在</p>
<hr/>
<h2>如何建立自己的?在</h2>
<p>声明一个适当配置的<strong><code>eventprofiler.Predicate</code></strong>就足够了,它将被注入到<code>evenprofiler</code>实例化中:</p>
<pre><code>class DavidsSTRATEGY( eventprofiler.Predicate ):
def __init__( self, feed ): # mandatory .__init__
""" no need for this code
left here for didactic
purposes only
to show the principle
self.__returns = {} # CLASS ATTR
for inst in feed.getRegisteredInstruments():
priceDS = feed[inst].getAdjCloseDataSeries() # STORE: priceDS ( a temporary representation )
self.__returns[inst] = roc.RateOfChange( priceDS, 1 ) # CALC: ATTR <- Returns over the adjusted close values, consumed priceDS ( could be expressed as self.__returns[inst] = roc.RateOfChange( ( feed[inst].getAdjCloseDataSeries() ), 1 ), but would be less readable
"""
def eventOccurred( self, instrument, aBarDS ): # mandatory .eventOccured
if ( aBarDS[-1].getVolume() > 1000 # "last" Bar's Volume >
and aBarDS[-1].getClose() < 50 # "last" Bar's Close <
):
return True
else:
return False
</code></pre>
<p>剩下的事情将一如既往地简单:</p>
^{pr2}$
<hr/>
<h2>定量结语:</h2>
<p>一位细心的读者注意到,建议的代码没有调用<code>.getAdjClose()</code>方法。理由是,深度回溯测试可能会被非常接近的调整所扭曲,在调整尚未可知的情况下做出决策。每一个专业的定量分析师都有责任避免任何窥视未来的手段,并仔细决定在需要调整的地方,就投资组合估值而言,一个工具持有时间是否在其各自的生命周期内经历了调整。在</p>