Shorting calculations & analyzer chart

This commit is contained in:
HojouFotytu 2020-01-16 20:50:42 +09:00
parent d77923ae04
commit ff522363a9
6 changed files with 146 additions and 102 deletions

View File

@ -57,6 +57,7 @@ namespace Core.Main.DataObjects.PTMagicData
public bool IsPasswordProtected { get; set; } = true;
public bool OpenBrowserOnStart { get; set; } = false;
public int Port { get; set; } = 5000;
public string AnalyzerChart { get; set; } = "";
public int GraphIntervalMinutes { get; set; } = 60;
public int GraphMaxTimeframeHours { get; set; } = 24;
public int RefreshSeconds { get; set; } = 30;

View File

@ -304,10 +304,22 @@ namespace Core.Main.DataObjects
sellLogData.AverageBuyPrice = rsld.avgPrice;
sellLogData.TotalCost = sellLogData.SoldAmount * sellLogData.AverageBuyPrice;
double soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice);
double soldValueAfterFees = soldValueRaw - (soldValueRaw * ((double)rsld.fee / 100));
sellLogData.SoldValue = soldValueAfterFees;
sellLogData.Profit = Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8);
if (sellLogData.ProfitPercent >0)
{
double soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice);
double soldValueAfterFees = soldValueRaw + (soldValueRaw * ((double)rsld.fee / 100));
sellLogData.SoldValue = soldValueAfterFees;
sellLogData.Profit = Math.Abs(Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8));
}
else
{
double soldValueRaw = (sellLogData.SoldAmount * sellLogData.SoldPrice);
double soldValueAfterFees = soldValueRaw - (soldValueRaw * ((double)rsld.fee / 100));
sellLogData.SoldValue = soldValueAfterFees;
sellLogData.Profit = Math.Round(sellLogData.SoldValue - sellLogData.TotalCost, 8);
}
//Convert Unix Timestamp to Datetime
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);

View File

@ -8,18 +8,14 @@
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/tablesaw/css/tablesaw.css" rel="stylesheet" type="text/css" />
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/nvd3/nv.d3.min.css" rel="stylesheet" type="text/css" />
}
<div class="row">
<div class="col-sm-12">
<div class="card-box">
@if (Model.Summary.MainMarket.Equals("USDT", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("TUSD", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("USDC", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("PAX", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("USD", StringComparison.InvariantCultureIgnoreCase))
{
string TvSymbol = @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket)+"USD";
@if (!Model.PTMagicConfiguration.GeneralSettings.Monitor.AnalyzerChart.Equals(""))
{
string TvSymbol = @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket)+"USD";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"symbol": "@Model.PTMagicConfiguration.GeneralSettings.Monitor.AnalyzerChart",
"width": "100%",
"height": "200",
"locale": "en",
@ -33,102 +29,129 @@
}
</script>
</div>
}
else
{
<div class="row">
<div class="col-sm-12">
<div class="card-box">
@if (Model.Summary.MainMarket.Equals("USDT", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("TUSD", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("USDC", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("PAX", StringComparison.InvariantCultureIgnoreCase) || Model.Summary.MainMarket.Equals("USD", StringComparison.InvariantCultureIgnoreCase))
{
string TvSymbol = @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket)+"USD";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "200",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
}
else {
if (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.Equals("Binance", StringComparison.InvariantCultureIgnoreCase))
{
string TvSymbol = "BINANCE:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USDT";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "200",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
}
else
if (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.Equals("BinanceUS", StringComparison.InvariantCultureIgnoreCase)) {
string TvSymbol = "BINANCE:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USD";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "100%",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
else {
if (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.Equals("Binance", StringComparison.InvariantCultureIgnoreCase))
{
string TvSymbol = "BINANCE:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USDT";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "200",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
}
else
if (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.Equals("BinanceUS", StringComparison.InvariantCultureIgnoreCase)) {
string TvSymbol = "BINANCE:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USD";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "100%",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
}
else
if (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.Equals("Bittrex", StringComparison.InvariantCultureIgnoreCase)) {
string TvSymbol = "BITTREX:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USD";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "100%",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
}
else
{
string TvSymbol = "Poloniex:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USDT";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "100%",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
}
}
else
if (Model.PTMagicConfiguration.GeneralSettings.Application.Exchange.Equals("Bittrex", StringComparison.InvariantCultureIgnoreCase)) {
string TvSymbol = "BITTREX:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USD";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "100%",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
}
else
{
string TvSymbol = "Poloniex:" + @Core.Helper.SystemHelper.GetMainCurrencySymbol(Model.Summary.MainMarket) + "USDT";
<div class="tradingview-widget-container">
<div class="tradingview-widget-container__widget"></div>
<script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-mini-symbol-overview.js" async>
{
"symbol": "@Core.Helper.SystemHelper.GetMainCurrencySymbol(@TvSymbol)",
"width": "100%",
"height": "100%",
"locale": "en",
"dateRange": "1d",
"colorTheme": "dark",
"trendLineColor": "#37a6ef",
"underLineColor": "rgba(55, 166, 239, 0.15)",
"isTransparent": true,
"autosize": true,
"largeChartUrl": ""
}
</script>
</div>
}
}
</div>
</div>
</div>
</div>
}
<div class="row">
<div class="col-sm-12">
<div class="card-box">

View File

@ -196,6 +196,12 @@
</div>
</div>
<div class="form-group row">
<label class="col-md-4 col-form-label">Market Analyzer Chart <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="By default the price chart on the analyzer page displays your base currency. You can select a different currency here"></i></label>
<div class="col-md-8">
<input type="text" class="form-control" name="Monitor_AnalyzerChart" value="@Model.PTMagicConfiguration.GeneralSettings.Monitor.AnalyzerChart.ToString(new System.Globalization.CultureInfo("en-US"))">
</div>
</div>
<div class="form-group row">
<label class="col-md-4 col-form-label">Graph Interval Minutes <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The interval for the monitor market trend graph to draw points."></i></label>
<div class="col-md-8">

View File

@ -82,6 +82,7 @@ namespace Monitor.Pages
//
PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected = HttpContext.Request.Form["Monitor_IsPasswordProtected"].Equals("on");
PTMagicConfiguration.GeneralSettings.Monitor.OpenBrowserOnStart = HttpContext.Request.Form["Monitor_OpenBrowserOnStart"].Equals("on");
PTMagicConfiguration.GeneralSettings.Monitor.DefaultDCAMode = HttpContext.Request.Form["Monitor_AnalyzerChart"];
PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_GraphIntervalMinutes"], PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes);
PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_GraphMaxTimeframeHours"], PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours);
PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_RefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds);

View File

@ -22,6 +22,7 @@
"OpenBrowserOnStart": false, // If active, a browser window will open as soon as you start the monitor
"Port": 5000, // The port you want to run your monitor on
"RootUrl": "/", // The root Url of your monitor
"AnalyzerChart":, // By default the chart on the market analyzer page displays your base currency against USD. You may change this if you like (eg., BTCEUR)
"GraphIntervalMinutes": 60, // The interval for the monitor market trend graph to draw points
"GraphMaxTimeframeHours": 24, // This will enable you to define the timeframe that your graph for market trends covers
"RefreshSeconds": 30, // The refresh interval of your monitor main page