0

I have a vector vv containing market volume data for each tick, and a vector minuteIdx containing an index for different minutes. I'm using accumarray to sum the volume within each minute, like this:

orgMinuteVolumes = accumarray(minuteIdx, vv); %default function is @sum  
notrades = orgMinuteVolumes == 0;   
minuteVolumes = orgMinuteVolumes;
minuteVolumes(notrades) = []; 

Usually it works perfectly, but occasionally volume data could not be obtained for all the ticks in a minute, and there are 0s in the volume vector. This results in the minuteVolumes vector being shorter than it would be otherwise since I got rid of all the zeros. For example if vv begins with a 1 (and there is only one tick in the first minute), then minuteVolumes is 175 long, but if I change vv to begin with a 0 then minuteVolumes is only 174 long. I want a 0 to appear in my minuteVolumes vector, not to make it shorter. Is there a smart way to make this happen? My original logic was that for a trade to occur volume had to be nonzero, but I didn't take into account occasional bad data.

OmG
  • 18,337
  • 10
  • 57
  • 90
siegel
  • 819
  • 2
  • 12
  • 24
  • 2
    This is confusing. orgMinuteVolumes is, your example, 175 long, with a zero in the first element. Then you have code specifically written to delete all your zero elements. Now you're asking that the zeros not be deleted. So... don't delete them. Or there's more to your code/question that's not explicitly stated. – Peter Jun 28 '13 at 17:42
  • @Peter, my thoughts exactly, except I wasn't confident enough to ask. siegel, seems like you're a bit of a "Quant" is that your full time job? – macduff Jun 28 '13 at 17:54
  • Sorry for the poorly thought out question, I'm going to work on this more and maybe ask another later. And no, I'm just working on this project as a hobby. I'm in college – siegel Jun 28 '13 at 18:01

0 Answers0