Fixed iceberg table in sql command.

This commit is contained in:
Pedro Pinto committed 2020-12-10 12:22:00 -05:00
1 parent dd3c33387d
commit b3e7bcf2e1
3 files changed
+21 -3

No files matched your search

+2 -1
View File
@@ -82,9 +82,10 @@ CREATE INDEX book_sid_idx ON books(sid);
drop table if exists icebergs;
CREATE TABLE icebergs(
ok numeric,
eid numeric,
total_qty numeric,
show_qty numeric,
filled numeric
fill_qty numeric
);
/* All the securities*/
@@ -723,8 +723,16 @@ int to_csv(std::string const &file) {
observe_channel(file, {&cvs, &ice_finder, &def_collector, &poly_finder});
auto icebergs = std::ofstream(drop_extensions(file) + ".icebergs.csv");
for (auto &i : ice_finder.result)
icebergs << i.first.value() << "," << i.second.total_qty().value();
for (auto &i : ice_finder.result) {
auto relevent_eids = i.second.all_eids();
for (auto eid : relevent_eids)
icebergs << i.first.value() << ","
<< eid << ","
<< i.second.total_qty().value() << ","
<< std::get<0> (i.second.show_qty_at(eid)) << ","
<< i.second.count_fills_by(eid)
<< std::endl;
}
auto polys = std::ofstream(drop_extensions(file) + ".polygons.csv");
auto poly_legs = std::ofstream(drop_extensions(file) + ".polygon_legs.csv");
@@ -31,6 +31,15 @@ struct IcebergInput {
}
MDP3Quantity count_fills_by(size_t event_id) const;
std::set<size_t> all_eids() {
std::set<size_t> result;
for (auto const &p : _show_quantities)
result.insert(std::get<0>(p));
for (auto const &p : _fill_quantities)
result.insert(std::get<0>(p));
return result;
}
private:
MDP3Quantity _total_qty = MDP3Quantity(0);
std::vector<std::tuple<size_t, MDP3Quantity>> _show_quantities;