| | |
| | | namespace json |
| | | { |
| | | enum MessageTypes { |
| | | FUTURE_TYPE, |
| | | SPREAD_TYPE, |
| | | CALL_TYPE, |
| | | PUT_TYPE, |
| | | SETTLEMENT, |
| | | ADD, |
| | | ADDED, |
| | | DELETE, |
| | | DELETED, |
| | | REJECT, |
| | | TRADE, |
| | | BROKER_REQUEST, |
| | | BROKER_ACK, |
| | | BROKER_CONFIRM, |
| | | NONE |
| | | FUTURE_TYPE, |
| | | SPREAD_TYPE, |
| | | CALL_TYPE, |
| | | PUT_TYPE, |
| | | SETTLEMENT, |
| | | ADD, |
| | | ADDED, |
| | | DELETE, |
| | | DELETED, |
| | | REJECT, |
| | | TRADE, |
| | | BROKER_REQUEST, |
| | | BROKER_ACK, |
| | | BROKER_CONFIRM, |
| | | ERROR, |
| | | NONE |
| | | }; |
| | | |
| | | enum TradeTypeEnum { BUY_AGGRESSOR, SELL_AGGRESSOR }; |
| | | enum TradeTypeEnum { BUY_AGGRESSOR, SELL_AGGRESSOR, BROKER_TRADE }; |
| | | |
| | | struct Message { |
| | | MessageTypes type; |
| | | std::string product; |
| | | Message(MessageTypes type, std::string product); |
| | | Message(); |
| | | virtual ~Message() = default; |
| | | MessageTypes type; |
| | | std::string product; |
| | | Message(MessageTypes type, std::string product); |
| | | Message(); |
| | | virtual ~Message() = default; |
| | | }; |
| | | |
| | | struct ErrorMessage : public Message { |
| | | std::string message; |
| | | ErrorMessage(std::string message); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct FromExchange : public Message { |
| | | uint64_t sequence; |
| | | double timestamp; |
| | | FromExchange(MessageTypes type, std::string product, uint64_t sequence, |
| | | double timestamp); |
| | | virtual ~FromExchange() = default; |
| | | uint64_t sequence; |
| | | double timestamp; |
| | | FromExchange(MessageTypes type, std::string product, uint64_t sequence, |
| | | double timestamp); |
| | | virtual ~FromExchange() = default; |
| | | }; |
| | | |
| | | struct ToExchange : public Message { |
| | | ToExchange(MessageTypes type, std::string product); |
| | | virtual ~ToExchange() = default; |
| | | ToExchange(MessageTypes type, std::string product); |
| | | virtual ~ToExchange() = default; |
| | | }; |
| | | |
| | | struct Broker : public Message { |
| | | double price; |
| | | book::OrderSideEnum side; |
| | | uint64_t volume; |
| | | std::string counterparty; |
| | | Broker(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume, std::string counterparty); |
| | | virtual ~Broker() = default; |
| | | double price; |
| | | book::OrderSideEnum side; |
| | | uint64_t volume; |
| | | std::string counterparty; |
| | | Broker(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume, std::string counterparty); |
| | | virtual ~Broker() = default; |
| | | }; |
| | | |
| | | struct AnnounceMessage : public FromExchange { |
| | | int stationId; |
| | | std::string stationName; |
| | | std::string unit; |
| | | std::chrono::nanoseconds expiry; |
| | | double aggFee; |
| | | double pasFee; |
| | | double broFee; |
| | | int stationId; |
| | | std::string stationName; |
| | | std::string unit; |
| | | std::chrono::nanoseconds expiry; |
| | | double aggFee; |
| | | double pasFee; |
| | | double broFee; |
| | | |
| | | AnnounceMessage(MessageTypes type, std::string product, |
| | | int stationId, std::string stationName, |
| | | std::string unit, std::chrono::nanoseconds expiry, |
| | | double aggFee, double pasFee, double broFee, |
| | | uint64_t sequence, double timestamp); |
| | | AnnounceMessage(MessageTypes type, std::string product, int stationId, |
| | | std::string stationName, std::string unit, |
| | | std::chrono::nanoseconds expiry, double aggFee, |
| | | double pasFee, double broFee, uint64_t sequence, |
| | | double timestamp); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct SettleMessage : public FromExchange { |
| | | std::string stationName; |
| | | std::chrono::nanoseconds expiry; |
| | | double price; |
| | | SettleMessage(MessageTypes type, std::string product, |
| | | std::string stationName, std::chrono::nanoseconds expiry, |
| | | double price, uint64_t sequence, double timestamp); |
| | | std::string stationName; |
| | | std::chrono::nanoseconds expiry; |
| | | double price; |
| | | SettleMessage(MessageTypes type, std::string product, |
| | | std::string stationName, std::chrono::nanoseconds expiry, |
| | | double price, uint64_t sequence, double timestamp); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct AddMessage : public ToExchange { |
| | | double price; |
| | | book::OrderSideEnum side; |
| | | uint64_t volume; |
| | | AddMessage(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume); |
| | | std::string as_string(); |
| | | double price; |
| | | book::OrderSideEnum side; |
| | | uint64_t volume; |
| | | AddMessage(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct AddedMessage : public FromExchange { |
| | | std::string id; |
| | | book::OrderSideEnum side; |
| | | double price; |
| | | uint64_t filled; |
| | | uint64_t resting; |
| | | AddedMessage(MessageTypes type, std::string product, std::string id, |
| | | book::OrderSideEnum side, double price, uint64_t filled, |
| | | uint64_t resting, uint64_t sequence, double timestamp); |
| | | std::string id; |
| | | book::OrderSideEnum side; |
| | | double price; |
| | | uint64_t filled; |
| | | uint64_t resting; |
| | | std::string owner; |
| | | AddedMessage(MessageTypes type, std::string product, std::string id, |
| | | book::OrderSideEnum side, double price, uint64_t filled, |
| | | uint64_t resting, std::string owner, uint64_t sequence, double timestamp); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct DeleteMessage : public ToExchange { |
| | | std::string id; |
| | | DeleteMessage(MessageTypes type, std::string product, std::string id); |
| | | std::string as_string(); |
| | | std::string id; |
| | | DeleteMessage(MessageTypes type, std::string product, std::string id); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct DeletedMessage : public FromExchange { |
| | | std::string id; |
| | | book::OrderSideEnum side; |
| | | DeletedMessage(MessageTypes type, std::string product, std::string id, |
| | | book::OrderSideEnum side, uint64_t sequence, |
| | | double timestamp); |
| | | std::string id; |
| | | book::OrderSideEnum side; |
| | | DeletedMessage(MessageTypes type, std::string product, std::string id, |
| | | book::OrderSideEnum side, uint64_t sequence, |
| | | double timestamp); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct RejectMessage : public FromExchange { |
| | | std::string error; |
| | | RejectMessage(MessageTypes type, std::string product, std::string error, |
| | | uint64_t sequence, double timestamp); |
| | | std::string error; |
| | | RejectMessage(MessageTypes type, std::string product, std::string error, |
| | | uint64_t sequence, double timestamp); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct TradeMessage : public FromExchange { |
| | | double price; |
| | | uint64_t volume; |
| | | std::string buyer; |
| | | std::string seller; |
| | | TradeTypeEnum tradeType; |
| | | std::string passiveOrder; |
| | | uint64_t passiveOrderRemaining; |
| | | TradeMessage(MessageTypes type, std::string product, double price, |
| | | uint64_t volume, std::string buyer, std::string seller, |
| | | TradeTypeEnum tradeType, std::string passiveOrder, |
| | | uint64_t passiveOrderRemaining, uint64_t sequence, |
| | | double timestamp); |
| | | double price; |
| | | uint64_t volume; |
| | | std::string buyer; |
| | | std::string seller; |
| | | TradeTypeEnum tradeType; |
| | | std::string passiveOrder; |
| | | uint64_t passiveOrderRemaining; |
| | | TradeMessage(MessageTypes type, std::string product, double price, |
| | | uint64_t volume, std::string buyer, std::string seller, |
| | | TradeTypeEnum tradeType, std::string passiveOrder, |
| | | uint64_t passiveOrderRemaining, uint64_t sequence, |
| | | double timestamp); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct BrokerRequest : public Broker { |
| | | BrokerRequest(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume, |
| | | std::string counterparty); |
| | | BrokerRequest(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume, |
| | | std::string counterparty); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct BrokerAck : public Broker { |
| | | std::string id; |
| | | std::string brokerTradeStatus; |
| | | std::string owner; |
| | | BrokerAck(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume, |
| | | std::string counterparty, std::string id, |
| | | std::string brokerTradeStatus, std::string owner); |
| | | std::string id; |
| | | std::string brokerTradeStatus; |
| | | std::string owner; |
| | | BrokerAck(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume, |
| | | std::string counterparty, std::string id, |
| | | std::string brokerTradeStatus, std::string owner); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | struct BrokerConfirm : public Broker { |
| | | std::string id; |
| | | BrokerConfirm(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume, |
| | | std::string counterparty, std::string id); |
| | | std::string id; |
| | | BrokerConfirm(MessageTypes type, std::string product, double price, |
| | | book::OrderSideEnum side, uint64_t volume, |
| | | std::string counterparty, std::string id); |
| | | std::string as_string(); |
| | | }; |
| | | |
| | | std::queue<Message*> parse(std::string& str); |