151 lines
4.8 KiB
C++
Executable File
151 lines
4.8 KiB
C++
Executable File
// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
|
|
//
|
|
// This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
|
|
// and international copyright treaties.
|
|
//
|
|
// Access to and use of the software is governed by the terms of the applicable OnixS Software
|
|
// Services Agreement (the Agreement) and Customer end user license agreements granting
|
|
// a non-assignable, non-transferable and non-exclusive license to use the software
|
|
// for it's own data processing purposes under the terms defined in the Agreement.
|
|
//
|
|
// Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
|
|
// of this source code or associated reference material to any other location for further reproduction
|
|
// or redistribution, and any amendments to this copyright notice, are expressly prohibited.
|
|
//
|
|
// Any reproduction or redistribution for sale or hiring of the Software not in accordance with
|
|
// the terms of the Agreement is a violation of copyright law.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include "OnixS/CME/MDP3/BookChangeBase.h"
|
|
#include "OnixS/CME/MDP3/DirectPriceLevel.h"
|
|
|
|
namespace OnixS
|
|
{
|
|
namespace CME
|
|
{
|
|
namespace MDP3
|
|
{
|
|
#if defined (_MSC_VER)
|
|
|
|
template
|
|
class
|
|
ONIXS_CME_MDP3_API
|
|
BookChangeBase<DirectPriceLevel>;
|
|
|
|
#endif
|
|
|
|
template <>
|
|
inline
|
|
bool BookChangeBase<DirectPriceLevel>::extract(
|
|
const GroupInstance& entry,
|
|
DirectPriceLevel& level)
|
|
{
|
|
const bool hasPrice = getDecimal(
|
|
entry, Tags::MDEntryPx, level.price());
|
|
|
|
const bool hasSize = getNumber(
|
|
entry, Tags::MDEntrySize, level.quantity());
|
|
|
|
const bool hasOrders = getNumber(
|
|
entry, Tags::NumberOfOrders, level.numberOfOrders());
|
|
|
|
return hasPrice || hasSize || hasOrders;
|
|
}
|
|
|
|
typedef
|
|
BookChangeBase<DirectPriceLevel>
|
|
DirectBookChangeBase;
|
|
|
|
/// Order book change.
|
|
///
|
|
/// @see DirectBookChangeListener.
|
|
class
|
|
ONIXS_CME_MDP3_API
|
|
DirectBookChange
|
|
: public DirectBookChangeBase
|
|
{
|
|
public:
|
|
/// Provides access to price component if exists.
|
|
/// @return 'true' if price component is available.
|
|
bool
|
|
price(
|
|
Price& price) const
|
|
{
|
|
if (
|
|
priceLevelData() &&
|
|
priceLevelData()->exist())
|
|
{
|
|
price = priceLevelData()->price();
|
|
|
|
return true;
|
|
}
|
|
|
|
return getDecimal(marketDataEntry(), Tags::MDEntryPx, price);
|
|
}
|
|
|
|
/// Provides access to quantity component if exists.
|
|
/// @return 'true' if quantity component is available.
|
|
bool
|
|
quantity(
|
|
SignedQuantity& quantity) const
|
|
{
|
|
if (
|
|
priceLevelData() &&
|
|
priceLevelData()->exist())
|
|
{
|
|
quantity = priceLevelData()->quantity();
|
|
|
|
return true;
|
|
}
|
|
|
|
return getNumber(marketDataEntry(), Tags::MDEntrySize, quantity);
|
|
}
|
|
|
|
/// Provides access to number of orders component if exists.
|
|
/// @return 'true' if number of orders component is available.
|
|
bool
|
|
numberOfOrders(
|
|
Quantity& numberOfOrders) const
|
|
{
|
|
if (
|
|
priceLevelData() &&
|
|
priceLevelData()->exist())
|
|
{
|
|
numberOfOrders =
|
|
priceLevelData()->numberOfOrders();
|
|
|
|
return true;
|
|
}
|
|
|
|
return getNumber(marketDataEntry(), Tags::NumberOfOrders, numberOfOrders);
|
|
}
|
|
|
|
/// Returns the text representation.
|
|
std::string toString() const
|
|
{
|
|
std::string str;
|
|
|
|
toString(str);
|
|
|
|
return str;
|
|
}
|
|
|
|
/// Appends the text representation.
|
|
void toString(std::string&) const;
|
|
|
|
protected:
|
|
DirectBookChange(
|
|
SecurityId id,
|
|
const GroupInstance& entry)
|
|
: DirectBookChangeBase(
|
|
id,
|
|
entry)
|
|
{
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|