Lean
$LEAN_TAG$
WolverineBrokerageModel.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
17
using
QuantConnect
.
Orders
;
18
using
QuantConnect
.
Securities
;
19
using
QuantConnect
.
Orders
.
Fees
;
20
21
namespace
QuantConnect.Brokerages
22
{
23
/// <summary>
24
/// Wolverine Brokerage model
25
/// </summary>
26
public
class
WolverineBrokerageModel
:
DefaultBrokerageModel
27
{
28
/// <summary>
29
/// Constructor for Wolverine brokerage model
30
/// </summary>
31
/// <param name="accountType">Cash or Margin</param>
32
public
WolverineBrokerageModel
(
AccountType
accountType =
AccountType
.Margin) : base(accountType)
33
{
34
}
35
36
/// <summary>
37
/// Returns true if the brokerage could accept this order. This takes into account
38
/// order type, security type, and order size limits.
39
/// </summary>
40
/// <remarks>
41
/// For example, a brokerage may have no connectivity at certain times, or an order rate/size limit
42
/// </remarks>
43
/// <param name="security">The security of the order</param>
44
/// <param name="order">The order to be processed</param>
45
/// <param name="message">If this function returns false, a brokerage message detailing why the order may not be submitted</param>
46
/// <returns>True if the brokerage could process the order, false otherwise</returns>
47
public
override
bool
CanSubmitOrder
(
Security
security,
Order
order, out
BrokerageMessageEvent
message)
48
{
49
if
(!
IsValidOrderSize
(security, order.
Quantity
, out message))
50
{
51
return
false
;
52
}
53
54
message =
null
;
55
if
(security.
Type
!=
SecurityType
.Equity)
56
{
57
message =
new
BrokerageMessageEvent
(
BrokerageMessageType
.Warning,
"NotSupported"
,
58
Messages
.
DefaultBrokerageModel
.
UnsupportedSecurityType
(
this
, security));
59
60
return
false
;
61
}
62
63
if
(order.
Type
!=
OrderType
.Market)
64
{
65
message =
new
BrokerageMessageEvent
(
BrokerageMessageType
.Warning,
"NotSupported"
,
66
Messages
.
WolverineBrokerageModel
.
UnsupportedOrderType
(order));
67
68
return
false
;
69
}
70
71
return
base.CanSubmitOrder(security, order, out message);
72
}
73
74
/// <summary>
75
/// Wolverine does not support update of orders
76
/// </summary>
77
/// <param name="security">Security</param>
78
/// <param name="order">Order that should be updated</param>
79
/// <param name="request">Update request</param>
80
/// <param name="message">Outgoing message</param>
81
/// <returns>Always false as Wolverine does not support update of orders</returns>
82
public
override
bool
CanUpdateOrder
(
Security
security,
Order
order,
UpdateOrderRequest
request, out
BrokerageMessageEvent
message)
83
{
84
message =
new
BrokerageMessageEvent
(
BrokerageMessageType
.Warning, 0,
Messages
.
DefaultBrokerageModel
.
OrderUpdateNotSupported
);
85
return
false
;
86
}
87
88
/// <summary>
89
/// Provides Wolverine fee model
90
/// </summary>
91
/// <param name="security">Security</param>
92
/// <returns>Wolverine fee model</returns>
93
public
override
IFeeModel
GetFeeModel
(
Security
security)
94
{
95
return
new
WolverineFeeModel
();
96
}
97
}
98
}
Common
Brokerages
WolverineBrokerageModel.cs
Generated by
1.8.17