Files
spark/src/lib/md/test/Co2TestInstrument.cpp
T

53 lines
1.9 KiB
C++

#define _DISABLE_EXTENDED_ALIGNED_STORAGE
#include "Co2TestInstrument.h"
#include "lib/md/MemorySegmentUtils.h"
namespace bts {
namespace md {
Co2TestInstrument::Co2TestInstrument(const std::string& symbol, SecurityType type):
_cold_buffer(),
_cold(nullptr),
_hot(std::make_shared<HotDepthEntry>()),
_cheader(std::make_shared<ColdHeader>()),
_hheader(std::make_shared<HotHeader>())
{
_cheader->has_depth = enable_depth(symbol, type);
with_security(type, 4, nullptr, [&](FixedSecurity& fsec) {
fsec.exchange = api::VENUE_BTS;
_cold_buffer = std::shared_ptr<uint8_t>(new uint8_t[ColdEntry::fixed_size() + fsec.size], std::default_delete<uint8_t[]>());
_cold = new (_cold_buffer.get()) ColdEntry(fsec.size);
memcpy(&_cold->security, &fsec, fsec.size);
});
}
Co2TestInstrument::Co2TestInstrument(const Security& security, std::shared_ptr<ColdHeader> cheader, std::shared_ptr<HotHeader> hheader):
_cold(nullptr),
_hot(std::make_shared<HotDepthEntry>()),
_cheader(cheader),
_hheader(hheader)
{
bts_assert_d(_cheader->has_depth == false);
//_cheader->has_depth = enable_depth(md::SecurityHelper::symbol(security), security.security_type());
with_security_like(security, [&](FixedSecurity& fsec) {
convert_security(security, fsec, false);
_cold_buffer = std::shared_ptr<uint8_t>(new uint8_t[ColdEntry::fixed_size() + fsec.size], std::default_delete<uint8_t[]>());
_cold = new (_cold_buffer.get()) ColdEntry(fsec.size);
memcpy(&_cold->security, &fsec, fsec.size);
});
}
MDProducerHandle Co2TestInstrument::producer() {
return MDProducerHandle(*_cheader, *_hheader, *_cold, _hot.get(), MDProducerChannel());
}
MDConsumerHandle Co2TestInstrument::consumer() {
MDConsumerHandle handle;
handle.init(*_cheader, *_cold, _hot.get(), nullptr/*mbo*/);
return handle;
}
Co2TestInstrument::~Co2TestInstrument() { }
}}//namespace