144 lines
4.7 KiB
C++
144 lines
4.7 KiB
C++
/* -*- C++ -*- */
|
|
|
|
/****************************************************************************
|
|
** Copyright (c) 2001-2014
|
|
**
|
|
** This file is part of the QuickFIX FIX Engine
|
|
**
|
|
** This file may be distributed under the terms of the quickfixengine.org
|
|
** license as defined by quickfixengine.org and appearing in the file
|
|
** LICENSE included in the packaging of this file.
|
|
**
|
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
**
|
|
** See http://www.quickfixengine.org/LICENSE for licensing information.
|
|
**
|
|
** Contact ask@quickfixengine.org if any conditions of this licensing are
|
|
** not clear to you.
|
|
**
|
|
****************************************************************************/
|
|
|
|
#ifndef ORDERMATCH_APPLICATION_H
|
|
#define ORDERMATCH_APPLICATION_H
|
|
|
|
#include "lib/utils/warn_ctrl.h"
|
|
|
|
GCC_DIAG_OFF("-Woverloaded-virtual")
|
|
GCC_DIAG_OFF("-Wdeprecated")
|
|
GCC_DIAG_OFF("-Wignored-qualifiers")
|
|
|
|
#include <iostream>
|
|
#include <queue>
|
|
|
|
#include <quickfix/Application.h>
|
|
#include <quickfix/MessageCracker.h>
|
|
#include <quickfix/Mutex.h>
|
|
#include <quickfix/Utility.h>
|
|
#include <quickfix/Values.h>
|
|
|
|
#include "lib/domain_model/Security.pb.h"
|
|
#include "server/sparkd/exchange_sim/IMDPlayerObserver.h"
|
|
#include <quickfix/fix42/NewOrderSingle.h>
|
|
#include <quickfix/fix42/OrderCancelRequest.h>
|
|
|
|
namespace bts {
|
|
namespace api {
|
|
class Security;
|
|
}
|
|
namespace md {
|
|
class MDConsumerHandle;
|
|
class MBOWriter;
|
|
} // namespace md
|
|
namespace ex_sim {
|
|
static const int precision = 9;
|
|
class Order;
|
|
struct Book;
|
|
class OrderBook;
|
|
class ExchangeSimApplication : public sim::IMDPlayerObserver,
|
|
public FIX::Application,
|
|
public FIX::MessageCracker {
|
|
public:
|
|
ExchangeSimApplication(bts::api::Venue venue, md::MBOWriter *);
|
|
~ExchangeSimApplication();
|
|
void merge_with_md_book();
|
|
|
|
private:
|
|
// Application overloads
|
|
void onCreate(const FIX::SessionID &) override;
|
|
void onLogon(const FIX::SessionID &sessionID) override;
|
|
void onLogout(const FIX::SessionID &sessionID) override;
|
|
void toAdmin(FIX::Message &, const FIX::SessionID &) override;
|
|
void toApp(FIX::Message &, const FIX::SessionID &) EXCEPT(FIX::DoNotSend) override;
|
|
void fromAdmin(const FIX::Message &, const FIX::SessionID &) EXCEPT(
|
|
FIX::FieldNotFound,
|
|
FIX::IncorrectDataFormat,
|
|
FIX::IncorrectTagValue,
|
|
FIX::RejectLogon) override;
|
|
void
|
|
fromApp(const FIX::Message &message, const FIX::SessionID &sessionID) EXCEPT(
|
|
FIX::FieldNotFound,
|
|
FIX::IncorrectDataFormat,
|
|
FIX::IncorrectTagValue,
|
|
FIX::UnsupportedMessageType) override;
|
|
|
|
// MessageCracker overloads
|
|
void
|
|
onMessage(const FIX42::NewOrderSingle &, const FIX::SessionID &) override;
|
|
void onMessage(
|
|
const FIX42::OrderCancelReplaceRequest &,
|
|
const FIX::SessionID &) override;
|
|
void onMessage(
|
|
const FIX42::OrderCancelRequest &, const FIX::SessionID &) override;
|
|
|
|
// Order functionality
|
|
void processOrder(const Order &);
|
|
// void processCancel( const std::string& id, const std::string& symbol,
|
|
// Order::Side );
|
|
void send_execution_report(const Order &, char status);
|
|
void rejectOrder(const Order &order);
|
|
// void acceptOrder( const Order& order );
|
|
void fillOrder(const Order &order);
|
|
// void cancelOrder( const Order& order );
|
|
void rejectOrder(
|
|
const FIX::SenderCompID &,
|
|
const FIX::SenderSubID &sender_sub_id,
|
|
const FIX::TargetCompID &,
|
|
const FIX::ClOrdID &clOrdID,
|
|
const FIX::SecurityDesc &symbol,
|
|
const FIX::Side &side,
|
|
const std::string &account,
|
|
const std::string &message);
|
|
|
|
public:
|
|
struct PImpl;
|
|
std::unique_ptr<PImpl> me;
|
|
struct MDConsumerRec;
|
|
void update_md(std::string const &sec_desc);
|
|
void persist_book(OrderBook const &b);
|
|
|
|
void on_new_security(md::Security const &) override;
|
|
void on_high(md::Security const &sec, md::Price price) override;
|
|
void on_low(md::Security const &sec, md::Price price) override;
|
|
void on_open(md::Security const &sec, md::Price price) override;
|
|
void on_close(md::Security const &sec, md::Price price) override;
|
|
void on_settlement(md::Security const &, md::IntPrice) override;
|
|
void on_depth(
|
|
md::Security const &s,
|
|
md::PriceSize bids[md::COCONUT_MAX_DEPTH],
|
|
md::PriceSize asks[md::COCONUT_MAX_DEPTH],
|
|
std::array<md::PriceSize, md::COCONUT_MAX_IMPLIED_DEPTH> *implied_bids,
|
|
std::array<md::PriceSize, md::COCONUT_MAX_IMPLIED_DEPTH> *implied_asks)
|
|
override;
|
|
void merge_with_order_book(
|
|
std::string const &sec_desc, Book const &previous, Book const ¤t);
|
|
};
|
|
} // namespace ex_sim
|
|
} // namespace bts
|
|
|
|
GCC_DIAG_RESTORE()
|
|
GCC_DIAG_RESTORE()
|
|
GCC_DIAG_RESTORE()
|
|
|
|
#endif
|