commit
1cb708f0fc
|
@ -536,20 +536,14 @@ namespace Core.Helper
|
||||||
string result = "#";
|
string result = "#";
|
||||||
if (platform.Equals("TradingView"))
|
if (platform.Equals("TradingView"))
|
||||||
{
|
{
|
||||||
result = "https://www.tradingview.com/symbols/" + market.ToUpper() + "/?exchange=" + exchange.ToUpper();
|
if (exchange.Equals("binancefutures", StringComparison.InvariantCultureIgnoreCase))
|
||||||
}
|
|
||||||
else if (platform.Equals("TradingViewFutures"))
|
|
||||||
{
|
|
||||||
result = "https://www.tradingview.com/chart/?symbol=";
|
|
||||||
|
|
||||||
string pairName = SystemHelper.StripBadCode(market, Constants.WhiteListMinimal);
|
|
||||||
|
|
||||||
if (pairName.StartsWith(mainMarket))
|
|
||||||
{
|
{
|
||||||
pairName = pairName.Replace(mainMarket, "") + mainMarket;
|
result = "https://uk.tradingview.com/chart/?symbol=BINANCE:" + market.ToUpper() + "PERP";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = "https://uk.tradingview.com/?symbol=" + exchange.ToUpper() + ":" + market.ToUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
result += pairName + "PERP";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -614,7 +608,15 @@ namespace Core.Helper
|
||||||
pairName = pairName.Replace(mainMarket, "") + mainMarket;
|
pairName = pairName.Replace(mainMarket, "") + mainMarket;
|
||||||
}
|
}
|
||||||
|
|
||||||
result += pairName;
|
if (exchange.Equals("binancefutures", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
result = "BINANCE:" + pairName + "PERP";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += pairName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -161,7 +161,12 @@ namespace Monitor.Pages
|
||||||
double AvailableBalance = PTData.GetCurrentBalance();
|
double AvailableBalance = PTData.GetCurrentBalance();
|
||||||
foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in PTData.DCALog)
|
foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in PTData.DCALog)
|
||||||
{
|
{
|
||||||
totalCurrentValue = totalCurrentValue + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage != 0 ? dcaLogEntry.Leverage : 1);
|
double leverage = dcaLogEntry.Leverage;
|
||||||
|
if (leverage == 0)
|
||||||
|
{
|
||||||
|
leverage = 1;
|
||||||
|
}
|
||||||
|
totalCurrentValue = totalCurrentValue + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / leverage);
|
||||||
}
|
}
|
||||||
totalCurrentValue = totalCurrentValue + AvailableBalance;
|
totalCurrentValue = totalCurrentValue + AvailableBalance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,7 +243,6 @@
|
||||||
<select name="Monitor_LinkPlatform" class="form-control">
|
<select name="Monitor_LinkPlatform" class="form-control">
|
||||||
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("Exchange", StringComparison.InvariantCultureIgnoreCase))">Exchange</option>
|
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("Exchange", StringComparison.InvariantCultureIgnoreCase))">Exchange</option>
|
||||||
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("TradingView", StringComparison.InvariantCultureIgnoreCase))">TradingView</option>
|
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("TradingView", StringComparison.InvariantCultureIgnoreCase))">TradingView</option>
|
||||||
<option selected="@(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform.Equals("TradingViewFutures", StringComparison.InvariantCultureIgnoreCase))">TradingViewFutures</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -177,35 +177,22 @@ namespace Monitor.Pages
|
||||||
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
|
string sellStrategyText = Core.ProfitTrailer.StrategyHelper.GetStrategyText(Summary, dcaLogEntry.SellStrategies, dcaLogEntry.SellStrategy, isSellStrategyTrue, isTrailingSellActive);
|
||||||
|
|
||||||
// Aggregate totals
|
// Aggregate totals
|
||||||
if (dcaLogEntry.Leverage == 0)
|
double leverage = dcaLogEntry.Leverage;
|
||||||
|
if (leverage == 0)
|
||||||
{
|
{
|
||||||
if (sellStrategyText.Contains("PENDING"))
|
leverage = 1;
|
||||||
{
|
}
|
||||||
PendingBalance = PendingBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
|
if (sellStrategyText.Contains("PENDING"))
|
||||||
}
|
{
|
||||||
else if (dcaLogEntry.BuyStrategies.Count > 0)
|
PendingBalance = PendingBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / leverage);
|
||||||
{
|
}
|
||||||
DCABalance = DCABalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
|
else if (dcaLogEntry.BuyStrategies.Count > 0)
|
||||||
}
|
{
|
||||||
else
|
DCABalance = DCABalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / leverage);
|
||||||
{
|
|
||||||
PairsBalance = PairsBalance + (dcaLogEntry.Amount * dcaLogEntry.CurrentPrice);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sellStrategyText.Contains("PENDING"))
|
PairsBalance = PairsBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / leverage);
|
||||||
{
|
|
||||||
PendingBalance = PendingBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage != 0 ? dcaLogEntry.Leverage : 1);
|
|
||||||
}
|
|
||||||
else if (dcaLogEntry.BuyStrategies.Count > 0)
|
|
||||||
{
|
|
||||||
DCABalance = DCABalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage != 0 ? dcaLogEntry.Leverage : 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PairsBalance = PairsBalance + ((dcaLogEntry.Amount * dcaLogEntry.CurrentPrice) / dcaLogEntry.Leverage != 0 ? dcaLogEntry.Leverage : 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
totalCurrentValue = PendingBalance + DCABalance + PairsBalance + AvailableBalance;
|
totalCurrentValue = PendingBalance + DCABalance + PairsBalance + AvailableBalance;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
@page
|
||||||
|
@model DownloadFileModel
|
||||||
|
@{
|
||||||
|
Layout = null;
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Net.Http.Headers;
|
||||||
|
using Core.Helper;
|
||||||
|
|
||||||
|
namespace Monitor.Pages {
|
||||||
|
public class DownloadFileModel : _Internal.BasePageModelSecure {
|
||||||
|
|
||||||
|
public void OnGet() {
|
||||||
|
// Initialize Config
|
||||||
|
base.Init();
|
||||||
|
|
||||||
|
// Check we have a log in
|
||||||
|
if (base.IsLoggedIn(this.HttpContext))
|
||||||
|
{
|
||||||
|
InitializeDownload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void InitializeDownload() {
|
||||||
|
// Zip the file in an non web accessible folder
|
||||||
|
string fileName = GetStringParameter("f", "");
|
||||||
|
string tempFolder = PTMagicMonitorBasePath + System.IO.Path.DirectorySeparatorChar + "tmp" + System.IO.Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
|
if (System.IO.File.Exists(PTMagicBasePath + fileName)) {
|
||||||
|
if (!System.IO.Directory.Exists(tempFolder)) {
|
||||||
|
System.IO.Directory.CreateDirectory(tempFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
string sourcefilePath = PTMagicBasePath + fileName;
|
||||||
|
string destinationFilePath = tempFolder + fileName + ".zip";
|
||||||
|
|
||||||
|
ZIPHelper.CreateZipFile(new ArrayList() { sourcefilePath }, destinationFilePath);
|
||||||
|
|
||||||
|
// Write out the file
|
||||||
|
var data = System.IO.File.ReadAllBytes(destinationFilePath);
|
||||||
|
|
||||||
|
Response.ContentType = "application/zip";
|
||||||
|
Response.Headers[HeaderNames.CacheControl] = "no-cache";
|
||||||
|
Response.Headers[HeaderNames.ContentDisposition] = String.Format("attachment; filename={0}", fileName);
|
||||||
|
await Response.BodyWriter.WriteAsync(new Memory<byte>(data));
|
||||||
|
Response.BodyWriter.Complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
using Core.Main;
|
using Core.Main;
|
||||||
|
using Core.Helper;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
@ -58,6 +59,13 @@ namespace Monitor
|
||||||
{
|
{
|
||||||
options.AllowSynchronousIO = true;
|
options.AllowSynchronousIO = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove the old tmp folder if it exists
|
||||||
|
string oldTmpFolder = monitorBasePath + System.IO.Path.DirectorySeparatorChar + "wwwroot" + System.IO.Path.DirectorySeparatorChar + "assets" + System.IO.Path.DirectorySeparatorChar + "tmp" + System.IO.Path.DirectorySeparatorChar;
|
||||||
|
if (System.IO.Directory.Exists(oldTmpFolder))
|
||||||
|
{
|
||||||
|
System.IO.Directory.Delete(oldTmpFolder, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
|
|
@ -7,32 +7,72 @@ namespace Monitor._Internal
|
||||||
{
|
{
|
||||||
public class BasePageModelSecure : BasePageModel
|
public class BasePageModelSecure : BasePageModel
|
||||||
{
|
{
|
||||||
|
// The string to redirect to if it fails security
|
||||||
|
protected string _redirectUrl;
|
||||||
|
|
||||||
|
public BasePageModelSecure(string redirect = null)
|
||||||
|
{
|
||||||
|
// Configure redirect URL
|
||||||
|
_redirectUrl = !String.IsNullOrEmpty(redirect) ? redirect : "Login";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Must be called from inheritting pages to check security
|
||||||
|
/// </summary>
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
|
// Initialise base class
|
||||||
base.PreInit();
|
base.PreInit();
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(HttpContext.Session.GetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString())) && PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected)
|
// Security check
|
||||||
|
if (!IsLoggedIn(this.HttpContext))
|
||||||
{
|
{
|
||||||
bool redirectToLogin = true;
|
HttpContext.Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + _redirectUrl);
|
||||||
if (Request.Cookies.ContainsKey("PTMRememberMeKey"))
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check to see a user if logged in interactively
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Boolean - User logged in or not</returns>
|
||||||
|
protected Boolean IsLoggedIn(HttpContext context)
|
||||||
|
{
|
||||||
|
bool isLoggedIn = false;
|
||||||
|
|
||||||
|
if (PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected)
|
||||||
|
{
|
||||||
|
// Do we have a session active?
|
||||||
|
if (!String.IsNullOrEmpty(context.Session.GetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString())))
|
||||||
{
|
{
|
||||||
string rememberMeKey = Request.Cookies["PTMRememberMeKey"];
|
isLoggedIn = true;
|
||||||
if (!rememberMeKey.Equals(""))
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Do we have a auto login cookie?
|
||||||
|
if (Request.Cookies.ContainsKey("PTMRememberMeKey"))
|
||||||
{
|
{
|
||||||
string encryptedPassword = EncryptionHelper.Decrypt(Request.Cookies["PTMRememberMeKey"]);
|
string rememberMeKey = Request.Cookies["PTMRememberMeKey"];
|
||||||
if (encryptedPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword))
|
if (!rememberMeKey.Equals(""))
|
||||||
{
|
{
|
||||||
HttpContext.Session.SetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString(), DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"));
|
string encryptedPassword = EncryptionHelper.Decrypt(Request.Cookies["PTMRememberMeKey"]);
|
||||||
redirectToLogin = false;
|
if (encryptedPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword))
|
||||||
|
{
|
||||||
|
context.Session.SetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString(), DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"));
|
||||||
|
isLoggedIn = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redirectToLogin)
|
|
||||||
{
|
|
||||||
HttpContext.Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "Login");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No password required
|
||||||
|
isLoggedIn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isLoggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +1,12 @@
|
||||||
using System;
|
namespace Monitor._Internal
|
||||||
using System.IO;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Core.Main;
|
|
||||||
using Core.Helper;
|
|
||||||
using Core.Main.DataObjects.PTMagicData;
|
|
||||||
using Core.MarketAnalyzer;
|
|
||||||
using Core.ProfitTrailer;
|
|
||||||
using Microsoft.Extensions.Primitives;
|
|
||||||
|
|
||||||
namespace Monitor._Internal
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public class BasePageModelSecureAJAX : BasePageModel
|
public class BasePageModelSecureAJAX : BasePageModelSecure
|
||||||
{
|
{
|
||||||
public void Init()
|
public BasePageModelSecureAJAX() : base(@"_get/ReturnToLogin") {
|
||||||
{
|
// Logic in base class
|
||||||
base.PreInit();
|
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(HttpContext.Session.GetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString())) && PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected)
|
|
||||||
{
|
|
||||||
bool redirectToLogin = true;
|
|
||||||
if (Request.Cookies.ContainsKey("PTMRememberMeKey"))
|
|
||||||
{
|
|
||||||
string rememberMeKey = Request.Cookies["PTMRememberMeKey"];
|
|
||||||
if (!rememberMeKey.Equals(""))
|
|
||||||
{
|
|
||||||
string encryptedPassword = EncryptionHelper.Decrypt(Request.Cookies["PTMRememberMeKey"]);
|
|
||||||
if (encryptedPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword))
|
|
||||||
{
|
|
||||||
HttpContext.Session.SetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString(), DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"));
|
|
||||||
redirectToLogin = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (redirectToLogin)
|
|
||||||
{
|
|
||||||
HttpContext.Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl + "_get/ReturnToLogin");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ using Core.Helper;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.5.4")]
|
[assembly: AssemblyVersion("2.5.5")]
|
||||||
[assembly: AssemblyProduct("PT Magic")]
|
[assembly: AssemblyProduct("PT Magic")]
|
||||||
|
|
||||||
namespace PTMagic
|
namespace PTMagic
|
||||||
|
|
Loading…
Reference in New Issue