95af5f8877
- `SecurityHolding` will now have a reference to a `ICurrencyConverter` instance, provided as a constructor argument, called by the owning `Security`.
106 lines
4.4 KiB
C#
106 lines
4.4 KiB
C#
/*
|
|
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
|
|
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
using QuantConnect.Data;
|
|
using QuantConnect.Orders.Fees;
|
|
using QuantConnect.Orders.Fills;
|
|
using QuantConnect.Orders.Slippage;
|
|
|
|
namespace QuantConnect.Securities.Cfd
|
|
{
|
|
/// <summary>
|
|
/// CFD Security Object Implementation for CFD Assets
|
|
/// </summary>
|
|
/// <seealso cref="Security"/>
|
|
public class Cfd : Security
|
|
{
|
|
/// <summary>
|
|
/// Constructor for the CFD security
|
|
/// </summary>
|
|
/// <param name="exchangeHours">Defines the hours this exchange is open</param>
|
|
/// <param name="quoteCurrency">The cash object that represent the quote currency</param>
|
|
/// <param name="config">The subscription configuration for this security</param>
|
|
/// <param name="symbolProperties">The symbol properties for this security</param>
|
|
/// <param name="currencyConverter">Currency converter used to convert <see cref="CashAmount"/>
|
|
/// instances into units of the account currency</param>
|
|
public Cfd(SecurityExchangeHours exchangeHours, Cash quoteCurrency, SubscriptionDataConfig config, SymbolProperties symbolProperties, ICurrencyConverter currencyConverter)
|
|
: base(config,
|
|
quoteCurrency,
|
|
symbolProperties,
|
|
new CfdExchange(exchangeHours),
|
|
new CfdCache(),
|
|
new SecurityPortfolioModel(),
|
|
new ImmediateFillModel(),
|
|
new ConstantFeeModel(0),
|
|
new ConstantSlippageModel(0),
|
|
new ImmediateSettlementModel(),
|
|
Securities.VolatilityModel.Null,
|
|
new SecurityMarginModel(50m),
|
|
new CfdDataFilter(),
|
|
new SecurityPriceVariationModel(),
|
|
currencyConverter
|
|
)
|
|
{
|
|
Holdings = new CfdHolding(this, currencyConverter);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor for the CFD security
|
|
/// </summary>
|
|
/// <param name="symbol">The security's symbol</param>
|
|
/// <param name="exchangeHours">Defines the hours this exchange is open</param>
|
|
/// <param name="quoteCurrency">The cash object that represent the quote currency</param>
|
|
/// <param name="symbolProperties">The symbol properties for this security</param>
|
|
/// <param name="currencyConverter">Currency converter used to convert <see cref="CashAmount"/>
|
|
/// instances into units of the account currency</param>
|
|
public Cfd(Symbol symbol, SecurityExchangeHours exchangeHours, Cash quoteCurrency, SymbolProperties symbolProperties, ICurrencyConverter currencyConverter)
|
|
: base(symbol,
|
|
quoteCurrency,
|
|
symbolProperties,
|
|
new CfdExchange(exchangeHours),
|
|
new CfdCache(),
|
|
new SecurityPortfolioModel(),
|
|
new ImmediateFillModel(),
|
|
new ConstantFeeModel(0),
|
|
new ConstantSlippageModel(0),
|
|
new ImmediateSettlementModel(),
|
|
Securities.VolatilityModel.Null,
|
|
new SecurityMarginModel(50m),
|
|
new CfdDataFilter(),
|
|
new SecurityPriceVariationModel(),
|
|
currencyConverter
|
|
)
|
|
{
|
|
Holdings = new CfdHolding(this, currencyConverter);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the contract multiplier for this CFD security
|
|
/// </summary>
|
|
public decimal ContractMultiplier
|
|
{
|
|
get { return SymbolProperties.ContractMultiplier; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the minimum price variation for this CFD security
|
|
/// </summary>
|
|
public decimal MinimumPriceVariation
|
|
{
|
|
get { return SymbolProperties.MinimumPriceVariation; }
|
|
}
|
|
}
|
|
}
|