Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8569441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:20:06+00:00 2026-06-11T18:20:06+00:00

I have some financial data that I am processing in C++. I am storing

  • 0

I have some financial data that I am processing in C++. I am storing it in a simple binary format because it requires fewer resources and is fast, however I would like to add compression to the file. I am guessing I will be IO bound so the compression won’t cost me much in terms of processing speed.

I have no idea how to do the compression, as I am an academic and not a real programmer. I could really use some hand holding on this one.

I have my data in a structure like this:

  struct TradesBin {
    int ttim;
    int prc;
    int siz;
    short int g127;
    short int corr;
    char cond[2];
    char ex[1];
}__attribute__((packed));

Which I can write to a binary file as follows:

ofstream fout(outfile.c_str(), ios::out | ios::binary);
fout.write((char *) &tbin, sizeof(TradesBin));

Where tbin is filled with TradesBin data.

How do I now add compression to these files? I have heard only vaguely of things like ZLO, Bzip2, zlib, and Boost.IOStreams. I much appreciate your guidance and suggestions!

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:20:07+00:00Added an answer on June 11, 2026 at 6:20 pm

    Zlib allows you to do this, but it is provides only a plain C interface. In a nutshell, you do

    gzFile fp = gzopen(fname.c_str(),"wb");
    gzwrite(fp, (void*) (&vec[0]), sizeof(TradesBin)*nelem);
    gzclose(fp);
    

    where vec would be for example a std::vector<TradesBin> for your TradesBin structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some financial data gathered at a List[(Int, Double)], like this: val snp
i have to build some financial data report, and for making the calculation, there
I've got some financial data to store and manipulate. Let's say I have 2
I have some arbitrary pixel data that I want to save as a PNG.
I have a (C#) genetic program that uses financial time-series data and it's currently
I have written a chart that displays financial data. Performance was good while I
I have been testing out pandas and pytables for some large financial data sets,
i have written a program to clean some financial data i have collected over
I'm trying to read some CSV-format financial tick data (source: HISTDATA_COM_ASCII_EURUSD_T_201209.zip ) into a
We have an application that works with financial data that is schemaless. More accurately,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.