Profile Picture

Pairs Trading

Posted By smersh 8 Years Ago
Message
Posted Friday September 30 2011
I think i have it now. Moved it. Will reply back with details when I am sure its working in case it can help others.
Posted Friday September 30 2011
I eat my words. I was thinking I could just create the hedge right after i create the position...but it as to be done after a position is created othewise it will open the hedge for every theoretical signal, even if the limit doesn't get hit.

However, putting the is in on Filled causes it to put the hedge on 1 day too late.

Basically I need a way for on Filled to put the hedge on, on the same bar.

Thoughts?
Posted Friday September 30 2011
Right, there isn't any way to force something to happen on the same bar without some finer granularity of data. You could break bars into (4) ticks, but that still doesn't guarantee proper order of execution. The only way to get it close to live is to have tick data or perhaps 1 minute bars. Then you could have a multi frequency system. Is getting your hands on that data a possibility?
Posted Saturday October 01 2011
Yes, I can pull 1 min bars no problem. However, I've found 2 issues in doing it this way.
1) When I convert 1mins to Daily Bars. The HLOC values are way off.
I have suspected the issue to be that Daily bars use the date to aggregate and create the bar. This mean that if a ticker trades pre/post market and we have a 1 min bar for that trade...it throws off the Daily Bar, so they don;t match what is normally considered a daily Bar.
I really need a way to say. Only create HLOC for daily using trades when market is open.

2) Have not been able to figure out how to create an indicator using the Custom bars. That is If I use 1 mins to generate a daily. And I want to create RSI 14 using the close of the Daily Bar...how is that done?
Posted Saturday October 01 2011
Bill,
It would be nice to have a way to tell the frequency object to only create bars using marketHours.
That is instead of using the 12:00AM to 11:59PM trades...only use 9:30 to 4:00PM. This way the daily bars match up with Yahoo.
The 12am to 1159pm bar is worthless especially since you will unlikely find a gap on the daily anymore (at least not an accurate one)

Having this ability to create daily from 1min market hours would take my backtesting to another level.
FYI...I use IQfeed to pulll my 1 min bars.


Next:
Because I really don't want to wait for the next release if you agree with the above....can I use the example here to create both my daily bars and to create an indicator off my custom daily bar? Do you think that would work?

http://www.rightedgesystems.com/forums/Topic6392-7-2.aspx?Highlight=DailyBars

Posted Monday October 03 2011
OK, I understand the problem now. You're effectively getting all of the one minute bars for the entire day, which is not going to match the daily bars constructed by something like Yahoo that only takes the prints during market hours. Some ideas that come to mind might be to derive from the IQFeed plugin and discard the 1 minute bars that fall outside of the desired hours. If you're using a database store, it might be a simple delete statement to remove these bars from the store. Finally, you could create a custom data store plugin that only returns the data you require. Again, deriving from an existing plugin instead of reinventing the wheel.

I'm not sure I understand the last part about creating a custom indicator from the daily bar and custom daily bar. Aren't you trying to make the daily bars match? Or do you still have a use for daily bars that are constructed from the 1min bars that which print outside of market hours?

gregoryj (10/1/2011)
Bill,
It would be nice to have a way to tell the frequency object to only create bars using marketHours.
That is instead of using the 12:00AM to 11:59PM trades...only use 9:30 to 4:00PM. This way the daily bars match up with Yahoo.
The 12am to 1159pm bar is worthless especially since you will unlikely find a gap on the daily anymore (at least not an accurate one)

Having this ability to create daily from 1min market hours would take my backtesting to another level.
FYI...I use IQfeed to pulll my 1 min bars.


Next:
Because I really don't want to wait for the next release if you agree with the above....can I use the example here to create both my daily bars and to create an indicator off my custom daily bar? Do you think that would work?

http://www.rightedgesystems.com/forums/Topic6392-7-2.aspx?Highlight=DailyBars

Posted Tuesday October 04 2011
I'm not sure I like the approach of removing my 1 min bars. There are some things I will do in the post market so doing it that way I will no longer have data.
Couldn't we have a property for the frequency object that will ignore prints outside of market hours. That seems like the most flexible approach.

To make it even more flexible, you could set a start and end timespan and the frequency object will only add to a bar if it falls inside the start and end timespan.

Would it be possible for me to extend Frequency to do this or would it require a source code change?
Posted Wednesday October 05 2011
Frequencies are also plugins, so you could take the existing TimeFrequency class and extend it with your own code. However, the FrequencyPlugin class does not really have the ability to discard data. The only thing I can think of is to perhaps modify the time stamp of incoming ticks to be within trading hours. This has the potential downside of duplicate ticks and doesn't really discard anything so the price bars will remain the same.

But I like the setting idea, but maybe it gets carried conceptually to a data store plugin or a the data provider instead? That way you don't lose any data, but the data that's played back is potentially different based on the asking frequency?
Posted Wednesday October 05 2011
Actually, you can discard data in custom frequency plugins if you like. Attached is code for a frequency plugin which should do what you want: create daily bars but only use data from within a time of day range you can specify. I haven't tested it at all yet so their might be bugs-- either in the plugin or in RightEdge where it might not expect data to be discarded or something.

EDIT: To use an indicator with a custom frequency, call SystemData.IndicatorManager.SetFrequency. For more details, see the "Multiple Frequencies" section of the documentation here.

Thanks,
Daniel

Attachments
FilteredDailyFrequency.cs (279 views, 4.00 KB)
Posted Thursday October 06 2011
After testing this, it turns out that discarding some of the data breaks an assumption that RightEdge makes and you will get an exception that says "Partial bar should have been generated after processing time update tick."

I'll see if I can fix this.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems