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
This commit is contained in:
@@ -2,6 +2,8 @@ using System.Text;
|
||||
using MySql.Data.MySqlClient;
|
||||
using MarketData.MarketDataModel;
|
||||
using MarketData.Utils;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace MarketData.DataAccess
|
||||
{
|
||||
@@ -11,6 +13,83 @@ namespace MarketData.DataAccess
|
||||
{
|
||||
}
|
||||
|
||||
public static bool DeleteStopLimit(String symbol,double shares)
|
||||
{
|
||||
MySqlConnection sqlConnection = null;
|
||||
MySqlCommand sqlCommand = null;
|
||||
String strQuery = null;
|
||||
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (null == symbol) return false;
|
||||
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));
|
||||
sb.Append("delete from stoplimits ");
|
||||
sb.Append("where symbol='").Append(symbol).Append("'");
|
||||
sb.Append(" ");
|
||||
sb.Append("and shares=").Append(Utility.FormatNumber(shares,3));
|
||||
strQuery = sb.ToString();
|
||||
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
|
||||
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, exception);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (null != sqlCommand) sqlCommand.Dispose();
|
||||
if (null != sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static StopLimits GetStopLimits(String symbol)
|
||||
{
|
||||
MySqlConnection sqlConnection = null;
|
||||
MySqlDataReader sqlDataReader = null;
|
||||
MySqlCommand sqlCommand = null;
|
||||
String strQuery = null;
|
||||
StopLimits stopLimits = new StopLimits();
|
||||
|
||||
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();
|
||||
while (sqlDataReader.Read())
|
||||
{
|
||||
StopLimit stopLimit = new StopLimit();
|
||||
stopLimit.Symbol = sqlDataReader.GetString(0);
|
||||
stopLimit.StopPrice = sqlDataReader.GetDouble(1);
|
||||
stopLimit.Shares = sqlDataReader.GetDouble(2);
|
||||
stopLimit.StopType = sqlDataReader.GetString(3);
|
||||
stopLimits.Add(stopLimit);
|
||||
}
|
||||
return stopLimits;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, exception);
|
||||
return stopLimits;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (null != sqlCommand) sqlCommand.Dispose();
|
||||
if (null != sqlDataReader) { sqlDataReader.Close(); sqlDataReader.Dispose(); }
|
||||
if (null != sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("This method is obsolete. Use GetSopLimits(String symbol) instead.", false)]
|
||||
public static StopLimit GetStopLimit(String symbol)
|
||||
{
|
||||
MySqlConnection sqlConnection = null;
|
||||
@@ -49,12 +128,14 @@ namespace MarketData.DataAccess
|
||||
if (null != sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool InsertUpdateStopLimit(StopLimit stopLimit)
|
||||
{
|
||||
if (null == stopLimit || null == stopLimit.Symbol || double.IsNaN(stopLimit.StopPrice)) return false;
|
||||
if (!HasStopLimit(stopLimit.Symbol)) return InsertStopLimit(stopLimit);
|
||||
return UpdateStopLimit(stopLimit);
|
||||
}
|
||||
|
||||
private static bool InsertStopLimit(StopLimit stopLimit)
|
||||
{
|
||||
MySqlConnection sqlConnection = null;
|
||||
@@ -93,6 +174,7 @@ namespace MarketData.DataAccess
|
||||
if (null != sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool UpdateStopLimit(StopLimit stopLimit)
|
||||
{
|
||||
MySqlConnection sqlConnection = null;
|
||||
@@ -207,35 +289,5 @@ namespace MarketData.DataAccess
|
||||
if (null != sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
public static bool DeleteStopLimit(String symbol)
|
||||
{
|
||||
MySqlConnection sqlConnection = null;
|
||||
MySqlCommand sqlCommand = null;
|
||||
String strQuery = null;
|
||||
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (null == symbol) return false;
|
||||
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));
|
||||
sb.Append("delete from stoplimits ");
|
||||
sb.Append("where symbol='").Append(symbol).Append("'");
|
||||
strQuery = sb.ToString();
|
||||
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
|
||||
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG, exception);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (null != sqlCommand) sqlCommand.Dispose();
|
||||
if (null != sqlConnection) sqlConnection.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user