284 lines
9.2 KiB
C++
Executable File
284 lines
9.2 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/Tags.h"
|
|
#include "OnixS/CME/MDP3/EventIndicator.h"
|
|
|
|
namespace OnixS
|
|
{
|
|
namespace CME
|
|
{
|
|
namespace MDP3
|
|
{
|
|
/// Known Security Trading Statuses.
|
|
struct
|
|
ONIXS_CME_MDP3_API
|
|
SecurityTradingStatuses
|
|
{
|
|
/// Known Security Trading Statuses.
|
|
enum Enum
|
|
{
|
|
Undefined = 0,
|
|
|
|
TradingHalt = 2,
|
|
Close = 4,
|
|
NewPriceIndication = 15,
|
|
ReadyToTrade = 17,
|
|
NotAvailableForTrading = 18,
|
|
UnknownOrInvalid = 20,
|
|
PreOpen = 21,
|
|
PreCross = 24,
|
|
Cross = 25,
|
|
PostClose = 26,
|
|
NoChange = 103
|
|
};
|
|
|
|
/// Returns constant from its string representation.
|
|
static Enum deserialize(const char* status);
|
|
|
|
/// Returns string representation of trading status.
|
|
static const char* toString(Enum status);
|
|
};
|
|
|
|
/// Known Security Trading Statuses.
|
|
typedef
|
|
SecurityTradingStatuses::Enum
|
|
SecurityTradingStatus;
|
|
|
|
/// Known Halt reasons.
|
|
struct
|
|
ONIXS_CME_MDP3_API
|
|
HaltReasons
|
|
{
|
|
enum Enum
|
|
{
|
|
Undefined = -1,
|
|
|
|
GroupSchedule = 0,
|
|
SurveillanceIntervention = 1,
|
|
MarketEvent = 2,
|
|
InstrumentActivation = 3,
|
|
InstrumentExpiration = 4,
|
|
Unknown = 5,
|
|
RecoveryInProcess = 6
|
|
};
|
|
|
|
/// Returns constant from its string representation.
|
|
static Enum deserialize(const char* status);
|
|
|
|
/// Text representation of Enum value.
|
|
static const char* toString(Enum);
|
|
};
|
|
|
|
typedef
|
|
HaltReasons::Enum
|
|
HaltReason;
|
|
|
|
/// Known Security Trading Events.
|
|
struct
|
|
ONIXS_CME_MDP3_API
|
|
SecurityTradingEvents
|
|
{
|
|
/// Known Security Trading Events.
|
|
enum Enum
|
|
{
|
|
Undefined = -1,
|
|
|
|
NoEvent = 0,
|
|
NoCancel = 1,
|
|
ChangeOfTradingSession = 4,
|
|
ImpliedMatchingOn = 5,
|
|
ImpliedMatchingOff = 6
|
|
};
|
|
|
|
/// Returns constant from its string representation.
|
|
static Enum deserialize(const char* status);
|
|
|
|
/// Returns string representation of trading event.
|
|
static const char* toString(Enum value);
|
|
};
|
|
|
|
/// Security Trading Event type.
|
|
typedef
|
|
SecurityTradingEvents::Enum
|
|
SecurityTradingEvent;
|
|
|
|
/// Security Status.
|
|
class
|
|
ONIXS_CME_MDP3_API
|
|
SecurityStatus
|
|
{
|
|
public:
|
|
/// Initializes instance from given FIX message.
|
|
SecurityStatus(
|
|
const Message& message)
|
|
: message_(message)
|
|
{
|
|
}
|
|
|
|
// Releases associated message.
|
|
~SecurityStatus()
|
|
{
|
|
}
|
|
|
|
/// Start of event processing time (UTC).
|
|
Timestamp transactTime() const
|
|
{
|
|
return message_.getTimestamp(Tags::TransactTime, SinceEpochUnits::Nanoseconds);
|
|
}
|
|
|
|
/// Indicates the date of the trade session.
|
|
Timestamp tradeDate() const
|
|
{
|
|
return message_.getTimestamp(Tags::TradeDate, SinceEpochUnits::Days);
|
|
}
|
|
|
|
/// Market data events present in the
|
|
/// message containing given instance.
|
|
EventIndicator
|
|
eventIndicator() const
|
|
{
|
|
return EventIndicator(message_);
|
|
}
|
|
|
|
/// If this tag is present (value is not empty),
|
|
/// status is sent for instrument group.
|
|
StringRef
|
|
securityGroup() const
|
|
{
|
|
StringRef group;
|
|
|
|
message_.
|
|
get(Tags::SecurityGroup).
|
|
toStringRef(group);
|
|
|
|
return group;
|
|
}
|
|
|
|
/// Product Code.
|
|
///
|
|
/// @return Empty value if no product code is available.
|
|
StringRef
|
|
asset() const
|
|
{
|
|
StringRef asset;
|
|
|
|
message_.
|
|
get(Tags::Asset).
|
|
toStringRef(asset);
|
|
|
|
return asset;
|
|
}
|
|
|
|
/// If id presents, status is sent for instrument.
|
|
/// Returns 'false' if status is sent for group.
|
|
bool
|
|
securityId(
|
|
SecurityId& id) const
|
|
{
|
|
return
|
|
message_.get(Tags::SecurityID).
|
|
toNumber(id);
|
|
}
|
|
|
|
/// Accesses to security trading status if available.
|
|
SecurityTradingStatus
|
|
tradingStatus() const
|
|
{
|
|
return getIntEnumFieldValue
|
|
<SecurityTradingStatuses>
|
|
(
|
|
message_,
|
|
message_.type() == "f"
|
|
? Tags::SecurityTradingStatus
|
|
: Tags::MDSecurityTradingStatus
|
|
);
|
|
}
|
|
|
|
/// Identifies the reason for the status change.
|
|
HaltReason
|
|
haltReason() const
|
|
{
|
|
return message_.type() == "f"
|
|
? getIntEnumFieldValue
|
|
<HaltReasons>
|
|
(
|
|
message_,
|
|
Tags::HaltReason
|
|
)
|
|
: HaltReasons::Undefined;
|
|
}
|
|
|
|
/// Identifies an additional event or a rule
|
|
/// related to the SecurityTradingStatus (326).
|
|
SecurityTradingEvent
|
|
tradingEvent() const
|
|
{
|
|
return message_.type() == "f"
|
|
? getIntEnumFieldValue
|
|
<SecurityTradingEvents>
|
|
(
|
|
message_,
|
|
Tags::SecurityTradingEvent
|
|
)
|
|
: SecurityTradingEvents::Undefined;
|
|
}
|
|
|
|
/// Underlying FIX message containing security status.
|
|
const Message& message() const
|
|
{
|
|
return message_;
|
|
}
|
|
|
|
/// String representation.
|
|
std::string toString() const
|
|
{
|
|
std::string str;
|
|
toString(str);
|
|
return str;
|
|
}
|
|
|
|
/// Appends string representation.
|
|
void toString(std::string&) const;
|
|
|
|
private:
|
|
Message message_;
|
|
};
|
|
|
|
/// Security Status listener.
|
|
class
|
|
ONIXS_CME_MDP3_API
|
|
SecurityStatusListener
|
|
{
|
|
public:
|
|
/// Is called when Security Status is received.
|
|
virtual
|
|
void
|
|
onSecurityStatus(
|
|
const SecurityStatus& status,
|
|
const ChannelId& channelId) = 0;
|
|
|
|
protected:
|
|
virtual ~SecurityStatusListener();
|
|
};
|
|
}
|
|
}
|
|
}
|