-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFIXAdapter.h
101 lines (79 loc) · 3.59 KB
/
FIXAdapter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once
#include <string>
#include "quickfix/Application.h"
#include "quickfix/MessageCracker.h"
#include "quickfix/SocketInitiator.h"
#include "FIXOrderCollection.h"
#include "CurrencyCollection.h"
using namespace FIX;
class CFIXAdapter : public FIX::Application,
public FIX::MessageCracker
{
private:
FIX::SocketInitiator *m_pInitiator;
unsigned int m_OrderCount;
FIX::SessionID m_TradeSessionID;
FIX::SessionID m_PriceSessionID;
std::string m_UserName;
std::string m_Password;
std::string m_TradeCompID;
std::string m_PriceCompID;
bool m_bTradeLoggedIn;
bool m_bPriceLoggedIn;
std::map<int, std::string> m_mapMarketData;
// Stores all the orders we have received
CFIXOrderCollection m_Orders;
// Stores all the tradable currencies
CCurrencyCollection m_Currencies;
std::string GenerateClOrdID();
// Notification of a session begin created
virtual void onCreate( const SessionID& );
// These are all the message types we can get back from the server
void onMessage(const FIX44::Heartbeat &message, const FIX::SessionID&);
void onMessage(const FIX44::Reject &message, const FIX::SessionID&);
void onMessage(const FIX44::Logout &message, const FIX::SessionID&);
void onMessage(const FIX44::ExecutionReport &message, const FIX::SessionID&);
void onMessage(const FIX44::OrderCancelReject &message, const FIX::SessionID&);
void onMessage(const FIX44::Logon &message, const FIX::SessionID&);
void onMessage(const FIX44::MarketDataSnapshotFullRefresh &message, const FIX::SessionID&);
void handleNewOrder(const FIX44::ExecutionReport &message);
void handlePartiallyFilledOrder(const FIX44::ExecutionReport &message);
void handleFilledOrder(const FIX44::ExecutionReport &message);
void handleCanceledOrder(const FIX44::ExecutionReport &message);
void handleRejectedOrder(const FIX44::ExecutionReport &message);
// Notification of a session successfully logging on
virtual void onLogon( const SessionID& );
// Notification of a session logging off or disconnecting
virtual void onLogout( const SessionID& );
// Notification of admin message being sent to target
virtual void toAdmin( Message&, const SessionID& );
// Notification of app message being sent to target
virtual void toApp( Message&, const SessionID& ) throw( DoNotSend );
// Notification of admin message being received from target
virtual void fromAdmin( const Message&, const SessionID& )
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon );
// Notification of app message being received from target
virtual void fromApp( const Message&, const SessionID& )
throw( FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType );
public:
CFIXAdapter();
~CFIXAdapter();
// Alow the client to set the login details
void SetLoginDetails(const std::string &UserName,
const std::string &Password);
void SetCompIDs(const std::string &TradeCompID,
const std::string &PriceCompID);
bool Initialise();
bool Shutdown();
// Check to see if we are currently logged in
bool IsTradeLoggedIn();
bool IsPriceLoggedIn();
// These are all the messages we can send to the server
bool TestRequest(const std::string &RequestID);
bool SendSequenceReset();
bool Logout(const std::string &Reason);
bool NewOrderSingle(const std::string &Currency, double Quantity, double Price, bool bIsLimit, std::string &OrderID);
bool OrderCancelRequest(const std::string &OrigClOrdID, const std::string &Currency, double Quantity);
bool StartMarketDataRequest(const std::string &Currency);
bool DisableMarketDataRequest(const std::string &Currency);
};