curl_stocks
Loading...
Searching...
No Matches
plot.h
Go to the documentation of this file.
1
8#ifndef PLOT_H
9#define PLOT_H
10
11#include <string> // for string
12#include <vector> // for vector
13
14#include "gnuplot-iostream.h" // for Gnuplot
15
19enum class Plot_type;
20
24class Plot
25{
26private:
27 std::vector<std::string>
28 file_names;
29 std::string function;
30 static std::string csv_column_name;
31 static int csv_column;
32 static float time_in_weeks;
34public:
38 Plot();
45 Plot(std::string s, float time);
46
52 static float get_time_in_weeks();
53
57 void display() const;
63 void display(std::string const &s) const;
64
70 void setup_gnuplot(Gnuplot &g) const;
77 void process_data(std::string &s) const;
86 void get_first_datapoint(Gnuplot &g, std::string const &file_name) const;
96 void percentage_plot(Gnuplot &g,
97 std::string const &file_name,
98 const Plot_type type) const;
104 void set_function(std::string const &function);
105
113 void create_temp_file(std::string const &data, std::string const &file_name);
117 void cleanup() const;
118
122 ~Plot();
123};
124
125#endif /* ifndef PLOT_H */
126/* @}*/
Wraps gnuplot to plot stock data.
Definition plot.h:25
~Plot()
Destructor cleans up temporaray files storing stock data.
Definition plot.cpp:155
void display() const
Plot data for all stocks.
Definition plot.cpp:120
void percentage_plot(Gnuplot &g, std::string const &file_name, const Plot_type type) const
Plot data from time_in_weeks up until today. Oldest datapoint is normalized for all stocks.
Definition plot.cpp:89
void set_function(std::string const &function)
Set to daily / weekly / monthly data.
Definition plot.cpp:150
static float get_time_in_weeks()
Getter.
Definition plot.cpp:29
void setup_gnuplot(Gnuplot &g) const
Setup options for gnuplot.
Definition plot.cpp:65
void get_first_datapoint(Gnuplot &g, std::string const &file_name) const
Calculate furthest point back in time upto which to plot (time_in_weeks). The point is saved in a var...
Definition plot.cpp:78
void process_data(std::string &s) const
Figure out which column to plot, comment out first row for gnuplot and remove all carriage returns.
Definition plot.cpp:35
void cleanup() const
Delete files storing stock data.
Definition plot.cpp:141
void create_temp_file(std::string const &data, std::string const &file_name)
Create a file to store stock data. Will be deleted at end of program.
Definition plot.cpp:52
Plot()
Default constructor.
Definition plot.cpp:20
Plot_type
Definition plot.cpp:11