-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathOrder_Combo.hpp
100 lines (67 loc) · 2.7 KB
/
Order_Combo.hpp
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
/************************************************************************
* Copyright(c) 2023, One Unified. All rights reserved. *
* email: [email protected] *
* *
* This file is provided as is WITHOUT ANY WARRANTY *
* without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* This software may not be used nor distributed without proper license *
* agreement. *
* *
* See the file LICENSE.txt for redistribution information. *
************************************************************************/
/*
* File: Order_Combo.hpp
* Author: [email protected]
* Project: TFTrading
* Created: March 22, 2023 13:38:52
*/
#pragma once
#include <vector>
#include <functional>
#include "MonitorOrder.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
// ==================
class OrderCombo_TrackLeg {
public:
using pPosition_t = Position::pPosition_t;
using fLegDone_t = std::function<void()>;
OrderCombo_TrackLeg( pPosition_t, uint32_t nQuantity_, ou::tf::OrderSide::EOrderSide, fLegDone_t&& );
OrderCombo_TrackLeg( pPosition_t, fLegDone_t&& );
void Submit();
bool Tick( ptime dt ); // one second interval
void Cancel();
protected:
private:
enum class State { leg_add, leg_close, active, done } state;
uint32_t m_nQuantity;
ou::tf::OrderSide::EOrderSide m_side;
fLegDone_t m_fLegDone;
MonitorOrder m_mo;
};
// ==================
class OrderCombo {
public:
OrderCombo();
~OrderCombo();
using pPosition_t = Position::pPosition_t;
using fLegDone_t = OrderCombo_TrackLeg::fLegDone_t;
using fComboDone_t = std::function<void()>;
using pOrderCombo_t = std::shared_ptr<OrderCombo>;
static pOrderCombo_t Factory() { return std::make_shared<OrderCombo>(); }
void AddLeg( pPosition_t, uint32_t nOrderQuantity, ou::tf::OrderSide::EOrderSide, fLegDone_t&& );
void CloseLeg( pPosition_t, fLegDone_t&& );
void Submit( fComboDone_t&& );
void Cancel( fComboDone_t&& );
void Tick( ptime dt ); // one second interval
protected:
private:
enum class EState { bare, loading, placing, cancel, monitoring, done } m_state;
using vTrack_t = std::vector<OrderCombo_TrackLeg>;
vTrack_t m_vTrack;
fComboDone_t m_fComboDone; // TODO: needs a status: filled, partial fill, all cancelled
};
} // namespace tf
} // namespace ou