2018-05-22 10:11:50 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Core.Main;
|
|
|
|
|
using Core.Main.DataObjects.PTMagicData;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
namespace Monitor.Pages
|
|
|
|
|
{
|
|
|
|
|
public class ManageSMSModel : _Internal.BasePageModelSecure
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
public List<SingleMarketSettingSummary> SingleMarketSettingSummaries = new List<SingleMarketSettingSummary>();
|
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
public void OnGet()
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
base.Init();
|
|
|
|
|
|
|
|
|
|
BindData();
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
private void BindData()
|
|
|
|
|
{
|
|
|
|
|
if (System.IO.File.Exists(PTMagicBasePath + Constants.PTMagicPathData + Path.DirectorySeparatorChar + "SingleMarketSettingSummary.json"))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
SingleMarketSettingSummaries = JsonConvert.DeserializeObject<List<SingleMarketSettingSummary>>(System.IO.File.ReadAllText(PTMagicBasePath + Constants.PTMagicPathData + Path.DirectorySeparatorChar + "SingleMarketSettingSummary.json"));
|
2018-12-15 22:07:29 +01:00
|
|
|
|
}
|
|
|
|
|
catch { }
|
2018-05-22 10:11:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string notification = GetStringParameter("n", "");
|
2018-12-15 22:07:29 +01:00
|
|
|
|
if (notification.Equals("SettingReset"))
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
NotifyHeadline = "Setting Reset!";
|
|
|
|
|
NotifyMessage = "The setting will get reset on the next interval!";
|
|
|
|
|
NotifyType = "success";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
public double GetTrendChange(string marketTrend, MarketPairSummary mps, TriggerSnapshot ts, string marketTrendRelation)
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
double result = 0;
|
|
|
|
|
|
2018-12-15 22:07:29 +01:00
|
|
|
|
if (mps.MarketTrendChanges.ContainsKey(marketTrend))
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
result = mps.MarketTrendChanges[marketTrend];
|
|
|
|
|
double averageMarketTrendChange = Summary.MarketTrendChanges[marketTrend].OrderByDescending(mtc => mtc.TrendDateTime).First().TrendChange;
|
2018-12-15 22:07:29 +01:00
|
|
|
|
if (marketTrendRelation.Equals(Constants.MarketTrendRelationAbsolute, StringComparison.InvariantCulture))
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
result = result - averageMarketTrendChange;
|
2018-12-15 22:07:29 +01:00
|
|
|
|
}
|
|
|
|
|
else if (marketTrendRelation.Equals(Constants.MarketTrendRelationRelativeTrigger, StringComparison.InvariantCulture))
|
|
|
|
|
{
|
2018-05-22 10:11:50 +02:00
|
|
|
|
double currentPrice = mps.LatestPrice;
|
|
|
|
|
double triggerPrice = ts.LastPrice;
|
|
|
|
|
double triggerTrend = (currentPrice - triggerPrice) / triggerPrice * 100;
|
|
|
|
|
result = triggerTrend;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|