Lean
$LEAN_TAG$
FxcmFeeModel.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
using
System.Collections.Generic;
18
using
QuantConnect
.
Securities
;
19
20
namespace
QuantConnect.Orders.Fees
21
{
22
/// <summary>
23
/// Provides an implementation of <see cref="FeeModel"/> that models FXCM order fees
24
/// </summary>
25
public
class
FxcmFeeModel
:
FeeModel
26
{
27
private
readonly
string
_currency;
28
29
private
readonly HashSet<Symbol> _groupCommissionSchedule1 =
new
HashSet<Symbol>
30
{
31
Symbol
.
Create
(
"EURUSD"
,
SecurityType
.Forex,
Market
.
FXCM
),
32
Symbol
.
Create
(
"GBPUSD"
,
SecurityType
.Forex,
Market
.
FXCM
),
33
Symbol
.
Create
(
"USDJPY"
,
SecurityType
.Forex,
Market
.
FXCM
),
34
Symbol
.
Create
(
"USDCHF"
,
SecurityType
.Forex,
Market
.
FXCM
),
35
Symbol
.
Create
(
"AUDUSD"
,
SecurityType
.Forex,
Market
.
FXCM
),
36
Symbol
.
Create
(
"EURJPY"
,
SecurityType
.Forex,
Market
.
FXCM
),
37
Symbol
.
Create
(
"GBPJPY"
,
SecurityType
.Forex,
Market
.
FXCM
),
38
};
39
40
/// <summary>
41
/// Creates a new instance
42
/// </summary>
43
/// <param name="currency">The currency of the order fee, for FXCM this is the account currency</param>
44
public
FxcmFeeModel
(
string
currency =
"USD"
)
45
{
46
_currency = currency;
47
}
48
49
/// <summary>
50
/// Get the fee for this order in units of the account currency
51
/// </summary>
52
/// <param name="parameters">A <see cref="OrderFeeParameters"/> object
53
/// containing the security and order</param>
54
/// <returns>The cost of the order in units of the account currency</returns>
55
public
override
OrderFee
GetOrderFee
(
OrderFeeParameters
parameters)
56
{
57
// From http://www.fxcm.com/forex/forex-pricing/ (on Oct 6th, 2015)
58
// Forex: $0.04 per side per 1k lot for EURUSD, GBPUSD, USDJPY, USDCHF, AUDUSD, EURJPY, GBPJPY
59
// $0.06 per side per 1k lot for other instruments
60
61
// From https://www.fxcm.com/uk/markets/cfds/frequently-asked-questions/
62
// CFD: no commissions
63
64
decimal fee = 0;
65
if
(parameters.
Security
.
Type
==
SecurityType
.Forex)
66
{
67
var commissionRate = _groupCommissionSchedule1.Contains(parameters.
Security
.
Symbol
)
68
? 0.04m : 0.06m;
69
70
fee = Math.Abs(commissionRate * parameters.
Order
.
AbsoluteQuantity
/ 1000);
71
}
72
return
new
OrderFee
(
new
CashAmount
(fee,
73
_currency));
74
}
75
}
76
}
Common
Orders
Fees
FxcmFeeModel.cs
Generated by
1.8.17