MCPcopy Create free account
hub / github.com/Rblp/Rblpapi / processMessage

Function processMessage

src/getBars.cpp:96–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94};
95
96void processMessage(bbg::Message &msg, Bars &bars,
97 const int barInterval, const bool verbose) {
98 bbg::Element data = msg.getElement(BAR_DATA).getElement(BAR_TICK_DATA);
99 int numBars = data.numValues();
100 if (verbose) {
101 Rcpp::Rcout <<"Response contains " << numBars << " bars" << std::endl;
102 Rcpp::Rcout <<"Datetime\t\tOpen\t\tHigh\t\tLow\t\tClose" <<
103 "\t\tNumEvents\tVolume\t\tV" << std::endl;
104 }
105 for (int i = 0; i < numBars; ++i) {
106 bbg::Element bar = data.getValueAsElement(i);
107 bbg::Datetime time = bar.getElementAsDatetime(TIME);
108 assert(time.hasParts(bbg::DatetimeParts::DATE
109 | bbg::DatetimeParts::HOURS
110 | bbg::DatetimeParts::MINUTES));
111 double open = bar.getElementAsFloat64(OPEN);
112 double high = bar.getElementAsFloat64(HIGH);
113 double low = bar.getElementAsFloat64(LOW);
114 double close = bar.getElementAsFloat64(CLOSE);
115 int numEvents = bar.getElementAsInt32(NUM_EVENTS);
116 long long volume = bar.getElementAsInt64(VOLUME);
117 double value = bar.getElementAsFloat64(VALUE);
118
119 if (verbose) {
120 Rcpp::Rcout.setf(std::ios::fixed, std::ios::floatfield);
121 Rcpp::Rcout << time.month() << '/' << time.day() << '/' << time.year()
122 << " " << time.hours() << ":" << time.minutes()
123 << "\t\t" << std::showpoint
124 << std::setprecision(3) << open << "\t\t"
125 << high << "\t\t"
126 << low << "\t\t"
127 << close << "\t\t"
128 << numEvents << "\t\t"
129 << std::noshowpoint
130 << volume << "\t\t"
131 << value << std::endl;
132 }
133 bars.time.push_back(bbgDatetimeToUTC(time));
134 bars.open.push_back(open);
135 bars.high.push_back(high);
136 bars.low.push_back(low);
137 bars.close.push_back(close);
138 bars.numEvents.push_back(numEvents);
139 bars.volume.push_back(volume);
140 bars.value.push_back(value);
141 }
142}
143
144void processResponseEvent(bbg::Event &event, Bars &bars,
145 const int barInterval, const bool verbose) {

Callers 1

processResponseEventFunction · 0.70

Calls 1

bbgDatetimeToUTCFunction · 0.85

Tested by

no test coverage detected