Lean
$LEAN_TAG$
SettlementModelPythonWrapper.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
17
using
Python
.Runtime;
18
using
QuantConnect
.
Securities
;
19
20
namespace
QuantConnect.Python
21
{
22
/// <summary>
23
/// Provides an implementation of <see cref="ISettlementModel"/> that wraps a <see cref="PyObject"/> object
24
/// </summary>
25
public
class
SettlementModelPythonWrapper
:
BasePythonWrapper
<ISettlementModel>,
ISettlementModel
26
{
27
/// Constructor for initialising the <see cref="SettlementModelPythonWrapper"/> class with wrapped <see cref="PyObject"/> object
28
/// </summary>
29
/// <param name="model">Settlement Python Model</param>
30
public
SettlementModelPythonWrapper
(PyObject model)
31
: base(model)
32
{
33
}
34
35
/// <summary>
36
/// Applies cash settlement rules using the method defined in the Python class
37
/// </summary>
38
/// <param name="applyFundsParameters">The funds application parameters</param>
39
public
void
ApplyFunds
(
ApplyFundsSettlementModelParameters
applyFundsParameters)
40
{
41
InvokeMethod
(nameof(
ApplyFunds
), applyFundsParameters);
42
}
43
44
/// <summary>
45
/// Scan for pending settlements using the method defined in the Python class
46
/// </summary>
47
/// <param name="settlementParameters">The settlement parameters</param>
48
public
void
Scan
(
ScanSettlementModelParameters
settlementParameters)
49
{
50
InvokeMethod
(nameof(
Scan
), settlementParameters);
51
}
52
53
/// <summary>
54
/// Gets the unsettled cash amount for the security
55
/// </summary>
56
public
CashAmount
GetUnsettledCash
()
57
{
58
using
(Py.GIL())
59
{
60
var result = InvokeMethod<CashAmount?>(nameof(
GetUnsettledCash
));
61
if
(result ==
null
)
62
{
63
return
default
;
64
}
65
66
return
result.Value;
67
}
68
}
69
}
70
}
Common
Python
SettlementModelPythonWrapper.cs
Generated by
1.8.17