-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFIXOrderCollection.cpp
85 lines (63 loc) · 1.46 KB
/
FIXOrderCollection.cpp
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
#include "stdafx.h"
#include "FIXOrderCollection.h"
#include "CSGuardian.h"
using namespace std;
CFIXOrderCollection::CFIXOrderCollection(void)
{
}
CFIXOrderCollection::~CFIXOrderCollection(void)
{
}
bool CFIXOrderCollection::Add(const string &OrderID, double Requested, eOrderSide Side)
{
CCSGuardian csg(m_CS);
// If we already have an entry with this OrderID, fail
if (m_mapOrders.find(OrderID) != m_mapOrders.end())
{
return false;
}
CFIXOrder order(OrderID);
order.SetAmountRequested(Requested);
order.SetOrderSide(Side);
m_mapOrders[OrderID] = order;
return true;
}
bool CFIXOrderCollection::Update(const string &OrderID, double Received)
{
CCSGuardian csg(m_CS);
// Look for the matching order
auto it = m_mapOrders.find(OrderID);
if (it == m_mapOrders.end())
{
// No matching order to update
return false;
}
it->second.SetAmountReceived(Received);
return true;
}
bool CFIXOrderCollection::Update(const string &OrderID, eOrderState State)
{
CCSGuardian csg(m_CS);
// Look for the matching order
auto it = m_mapOrders.find(OrderID);
if (it == m_mapOrders.end())
{
// No matching order to update
return false;
}
it->second.SetOrderState(State);
return true;
}
bool CFIXOrderCollection::Delete(const string &OrderID)
{
CCSGuardian csg(m_CS);
// Look for the matching order
auto it = m_mapOrders.find(OrderID);
if (it == m_mapOrders.end())
{
// No matching order to update
return false;
}
m_mapOrders.erase(it);
return true;
}