R: Function for raw IQFeed into structured tick? - Matlab, R project and Python | futures io social day trading

R: Function for raw IQFeed into structured tick?
 Updated: August 13th, 2015 (01:39 AM) Views / Replies: 515 / 2 Created: August 3rd, 2015 (02:07 PM) by wmbeam02 Attachments: 0

 Welcome to futures io.

# R: Function for raw IQFeed into structured tick?

 August 3rd, 2015, 02:07 PM #1 (permalink) Elite Member austin tx   Futures Experience: Master Platform: TS & IB Favorite Futures: futures     Posts: 2 since Jul 2015 Thanks: 1 given, 0 received R: Function for raw IQFeed into structured tick? I'm thru 15 pages (out of 39) of Big Mike's IQFeed/SQL/R/IBroker thread so I hope I'm not asking a question that has already been answered. I'm curious if anyone knows of a function that already exists that will take the raw tick data I have accumulating in SQL and sort it (example: 500 tick bar, with OHLC/Up Volume & Down Volume)? I know I can build this but I really hate the thought of doing that work if there is something elegant in quantstrat or financialInstruments already built. Update: Here's what I wrote to do what I was after. I've left out some logic but anyone who is serious about finding a solution to this problem and knows R should be able to easily fill in the missing blanks. This is the last time I will open up this forum so don't bother responding to me below or in PM: OHLC=function( tick.wanted=1500, raw.df=raw, tick.df=tick, ... ){ for (i in seq( tick.df[ 1, 7 ] : (nrow( raw.df )))) { if (( tick.df[ 1, 9 ] == 1 ) && ( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ] < tick.wanted ) && (( tick.df[ 1, 6 ] + sum ( raw.df[ tick.df[ 1, 7 ] : nrow( raw.df ), 3 ] )) > tick.wanted )) { tick.df[ tick.df[ 1, 8 ], 1 ] = raw.df[ tick.df[ 1, 7 ], 1 ] tick.df[ tick.df[ 1, 8 ], 2 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 3 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 4 ] = raw.df[ tick.df[ 1, 7 ], 2 ] raw.df[ tick.df[ 1, 7 ], 4 ]= 1 # Incrementing counts tick.df[ 1, 6 ] = ( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ] ) tick.df[ 1, 7 ] = tick.df[ 1, 7 ] + 1 tick.df[ 1, 9 ] = tick.df[ 1, 9 ] + 1 }else if (( tick.df[ 1, 9 ] == 1 ) && ( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ] == tick.wanted )){ tick.df[ tick.df[ 1, 8 ], 1 ] = raw.df[ tick.df[ 1, 7 ], 1 ] tick.df[ tick.df[ 1, 8 ], 2 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 3 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 4 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 5 ] = raw.df[ tick.df[ 1, 7 ], 2 ] raw.df[ tick.df[ 1, 7 ], 4 ]= 2 tick.df[ 1, 6 ] = 0 tick.df[ 1, 9 ] = 1 tick.df[ 1, 7 ] = tick.df[ 1, 7 ] + 1 tick.df[ 1, 8 ] = tick.df[ 1, 8 ] + 1 }else if (( tick.df[ 1, 9 ] == 1 ) && ( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ] > tick.wanted )){ x = floor((( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ]) - tick.wanted) / tick.wanted) y = ((( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ]) - tick.wanted) / tick.wanted)-x for ( u in (tick.df[ 1, 7 ] : (tick.df[ 1,7 ] + (x-1)))){ tick.df[ tick.df[ 1, 8 ], 1 ] = raw.df[ tick.df[ 1, 7 ], 1 ] tick.df[ tick.df[ 1, 8 ], 2 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 3 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 4 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 5 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ 1, 8 ] = tick.df[ 1, 8 ] + 1 tick.df[ 1, 9 ] = 1 } if ( y != 0 ){ tick.df[ tick.df[ 1, 8 ], 1 ] = raw.df[ tick.df[ 1, 7 ], 1 ] tick.df[ tick.df[ 1, 8 ], 2 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 3 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 4 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ 1, 9 ] = tick.df[ 1, 9 ] + 1 } raw.df[ tick.df[ 1, 7 ], 4 ]= 8 tick.df[ 1, 6 ] = (tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ]) - ( (x+1) * tick.wanted ) tick.df[ 1, 7 ] = tick.df[ 1, 7 ] + 1 }else if ( ( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ] ) < tick.wanted && (( tick.df[ 1, 6 ] + sum ( raw.df[ tick.df[ 1, 7 ] : nrow( raw.df ), 3 ] )) > tick.wanted )){ if ( tick.df[ tick.df[ 1, 8 ], 3 ] <= raw.df[ tick.df[ 1, 7 ], 2 ] ){ tick.df[ tick.df[ 1, 8 ], 3 ] = raw.df[ tick.df[ 1, 7 ], 2 ] } else if ( tick.df[ tick.df[ 1, 8 ], 4 ] >= raw.df[ tick.df[ 1, 7 ], 2 ] ){ tick.df[ tick.df[ 1, 8 ], 4 ] = raw.df[ tick.df[ 1, 7 ], 2 ] } raw.df[ tick.df[ 1, 7 ], 4 ]= 4 # Incrementing counts tick.df[ 1, 6 ] = ( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ] ) tick.df[ 1, 9 ] = tick.df[ 1, 9 ] + 1 tick.df[ 1, 7 ] = tick.df[ 1, 7 ] + 1 }else if(( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ] ) == tick.wanted ){ if ( tick.df[ tick.df[ 1, 8 ], 3 ] <= raw.df[ tick.df[ 1, 7 ], 2 ]){ tick.df[ tick.df[ 1, 8 ], 3 ] = raw.df[ tick.df[ 1, 7 ], 2 ] }else if( tick.df[ tick.df[ 1, 8 ], 4 ] >= raw.df[ tick.df[ 1, 7 ], 2 ] ){ tick.df[ tick.df[ 1, 8 ], 4 ] = raw.df[ tick.df[ 1, 7 ], 2 ] } raw.df[ tick.df[ 1, 7 ], 4 ]= 5 # Incrementing counts tick.df[ tick.df[ 1, 8 ], 5 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ 1, 6 ] = 0 tick.df[ 1, 7 ] = tick.df[ 1, 7 ] + 1 tick.df[ 1, 8 ] = tick.df[ 1, 8 ] + 1 tick.df[ 1, 9 ] = 1 }else if(( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ] ) > tick.wanted && (( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ]) - tick.wanted) < tick.wanted ) { if ( tick.df[ tick.df[ 1, 8 ], 3 ] <= raw.df[ tick.df[ 1, 7 ], 2 ]){ tick.df[ tick.df[ 1, 8 ], 3 ] = raw.df[ tick.df[ 1, 7 ], 2 ] }else if( tick.df[ tick.df[ 1, 8 ], 4 ] >= raw.df[ tick.df[ 1, 7 ], 2 ] ){ tick.df[ tick.df[ 1, 8 ], 4 ] = raw.df[ tick.df[ 1, 7 ], 2 ] } tick.df[ tick.df[ 1, 8 ], 5 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ 1, 6 ] = (( tick.df[ 1, 6 ] + raw.df[ tick.df[ 1, 7 ], 3 ]) - tick.wanted) tick.df[ 1, 8 ] = tick.df[ 1, 8 ] + 1 tick.df[ 1, 9 ] = tick.df[ 1, 9 ] + 1 tick.df[ tick.df[ 1, 8 ], 1 ] = raw.df[ tick.df[ 1, 7 ], 1 ] tick.df[ tick.df[ 1, 8 ], 2 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 3 ] = raw.df[ tick.df[ 1, 7 ], 2 ] tick.df[ tick.df[ 1, 8 ], 4 ] = raw.df[ tick.df[ 1, 7 ], 2 ] raw.df[ tick.df[ 1, 7 ], 4 ]= 6 tick.df[ 1, 7 ] = tick.df[ 1, 7 ] + 1 } return(tick.df) } Last edited by wmbeam02; August 27th, 2015 at 08:53 AM. Reason: Paying it forward

 August 3rd, 2015, 02:07 PM #2 (permalink) Quick Summary Quick Summary Post Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 August 13th, 2015, 01:39 AM #3 (permalink) Elite Member San Diego, CA   Futures Experience: Intermediate Platform: x_trader pro, Excel Broker/Data: Advantage Favorite Futures: CL     Posts: 47 since Sep 2009 Thanks: 24 given, 24 received I don't use R, but I think what you want is cut Binning is core in most time-series libraries. In Python use pandas, C# use deedle, javascript use d3/array

 futures io > R: Function for raw IQFeed into structured tick?

Upcoming Webinars and Events (4:30PM ET unless noted)

Elite only

Elite only

Jan 18

Jan 23

Elite only

Elite only

## Ran Aroussi: TBA

Elite only

 Similar Threads Thread Thread Starter Forum Replies Last Post Big Mike AmiBroker 29 May 9th, 2015 04:28 PM vampirelord AmiBroker 4 March 28th, 2014 01:23 PM Quick Summary News and Current Events 0 January 31st, 2013 08:40 AM kbit News and Current Events 0 May 17th, 2012 11:22 PM benharrell Reviews of Brokers and Data Feeds 36 June 11th, 2011 04:06 PM

All times are GMT -4. The time now is 06:44 PM.

 Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io All information is for educational use only and is not investment advice.There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-18 in 0.09 seconds with 19 queries on phoenix via your IP 54.221.93.187