Lean
$LEAN_TAG$
MarketOnCloseOrder.cs
1
/*
2
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
16
using
System;
17
using
QuantConnect
.
Interfaces
;
18
using
QuantConnect
.
Securities
;
19
20
namespace
QuantConnect.Orders
21
{
22
/// <summary>
23
/// Market on close order type - submits a market order on exchange close
24
/// </summary>
25
public
class
MarketOnCloseOrder
:
Order
26
{
27
/// <summary>
28
/// Gets the default interval before market close that an MOC order may be submitted.
29
/// For example, US equity exchanges typically require MOC orders to be placed no later
30
/// than 15 minutes before market close, which yields a nominal time of 3:45PM.
31
/// This buffer value takes into account the 15 minutes and adds an additional 30 seconds
32
/// to account for other potential delays, such as LEAN order processing and placement of
33
/// the order to the exchange.
34
/// </summary>
35
public
static
readonly TimeSpan
DefaultSubmissionTimeBuffer
= TimeSpan.FromMinutes(15.5);
36
37
/// <summary>
38
/// The interval before market close that an MOC order may be submitted.
39
/// </summary>
40
/// <remarks>Configurable so advanced users may modify this for special cases;
41
/// Related issue: Github #5481</remarks>
42
public
static
TimeSpan
SubmissionTimeBuffer
=
DefaultSubmissionTimeBuffer
;
43
44
/// <summary>
45
/// MarketOnClose Order Type
46
/// </summary>
47
public
override
OrderType
Type
48
{
49
get
{
return
OrderType
.MarketOnClose; }
50
}
51
52
/// <summary>
53
/// Intiializes a new instance of the <see cref="MarketOnCloseOrder"/> class.
54
/// </summary>
55
public
MarketOnCloseOrder
()
56
{
57
}
58
59
/// <summary>
60
/// Intiializes a new instance of the <see cref="MarketOnCloseOrder"/> class.
61
/// </summary>
62
/// <param name="symbol">The security's symbol being ordered</param>
63
/// <param name="quantity">The number of units to order</param>
64
/// <param name="time">The current time</param>
65
/// <param name="tag">A user defined tag for the order</param>
66
/// <param name="properties">The order properties for this order</param>
67
public
MarketOnCloseOrder
(
Symbol
symbol, decimal quantity, DateTime time,
string
tag =
""
,
IOrderProperties
properties =
null
)
68
: base(symbol, quantity, time, tag, properties)
69
{
70
}
71
72
/// <summary>
73
/// Gets the order value in units of the security's quote currency
74
/// </summary>
75
/// <param name="security">The security matching this order's symbol</param>
76
protected
override
decimal
GetValueImpl
(
Security
security)
77
{
78
return
Quantity
*security.
Price
;
79
}
80
81
/// <summary>
82
/// Creates a deep-copy clone of this order
83
/// </summary>
84
/// <returns>A copy of this order</returns>
85
public
override
Order
Clone
()
86
{
87
var order =
new
MarketOnCloseOrder
();
88
CopyTo
(order);
89
return
order;
90
}
91
}
92
}
Common
Orders
MarketOnCloseOrder.cs
Generated by
1.8.17