Changes for MGSHBacktest model.
Code cleanup.
This commit is contained in:
@@ -5,6 +5,10 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
/// <summary>
|
||||
/// This StopLimit class is used by models and the UI
|
||||
/// </summary>
|
||||
|
||||
namespace MarketData.Generator.Model
|
||||
{
|
||||
public class StopLimits:List<StopLimit>
|
||||
@@ -53,6 +57,7 @@ namespace MarketData.Generator.Model
|
||||
this.CurrentPriceLow=stopLimit.CurrentPriceLow;
|
||||
this.CurrentPriceClose=stopLimit.CurrentPriceClose;
|
||||
this.PriceTrendIndicatorSlope=stopLimit.PriceTrendIndicatorSlope;
|
||||
this.StopLimitId=stopLimit.StopLimitId;
|
||||
}
|
||||
public StopLimit(String symbol,DateTime analysisDate,double previousStop,double newStop,double currentPriceLow,double currentPriceClose,double priceTrendIndicatorSlope)
|
||||
{
|
||||
@@ -71,15 +76,17 @@ namespace MarketData.Generator.Model
|
||||
public double CurrentPriceLow{get;set;}
|
||||
public double CurrentPriceClose{get;set;}
|
||||
public double PriceTrendIndicatorSlope{get;set;}
|
||||
public String StopLimitId {get;set;}
|
||||
public static String Header()
|
||||
{
|
||||
StringBuilder sb=new StringBuilder();
|
||||
sb.Append("Symbol,AnalysisDate,PreviousStop,NewStop,CurrentPriceLow,CurrentPriceClose,PriceTrendIndicatorSlope");
|
||||
sb.Append("Id,Symbol,AnalysisDate,PreviousStop,NewStop,CurrentPriceLow,CurrentPriceClose,PriceTrendIndicatorSlope");
|
||||
return sb.ToString();
|
||||
}
|
||||
public override String ToString()
|
||||
{
|
||||
StringBuilder sb=new StringBuilder();
|
||||
sb.Append(null==StopLimitId?"":StopLimitId).Append(",");
|
||||
sb.Append(Symbol).Append(",");
|
||||
sb.Append(AnalysisDate.ToShortDateString()).Append(",");
|
||||
sb.Append(Utility.FormatCurrency(PreviousStop)).Append(",");
|
||||
@@ -99,6 +106,7 @@ namespace MarketData.Generator.Model
|
||||
nvpCollection.Add(new NVP("CurrentPriceLow",CurrentPriceLow.ToString()));
|
||||
nvpCollection.Add(new NVP("CurrentPriceClose",CurrentPriceClose.ToString()));
|
||||
nvpCollection.Add(new NVP("PriceTrendIndicatorSlope",PriceTrendIndicatorSlope.ToString()));
|
||||
nvpCollection.Add(new NVP("StopLimitId",StopLimitId==null?"":StopLimitId));
|
||||
return nvpCollection;
|
||||
}
|
||||
public static StopLimit FromNVPCollection(NVPCollection nvpCollection)
|
||||
@@ -113,6 +121,7 @@ namespace MarketData.Generator.Model
|
||||
stopLimit.CurrentPriceLow=nvpDictionary["CurrentPriceLow"].Get<double>();
|
||||
stopLimit.CurrentPriceClose=nvpDictionary["CurrentPriceClose"].Get<double>();
|
||||
stopLimit.PriceTrendIndicatorSlope=nvpDictionary["PriceTrendIndicatorSlope"].Get<double>();
|
||||
if(nvpDictionary.ContainsKey("StopLimitId"))stopLimit.StopLimitId=nvpDictionary["StopLimitId"].Get<String>();
|
||||
return stopLimit;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user