Code cleanup.
Some checks failed
Build .NET Project / build (push) Has been cancelled

This commit is contained in:
2026-03-13 15:05:05 -04:00
parent 5fc0cf1961
commit b87dea3473
4 changed files with 9 additions and 112 deletions

View File

@@ -119,6 +119,8 @@ namespace MarketData
else cmParams.TargetBeta=1.00;
DateTime endDate=DateTime.Now;
if(commandArgs.Has("ENDDATE"))endDate=commandArgs.Get<DateTime>("ENDDATE");
String pathSessionFileName=commandArgs.Coalesce<String>("SESSIONFILE",null);
if(null!=pathSessionFileName) pathSessionFileName=pathSessionFileName.Trim();
cmParams.DisplayHeader();

View File

@@ -10,7 +10,8 @@ export DOTNET_ROOT=/opt/dotnet
CNNDAYCOUNT=90
#VERSION=05
VERSION=06
#VERSION=06
VERSION=07
USEMAXPOSITIONBUCKETWEIGHT=TRUE
USEMAXPOSITIONBUCKETWEIGHTMAXWEIGHT=.65
USEOVEREXTENDEDINDICATOR=TRUE
@@ -18,6 +19,7 @@ DAYS=10
VIOLATIONS=1
MARGINPERCENT=1.00
STARTDATE=10-31-2019
ENDDATE=12-31-2025
CNNREWARD=.25
PATHSESSIONFILE="CM${STARTDATE}_OI_${DAYS}_${VIOLATIONS}_MPBW_65_USEOV${USEOVEREXTENDEDINDICATOR}_V${VERSION}.TXT"
@@ -28,7 +30,7 @@ else
echo "Session file not found, proceeding: $PATHSESSIONFILE"
fi
# echo "RUNCMBACKTEST /USECNN:TRUE /USECNNCLIENT:TRUE /USECNNDAYCOUNT:${CNNDAYCOUNT} /USECNNHOST:127.0.0.1:5000 /USECNNREWARDPERCENTDECIMAL:${CNNREWARD} /USEMAXPOSITIONBUCKETWEIGHT:${USEMAXPOSITIONBUCKETWEIGHT} /USEMAXPOSITIONBUCKETWEIGHTMAXWEIGHT:${USEMAXPOSITIONBUCKETWEIGHTMAXWEIGHT} /STARTDATE:${STARTDATE} /MAXPOSITIONS:3 /INITIALCASH:10000 /HOLDINGPERIOD:3 /TARGETBETA:1 /SESSIONFILE:${PATHSESSIONFILE} /USEOVEREXTENDEDINDICATOR:${USEOVEREXTENDEDINDICATOR} /USEOVEREXTENDEDINDICATORDAYS:${DAYS} /USEOVEREXTENDEDINDICATORVIOLATIONTHRESHHOLD:${VIOLATIONS} /USEOVEREXTENDEDINDICATORMARGINPERCENT:${MARGINPERCENT}"
echo "RUNCMBACKTEST /USECNN:TRUE /USECNNCLIENT:TRUE /USECNNDAYCOUNT:${CNNDAYCOUNT} /USECNNHOST:127.0.0.1:5000 /USECNNREWARDPERCENTDECIMAL:${CNNREWARD} /USEMAXPOSITIONBUCKETWEIGHT:${USEMAXPOSITIONBUCKETWEIGHT} /USEMAXPOSITIONBUCKETWEIGHTMAXWEIGHT:${USEMAXPOSITIONBUCKETWEIGHTMAXWEIGHT} /STARTDATE:${STARTDATE} /ENDDATE:${ENDDATE} /MAXPOSITIONS:3 /INITIALCASH:10000 /HOLDINGPERIOD:3 /TARGETBETA:1 /SESSIONFILE:${PATHSESSIONFILE} /USEOVEREXTENDEDINDICATOR:${USEOVEREXTENDEDINDICATOR} /USEOVEREXTENDEDINDICATORDAYS:${DAYS} /USEOVEREXTENDEDINDICATORVIOLATIONTHRESHHOLD:${VIOLATIONS} /USEOVEREXTENDEDINDICATORMARGINPERCENT:${MARGINPERCENT}"
/home/pi/ARM64/MarketData/MarketData/bin/Debug/net8.0/mk RUNCMBACKTEST \
/USECNN:TRUE \
@@ -39,6 +41,7 @@ fi
/USEMAXPOSITIONBUCKETWEIGHT:${USEMAXPOSITIONBUCKETWEIGHT} \
/USEMAXPOSITIONBUCKETWEIGHTMAXWEIGHT:${USEMAXPOSITIONBUCKETWEIGHTMAXWEIGHT} \
/STARTDATE:${STARTDATE} \
/ENDDATE:${ENDDATE} \
/MAXPOSITIONS:3 \
/INITIALCASH:10000 \
/HOLDINGPERIOD:3 \

