149 lines
3.4 KiB
C++
149 lines
3.4 KiB
C++
// 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 <string>
|
|
|
|
#include <OnixS/CME/MDH/Decimal.h>
|
|
|
|
ONIXS_CMEMDH_NAMESPACE_BEGIN
|
|
|
|
/// Encapsulates price level concept.
|
|
ONIXS_CMEMDH_LTWT_CLASS ImpliedPriceLevel
|
|
{
|
|
// Indicates whether data is available.
|
|
bool exist_;
|
|
|
|
// Price value for the level.
|
|
Decimal price_;
|
|
|
|
// Quantity component.
|
|
Int32 qty_;
|
|
|
|
public:
|
|
/// Initializes undefined level.
|
|
ImpliedPriceLevel()
|
|
: exist_(false)
|
|
, price_()
|
|
, qty_(0)
|
|
{
|
|
}
|
|
|
|
/// Initializes as copy of other level.
|
|
ImpliedPriceLevel(
|
|
const ImpliedPriceLevel& other)
|
|
: exist_(other.exist_)
|
|
, price_(other.price_)
|
|
, qty_(other.qty_)
|
|
{
|
|
}
|
|
|
|
/// Initializes defined level
|
|
/// according to specified attributes.
|
|
ImpliedPriceLevel(
|
|
const Decimal& price, Int32 qty)
|
|
: exist_(true), price_(price), qty_(qty)
|
|
{
|
|
}
|
|
|
|
/// Cleans everything up.
|
|
~ImpliedPriceLevel()
|
|
{
|
|
}
|
|
|
|
/// Identifies whether price level exist.
|
|
bool exist() const
|
|
{
|
|
return exist_;
|
|
}
|
|
|
|
/// Updates existence status.
|
|
bool& exist()
|
|
{
|
|
return exist_;
|
|
}
|
|
|
|
/// Price value.
|
|
///
|
|
/// @note For CME Globex channels (market data groups)
|
|
/// value presents if price level exists. However, for
|
|
/// CME Partner Exchanges channels like BVMF price value
|
|
/// may be NULL in a valid (existent) price level.
|
|
///
|
|
/// @see NullPRICE.
|
|
const Decimal& price() const
|
|
{
|
|
return price_;
|
|
}
|
|
|
|
/// Price value.
|
|
Decimal& price()
|
|
{
|
|
return price_;
|
|
}
|
|
|
|
/// Quantify for the given price.
|
|
Int32 quantity() const
|
|
{
|
|
return qty_;
|
|
}
|
|
|
|
/// Quantify for the given price.
|
|
Int32& quantity()
|
|
{
|
|
return qty_;
|
|
}
|
|
|
|
// Re-initializes as copy of other instance.
|
|
ImpliedPriceLevel&
|
|
operator =(
|
|
const ImpliedPriceLevel& other)
|
|
{
|
|
price_ = other.price_;
|
|
qty_ = other.qty_;
|
|
exist_ = other.exist_;
|
|
|
|
return *this;
|
|
}
|
|
};
|
|
|
|
/// Serializes price level attributes into a string.
|
|
ONIXS_CMEMDH_EXPORTED
|
|
void
|
|
toStr(
|
|
std::string&,
|
|
const ImpliedPriceLevel&);
|
|
|
|
/// Serializes price level attributes into a string.
|
|
inline
|
|
std::string
|
|
toStr(
|
|
const ImpliedPriceLevel& priceLevel)
|
|
{
|
|
std::string str;
|
|
|
|
toStr(str, priceLevel);
|
|
|
|
return str;
|
|
}
|
|
|
|
ONIXS_CMEMDH_NAMESPACE_END
|