Lean
$LEAN_TAG$
ErrorCurrencyConverter.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
18
namespace
QuantConnect.Securities
19
{
20
/// <summary>
21
/// Provides an implementation of <see cref="ICurrencyConverter"/> for use in
22
/// tests that don't depend on this behavior.
23
/// </summary>
24
public
class
ErrorCurrencyConverter
:
ICurrencyConverter
25
{
26
/// <summary>
27
/// Gets account currency
28
/// </summary>
29
public
string
AccountCurrency
30
{
31
get
32
{
33
throw
new
InvalidOperationException(
Messages
.
ErrorCurrencyConverter
.
AccountCurrencyUnexpectedUsage
);
34
}
35
}
36
37
/// <summary>
38
/// Provides access to the single instance of <see cref="ErrorCurrencyConverter"/>.
39
/// This is done this way to ensure usage is explicit.
40
/// </summary>
41
public
static
ICurrencyConverter
Instance
=
new
ErrorCurrencyConverter
();
42
43
private
ErrorCurrencyConverter
()
44
{
45
}
46
47
/// <summary>
48
/// Converts a cash amount to the account currency
49
/// </summary>
50
/// <param name="cashAmount">The <see cref="CashAmount"/> instance to convert</param>
51
/// <returns>A new <see cref="CashAmount"/> instance denominated in the account currency</returns>
52
public
CashAmount
ConvertToAccountCurrency
(
CashAmount
cashAmount)
53
{
54
throw
new
InvalidOperationException(
Messages
.
ErrorCurrencyConverter
.
ConvertToAccountCurrencyPurposefullyThrow
);
55
}
56
}
57
}
Common
Securities
ErrorCurrencyConverter.cs
Generated by
1.8.17