Cleanup DA

This commit is contained in:
2025-04-01 18:29:51 -04:00
parent a97a532d33
commit 377132fae6
34 changed files with 33 additions and 237 deletions

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
@@ -88,17 +87,6 @@ namespace MarketData.DataAccess
sb.Append(" where A.date>=@minDate and A.date<=@maxDate ");
sb.Append(" order by date ");
//sb.Append(" select A.* from ");
//sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings where symbol=").Append(SqlUtils.ToSqlString(symbol));
//sb.Append(" union ");
//sb.Append(" select zr.date,zr.symbol,upper(sm.company) as company,'Zacks' as brokerage_firm,zr.type,zr.zacks_rank as ratings_change,null as price_target from zacksrank zr ");
//sb.Append(" left join securitymaster sm on sm.symbol=zr.symbol ");
//sb.Append(" where zr.symbol=").Append(SqlUtils.ToSqlString(symbol)).Append(" and zr.type is not null ");
//sb.Append(" )A ");
//sb.Append(" where A.date>=").Append(SqlUtils.SqlDate(minDate,true)).Append(" and A.date<=").Append(SqlUtils.SqlDate(maxDate,true));
//sb.Append(" order by date ");
strQuery = sb.ToString(); ;
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
@@ -220,31 +208,6 @@ namespace MarketData.DataAccess
{
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
// sb.Append("set @symbol='").Append(symbol).Append("' COLLATE utf8mb4_unicode_ci ;");
//sb.Append("set @symbol='").Append(symbol).Append("';");
//sb.Append("set @maxDate='").Append(Utility.DateTimeToStringYYYYHMMHDD(maxDate)).Append("';");
//sb.Append(" select A.* from ");
//sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings where symbol=@symbol ");
//sb.Append(" union ");
//sb.Append(" select zr.date,zr.symbol,upper(sm.company) as company,'Zacks' as brokerage_firm,zr.type,zr.zacks_rank as ratings_change,null as price_target from zacksrank zr ");
//sb.Append(" left join securitymaster sm on sm.symbol=zr.symbol ");
//sb.Append(" where zr.symbol=@symbol and zr.type is not null ");
//sb.Append(" )A ");
//sb.Append(" where A.date<=@maxDate ");
//sb.Append(" order by date");
//sb.Append(" select A.* from ");
//sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings where symbol=").Append(SqlUtils.ToSqlString(symbol));
//sb.Append(" union ");
//sb.Append(" select zr.date,zr.symbol,upper(sm.company) as company,'Zacks' as brokerage_firm,zr.type,zr.zacks_rank as ratings_change,null as price_target from zacksrank zr ");
//sb.Append(" left join securitymaster sm on sm.symbol=zr.symbol ");
//sb.Append(" where zr.symbol=").Append(SqlUtils.ToSqlString(symbol)).Append(" and zr.type is not null ");
//sb.Append(" )A ");
//sb.Append(" where A.date<=").Append(SqlUtils.SqlDate(maxDate,true));
//sb.Append(" order by date");
sb.Append("set @symbol='").Append(symbol).Append("';");
sb.Append("set @maxDate='").Append(Utility.DateTimeToStringYYYYHMMHDD(maxDate)).Append("';");
sb.Append(" select A.* from ");
@@ -300,7 +263,6 @@ namespace MarketData.DataAccess
{
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
// sb.Append("set @symbol='").Append(symbol).Append("' COLLATE utf8mb4_unicode_ci ;");
sb.Append("set @symbol='").Append(symbol).Append("';");
sb.Append("set @date='").Append(Utility.DateTimeToStringYYYYHMMHDD(date)).Append("';");
sb.Append(" select A.* from ");
@@ -313,16 +275,6 @@ namespace MarketData.DataAccess
sb.Append(" where A.date=@date ");
sb.Append(" order by A.symbol");
//sb.Append(" select A.* from ");
//sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings where symbol=").Append(SqlUtils.ToSqlString(symbol));
//sb.Append(" union ");
//sb.Append(" select zr.date,zr.symbol,upper(sm.company) as company,'Zacks' as brokerage_firm,zr.type,zr.zacks_rank as ratings_change,null as price_target from zacksrank zr ");
//sb.Append(" left join securitymaster sm on sm.symbol=zr.symbol ");
//sb.Append(" where zr.symbol=@symbol and zr.type is not null ");
//sb.Append(" )A ");
//sb.Append(" where A.date=").Append(SqlUtils.SqlDate(date,true));
//sb.Append(" order by A.symbol");
strQuery = sb.ToString(); ;
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;
@@ -366,18 +318,6 @@ namespace MarketData.DataAccess
{
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
//sb.Append("set @date='").Append(Utility.DateTimeToStringYYYYHMMHDD(date)).Append("';");
//sb.Append(" select A.* from ");
//sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings ");
//sb.Append(" union ");
//sb.Append(" select zr.date,zr.symbol,upper(sm.company) as company,'Zacks' as brokerage_firm,zr.type,zr.zacks_rank as ratings_change,null as price_target from zacksrank zr ");
//sb.Append(" left join securitymaster sm on sm.symbol=zr.symbol ");
//sb.Append(" where zr.type is not null ");
//sb.Append(" )A ");
//sb.Append(" where A.date=@date ");
//sb.Append(" order by A.symbol; ");
//sb.Append("set @date='").Append(Utility.DateTimeToStringYYYYHMMHDD(date)).Append("';");
sb.Append(" select A.* from ");
sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings ");
sb.Append(" union ");
@@ -432,25 +372,6 @@ namespace MarketData.DataAccess
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("market_data"));
//sb.Append(" set @symbol='").Append(symbol).Append("';");
//sb.Append(" select A.* from ");
//sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings where symbol=@symbol ");
//sb.Append(" union ");
//sb.Append(" select zr.date,zr.symbol,upper(sm.company) as company,'Zacks' as brokerage_firm,zr.type,zr.zacks_rank as ratings_change,null as price_target from zacksrank zr ");
//sb.Append(" left join securitymaster sm on sm.symbol=zr.symbol ");
//sb.Append(" where zr.symbol=@symbol and zr.type is not null ");
//sb.Append(" )A ");
//sb.Append(" order by date desc ");
//sb.Append(" select A.* from ");
//sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings where symbol=").Append(SqlUtils.ToSqlString(symbol));
//sb.Append(" union ");
//sb.Append(" select zr.date,zr.symbol,upper(sm.company) as company,'Zacks' as brokerage_firm,zr.type,zr.zacks_rank as ratings_change,null as price_target from zacksrank zr ");
//sb.Append(" left join securitymaster sm on sm.symbol=zr.symbol ");
//sb.Append(" where zr.symbol=").Append(SqlUtils.ToSqlString(symbol)).Append(" and zr.type is not null ");
//sb.Append(" )A ");
//sb.Append(" order by date desc ");
sb.Append(" set @symbol='").Append(symbol).Append("';");
sb.Append(" select A.* from ");
sb.Append(" (select date,symbol,upper(company),brokerage_firm,type,ratings_change,price_target from analystratings where symbol=@symbol ");
@@ -461,7 +382,6 @@ namespace MarketData.DataAccess
sb.Append(" )A ");
sb.Append(" order by date desc ");
strQuery = sb.ToString(); ;
sqlCommand = new MySqlCommand(strQuery, sqlConnection);
sqlCommand.CommandTimeout = SqlUtils.COMMAND_TIMEOUT;

View File

@@ -1,6 +1,4 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;
@@ -98,7 +96,6 @@ namespace MarketData.DataAccess
{
StringBuilder sb = new StringBuilder();
sqlConnection = SqlUtils.CreateMySqlConnection(MainDataSource.Instance.LocateDataSource("portfolio_data"));
// sb.Append("select sum(a.balance) from (select account,balance,date from cash b group by account desc) a");
sb.Append("select sum(balance) from cash");
strQuery = sb.ToString();
sqlCommand = new MySqlCommand(strQuery, sqlConnection);

View File

@@ -1,6 +1,4 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,5 +1,4 @@
using System;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,5 +1,4 @@
using System;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;
@@ -38,7 +37,6 @@ namespace MarketData.DataAccess
sb.Append("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;select 'Splits' description,count(*), modified from splits group by 3 order by modified desc");
break;
case FeedStatistic.FeedStatisticType.SECURITY_MASTER:
// sb.Append("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;select 'Security Master' description,count(*), date(create_date) from securitymaster group by 3 order by create_date desc");
sb.Append("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;select 'Security Master' description,count(*), date(create_date) from securitymaster group by 3 order by 3 desc");
break;
case FeedStatistic.FeedStatisticType.SEC_FILINGS:

View File

@@ -1,7 +1,4 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;
@@ -231,7 +228,6 @@ namespace MarketData.DataAccess
if (null == dividendHistoryItem.PaymentDate) sb.Append("null").Append(",");
else sb.Append(SqlUtils.AddQuotes(Utility.DateTimeToStringYYYYHMMHDD(dividendHistoryItem.PaymentDate.Value))).Append(",");
// sb.Append(SqlUtils.AddQuotes(Utility.DateTimeToStringYYYYHMMHDD(modified)));
sb.Append(SqlUtils.AddQuotes(SqlUtils.ToSqlDateTime(modified)));
sb.Append(")");
strQuery = sb.ToString();

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,7 +1,4 @@
using System;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,7 +1,4 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,8 +1,4 @@
using System;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,9 +1,5 @@
using System;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;
namespace MarketData.DataAccess

View File

@@ -1,6 +1,4 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,10 +1,5 @@
using System;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;
namespace MarketData.DataAccess

View File

@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;
using MarketData.Numerical;
namespace MarketData.DataAccess
{

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;
@@ -13,9 +10,6 @@ namespace MarketData.DataAccess
private PremarketDA()
{
}
//SELECT market, change_value,change_percent,timestamp, STR_TO_DATE(SUBSTRING(TIMESTAMP,12,11),'%h:%i:%s %p') time_of_day,CONVERT(TIMESTAMP,DATE) AS the_day
//FROM premarket WHERE market='S&P' ORDER BY the_day DESC, time_of_day DESC
public static bool AddElements(PremarketElements premarketElements)
{
MySqlConnection sqlConnection=null;

View File

@@ -1,7 +1,4 @@
using System;
using System.Text;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,5 +1,4 @@
using System;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.Utils;
using MarketData.MarketDataModel.User;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text;
using MySql.Data.MySqlClient;
using MarketData.MarketDataModel;
using MarketData.Utils;

View File

@@ -1,6 +1,5 @@
using System.Text;
using System.IO.Compression;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using MarketData.MarketDataModel;
@@ -98,6 +97,7 @@ namespace MarketData.Utils
{
DateTime creationTime = File.GetCreationTime(logFile);
int age = dateGenerator.DaysBetweenActual(currentDate, creationTime);
MDTrace.WriteLine($"[ExpireLogs ]{logFile} is {age} {(age>1?"days":"day")} old");
if(age>=expiryDays)
{
File.Delete(logFile);
@@ -107,45 +107,6 @@ namespace MarketData.Utils
}
}
// public static void RemoveLogFiles(String strFolder=null)
// {
// if(null==strFolder)strFolder=Directory.GetCurrentDirectory();
// String[] logFiles=Directory.GetFiles(strFolder);
// if(null==logFiles || 0==logFiles.Length)return;
// logFiles=logFiles.Where(x => x.EndsWith(".log",StringComparison.InvariantCultureIgnoreCase)).ToArray<String>();
// if(null==logFiles || 0==logFiles.Length)return;
// foreach(String logFile in logFiles)
// {
// try
// {
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Removing {0}",logFile));
// File.Delete(logFile);
// }
// catch(Exception){;}
// }
// }
// public static void RemoveLogFilesExcept(String exceptFile,String strFolder=null)
// {
// if(null==strFolder)strFolder=Directory.GetCurrentDirectory();
// String[] logFiles=Directory.GetFiles(strFolder,"*.log");
// if(null==logFiles || 0==logFiles.Length)return;
// logFiles=logFiles
// .Where(x => x.EndsWith(".log",StringComparison.InvariantCultureIgnoreCase) &&
// !x.EndsWith(exceptFile,StringComparison.InvariantCultureIgnoreCase)).ToArray<String>();
// if(null==logFiles || 0==logFiles.Length)return;
// foreach(String logFile in logFiles)
// {
// try
// {
// MDTrace.WriteLine(LogLevel.DEBUG,String.Format("Removing {0}",logFile));
// File.Delete(logFile);
// }
// catch(Exception){;}
// }
// }
public static String Pad(string str, char filler, int length)
{
int stringLength = str.Length;