After looking around and looking at the code, it seems like all I have to do is create my model,
public class EstimatedSlippageModel : ISlippageModel
{
public decimal GetSlippageApproximation(Security asset, Order order)
{
....
}
}
And then add it to the security:
Securities[equity.Symbol].SlippageModel = new EstimatedSlippageModel();
But it doesn't look like this is working. When Buying, it's still calling into the SpreadSlippageModel which is being supplied through the default ISecurityTransactionModel.
So I create a custom ISecurityTransactionModel,
public class MySecurityTransactionModel : SecurityTransactionModel
{
private ISlippageModel SlippageModel { get; set; }
public MySecurityTransactionModel(ISlippageModel slippageModel)
{
this.SlippageModel = slippageModel;
}
public override decimal GetSlippageApproximation(Security security, Order order)
{
return this.SlippageModel.GetSlippageApproximation(security, order);
}
}
And then assigned it to the Security's model,
Securities[equity.Symbol].Model = new MySecurityTransactionModel(new EstimatedSlippageModel());
But this is still not working. The default SpreadSlippageModel is being ran through the default SecurityTransactionModel.
Any suggestions?