Lean
$LEAN_TAG$
CryptoFuture.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
QuantConnect
.
Orders
.
Fees
;
17
using
QuantConnect
.
Orders
.
Fills
;
18
using
QuantConnect
.
Orders
.
Slippage
;
19
20
namespace
QuantConnect.Securities.CryptoFuture
21
{
22
/// <summary>
23
/// Crypto Future Security Object Implementation for Crypto Future Assets
24
/// </summary>
25
public
class
CryptoFuture
:
Security
,
IBaseCurrencySymbol
26
{
27
/// <summary>
28
/// Gets the currency acquired by going long this currency pair
29
/// </summary>
30
/// <remarks>
31
/// For example, the EUR/USD has a base currency of the euro, and as a result
32
/// of going long the EUR/USD a trader is acquiring euros in exchange for US dollars
33
/// </remarks>
34
public
Cash
BaseCurrency
{
get
;
protected
set
; }
35
36
/// <summary>
37
/// Constructor for the Crypto Future security
38
/// </summary>
39
/// <param name="symbol">The symbol</param>
40
/// <param name="exchangeHours">Defines the hours this exchange is open</param>
41
/// <param name="quoteCurrency">The cash object that represent the quote currency</param>
42
/// <param name="baseCurrency">The cash object that represent the base currency</param>
43
/// <param name="symbolProperties">The symbol properties for this security</param>
44
/// <param name="currencyConverter">Currency converter used to convert <see cref="CashAmount"/>
45
/// instances into units of the account currency</param>
46
/// <param name="registeredTypes">Provides all data types registered in the algorithm</param>
47
/// <param name="cache">The security cache</param>
48
public
CryptoFuture
(
Symbol
symbol,
49
SecurityExchangeHours
exchangeHours,
50
Cash
quoteCurrency,
51
Cash
baseCurrency,
52
SymbolProperties
symbolProperties,
53
ICurrencyConverter
currencyConverter,
54
IRegisteredSecurityDataTypesProvider
registeredTypes,
55
SecurityCache
cache)
56
: base(symbol,
57
quoteCurrency,
58
symbolProperties,
59
new
CryptoFutureExchange
(exchangeHours),
60
cache,
61
new
SecurityPortfolioModel
(),
62
new
ImmediateFillModel
(),
63
IsCryptoCoinFuture
(quoteCurrency.
Symbol
) ? new
BinanceCoinFuturesFeeModel
() : new
BinanceFuturesFeeModel
(),
64
NullSlippageModel
.Instance,
65
new
ImmediateSettlementModel
(),
66
Securities.
VolatilityModel
.Null,
67
new
CryptoFutureMarginModel
(),
68
new
SecurityDataFilter
(),
69
new
SecurityPriceVariationModel
(),
70
currencyConverter,
71
registeredTypes,
72
// only applies for perpetual futures
73
symbol.ID.Date ==
SecurityIdentifier
.DefaultDate ? new
BinanceFutureMarginInterestRateModel
() : Securities.
MarginInterestRateModel
.Null
74
)
75
{
76
BaseCurrency
= baseCurrency;
77
Holdings
=
new
CryptoFutureHolding
(
this
, currencyConverter);
78
}
79
80
/// <summary>
81
/// Checks whether the security is a crypto coin future
82
/// </summary>
83
/// <returns>True if the security is a crypto coin future</returns>
84
public
bool
IsCryptoCoinFuture
()
85
{
86
return
IsCryptoCoinFuture
(
QuoteCurrency
.
Symbol
);
87
}
88
89
/// <summary>
90
/// Checks whether the security is a crypto coin future
91
/// </summary>
92
/// <param name="quoteCurrency">The security quote currency</param>
93
/// <returns>True if the security is a crypto coin future</returns>
94
private
static
bool
IsCryptoCoinFuture
(
string
quoteCurrency)
95
{
96
return
quoteCurrency !=
"USDT"
&& quoteCurrency !=
"BUSD"
;
97
}
98
}
99
}
Common
Securities
CryptoFuture
CryptoFuture.cs
Generated by
1.8.17