Files
ARM64/MarketData/MarketDataLib/MarketDataModel/StopLimit.cs
Sean 523c2dfb21 StopLimitDA.cs Removed DeleteStopLimt(String symbol)
Added DeleteStopLimit(String symbol, double shares)
               Added GetStopLimits(String symbol)
               Obsoleted GetStopLimit(String symbol)

StopLimit.cs - Commented out references to EffectiveDate
2026-02-05 13:32:00 -05:00

102 lines
3.2 KiB
C#
Executable File

using MarketData.Utils;
using System;
using System.Collections.Generic;
using System.Text;
/// <summary>
/// This StopLimit class is used for database persistence
/// </summary>
namespace MarketData.MarketDataModel
{
public class StopLimitConstants
{
public static readonly String STOP_QUOTE="Stop Quote";
}
public class StopLimits:List<StopLimit>
{
public StopLimits()
{
}
public StopLimits(List<StopLimit> stopLimits)
{
foreach(StopLimit stopLimit in stopLimits) Add(stopLimit);
}
public NVPCollections ToNVPCollections()
{
NVPCollections nvpCollections=new NVPCollections();
foreach(StopLimit stopLimit in this)
{
nvpCollections.Add(stopLimit.ToNVPCollection());
}
return nvpCollections;
}
public static StopLimits FromNVPCollections(NVPCollections nvpCollections)
{
StopLimits stopLimits=new StopLimits();
foreach(NVPCollection nvpCollection in nvpCollections)
{
stopLimits.Add(StopLimit.FromNVPCollection(nvpCollection));
}
return stopLimits;
}
public void AddFromNVPCollection(NVPCollection nvpCollection)
{
Add(StopLimit.FromNVPCollection(nvpCollection));
}
public void Add(StopLimits stopLimits)
{
foreach(StopLimit stopLimit in stopLimits)this.Add(stopLimit);
}
}
public class StopLimit
{
public String Symbol{get;set;}
public double StopPrice{get;set;}
public double Shares{get;set;}
public String StopType{get;set;}
// public DateTime EffectiveDate{get;set;} // if the EffectiveDate is Epoch then the StopLimit is taken to be in effect and is the most recent. Otherwise it is considered an historical stop limit
public StopLimit()
{
}
public override String ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append(Symbol).Append(",");
sb.Append(Utility.FormatCurrency(StopPrice)).Append(",");
sb.Append(Utility.FormatNumber(Shares, 3)).Append(",");
sb.Append(StopType).Append(",");
// sb.Append(EffectiveDate.ToShortDateString());
return sb.ToString();
}
public virtual NVPCollection ToNVPCollection()
{
NVPCollection nvpCollection = new NVPCollection();
nvpCollection.Add(new NVP("Symbol", Symbol.ToString()));
nvpCollection.Add(new NVP("StopPrice", StopPrice.ToString()));
nvpCollection.Add(new NVP("Shares", Shares.ToString()));
nvpCollection.Add(new NVP("StopType", StopType.ToString()));
// nvpCollection.Add(new NVP("EffectiveDate", EffectiveDate.ToShortDateString()));
return nvpCollection;
}
public static StopLimit FromNVPCollection(NVPCollection nvpCollection)
{
StopLimit stopLimit=new StopLimit();
NVPDictionary nvpDictionary=nvpCollection.ToDictionary();
stopLimit.Symbol=nvpDictionary["Symbol"].Get<String>();
stopLimit.StopPrice=nvpDictionary["StopPrice"].Get<double>();
stopLimit.Shares=nvpDictionary["Shares"].Get<double>();
stopLimit.StopType=nvpDictionary["StopType"].Get<String>();
// stopLimit.EffectiveDate=nvpDictionary["EffectiveDate"].Get<DateTime>();
return stopLimit;
}
}
}