Add MarketDataServer
This commit is contained in:
55
MarketDataServer/Controllers/PriceController.cs
Executable file
55
MarketDataServer/Controllers/PriceController.cs
Executable file
@@ -0,0 +1,55 @@
|
||||
using MarketData.MarketDataModel;
|
||||
using MarketData.DataAccess;
|
||||
using MarketDataServer.Authorization;
|
||||
using MarketData.Generator;
|
||||
using MarketData;
|
||||
using LogLevel = MarketData.LogLevel;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace MarketDataServer.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
//http://localhost:8000/api/Price
|
||||
//http://localhost:8000/api/Price/GetPrices?&symbol=MIDD&days=5
|
||||
//http://73.245.214.234:8000/api/Price/GetPrices?&symbol=MIDD&days=5
|
||||
|
||||
public class PriceController : ControllerBase
|
||||
{
|
||||
[HttpGet(Name = "GetPrices")]
|
||||
public IEnumerable<Price> GetPrices(String token, String symbol, int days)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetPrices]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
return PricingDA.GetPrices(symbol, days);
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetBollingerBands")]
|
||||
public BollingerBands GetBollingerBands(String token,String symbol,int dayCount)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetBollingerBands]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
Prices prices=PricingDA.GetPrices(symbol,dayCount);
|
||||
BollingerBands bollingerBands=BollingerBandGenerator.GenerateBollingerBands(prices);
|
||||
return bollingerBands;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetLatestPricingDate")]
|
||||
public DateTime GetLatestPricingDate(String token)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PriceController::GetLatestPricingDate]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return DateTime.MinValue;
|
||||
DateTime latestPricingDate=PricingDA.GetLatestDate();
|
||||
return latestPricingDate;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetCompanyNameForSymbol")]
|
||||
public String GetCompanyNameForSymbol(String token, String symbol)
|
||||
{
|
||||
MDTrace.WriteLine(LogLevel.DEBUG,String.Format("[{0:G}][PortfolioController::GetCompanyNameForSymbol]", DateTime.Now));
|
||||
if (!Authorizations.GetInstance().IsAuthorized(token)) return null;
|
||||
String companyName=PricingDA.GetNameForSymbol(symbol);
|
||||
return companyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user