Refactors Custom Models for python

Moves custom model setters from QCAlgorithm class to Security class.
Modifies algorithm examples to reflect the change.
This commit is contained in:
AlexCatarino
2017-09-29 22:56:52 +01:00
parent 5b3e456d4b
commit 751a66a36a
4 changed files with 64 additions and 68 deletions
+1 -61
View File
@@ -508,67 +508,7 @@ namespace QuantConnect.Algorithm
return _converter.GetDataFrame(History(symbols, start, end, resolution));
}
/// <summary>
/// Sets the fee model for securities
/// </summary>
/// <param name="model">Model that represents a fee model</param>
/// <param name="security">Security that will use the fee model, if null, sets the model to all securities</param>
public void SetFeeModel(PyObject model, Security security = null)
{
if (security != null)
{
security.FeeModel = new FeeModelPythonWrapper(model);
}
else
{
foreach (var sec in Securities.Values)
{
sec.FeeModel = new FeeModelPythonWrapper(model);
}
}
}
/// <summary>
/// Sets the fill model for securities
/// </summary>
/// <param name="model">Model that represents a fill model</param>
/// <param name="security">Security that will use the fill model, if null, sets the model to all securities</param>
public void SetFillModel(PyObject model, Security security = null)
{
if (security != null)
{
security.FillModel = new FillModelPythonWrapper(model);
}
else
{
foreach (var sec in Securities.Values)
{
sec.FillModel = new FillModelPythonWrapper(model);
}
}
}
/// <summary>
/// Sets the slippage model for securities
/// </summary>
/// <param name="model">Model that represents a slippage model</param>
/// <param name="security">Security that will use the slippage model, if null, sets the model to all securities</param>
public void SetSlippageModel(PyObject model, Security security = null)
{
if (security != null)
{
security.SlippageModel = new SlippageModelPythonWrapper(model);
}
else
{
foreach (var sec in Securities.Values)
{
sec.SlippageModel = new SlippageModelPythonWrapper(model);
}
}
}
/// <summary>
/// Gets the symbols/string from a PyObject
/// </summary>