Merge pull request #249 from HojouFotytu/develop

leveraged profits fix
This commit is contained in:
HojouFotytu 2021-02-09 22:54:16 +09:00 committed by GitHub
commit 6af375d87c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 31 deletions

View File

@ -1642,17 +1642,6 @@ namespace Core.Main
// Calculate average market change, skip any that are outside the threshold if enabled // Calculate average market change, skip any that are outside the threshold if enabled
if (trendThreshold.TrendThreshold != 0) if (trendThreshold.TrendThreshold != 0)
{ {
// Exclude trends outside the threshhold.
var excludedMarkets = from m in marketTrendChanges
where m.TrendChange > trendThreshold.TrendThreshold || m.TrendChange < (trendThreshold.TrendThreshold * -1.0)
orderby m.Market
select m;
foreach (var marketTrend in excludedMarkets)
{
this.Log.DoLogInfo(String.Format("SMS Off Trigger for '{0}' is ignoring {1} for exceeding TrendThreshold {2}% with {3}% on {4}", marketSetting.SettingName, marketTrend.Market, (double)trendThreshold.TrendThreshold, Math.Round(marketTrend.TrendChange, 3, MidpointRounding.ToEven), offTrigger.MarketTrendName));
}
var includedMarkets = from m in marketTrendChanges var includedMarkets = from m in marketTrendChanges
where m.TrendChange <= trendThreshold.TrendThreshold && m.TrendChange >= (trendThreshold.TrendThreshold * -1.0) where m.TrendChange <= trendThreshold.TrendThreshold && m.TrendChange >= (trendThreshold.TrendThreshold * -1.0)
orderby m.Market orderby m.Market
@ -1856,17 +1845,6 @@ namespace Core.Main
// Calculate average market change, skip any that are outside the threshold if enabled // Calculate average market change, skip any that are outside the threshold if enabled
if (trendThreshold.TrendThreshold != 0) if (trendThreshold.TrendThreshold != 0)
{ {
// Exclude trends outside the threshhold.
var excludedMarkets = from m in marketTrendChanges
where m.TrendChange > trendThreshold.TrendThreshold || m.TrendChange < (trendThreshold.TrendThreshold * -1.0)
orderby m.Market
select m;
foreach (var marketTrend in excludedMarkets)
{
this.Log.DoLogInfo(String.Format("SMS Trigger for '{0}' is ignoring {1} for exceeding TrendThreshold {2}% with {3}% on {4}", marketSetting.SettingName, marketTrend.Market, (double)trendThreshold.TrendThreshold, Math.Round(marketTrend.TrendChange, 3, MidpointRounding.ToEven), trigger.MarketTrendName));
}
var includedMarkets = from m in marketTrendChanges var includedMarkets = from m in marketTrendChanges
where m.TrendChange <= trendThreshold.TrendThreshold && m.TrendChange >= (trendThreshold.TrendThreshold * -1.0) where m.TrendChange <= trendThreshold.TrendThreshold && m.TrendChange >= (trendThreshold.TrendThreshold * -1.0)
orderby m.Market orderby m.Market

View File

@ -278,7 +278,15 @@ else
if (mps.MarketTrendChanges.ContainsKey(marketTrend.Name)) { if (mps.MarketTrendChanges.ContainsKey(marketTrend.Name)) {
marketTrendsDisplayed++; marketTrendsDisplayed++;
string trendChangeOutput = mps.MarketTrendChanges[marketTrend.Name].ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")); string trendChangeOutput = mps.MarketTrendChanges[marketTrend.Name].ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"));
<td class="text-right text-autocolor-saw">@trendChangeOutput%</td> if ((mps.MarketTrendChanges[marketTrend.Name] > marketTrend.TrendThreshold) || (mps.MarketTrendChanges[marketTrend.Name] > marketTrend.TrendThreshold) )
{
<td class="text-right text-autocolor-saw"><i class="fa fa-ban text-muted" data-toggle="tooltip" data-placement="top" title="This coin has been excluded from the average market trend on this timeframe due to your Threshold setting."></i>&nbsp; @trendChangeOutput%</td>
}
else
{
<td class="text-right text-autocolor-saw">@trendChangeOutput%</td>
}
} }
} }
@for (int i = 0; i < marketTrends.Count - marketTrendsDisplayed; i++) { @for (int i = 0; i < marketTrends.Count - marketTrendsDisplayed; i++) {

View File

@ -160,11 +160,6 @@
} }
} }
// Aggregate totals
double bagGain = (profitPercentage / 100) * dcaLogEntry.TotalCost * leverageValue;
Model.TotalBagCost = Model.TotalBagCost + dcaLogEntry.TotalCost;
Model.TotalBagGain = Model.TotalBagGain + bagGain;
// Render the row // Render the row
<tr @(lostValue ? "class=errorRow" : "") > <tr @(lostValue ? "class=errorRow" : "") >
<!-- Market --> <!-- Market -->
@ -226,20 +221,25 @@
{ {
<td class="text-left"></td> <td class="text-left"></td>
} }
<!-- Profit --> <!-- Profit -->
@if (!@lostValue) @if (!@lostValue)
{ {
profitPercentage = profitPercentage * leverageValue;
<td class="text-autocolor">@profitPercentage.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</td> <td class="text-autocolor">@profitPercentage.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</td>
} }
else else
{ {
<td class="text-left">No Value!</td> <td class="text-left">No Value!</td>
} }
<!-- Bag details --> <!-- Bag details -->
<td class="text-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/BagDetails/?m=@dcaLogEntry.Market" data-remote="false" data-toggle="modal" data-target="#dca-chart"><i class="fa fa-plus-circle"></i></a></td> <td class="text-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)_get/BagDetails/?m=@dcaLogEntry.Market" data-remote="false" data-toggle="modal" data-target="#dca-chart"><i class="fa fa-plus-circle"></i></a></td>
</tr> </tr>
{
// Aggregate totals
double bagGain = (profitPercentage / 100) * dcaLogEntry.TotalCost;
Model.TotalBagCost = Model.TotalBagCost + dcaLogEntry.TotalCost;
Model.TotalBagGain = Model.TotalBagGain + bagGain;
}
} }
<td>Totals:</td> <td>Totals:</td>
<td></td> <td></td>

View File

@ -77,6 +77,14 @@
</div> </div>
</div> </div>
<div class="form-group row">
<label class="col-md-4 col-form-label">Trend Threshold <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Exclude coins above/below this value when calculing market trend average."></i></label>
<div class="col-md-8">
<input type="text" class="form-control" name="MarketAnalyzer_MarketTrend_@(Model.MarketTrendName)|TrendThreshold" value="@Model.MarketTrend.TrendThreshold.ToString()">
<span class="help-block"><small>Leave empty to exclude none</small></span>
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<label class="col-md-4 col-form-label">Display Graph <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Displays or hides the graph for this trend on the dashboard of your PT Magic monitor."></i></label> <label class="col-md-4 col-form-label">Display Graph <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Displays or hides the graph for this trend on the dashboard of your PT Magic monitor."></i></label>
<div class="col-md-8"> <div class="col-md-8">