Lean
$LEAN_TAG$
ShortableProviderPythonWrapper.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
.
Interfaces
;
19
using
QuantConnect
.
Python
;
20
using
System;
21
22
namespace
QuantConnect.Data.Shortable
23
{
24
/// <summary>
25
/// Python wrapper for custom shortable providers
26
/// </summary>
27
public
class
ShortableProviderPythonWrapper
:
BasePythonWrapper
<IShortableProvider>,
IShortableProvider
28
{
29
/// <summary>
30
/// Creates a new instance
31
/// </summary>
32
/// <param name="shortableProvider">The python custom shortable provider</param>
33
public
ShortableProviderPythonWrapper
(PyObject shortableProvider)
34
: base(shortableProvider)
35
{
36
}
37
38
/// <summary>
39
/// Gets the fee rate for the Symbol at the given date.
40
/// </summary>
41
/// <param name="symbol">Symbol to lookup fee rate</param>
42
/// <param name="localTime">Time of the algorithm</param>
43
/// <returns>zero indicating that it is does have borrowing costs</returns>
44
public
decimal
FeeRate
(
Symbol
symbol, DateTime localTime)
45
{
46
return
InvokeMethod<decimal>(nameof(
FeeRate
), symbol, localTime);
47
}
48
49
/// <summary>
50
/// Gets the Fed funds or other currency-relevant benchmark rate minus the interest rate charged on borrowed shares for a given asset.
51
/// E.g.: Interest rate - borrow fee rate = borrow rebate rate: 5.32% - 0.25% = 5.07%.
52
/// </summary>
53
/// <param name="symbol">Symbol to lookup rebate rate</param>
54
/// <param name="localTime">Time of the algorithm</param>
55
/// <returns>zero indicating that it is does have borrowing costs</returns>
56
public
decimal
RebateRate
(
Symbol
symbol, DateTime localTime)
57
{
58
return
InvokeMethod<decimal>(nameof(
RebateRate
), symbol, localTime);
59
}
60
61
/// <summary>
62
/// Gets the quantity shortable for a <see cref="Symbol"/>, from python custom shortable provider
63
/// </summary>
64
/// <param name="symbol">Symbol to check shortable quantity</param>
65
/// <param name="localTime">Local time of the algorithm</param>
66
/// <returns>The quantity shortable for the given Symbol as a positive number. Null if the Symbol is shortable without restrictions.</returns>
67
public
long
?
ShortableQuantity
(
Symbol
symbol, DateTime localTime)
68
{
69
return
InvokeMethod<long?>(nameof(
ShortableQuantity
), symbol, localTime);
70
}
71
}
72
}
Common
Data
Shortable
ShortableProviderPythonWrapper.cs
Generated by
1.8.17