Lean  $LEAN_TAG$
AlphaStreamsBrokerageModel.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;
20 
22 {
23  /// <summary>
24  /// Provides properties specific to Alpha Streams
25  /// </summary>
27  {
28  /// <summary>
29  /// Initializes a new instance of the <see cref="AlphaStreamsBrokerageModel"/> class
30  /// </summary>
31  /// <param name="accountType">The type of account to be modeled, defaults to <see cref="AccountType.Margin"/> does not accept <see cref="AccountType.Cash"/>.</param>
32  public AlphaStreamsBrokerageModel(AccountType accountType = AccountType.Margin)
33  : base(accountType)
34  {
35  if (accountType == AccountType.Cash)
36  {
37  throw new ArgumentException(Messages.AlphaStreamsBrokerageModel.UnsupportedAccountType, nameof(accountType));
38  }
39  }
40 
41  /// <summary>
42  /// Gets a new fee model that represents this brokerage's fee structure
43  /// </summary>
44  /// <param name="security">The security to get a fee model for</param>
45  /// <returns>The new fee model for this brokerage</returns>
46  public override IFeeModel GetFeeModel(Security security) => new AlphaStreamsFeeModel();
47 
48  /// <summary>
49  /// Gets a new slippage model that represents this brokerage's fill slippage behavior
50  /// </summary>
51  /// <param name="security">The security to get a slippage model for</param>
52  /// <returns>The new slippage model for this brokerage</returns>
53  public override ISlippageModel GetSlippageModel(Security security) => new AlphaStreamsSlippageModel();
54 
55  /// <summary>
56  /// Gets the brokerage's leverage for the specified security
57  /// </summary>
58  /// <param name="security">The security's whose leverage we seek</param>
59  /// <returns>The leverage for the specified security</returns>
60  public override decimal GetLeverage(Security security)
61  {
62  switch (security.Type)
63  {
64  case SecurityType.Forex:
65  case SecurityType.Cfd:
66  return 10m;
67 
68  default:
69  return 1m;
70  }
71  }
72 
73  /// <summary>
74  /// Gets a new settlement model for the security
75  /// </summary>
76  /// <param name="security">The security to get a settlement model for</param>
77  /// <returns>The settlement model for this brokerage</returns>
78  public override ISettlementModel GetSettlementModel(Security security) => new ImmediateSettlementModel();
79  }
80 }