[R-SIG-Finance] Luxor strategy (quantstrat) - Why are successive short (and long) trades happening ?

Pablo Rios pablo.javier.rios at gmail.com
Tue May 6 19:58:37 CEST 2014


Hi R/Finance community, blotter/quantstrat developers,

I'm running the Luxor basic strategy available in the quantstrat package
(file demo\luxor.1.strategy.basic.R) with its demo data (.rda files in
extdata\GBPUSD), and I don't understand why are successive short trades
occurring. This is making the position quantity going above +100,000 (or
below -100,000). Is this the expected behaviour of this strategy ? Isn't it
supposed to alternate between long and short trades of .orderqty = 100000
each (i.e., enter long, leave long, enter short, leave short, ...) ?

I'm attaching an screenshot of the well-known three panels chart from
blotter (output of chart.Posn() function) to quickly visualize this
situation, and a .csv file for the order book, per trade stats, market
data, transactions table and P&L values.

I'm running this example with revision 1608 of the source repository (svn://
svn.r-forge.r-project.org/svnroot/blotter), but I observed exactly the same
behaviour with previous versions of blotter/quantstrat code, though with
different time period of the GBP/USD forex data.

Furthermore, with revision 1608 I started to see the following warning
messages never seen before:

> applyStrategy(strategy.st, portfolio.st)
Warning: stack imbalance in 'lapply', 14 then 15
[1] "2002-10-22 02:00:00 GBPUSD 1e+05 @ 1.5447"
Warning: stack imbalance in 'lapply', 18 then 19
[1] "2002-10-22 17:30:00 GBPUSD -1e+05 @ 1.5435"
[1] "2002-10-22 17:30:00 GBPUSD -1e+05 @ 1.5447"
Warning: stack imbalance in 'lapply', 20 then 21
[1] "2002-10-23 03:00:00 GBPUSD 1e+05 @ 1.5486"
[1] "2002-10-23 03:00:00 GBPUSD 1e+05 @ 1.5492"
Warning: stack imbalance in 'lapply', 22 then 23
[1] "2002-10-23 17:30:00 GBPUSD -1e+05 @ 1.5468"
Warning: stack imbalance in 'lapply', 24 then 26
Warning: stack imbalance in 'lapply', 28 then 31
[1] "2002-10-24 02:00:00 GBPUSD -1e+05 @ 1.5463"
[1] "2002-10-24 03:00:00 GBPUSD -1e+05 @ 1.5459"
Warning: stack imbalance in 'lapply', 34 then 35
[1] "2002-10-24 11:30:00 GBPUSD 2e+05 @ 1.5484"
[1] "2002-10-24 12:00:00 GBPUSD 1e+05 @ 1.5493"
Warning: stack imbalance in 'lapply', 37 then 38
[1] "2002-10-25 04:00:00 GBPUSD -1e+05 @ 1.553"
[1] "2002-10-25 04:00:00 GBPUSD -1e+05 @ 1.553"
Warning: stack imbalance in 'lapply', 39 then 40
[1] "2002-10-25 12:00:00 GBPUSD 1e+05 @ 1.5513"
Warning: stack imbalance in 'lapply', 40 then 42
[1] "2002-10-27 23:30:00 GBPUSD -1e+05 @ 1.5475"
[1] "2002-10-28 09:30:00 GBPUSD 1e+05 @ 1.5533"
Warning: stack imbalance in 'lapply', 46 then 47
[1] "2002-10-28 10:30:00 GBPUSD 1e+05 @ 1.555"
Warning: stack imbalance in 'lapply', 49 then 50
[1] "2002-10-29 00:00:00 GBPUSD -1e+05 @ 1.5583"
Warning: stack imbalance in 'lapply', 51 then 53
Warning: stack imbalance in 'lapply', 54 then 57
[1] "2002-10-29 07:30:00 GBPUSD -1e+05 @ 1.5572"
[1] "2002-10-29 07:30:00 GBPUSD -1e+05 @ 1.5572"
[1] "2002-10-29 09:30:00 GBPUSD 1e+05 @ 1.5594"
Warning: stack imbalance in 'lapply', 60 then 61
[1] "2002-10-30 05:30:00 GBPUSD 1e+05 @ 1.5568"
[1] "2002-10-30 09:30:00 GBPUSD 1e+05 @ 1.5578"
Warning: stack imbalance in 'lapply', 63 then 64
[1] "2002-10-30 11:30:00 GBPUSD -1e+05 @ 1.5568"
Warning: stack imbalance in 'lapply', 65 then 67
[1] "2002-10-30 13:00:00 GBPUSD 1e+05 @ 1.5579"
[1] "2002-10-30 19:00:00 GBPUSD -1e+05 @ 1.5558"

Thank you
Pablo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20140506/6b0e2f00/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: defect.in.blotter.png
Type: image/png
Size: 47442 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20140506/6b0e2f00/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mktdata.csv
Type: text/csv
Size: 31910 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20140506/6b0e2f00/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pertradestats.csv
Type: text/csv
Size: 1557 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20140506/6b0e2f00/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orderbook.csv
Type: text/csv
Size: 3333 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20140506/6b0e2f00/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: posPL.csv
Type: text/csv
Size: 23393 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20140506/6b0e2f00/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: txn.csv
Type: text/csv
Size: 2228 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20140506/6b0e2f00/attachment-0004.bin>


More information about the R-SIG-Finance mailing list