[Rprotobuf-commits] r341 - pkg/inst/examples/HighFrequencyFinance
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jul 18 22:12:16 CEST 2010
Author: edd
Date: 2010-07-18 22:12:15 +0200 (Sun, 18 Jul 2010)
New Revision: 341
Modified:
pkg/inst/examples/HighFrequencyFinance/loadInR.r
pkg/inst/examples/HighFrequencyFinance/protoCreate.cpp
Log:
minor changes, one is just whitespace
Modified: pkg/inst/examples/HighFrequencyFinance/loadInR.r
===================================================================
--- pkg/inst/examples/HighFrequencyFinance/loadInR.r 2010-07-18 15:54:32 UTC (rev 340)
+++ pkg/inst/examples/HighFrequencyFinance/loadInR.r 2010-07-18 20:12:15 UTC (rev 341)
@@ -100,9 +100,9 @@
dll <- dyn.load("protoModule.so")
-print(summary(moduled()));
-print(summary(moduled()));
-q()
+#print(summary(moduled()));
+#print(summary(moduled()));
+#q()
Modified: pkg/inst/examples/HighFrequencyFinance/protoCreate.cpp
===================================================================
--- pkg/inst/examples/HighFrequencyFinance/protoCreate.cpp 2010-07-18 15:54:32 UTC (rev 340)
+++ pkg/inst/examples/HighFrequencyFinance/protoCreate.cpp 2010-07-18 20:12:15 UTC (rev 341)
@@ -1,47 +1,46 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
-#include "TradeData.pb.h" // auto-generated ProtoBuffer data structure accessor
+#include "TradeData.pb.h" // auto-generated ProtoBuffer data structure accessor
#include <iostream>
#include <fstream>
-#define MATHLIB_STANDALONE 1 // so that we get set_seed()
-#include <Rmath.h> // to use R's RNGs and random distribution functions
+#define MATHLIB_STANDALONE 1 // so that we get set_seed()
+#include <Rmath.h> // to use R's RNGs and random distribution functions
int main(int argc, char **argv)
{
- // Verify that the version of the library that we linked against is
- // compatible with the version of the headers we compiled against.
- GOOGLE_PROTOBUF_VERIFY_VERSION;
+ // Verify that the version of the library that we linked against is
+ // compatible with the version of the headers we compiled against.
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
- const char* pbfile = "trades.pb";
- const int N = 1000;
+ const char* pbfile = "trades.pb";
+ const int N = 1000;
set_seed(123, 456);
- double tstamp = 1277973000; // 2010-07-01 08:30:00
- double tprice = 100.0; // gotta start somewhere
- char sym[] = "ABC";
+ double tstamp = 1277973000; // 2010-07-01 08:30:00
+ double tprice = 100.0; // gotta start somewhere
+ char sym[] = "ABC";
- TradeData::Trades tr;
- for (int i=0; i<N; i++) {
- TradeData::Fill *fill = tr.add_fill();
- tstamp += runif(0.000, 0.100); // time steps anywhere between 0 and 100 msec
- tprice += round(rt(5) * 0.01 * 100)/100; // price move as dampened t(5), rounded to pennies
- int tsize = 100 + round(runif(0,9))*100; // size in 100 lots
+ TradeData::Trades tr;
+ for (int i=0; i<N; i++) {
+ TradeData::Fill *fill = tr.add_fill();
+ tstamp += runif(0.000, 0.100); // time steps anywhere between 0 and 100 msec
+ tprice += round(rt(5) * 0.01 * 100)/100; // price move as dampened t(5), rounded to pennies
+ int tsize = 100 + round(runif(0,9))*100; // size in 100 lots
- fill->set_timestamp(tstamp);
- fill->set_price(tprice);
- fill->set_symbol(sym);
- fill->set_size(tsize);
- }
+ fill->set_timestamp(tstamp);
+ fill->set_price(tprice);
+ fill->set_symbol(sym);
+ fill->set_size(tsize);
+ }
- // Write the new address book back to disk.
- std::fstream output(pbfile, std::ios::out | std::ios::binary);
+ std::fstream output(pbfile, std::ios::out | std::ios::binary);
if (!tr.SerializeToOstream(&output)) {
- std::cerr << "Failed to write address book." << std::endl;
- return -1;
+ std::cerr << "Failed to write data." << std::endl;
+ return -1;
}
- google::protobuf::ShutdownProtobufLibrary();
+ google::protobuf::ShutdownProtobufLibrary();
- return 0;
+ return 0;
}
More information about the Rprotobuf-commits
mailing list