109 lines
2.9 KiB
C#
109 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Linq;
|
|
using MarketData.Utils;
|
|
|
|
namespace MarketData.MarketDataModel
|
|
{
|
|
public class SwingTrades : List<SwingTrade>
|
|
{
|
|
public SwingTrades()
|
|
{
|
|
}
|
|
public bool HasEntryOn(DateTime date)
|
|
{
|
|
if(0==Count)return false;
|
|
return 0==this.Select(x => x.EntryDate.Date.Equals(date.Date)).Count()?false:true;
|
|
}
|
|
}
|
|
// *********************************************************************************************************************************************************************************************************
|
|
public class SwingTrade
|
|
{
|
|
public enum TypeOfSwing { Long, Short, LongBand, ShortBand };
|
|
private String symbol;
|
|
private DateTime candleDate;
|
|
private double candleHigh;
|
|
private double stopPrice;
|
|
private DateTime closeDate;
|
|
private DateTime entryDate;
|
|
private TypeOfSwing swingType;
|
|
|
|
public SwingTrade()
|
|
{
|
|
}
|
|
public String Symbol
|
|
{
|
|
get { return symbol; }
|
|
set { symbol = value; }
|
|
}
|
|
public DateTime CandleDate
|
|
{
|
|
get { return candleDate; }
|
|
set { candleDate = value; }
|
|
}
|
|
public double CandleHigh
|
|
{
|
|
get { return candleHigh; }
|
|
set { candleHigh = value; }
|
|
}
|
|
public double StopPrice
|
|
{
|
|
get { return stopPrice; }
|
|
set { stopPrice = value; }
|
|
}
|
|
public DateTime EntryDate
|
|
{
|
|
get { return entryDate; }
|
|
set { entryDate = value; }
|
|
}
|
|
public DateTime CloseDate
|
|
{
|
|
get { return closeDate; }
|
|
set { closeDate = value; }
|
|
}
|
|
public SwingTrade.TypeOfSwing SwingType
|
|
{
|
|
get { return swingType; }
|
|
set { swingType = value; }
|
|
}
|
|
public static String Header
|
|
{
|
|
get { return "Symbol,SwingType,CandleDate,CandleHigh,StopPrice,CloseDate,EntryDate"; }
|
|
}
|
|
public override String ToString()
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append(symbol).Append(",");
|
|
switch (swingType)
|
|
{
|
|
case TypeOfSwing.Long:
|
|
sb.Append("Long").Append(",");
|
|
break;
|
|
case TypeOfSwing.LongBand:
|
|
sb.Append("LongBand").Append(",");
|
|
break;
|
|
case TypeOfSwing.Short:
|
|
sb.Append("Short").Append(",");
|
|
break;
|
|
case TypeOfSwing.ShortBand:
|
|
sb.Append("ShortBand").Append(",");
|
|
break;
|
|
default:
|
|
sb.Append("?,");
|
|
break;
|
|
}
|
|
sb.Append(Utility.DateTimeToStringMMHDDHYYYY(candleDate)).Append(",");
|
|
sb.Append(String.Format("{0:0.00000}", candleHigh)).Append(",");
|
|
sb.Append(String.Format("{0:0.00000}", stopPrice)).Append(",");
|
|
if (Utility.IsEpoch(entryDate)) sb.Append("?,?");
|
|
else
|
|
{
|
|
sb.Append(Utility.DateTimeToStringMMHDDHYYYY(closeDate)).Append(",");
|
|
sb.Append(Utility.DateTimeToStringMMHDDHYYYY(entryDate));
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|