View File

@@ -175,115 +175,6 @@ namespace MarketData.Numerical
}
return default;
}
// assuming that the list is in descending date order
/// <summary>
/// Fetch the first price of the month for both the asset and the benchmark, allowing both to walk forward in the month by up to 10 days until we get a good price
/// </summary>
/// <param name="symbol"></param>
/// <param name="benchmark"></param>
/// <param name="requestedDate"></param>
/// <param name="symbolPricesByDate"></param>
/// <param name="benchmarkPricesByDate"></param>
/// <returns></returns>
//private static BetaPrice GetPrice(String symbol, String benchmark, DateTime requestedDate, Dictionary<DateTime, Price> symbolPricesByDate, Dictionary<DateTime, Price> benchmarkPricesByDate)
//{
// try
// {
// int maxAdvanceDays = 10;
// Price symbolPrice = default;
// Price benchmarkPrice = default;
// for (int advanceDays = 0; advanceDays < maxAdvanceDays; advanceDays++)
// {
// if (!symbolPricesByDate.ContainsKey(requestedDate))
// {
// requestedDate = requestedDate.AddDays(1);
// continue;
// }
// symbolPrice = symbolPricesByDate[requestedDate];
// if (!benchmarkPricesByDate.ContainsKey(requestedDate))
// {
// requestedDate = requestedDate.AddDays(1);
// continue;
// }
// benchmarkPrice = benchmarkPricesByDate[requestedDate];
// if(null != symbolPrice && null != benchmarkPrice)break;
// }
// if (null == symbolPrice || null == benchmarkPrice) return null;
// symbolPrice.Date = requestedDate.Date;
// benchmarkPrice.Date = requestedDate.Date;
// return new BetaPrice(symbol, benchmark, symbolPrice, benchmarkPrice, requestedDate);
// }
// catch (Exception exception)
// {
// MDTrace.WriteLine(LogLevel.DEBUG, String.Format("Exception:{0}", exception.ToString()));
// return null;
// }
//}
//public static double Beta(String symbol,DateTime asof,int months=36)
//{
// try
// {
// String benchmark = "SPY";
// DateGenerator dateGenerator = new DateGenerator();
// BetaPrices betaPrices = new BetaPrices();
// DateTime startDate = dateGenerator.GetPrevMonthStart(asof);
// DateTime minPricingDate = PricingDA.GetEarliestDate(symbol);
// Dictionary<DateTime, Price> symbolPricesByDate = new Dictionary<DateTime, Price>();
// Dictionary<DateTime, Price> benchmarkPricesByDate = new Dictionary<DateTime, Price>();
// List<DateTime> historicalDates = new List<DateTime>();
// while (historicalDates.Count < (months + 1))
// {
// historicalDates.Add(startDate);
// startDate = dateGenerator.GetPrevMonthStart(startDate);
// }
// DateTime earliestDate = historicalDates[historicalDates.Count - 1];
// Prices symbolPrices = PricingDA.GetPrices(symbol, asof, earliestDate);
// Prices benchmarkPrices = PricingDA.GetPrices(benchmark, asof, earliestDate);
// foreach (Price price in symbolPrices) symbolPricesByDate.Add(price.Date, price);
// foreach (Price price in benchmarkPrices) benchmarkPricesByDate.Add(price.Date, price);
// startDate = dateGenerator.GetPrevMonthStart(asof);
// while (betaPrices.Count < (months + 1))
// {
// BetaPrice betaPrice = GetPrice(symbol, benchmark, startDate, symbolPricesByDate, benchmarkPricesByDate);
// if (null == betaPrice)
// {
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Beta({0},{1}).. Cannot calculate Beta. Missing price on {2}",symbol,Utility.DateTimeToStringMMHDDHYYYY(asof),Utility.DateTimeToStringMMHDDHYYYY(startDate)));
// return double.NaN;
// }
// betaPrices.Add(betaPrice);
// startDate = dateGenerator.GetPrevMonthStart(startDate);
// if (startDate < minPricingDate) break;
// }
// double[] returnsSymbol = betaPrices.ReturnsSymbol();
// double[] returnsBenchmark = betaPrices.ReturnsBenchmark();
// double beta = Numerics.Beta(ref returnsSymbol, ref returnsBenchmark);
// return beta;
// }
// catch (Exception exception)
// {
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Exception:{0}",exception.ToString()));
// return double.NaN;
// }
//}
}
}

View File

@@ -5,7 +5,8 @@ using MarketData.MarketDataModel;
namespace MarketData.Numerical
{
/// <summary>
/// Black Sholes Option Pricing Model for simplest scenario
/// Black Sholes Option Pricing Model for simplest scenario.
/// This is an adoption of the Abramowitz Stegun approximation for the cumulative normal distribution
/// </summary>
public class BlackScholesOptionPricingModel
{