Skip to content

Commit

Permalink
Deprecate ContractSecurityFilterUniverse.OnlyApplyFilterAtMarketOpen
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonabreul committed Dec 11, 2023
1 parent 4a51b3e commit de8dce1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 133 deletions.
128 changes: 0 additions & 128 deletions Algorithm.CSharp/CryptoFutureLeverageRegressionAlgorithm.cs

This file was deleted.

2 changes: 2 additions & 0 deletions Common/Securities/ContractSecurityFilterUniverse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ public T Contracts(Func<IEnumerable<Symbol>, IEnumerable<Symbol>> contractSelect
/// Instructs the engine to only filter contracts on the first time step of each market day.
/// </summary>
/// <returns>Universe with filter applied</returns>
/// <remarks>Deprecated since filters are non-dynamic by default now. See <see cref="Dynamic"/></remarks>
[Obsolete("Deprecated as of 2023-12-11. Filters are non-dynamic by default, which means they will only bee applied daily")]
public T OnlyApplyFilterAtMarketOpen()
{
_onlyApplyOnMarketOpen = true;
Expand Down
16 changes: 11 additions & 5 deletions Common/Securities/Future/Future.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,10 @@ public override void SetLocalTimeKeeper(LocalTimeKeeper localTimeKeeper)
/// would exclude contracts expiring in less than 10 days</param>
/// <param name="maxExpiry">The maximum time until expiry to include, for example, TimeSpan.FromDays(10)
/// would exclude contracts expiring in more than 10 days</param>
public void SetFilter(TimeSpan minExpiry, TimeSpan maxExpiry)
/// <param name="dynamic">Whether to mark the filter as dynamic for regular reapplying</param>
public void SetFilter(TimeSpan minExpiry, TimeSpan maxExpiry, bool dynamic = false)
{
SetFilterImp(universe => universe.Expiration(minExpiry, maxExpiry));
SetFilterImp(universe => universe.Expiration(minExpiry, maxExpiry), dynamic);
}

/// <summary>
Expand All @@ -236,9 +237,10 @@ public void SetFilter(TimeSpan minExpiry, TimeSpan maxExpiry)
/// would exclude contracts expiring in less than 10 days</param>
/// <param name="maxExpiryDays">The maximum time, expressed in days, until expiry to include, for example, 10
/// would exclude contracts expiring in more than 10 days</param>
public void SetFilter(int minExpiryDays, int maxExpiryDays)
/// <param name="dynamic">Whether to mark the filter as dynamic for regular reapplying</param>
public void SetFilter(int minExpiryDays, int maxExpiryDays, bool dynamic = false)
{
SetFilterImp(universe => universe.Expiration(minExpiryDays, maxExpiryDays));
SetFilterImp(universe => universe.Expiration(minExpiryDays, maxExpiryDays), dynamic);
}

/// <summary>
Expand All @@ -261,12 +263,16 @@ public void SetFilter(PyObject universeFunc)
SetFilter(pyUniverseFunc);
}

private void SetFilterImp(Func<FutureFilterUniverse, FutureFilterUniverse> universeFunc)
private void SetFilterImp(Func<FutureFilterUniverse, FutureFilterUniverse> universeFunc, bool dynamic = false)
{
Func<IDerivativeSecurityFilterUniverse, IDerivativeSecurityFilterUniverse> func = universe =>
{
var futureUniverse = universe as FutureFilterUniverse;
var result = universeFunc(futureUniverse);
if (dynamic)
{
result.Dynamic();
}
return result.ApplyTypesFilter();
};
ContractFilter = new FuncSecurityDerivativeFilter(func);
Expand Down

0 comments on commit de8dce1

Please sign in to comment.