Profile Picture

Tomorrow prices

Posted By mokka 3 Years Ago
Message
Posted Saturday July 19 2014
Hi all,
I know RE doesn't permit looking into the future and consequently tomorrow price data are never available. But is there no way to overcome such a limit, if I'd need to access tomorrow high and low intentionally ? I'd like to simulate a bad fill, for example, as buy at tomorrow low or something else like this, you have the idea ... Is it possible ?

Thank you in advance.

Edited: Monday July 21 2014 by mokka
Posted Wednesday July 23 2014
no ideas ?
Posted Wednesday July 23 2014
In a paper broker implementation (see SlippagePaperTrader in the forums), you can override SimTick and determine if the tick is a Open, High, Low, Close for that bar based on the time of the tick. Then use this information in ShouldFill.

Does the above work?

Duane
Posted Wednesday July 23 2014
Thank you Duane.
I'll do as you suggested: I'm testing RE and PaperBroker is absolutely new to me. It's seems not a trivial task, anyway. I found the topic you mention and I wonder if nothing is changed since 2008. What I'm trying to accomplish is a classic backtesting using an hystorical price data series. I'd like to access tomorrow bar to simulate different fills: I see a lot of sense in such a possibility, while I really appreciate RE philosophy in not allowing to move toward future. What I mentioned is the only really useful exception that I could think of and I'd hope RE provides a simpler approach to such simulation...

Thank you
Posted Thursday July 24 2014
I used to be of the same mindset when I first started using RightEdge but I now am firmly in the camp of not peeking at future data. You should be able to create a derived paper trader with all the functionality you need.

Not a lot has changed since the 2008 version regarding the paper trader (although method signatures may have changed - a straightforward change to any code in the 2008 version); however, Daniel did create functionality to handle partial fills in the paper broker and a partial fill paper trader which works great. See http://www.rightedgesystems.com/forums/Topic12604-11-1.aspx?Highlight=paper+trader+fillsize

Duane
Posted Tuesday July 29 2014
Duane,
I was able to determine the Low via tick.time in a overrided SimTick, but this one is not the tomorrow price, when the order is filled. It's today price, when the signal is triggered: at this time, SimTick is called several times and, in the end, all prices (Open, Low, High, Close) are visible, but just before the ShouldFilled call, SimTick registers only the Open and is not possible to pass anything else to ShouldFilled. Or is there anything to add ?

Thanks
Posted Wednesday July 30 2014
In SimTick try setting a private variable, e.g., _tickType, of type TickFromBarType based upon the time of the tick. For example:

int timeRemainder;
Math.DivRem(tick.time.Minute, 5, out timeRemainder);

Then use remainder to determine and set _tickType to either O, H, L, or C. The above is for 5 minute bars.

In ShouldFill, only fill when _tickType == TickFromBarType.Low to fill only on the low of the bar.

Duane

Edited: Wednesday July 30 2014 by alpha23
Posted Wednesday July 30 2014
When tickType == tickType.LowPrice is tested and return False, a new position is opened anyway with Open as fillPrice. So I've setted fillPrice = 0, but again a new position appears with 0 as entry price ! When the test is passed, following your logic, I was able to set only the previous Low as fill price. As I said, ShouldFill is called just one single time, so I see no way to pass the Low of the entry day. My guess was, if an order is not filled then ShouldFill is recalled to check if conditions are changed in the meantime, but it isn't so, IMHO. I'm not so clear about how bars and ticks are processed in RE ...

BTW, I'm just backtesting a simple Crossover system on daily bars. No live system at all.

Edited: Wednesday July 30 2014 by mokka
Posted Wednesday July 30 2014
Just out of curiosity, are the following 2 lines in your System.Startup?

SystemData.EnableTradeOnClose = true;
SystemData.CreateTicksFromBars = true;

The first is not specifically need in your case but can be used with the BarClosing method (see separate discussions in forums).

ShouldFill should be triggered every tick if CreateTicksFromBars is set to true. ShouldFill is not recalled to my knowledge although a position may remain outstanding if it is a limit order.

Which raises another question regarding your system: are the orders market orders? If yes, the order will be opened on the next bar open if CreateTicksFromBars = false or the next tick if CreateTicksFromBars = true (or if you are simulating with tick data). While I have not tested this, one option may be either use limit orders or to change the order type in ShouldFill to a limit order and then fill when _tickType == TickFromBarType.Low.

Let me know what results you get.

Just out of curiosity, would it be easier to simulate a bad fill using a percent slippage rather than the low of the bar?
Posted Thursday July 31 2014
dwebber (7/30/2014)
Just out of curiosity, are the following 2 lines in your System.Startup?

SystemData.EnableTradeOnClose = true;
SystemData.CreateTicksFromBars = true;

The first is not specifically need in your case but can be used with the BarClosing method (see separate discussions in forums).

ShouldFill should be triggered every tick if CreateTicksFromBars is set to true. ShouldFill is not recalled to my knowledge although a position may remain outstanding if it is a limit order.

Which raises another question regarding your system: are the orders market orders? If yes, the order will be opened on the next bar open if CreateTicksFromBars = false or the next tick if CreateTicksFromBars = true (or if you are simulating with tick data). While I have not tested this, one option may be either use limit orders or to change the order type in ShouldFill to a limit order and then fill when _tickType == TickFromBarType.Low.

Let me know what results you get.


Duane, I've tried a lot, changing OrderType, FillPrice, ..., but I've found no way to 'force' ShouldFill to loop through the O,L,H,C of the entry day. While it's not difficult to set an entry price overriding NewTick in paperbroker, ShouldFill executes a test one time, so _tickType == TickFromBarType.Low has no effect.


Just out of curiosity, would it be easier to simulate a bad fill using a percent slippage rather than the low of the bar?


This is the core of what I'd like to accomplish: backtesting an EOD system with orders filled the next day, I'm looking for the opportunity to set whatever price I prefer. I want to be free to simulate an entry at tomorrow low, at a midprice between Open and High, ... ok, you have the idea. Using slippage is easier, but it's not enough. The logic would be to compute a price from O,L,H,C ticks and pass it to ShoudFill. I fully understand it's not consistent in a live system, but my interest in RE is for its backtesting capabilities and I'd like to feel reasonably free to test whatever I want.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems