Add profiling to MarketDataServer controllers

This commit is contained in:
2025-04-27 10:55:25 -04:00
parent cebf9f63e6
commit 1c1c0c35f4
9 changed files with 161 additions and 32 deletions

View File

@@ -21,9 +21,10 @@ namespace MarketDataServer.Controllers
[HttpGet] [HttpGet]
public IEnumerable<GainLossSummaryItem> GetGainLossByDate(String token,DateTime selectedDate) public IEnumerable<GainLossSummaryItem> GetGainLossByDate(String token,DateTime selectedDate)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetGainLoss](String token, DateTime selectedDate)", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
LocalPriceCache.GetInstance().Refresh(); LocalPriceCache.GetInstance().Refresh();
PortfolioTrades portfolioTrades = PortfolioDA.GetTrades(); PortfolioTrades portfolioTrades = PortfolioDA.GetTrades();
@@ -59,14 +60,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet] [HttpGet]
public IEnumerable<GainLossSummaryItem> GetGainLossByDateAndAccount(String token,DateTime selectedDate,String account) public IEnumerable<GainLossSummaryItem> GetGainLossByDateAndAccount(String token,DateTime selectedDate,String account)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetGainLoss](String token, DateTime selectedDate,String account)", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
LocalPriceCache.GetInstance().Refresh(); LocalPriceCache.GetInstance().Refresh();
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
PortfolioTrades portfolioTrades = PortfolioDA.GetTrades(); PortfolioTrades portfolioTrades = PortfolioDA.GetTrades();
@@ -103,14 +109,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet] [HttpGet]
public IEnumerable<GainLossSummaryItemDetail> GetGainLossWithDetailByDate(String token,DateTime selectedDate) public IEnumerable<GainLossSummaryItemDetail> GetGainLossWithDetailByDate(String token,DateTime selectedDate)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetGainLossWithDetail](String token, DateTime selectedDate)", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
LocalPriceCache.GetInstance().Refresh(); LocalPriceCache.GetInstance().Refresh();
PortfolioTrades portfolioTrades = PortfolioDA.GetTrades(); PortfolioTrades portfolioTrades = PortfolioDA.GetTrades();
@@ -197,14 +208,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet] [HttpGet]
public IEnumerable<GainLossSummaryItemDetail> GetGainLossWithDetailByDateAndAccount(String token, DateTime selectedDate, String account) public IEnumerable<GainLossSummaryItemDetail> GetGainLossWithDetailByDateAndAccount(String token, DateTime selectedDate, String account)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetGainLossWithDetail](String token, DateTime selectedDate,String account)", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
LocalPriceCache.GetInstance().Refresh(); LocalPriceCache.GetInstance().Refresh();
PortfolioTrades portfolioTrades = PortfolioDA.GetTrades(); PortfolioTrades portfolioTrades = PortfolioDA.GetTrades();
@@ -292,14 +308,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetCompoundGainLoss")] [HttpGet(Name = "GetCompoundGainLoss")]
public GainLossCompoundModelCollection GetCompoundGainLoss(String token, int selectedDays, bool includeDividends) public GainLossCompoundModelCollection GetCompoundGainLoss(String token, int selectedDays, bool includeDividends)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][GainLossController::GetCompundGainLoss](String token, int days)", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if(!Authorizations.GetInstance().IsAuthorized(token)) return null; if(!Authorizations.GetInstance().IsAuthorized(token)) return null;
LocalPriceCache.GetInstance().Refresh(); LocalPriceCache.GetInstance().Refresh();
DividendPayments dividendPayments = null; DividendPayments dividendPayments = null;
@@ -323,6 +344,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
} }
} }

View File

@@ -4,6 +4,7 @@ using MarketDataServer.Authorization;
using MarketData; using MarketData;
using LogLevel = MarketData.LogLevel; using LogLevel = MarketData.LogLevel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using MarketData.Utils;
namespace MarketDataServer.Controllers namespace MarketDataServer.Controllers
{ {
@@ -14,9 +15,10 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetLatestHeadlines")] [HttpGet(Name = "GetLatestHeadlines")]
public IEnumerable<Headline> GetLatestHeadlines(String token) public IEnumerable<Headline> GetLatestHeadlines(String token)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][HeadlinesController::GetLatestHeadlines]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return HeadlinesDA.GetLatestHeadlines(); return HeadlinesDA.GetLatestHeadlines();
} }
@@ -25,14 +27,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetHeadlineDates")] [HttpGet(Name = "GetHeadlineDates")]
public IEnumerable<String> GetHeadlineDates(String token) public IEnumerable<String> GetHeadlineDates(String token)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][HeadlinesController::GetHeadlineDates]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
List<string> headlineDates = HeadlinesDA.GetHeadlineDates(); List<string> headlineDates = HeadlinesDA.GetHeadlineDates();
if(headlineDates.Count>0)headlineDates=headlineDates.Take(252).ToList(); if(headlineDates.Count>0)headlineDates=headlineDates.Take(252).ToList();
@@ -43,14 +50,18 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
} finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
} }
[HttpGet(Name = "GetHeadlines")] [HttpGet(Name = "GetHeadlines")]
public IEnumerable<Headline> GetHeadlines(String token,DateTime headlineDate) public IEnumerable<Headline> GetHeadlines(String token,DateTime headlineDate)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][HeadlinesController::GetHeadliness(DateTime headlineDate)]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return HeadlinesDA.GetHeadlines(headlineDate); return HeadlinesDA.GetHeadlines(headlineDate);
} }
@@ -59,6 +70,9 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
} finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using MarketData; using MarketData;
using MarketData.Utils;
using MarketDataServer.Authorization; using MarketDataServer.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using LogLevel = MarketData.LogLevel; using LogLevel = MarketData.LogLevel;
@@ -12,20 +13,21 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetToken")] [HttpGet(Name = "GetToken")]
public String GetToken(String user, String password) public String GetToken(String user, String password)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][AuthorizationController::Authorize]",DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if(null==user)return null; if(null==user)return null;
user=Authorizations.Xor(user,5); user=Authorizations.Xor(user,5);
password=Authorizations.Xor(password,5); password=Authorizations.Xor(password,5);
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][Login requested for user '{1}']",DateTime.Now, user)); MDTrace.WriteLine(LogLevel.DEBUG,$"Login requested for user '{user}'");
if(!Authorizations.GetInstance().IsValidUser(user, password)) if(!Authorizations.GetInstance().IsValidUser(user, password))
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][User '{1}' is not authorized]", DateTime.Now,user)); MDTrace.WriteLine(LogLevel.DEBUG,$"User '{user}' is not authorized.");
return null; return null;
} }
String accessToken= Authorizations.GetInstance().GetAuthenticationToken(); String accessToken= Authorizations.GetInstance().GetAuthenticationToken();
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][Access token granted for user {1} : {2}]",DateTime.Now ,user, accessToken)); MDTrace.WriteLine(LogLevel.DEBUG,$"Access token granted for user {user} : {accessToken}.");
return accessToken; return accessToken;
} }
catch(Exception exception) catch(Exception exception)
@@ -33,6 +35,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using MarketData; using MarketData;
using MarketData.Utils;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using LogLevel = MarketData.LogLevel; using LogLevel = MarketData.LogLevel;
@@ -12,14 +13,18 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetPing")] [HttpGet(Name = "GetPing")]
public bool GetPing() public bool GetPing()
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PingController::GetPing]", DateTime.Now)); Profiler profiler = new Profiler();
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
return true; return true;
} }
[HttpGet(Name = "GetSystemInfo")] [HttpGet(Name = "GetSystemInfo")]
public String GetSystemInfo() public String GetSystemInfo()
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PingController::GetSystemInfo]", DateTime.Now)); Profiler profiler = new Profiler();
MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
return Environment.OSVersion.VersionString; return Environment.OSVersion.VersionString;
} }
} }

View File

@@ -5,6 +5,7 @@ using MarketData.Generator;
using MarketData; using MarketData;
using LogLevel = MarketData.LogLevel; using LogLevel = MarketData.LogLevel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using MarketData.Utils;
namespace MarketDataServer.Controllers namespace MarketDataServer.Controllers
{ {
@@ -20,9 +21,10 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetOpenPositionsWithDescription")] [HttpGet(Name = "GetOpenPositionsWithDescription")]
public IEnumerable<PositionWithDescription> GetOpenPositionsWithDescription(String token) public IEnumerable<PositionWithDescription> GetOpenPositionsWithDescription(String token)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetOpenPositionsWithDescriptionAsOf]",DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
List<PositionWithDescription> positionsWithDescription=new List<PositionWithDescription>(); List<PositionWithDescription> positionsWithDescription=new List<PositionWithDescription>();
PortfolioTrades openTrades=PortfolioDA.GetOpenTrades(); PortfolioTrades openTrades=PortfolioDA.GetOpenTrades();
@@ -39,15 +41,20 @@ namespace MarketDataServer.Controllers
{ {
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetAccounts")] [HttpGet(Name = "GetAccounts")]
public IEnumerable<String> GetAccounts(String token) public IEnumerable<String> GetAccounts(String token)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetAccounts]",DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return PortfolioDA.GetAccounts(); return PortfolioDA.GetAccounts();
} }
@@ -56,14 +63,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetAccountsWithOpenTrades")] [HttpGet(Name = "GetAccountsWithOpenTrades")]
public IEnumerable<String> GetAccountsWithOpenTrades(String token) public IEnumerable<String> GetAccountsWithOpenTrades(String token)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetAccountsWithOpenTrades]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return PortfolioDA.GetAccountsWithOpenTrades(); return PortfolioDA.GetAccountsWithOpenTrades();
} }
@@ -72,14 +84,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetStopLimit")] [HttpGet(Name = "GetStopLimit")]
public StopLimit GetStopLimit(String token,String symbol) public StopLimit GetStopLimit(String token,String symbol)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetStopLimit]",DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if(!Authorizations.GetInstance().IsAuthorized(token)) return null; if(!Authorizations.GetInstance().IsAuthorized(token)) return null;
StopLimit stopLimit=PortfolioDA.GetStopLimit(symbol); StopLimit stopLimit=PortfolioDA.GetStopLimit(symbol);
return stopLimit; return stopLimit;
@@ -89,14 +106,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetPortfolioTradesWithParityPrice")] [HttpGet(Name = "GetPortfolioTradesWithParityPrice")]
public PortfolioTradesWithParityPrice GetPortfolioTradesWithParityPrice(String token, String symbol) public PortfolioTradesWithParityPrice GetPortfolioTradesWithParityPrice(String token, String symbol)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetPortfolioTradesWithParityPrice]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
Price zeroPrice=null; Price zeroPrice=null;
DateTime latestPricingDate=PricingDA.GetLatestDate(symbol); DateTime latestPricingDate=PricingDA.GetLatestDate(symbol);
@@ -114,6 +136,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
} }
} }

View File

@@ -4,6 +4,7 @@ using MarketDataServer.Authorization;
using MarketData; using MarketData;
using LogLevel = MarketData.LogLevel; using LogLevel = MarketData.LogLevel;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using MarketData.Utils;
namespace MarketDataServer.Controllers namespace MarketDataServer.Controllers
{ {
@@ -15,9 +16,10 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetAvailableMarketDates")] [HttpGet(Name = "GetAvailableMarketDates")]
public IEnumerable<DateTime> GetAvailableMarketDates(String token,String market) public IEnumerable<DateTime> GetAvailableMarketDates(String token,String market)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PreMarketController::GetAvailableMarketDates]{1}",DateTime.Now,market)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if(!Authorizations.GetInstance().IsAuthorized(token)) return null; if(!Authorizations.GetInstance().IsAuthorized(token)) return null;
return PremarketDA.GetAvailableMarketDates(market); return PremarketDA.GetAvailableMarketDates(market);
} }
@@ -26,14 +28,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetAvailableMarkets")] [HttpGet(Name = "GetAvailableMarkets")]
public IEnumerable<String> GetAvailableMarkets(String token) public IEnumerable<String> GetAvailableMarkets(String token)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PreMarketController::GetAvailableMarkets]",DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if(!Authorizations.GetInstance().IsAuthorized(token)) return null; if(!Authorizations.GetInstance().IsAuthorized(token)) return null;
return PremarketDA.GetDistinctMarkets(); return PremarketDA.GetDistinctMarkets();
} }
@@ -42,14 +49,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetLatestPremarketData")] [HttpGet(Name = "GetLatestPremarketData")]
public IEnumerable<PremarketElement> GetLatestPremarketData(String token,String market,DateTime marketDate) public IEnumerable<PremarketElement> GetLatestPremarketData(String token,String market,DateTime marketDate)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PreMarketController::GetLatestPremarketData]{1},{2}",DateTime.Now,market,marketDate.ToShortDateString())); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if(!Authorizations.GetInstance().IsAuthorized(token)) return null; if(!Authorizations.GetInstance().IsAuthorized(token)) return null;
return PremarketDA.GetLatestPremarketData(market,marketDate); return PremarketDA.GetLatestPremarketData(market,marketDate);
} }
@@ -58,6 +70,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
} }
} }

View File

@@ -20,9 +20,10 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetPrices")] [HttpGet(Name = "GetPrices")]
public IEnumerable<Price> GetPrices(String token, String symbol, int days) public IEnumerable<Price> GetPrices(String token, String symbol, int days)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetPrices]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return PricingDA.GetPrices(symbol, days); return PricingDA.GetPrices(symbol, days);
} }
@@ -31,14 +32,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetBollingerBands")] [HttpGet(Name = "GetBollingerBands")]
public BollingerBands GetBollingerBands(String token,String symbol,int dayCount) public BollingerBands GetBollingerBands(String token,String symbol,int dayCount)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetBollingerBands]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
Prices prices=PricingDA.GetPrices(symbol,dayCount); Prices prices=PricingDA.GetPrices(symbol,dayCount);
BollingerBands bollingerBands=BollingerBandGenerator.GenerateBollingerBands(prices); BollingerBands bollingerBands=BollingerBandGenerator.GenerateBollingerBands(prices);
@@ -49,14 +55,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetLatestPricingDate")] [HttpGet(Name = "GetLatestPricingDate")]
public DateTime GetLatestPricingDate(String token) public DateTime GetLatestPricingDate(String token)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetLatestPricingDate]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return DateTime.MinValue; if (!Authorizations.GetInstance().IsAuthorized(token)) return DateTime.MinValue;
DateTime latestPricingDate=PricingDA.GetLatestDate(); DateTime latestPricingDate=PricingDA.GetLatestDate();
return latestPricingDate; return latestPricingDate;
@@ -66,14 +77,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return Utility.Epoch; return Utility.Epoch;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetCompanyNameForSymbol")] [HttpGet(Name = "GetCompanyNameForSymbol")]
public String GetCompanyNameForSymbol(String token, String symbol) public String GetCompanyNameForSymbol(String token, String symbol)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetCompanyNameForSymbol]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
String companyName=PricingDA.GetNameForSymbol(symbol); String companyName=PricingDA.GetNameForSymbol(symbol);
return companyName; return companyName;
@@ -83,6 +99,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
} }
} }

View File

@@ -4,6 +4,7 @@ using MarketDataServer.Authorization;
using MarketData; using MarketData;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using LogLevel = MarketData.LogLevel; using LogLevel = MarketData.LogLevel;
using MarketData.Utils;
namespace MarketDataServer.Controllers namespace MarketDataServer.Controllers
{ {
@@ -15,9 +16,10 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetDistinctPriceIndices")] [HttpGet(Name = "GetDistinctPriceIndices")]
public IEnumerable<String> GetDistinctPriceIndices(String token) public IEnumerable<String> GetDistinctPriceIndices(String token)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceIndexController::GetDistinctPriceIndices]",DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return ConsumerPriceIndexDA.GetDistinctIndices(); return ConsumerPriceIndexDA.GetDistinctIndices();
} }
@@ -26,14 +28,19 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
[HttpGet(Name = "GetConsumerPriceIndex")] [HttpGet(Name = "GetConsumerPriceIndex")]
public IEnumerable<PriceIndex> GetConsumerPriceIndex(String token,String indexCode) public IEnumerable<PriceIndex> GetConsumerPriceIndex(String token,String indexCode)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceIndexController::GetOpenPositionsWithDescriptionAsOf]",DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
PriceIndices priceIndices=ConsumerPriceIndexDA.GetConsumerPriceIndex(indexCode); PriceIndices priceIndices=ConsumerPriceIndexDA.GetConsumerPriceIndex(indexCode);
return priceIndices; return priceIndices;
@@ -43,6 +50,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
} }
} }

View File

@@ -1,5 +1,6 @@
using MarketData; using MarketData;
using MarketData.DataAccess; using MarketData.DataAccess;
using MarketData.Utils;
using MarketDataServer.Authorization; using MarketDataServer.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using LogLevel = MarketData.LogLevel; using LogLevel = MarketData.LogLevel;
@@ -13,9 +14,10 @@ namespace MarketDataServer.Controllers
[HttpGet(Name = "GetWatchList")] [HttpGet(Name = "GetWatchList")]
public IEnumerable<String> GetWatchList(String token,String watchList) public IEnumerable<String> GetWatchList(String token,String watchList)
{ {
Profiler profiler = new Profiler();
try try
{ {
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][WatchListController::GetWatchList]", DateTime.Now)); MDTrace.WriteLine(LogLevel.DEBUG,$"Start");
if (!Authorizations.GetInstance().IsAuthorized(token)) return null; if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
return WatchListDA.GetWatchList(watchList); return WatchListDA.GetWatchList(watchList);
} }
@@ -24,6 +26,10 @@ namespace MarketDataServer.Controllers
MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}"); MDTrace.WriteLine(LogLevel.DEBUG,$"Exception:{exception.ToString()}");
return null; return null;
} }
finally
{
MDTrace.WriteLine(LogLevel.DEBUG,$"Done, total took {profiler.End()} (ms)");
}
} }
} }
} }