我要设置的订单大小不是以绝对值(以手或美元为单位),而是以百分比。例如。我将定单大小设置为<-0.3,然后将必要的手数计算为当前权益的30%。我应该使用osMaxPos / osMaxDollar还是以某种方式编写自定义大小调整函数?
add.rule(
strategy.st, name = 'ruleSignal',
label = 'EnterLONG', type = 'enter',
arguments = list(
sigcol = signal$long$enter$label, sigval = TRUE,
replace = TRUE, orderset = 'ocolong', orderqty = 1,
ordertype = 'market', orderside = 'long'
)
)
add.rule(
strategy.st, name = 'ruleSignal',
label = 'ExitLONG', type = 'exit',
arguments = list(
sigcol = signal$long$exit$label, sigval = TRUE,
replace = TRUE, orderset = 'ocolong', orderqty = 'all',
ordertype = 'market', orderside = 'long'
)
)
答案 0 :(得分:2)
对于那些像我一样兴奋的人,这是一个解决方案:
我在创建自定义订单大小调整功能here方面找到了一个完美的开端,Tim Trice在Ilya Kipnis的博客中引用了comments section。我还发现,需要更新投资组合以获取Joshua Ulrich's answer中的实际权益。
[username@machine build]$ python
Python 2.7.12 (default, Feb 22 2017, 20:16:44)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.version)
2.7.12 (default, Feb 22 2017, 20:16:44)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy