[GAP-067]: remove shadowed property declarations
This commit is contained in:
@@ -59,46 +59,6 @@ namespace NinjaTrader.NinjaScript.Strategies
|
|||||||
[Range(1, 10)]
|
[Range(1, 10)]
|
||||||
public int MaxDailyTrades { get; set; }
|
public int MaxDailyTrades { get; set; }
|
||||||
|
|
||||||
// GAP-006: Gate legacy bar-driven _tradeTaken re-arm for SIM-only mode
|
|
||||||
[NinjaScriptProperty]
|
|
||||||
[Display(Name = "Enable Bar-Based Re-arm (SIM Only)", GroupName = "Trade Management", Order = 13, Description = "When true, allows bar-driven _tradeTaken re-arm. Disable for live trading; use position-close re-arm instead.")]
|
|
||||||
public bool EnableBarBasedRearm { get; set; }
|
|
||||||
|
|
||||||
// GAP-010: Short-side regime filter
|
|
||||||
[NinjaScriptProperty]
|
|
||||||
[Display(Name = "Enable Short Trend Filter", GroupName = "Trade Management", Order = 14, Description = "When true, short trades are vetoed if AVWAP slope > 0 (bullish regime).")]
|
|
||||||
public bool EnableShortTrendFilter { get; set; }
|
|
||||||
|
|
||||||
// GAP-008: CME Holiday Guard
|
|
||||||
[NinjaScriptProperty]
|
|
||||||
[Display(Name = "Enable CME Holiday Guard", GroupName = "Trade Management", Order = 15, Description = "When true, strategy skips ORB window on CME holidays (New Year, MLK, Presidents, Good Friday, Memorial, July 4, Labor, Thanksgiving, Christmas).")]
|
|
||||||
public bool EnableCMEHolidayGuard { get; set; }
|
|
||||||
|
|
||||||
// GAP-009: ATR-based trailing stop
|
|
||||||
[NinjaScriptProperty]
|
|
||||||
[Display(Name = "Enable ATR Trailing", GroupName = "Exit Management", Order = 16, Description = "When true, runner trailing stop uses ATR instead of fixed RunnerTrailTicks.")]
|
|
||||||
public bool EnableATRTrailing { get; set; }
|
|
||||||
|
|
||||||
[NinjaScriptProperty]
|
|
||||||
[Display(Name = "ATR Trailing Period", GroupName = "Exit Management", Order = 17, Description = "ATR period for trailing stop calculation.")]
|
|
||||||
[Range(2, 50)]
|
|
||||||
public int ATRTrailingPeriod { get; set; }
|
|
||||||
|
|
||||||
[NinjaScriptProperty]
|
|
||||||
[Display(Name = "ATR Trailing Multiplier", GroupName = "Exit Management", Order = 18, Description = "Multiplier applied to ATR value for trail distance.")]
|
|
||||||
[Range(0.1, 5.0)]
|
|
||||||
public double ATRTrailingMultiplier { get; set; }
|
|
||||||
|
|
||||||
[NinjaScriptProperty]
|
|
||||||
[Display(Name = "ATR Trailing Min Ticks", GroupName = "Exit Management", Order = 19, Description = "Minimum trail distance in ticks.")]
|
|
||||||
[Range(1, 100)]
|
|
||||||
public int ATRTrailingMinTicks { get; set; }
|
|
||||||
|
|
||||||
[NinjaScriptProperty]
|
|
||||||
[Display(Name = "ATR Trailing Max Ticks", GroupName = "Exit Management", Order = 20, Description = "Maximum trail distance in ticks.")]
|
|
||||||
[Range(1, 200)]
|
|
||||||
public int ATRTrailingMaxTicks { get; set; }
|
|
||||||
|
|
||||||
[NinjaScriptProperty]
|
[NinjaScriptProperty]
|
||||||
[Display(Name = "Profit Target Ticks", GroupName = "ORB Risk", Order = 2)]
|
[Display(Name = "Profit Target Ticks", GroupName = "ORB Risk", Order = 2)]
|
||||||
[Range(1, 100)]
|
[Range(1, 100)]
|
||||||
@@ -146,14 +106,6 @@ namespace NinjaTrader.NinjaScript.Strategies
|
|||||||
ForceSessionReset = false;
|
ForceSessionReset = false;
|
||||||
TestMode = false;
|
TestMode = false;
|
||||||
MaxDailyTrades = 1;
|
MaxDailyTrades = 1;
|
||||||
EnableBarBasedRearm = false; // GAP-006: default false for live trading
|
|
||||||
EnableShortTrendFilter = true; // GAP-010: default true for short trend filtering
|
|
||||||
EnableCMEHolidayGuard = true; // GAP-008: default true for CME holiday guard
|
|
||||||
EnableATRTrailing = false; // GAP-009: default false, uses fixed RunnerTrailTicks
|
|
||||||
ATRTrailingPeriod = 14; // GAP-009
|
|
||||||
ATRTrailingMultiplier = 2.0; // GAP-009
|
|
||||||
ATRTrailingMinTicks = 8; // GAP-009
|
|
||||||
ATRTrailingMaxTicks = 60; // GAP-009
|
|
||||||
// AdoptAccountPosition avoids NT8 start-up synchronization submitting or flattening during historical replay bursts before the first live bar.
|
// AdoptAccountPosition avoids NT8 start-up synchronization submitting or flattening during historical replay bursts before the first live bar.
|
||||||
StartBehavior = StartBehavior.AdoptAccountPosition;
|
StartBehavior = StartBehavior.AdoptAccountPosition;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
|
namespace NT8.Core.Tests.Adapters
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class NT8StrategyBaseShadowedPropertyTests
|
||||||
|
{
|
||||||
|
private static readonly string[] FormerlyShadowedProperties =
|
||||||
|
{
|
||||||
|
"EnableBarBasedRearm",
|
||||||
|
"EnableShortTrendFilter",
|
||||||
|
"EnableCMEHolidayGuard",
|
||||||
|
"EnableATRTrailing",
|
||||||
|
"ATRTrailingPeriod",
|
||||||
|
"ATRTrailingMultiplier",
|
||||||
|
"ATRTrailingMinTicks",
|
||||||
|
"ATRTrailingMaxTicks"
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly Regex PublicAutoProperty = new Regex(
|
||||||
|
@"(?m)^\s*public\s+[\w.<>,\[\]?]+\s+(\w+)\s*\{\s*get;\s*set;\s*\}",
|
||||||
|
RegexOptions.Compiled);
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void FormerlyShadowedProperties_AreNotDeclaredOnSimpleOrb()
|
||||||
|
{
|
||||||
|
HashSet<string> derivedProperties = ReadPublicProperties(FindSourceFile("SimpleORBNT8.cs"));
|
||||||
|
|
||||||
|
foreach (string name in FormerlyShadowedProperties)
|
||||||
|
Assert.IsFalse(derivedProperties.Contains(name), name + " must be inherited, not redeclared by SimpleORBNT8.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void FormerlyShadowedProperties_AreDeclaredExactlyOnceOnBase()
|
||||||
|
{
|
||||||
|
string source = File.ReadAllText(FindSourceFile("NT8StrategyBase.cs"));
|
||||||
|
|
||||||
|
foreach (string name in FormerlyShadowedProperties)
|
||||||
|
{
|
||||||
|
int count = Regex.Matches(source, @"(?m)^\s*public\s+[\w.<>,\[\]?]+\s+" + Regex.Escape(name) + @"\s*\{\s*get;\s*set;\s*\}").Count;
|
||||||
|
Assert.AreEqual(1, count, name + " must have exactly one public property declaration in NT8StrategyBase.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void SimpleOrbAndBase_HaveNoPublicPropertyNameOverlap()
|
||||||
|
{
|
||||||
|
HashSet<string> baseProperties = ReadPublicProperties(FindSourceFile("NT8StrategyBase.cs"));
|
||||||
|
HashSet<string> derivedProperties = ReadPublicProperties(FindSourceFile("SimpleORBNT8.cs"));
|
||||||
|
List<string> collisions = new List<string>();
|
||||||
|
|
||||||
|
foreach (string name in derivedProperties)
|
||||||
|
{
|
||||||
|
if (baseProperties.Contains(name))
|
||||||
|
collisions.Add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(0, collisions.Count, "SimpleORBNT8 must not shadow public base properties: " + string.Join(", ", collisions.ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashSet<string> ReadPublicProperties(string path)
|
||||||
|
{
|
||||||
|
HashSet<string> names = new HashSet<string>(StringComparer.Ordinal);
|
||||||
|
MatchCollection matches = PublicAutoProperty.Matches(File.ReadAllText(path));
|
||||||
|
foreach (Match match in matches)
|
||||||
|
names.Add(match.Groups[1].Value);
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string FindSourceFile(string fileName)
|
||||||
|
{
|
||||||
|
DirectoryInfo directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
|
||||||
|
while (directory != null)
|
||||||
|
{
|
||||||
|
string candidate = Path.Combine(directory.FullName, "src", "NT8.Adapters", "Strategies", fileName);
|
||||||
|
if (File.Exists(candidate))
|
||||||
|
return candidate;
|
||||||
|
directory = directory.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new FileNotFoundException("Could not locate src\\NT8.Adapters\\Strategies\\" + fileName + " from test output directory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user