Forum: help
Monitor Forum | Start New ThreadRE: osMaxPos - wrong size for SHORT positions - Is this a bug? [ Reply ] By: Joshua Ulrich on 2014-11-20 17:37 | [forum:41664] |
Fixed in revision 1654. |
RE: osMaxPos - wrong size for SHORT positions - Is this a bug? [ Reply ] By: Joshua Ulrich on 2014-11-18 03:43 | [forum:41652] osFUNs.R.patch (15) downloads |
It does look like a bug to me. I think the attached patch would fix it. |
RE: osMaxPos - wrong size for SHORT positions - Is this a bug? [ Reply ] By: Offer Markovich on 2014-11-06 14:32 | [forum:41640] |
To be clear, the problem can be seen with this line: > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=-5,ordertype="market", + orderside="short",ruletype="enter",portfolio=portfolio.st,symbol="SPY") MinPos 2009-01-30 -10 The return is -10 while it should be -5 Offer |
osMaxPos - wrong size for SHORT positions - Is this a bug? [ Reply ] By: Offer Markovich on 2014-11-06 07:35 | [forum:41617] osMaxPosTest.R (10) downloads |
Hi, osMaxPos should compare the requested number of units against the limits set with addPosLimit(). If the requested number is above the max units liit and below the minimum units limit it should return the limits. if not, it should return the requested amount. This is working well for long positions but not wrong for short positions. For short it always returns the limit. is this a BUG? addPosLimit(portfolio.st,symbol="SPY",timestamp=.from,maxpos=10,minpos=-10) > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=0,ordertype="market", + orderside="long",ruletype="enter",portfolio=portfolio.st,symbol="SPY") [1] 0 > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=5,ordertype="market", + orderside="long",ruletype="enter",portfolio=portfolio.st,symbol="SPY") [1] 5 > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=10,ordertype="market", + orderside="long",ruletype="enter",portfolio=portfolio.st,symbol="SPY") MaxPos 2009-01-30 10 > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=15,ordertype="market", + orderside="long",ruletype="enter",portfolio=portfolio.st,symbol="SPY") MaxPos 2009-01-30 10 > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=0,ordertype="market", + orderside="short",ruletype="enter",portfolio=portfolio.st,symbol="SPY") [1] 0 > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=-5,ordertype="market", + orderside="short",ruletype="enter",portfolio=portfolio.st,symbol="SPY") MinPos 2009-01-30 -10 > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=-10,ordertype="market", + orderside="short",ruletype="enter",portfolio=portfolio.st,symbol="SPY") MinPos 2009-01-30 -10 > osMaxPos(mktdata,timestamp=Sys.Date(),orderqty=-15,ordertype="market", + orderside="short",ruletype="enter",portfolio=portfolio.st,symbol="SPY") MinPos 2009-01-30 -10 |