41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
#include "md_test_utils.h"
|
|
#include "../MDProducer.h"
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
namespace bts {
|
|
namespace md {
|
|
namespace test {
|
|
|
|
std::vector<MDProducerHandle> create_test_securities(MDProducer& producer, const char* postfix ="") {
|
|
FixedFutureSecurity ffs;
|
|
FixedOptionSecurity fos;
|
|
ffs.symbol("FOO"+std::string(postfix));
|
|
fos.symbol("FOOX"+std::string(postfix));
|
|
ffs.exchange = api::VENUE_BTS;
|
|
fos.exchange = api::VENUE_BTS;
|
|
ffs.key = invalid_security_key;
|
|
fos.key = invalid_security_key;
|
|
ffs.expiration_year = fos.expiration_year = 2015;
|
|
ffs.expiration_day = fos.expiration_day = 27;
|
|
fos.strike = 1000;
|
|
fos.call_put = api::PUTORCALL_CALL;
|
|
// Add 12 expirations to 2 different shared memory regions
|
|
std::vector<MDProducerHandle> result;
|
|
for (uint32_t x = 1; x <= 12; ++x) {
|
|
ffs.expiration_month = fos.expiration_month = x;
|
|
result.push_back(producer.add_security(ffs));
|
|
result.push_back(producer.add_security(fos));
|
|
// In a real app these securities would now be passed to the SecurityIDRecorder
|
|
}
|
|
return result;
|
|
}
|
|
|
|
void assign_ids(std::vector<MDProducerHandle>::iterator begin, std::vector<MDProducerHandle>::iterator end, security_key start_key) {
|
|
for (; begin != end; ++begin) {
|
|
(*begin).set_key(++start_key);
|
|
}
|
|
}
|
|
|
|
}}}//namespace
|