Add EffectiveDate back to StopLimit
Some checks failed
Build .NET Project / build (push) Has been cancelled
Some checks failed
Build .NET Project / build (push) Has been cancelled
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Text;
|
|||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using MarketData.MarketDataModel;
|
using MarketData.MarketDataModel;
|
||||||
using MarketData.Utils;
|
using MarketData.Utils;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace MarketData.DataAccess
|
namespace MarketData.DataAccess
|
||||||
{
|
{
|
||||||
@@ -87,8 +88,48 @@ namespace MarketData.DataAccess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("This method is obsolete. Use GetSopLimits(String symbol) instead.", false)]
|
// [Obsolete("This method is obsolete. Use GetSopLimits(String symbol) instead.", false)]
|
||||||
public static StopLimit GetStopLimit(String symbol)
|
// public static StopLimit GetStopLimit(String symbol)
|
||||||
|
// {
|
||||||
|
// MySqlConnection sqlConnection = null;
|
||||||
|
// MySqlDataReader sqlDataReader = null;
|
||||||
|
// MySqlCommand sqlCommand = null;
|
||||||
|
// String strQuery = null;
|
||||||
|
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// StringBuilder sb = new StringBuilder();
|
||||||
|
// if (null == symbol) return null;
|
||||||
|
// sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));
|
||||||
|
// sb.Append("select symbol,stop_limit,shares,stop_type from stoplimits ");
|
||||||
|
// sb.Append("where symbol='").Append(symbol).Append("'");
|
||||||
|
// strQuery = sb.ToString();
|
||||||
|
// sqlCommand = new MySqlCommand(strQuery, sqlConnection);
|
||||||
|
// sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
|
||||||
|
// sqlDataReader = sqlCommand.ExecuteReader();
|
||||||
|
// if (!sqlDataReader.Read()) return null;
|
||||||
|
// StopLimit stopLimit = new StopLimit();
|
||||||
|
// stopLimit.Symbol = sqlDataReader.GetString(0);
|
||||||
|
// stopLimit.StopPrice = sqlDataReader.GetDouble(1);
|
||||||
|
// stopLimit.Shares = sqlDataReader.GetDouble(2);
|
||||||
|
// stopLimit.StopType = sqlDataReader.GetString(3);
|
||||||
|
// return stopLimit;
|
||||||
|
// }
|
||||||
|
// catch (Exception exception)
|
||||||
|
// {
|
||||||
|
// MDTrace.WriteLine(LogLevel.DEBUG, exception);
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// finally
|
||||||
|
// {
|
||||||
|
// if (null != sqlCommand) sqlCommand.Dispose();
|
||||||
|
// if (null != sqlDataReader) { sqlDataReader.Close(); sqlDataReader.Dispose(); }
|
||||||
|
// if (null != sqlConnection) sqlConnection.Close();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
public static StopLimit GetStopLimit(String symbol,double shares)
|
||||||
{
|
{
|
||||||
MySqlConnection sqlConnection = null;
|
MySqlConnection sqlConnection = null;
|
||||||
MySqlDataReader sqlDataReader = null;
|
MySqlDataReader sqlDataReader = null;
|
||||||
@@ -102,6 +143,8 @@ namespace MarketData.DataAccess
|
|||||||
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));
|
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));
|
||||||
sb.Append("select symbol,stop_limit,shares,stop_type from stoplimits ");
|
sb.Append("select symbol,stop_limit,shares,stop_type from stoplimits ");
|
||||||
sb.Append("where symbol='").Append(symbol).Append("'");
|
sb.Append("where symbol='").Append(symbol).Append("'");
|
||||||
|
sb.Append(" and ");
|
||||||
|
sb.Append("shares=").Append(Utility.FormatNumber(shares,2));
|
||||||
strQuery = sb.ToString();
|
strQuery = sb.ToString();
|
||||||
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
|
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
|
||||||
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
|
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
|
||||||
@@ -125,7 +168,7 @@ namespace MarketData.DataAccess
|
|||||||
if (null != sqlDataReader) { sqlDataReader.Close(); sqlDataReader.Dispose(); }
|
if (null != sqlDataReader) { sqlDataReader.Close(); sqlDataReader.Dispose(); }
|
||||||
if (null != sqlConnection) sqlConnection.Close();
|
if (null != sqlConnection) sqlConnection.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool InsertUpdateStopLimit(StopLimit stopLimit)
|
public static bool InsertUpdateStopLimit(StopLimit stopLimit)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ namespace MarketData.MarketDataModel
|
|||||||
public double StopPrice{get;set;}
|
public double StopPrice{get;set;}
|
||||||
public double Shares{get;set;}
|
public double Shares{get;set;}
|
||||||
public String StopType{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 StopLimit()
|
||||||
{
|
{
|
||||||
@@ -67,6 +69,7 @@ namespace MarketData.MarketDataModel
|
|||||||
sb.Append(Utility.FormatCurrency(StopPrice)).Append(",");
|
sb.Append(Utility.FormatCurrency(StopPrice)).Append(",");
|
||||||
sb.Append(Utility.FormatNumber(Shares, 3)).Append(",");
|
sb.Append(Utility.FormatNumber(Shares, 3)).Append(",");
|
||||||
sb.Append(StopType).Append(",");
|
sb.Append(StopType).Append(",");
|
||||||
|
sb.Append(EffectiveDate.ToShortDateString());
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +80,7 @@ namespace MarketData.MarketDataModel
|
|||||||
nvpCollection.Add(new NVP("StopPrice", StopPrice.ToString()));
|
nvpCollection.Add(new NVP("StopPrice", StopPrice.ToString()));
|
||||||
nvpCollection.Add(new NVP("Shares", Shares.ToString()));
|
nvpCollection.Add(new NVP("Shares", Shares.ToString()));
|
||||||
nvpCollection.Add(new NVP("StopType", StopType.ToString()));
|
nvpCollection.Add(new NVP("StopType", StopType.ToString()));
|
||||||
|
nvpCollection.Add(new NVP("EffectiveDate",EffectiveDate.ToShortDateString()));
|
||||||
return nvpCollection;
|
return nvpCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +93,7 @@ namespace MarketData.MarketDataModel
|
|||||||
stopLimit.StopPrice=nvpDictionary["StopPrice"].Get<double>();
|
stopLimit.StopPrice=nvpDictionary["StopPrice"].Get<double>();
|
||||||
stopLimit.Shares=nvpDictionary["Shares"].Get<double>();
|
stopLimit.Shares=nvpDictionary["Shares"].Get<double>();
|
||||||
stopLimit.StopType=nvpDictionary["StopType"].Get<String>();
|
stopLimit.StopType=nvpDictionary["StopType"].Get<String>();
|
||||||
|
stopLimit.EffectiveDate=nvpDictionary["EffectiveDate"].Get<DateTime>();
|
||||||
return stopLimit;
|
return stopLimit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user