SmartQuant Discussion Forum Index SmartQuant Discussion
Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question about BarSeries Class Compress Method

 
Post new topic   Reply to topic    SmartQuant Discussion Forum Index -> Strategy Programming (.NET, C# and other Languages)
View previous topic :: View next topic  
Author Message
Dytiscus



Joined: 23 Jul 2004
Posts: 76
Location: Odessa, Florida

PostPosted: Fri Jul 16, 2010 4:55 pm    Post subject: Question about BarSeries Class Compress Method Reply with quote

What exactly does the compress method do? In C# it has the prototype
Code:

public BarSeries Compress(
   long newBarSize
)


It is obvious to me that it will compress an existing BarSeries into another and return another compressed version of the original BarSeries, but the documentation is not clear.
Does:
Code:

BarSeries B;
// Put some code to populate B with 1 minute bars
// Then
BarSeries compressedSeries = B.Compress(17);


Does this mean that compressedSeries is now a version of B but with 17 minute bars or does it simply take every 17 bars of B and compresses them into a single Bar? One might think those two approaches are the same, but if you use some strange compression parameter (like 17 in the above example) does the compression stop with the last bar of the day or does it straddle days and makes a bar with (say 7) 1 minute bars from the previous day and a few (say 10) 1 minute bars from the current day?
I would like to think that this simply creates N minute bars from 1 minute bar series, or N minute bars from K minute bars where N is an integer multiple of K. As in make 60 minute bars from 10 minutes bars or from 20 minute bars, but not from 17 minute bars.
Any feedback?

P.S. Here is a suggestion.
I am not the only one to think that the documentation is sorely lacking. Perhaps, if someone can answer my question (or any other question about classes and methods) it could be done in such a way that the answer could be inserted in the documentation. In this way, over time, the documentation would be filled and completed in an organic way, meaning that those topics with the most relevance would be the one documented the quickest.
Just a thought
Back to top
View user's profile Send private message Send e-mail
Baraz Sergey



Joined: 08 Oct 2003
Posts: 405

PostPosted: Thu Aug 05, 2010 4:03 pm    Post subject: Reply with quote

Hi,

Quote:
I would like to think that this simply creates N minute bars from 1 minute bar series, or N minute bars from K minute bars where N is an integer multiple of K. As in make 60 minute bars from 10 minutes bars or from 20 minute bars, but not from 17 minute bars.
Any feedback?


Yes, it is exactly what it does, it is possible to create N minute bars from K minute bars where N is an integer multiple of K.

As to the question regarding compression of 1 min bar series to 17 min bars - it takes the begin time of the very first bar in the base series, let's call this time BT and then costructs time intervals like:
[BT + 17 * 0, BT + 17 * 1]
[BT + 17 * 1, BT + 17 * 2]
..
[BT + 17 * (X - 1), BT + 17 * X]

until the BT + 17 * X becomes greater then the last bar datetime from the vase series. Each interval defines a bar in the result compressed series.

So yes, it is possible that the 17 min bar series which were compressed from the 1 min bars contains several bars from one day and several from another.

Please note that if you want to compress your bars to a daily series - just set the newBarSize parameter to 86400 and it will create a "correct" bar series, it doesn't not use the algorithm described above (BT is the beginning of the day of the first bar in this case). The same for Weekly, Monthly and Annual bars.

Regards,
Sergey.
Back to top
View user's profile Send private message
Dytiscus



Joined: 23 Jul 2004
Posts: 76
Location: Odessa, Florida

PostPosted: Sun Aug 08, 2010 7:36 pm    Post subject: Information on Compress method Reply with quote

Thank you very much Sergey. This answers my question very nicely.
Now, back the suggestion I made in my original question. Why not take your reply and put it in the documentation for the compress method? What you have is very informative and definitely much better than what currently exists in the documentation, namely, nothing.
I would like that a simple cut and paste would do the job. Also, if your answer is as satisfying to others as it is to me, there should be no more questions about the topic. And if there should still be a question, you could simply send them to the documentation with a link. Using this method, the documentation should fill itself up very nicely, with the more important topics being answered first.

Regards,
Henrick
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    SmartQuant Discussion Forum Index -> Strategy Programming (.NET, C# and other Languages) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group