Skip to content

Commit

Permalink
Merge pull request #330 from PTMagicians/develop
Browse files Browse the repository at this point in the history
2.6.1  .NET update and bug fixes
  • Loading branch information
HojouFotytu committed Jul 1, 2023
2 parents f6ec007 + 6e8c574 commit aaf8c2f
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 125 deletions.
38 changes: 0 additions & 38 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

14 changes: 0 additions & 14 deletions .github/ISSUE_TEMPLATE/other.md

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

## What we expect from users who want to contribute a pull request
- Read the file [_Development/README.md](https://github.com/PTMagicians/PTMagic/blob/master/_Development/README.md) and follow the instructions carefully
- Knowledge of the project PT Magic and what it is supposed to do
- Knowledge of the architecture, the different parts and layers of PT Magic
- In depth knowledge of the project PT Magic and what it is supposed to do
- In depth knowledge of the architecture, the different parts and layers of PT Magic

## What main goal should I follow when I want to implement something and submit my pull request?
PT Magic is a project/addon that supports the trading experience of several users of Profit Trailer.
Expand Down
14 changes: 7 additions & 7 deletions Core/Core.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NLog" Version="4.6.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0" />
<PackageReference Include="SharpZipLib" Version="*" />
<PackageReference Include="Telegram.Bot" Version="*" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions Core/MarketAnalyzer/Binance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,12 @@ public static void CheckForMarketDataRecreation(string mainMarket, Dictionary<st
log.DoLogDebug("Binance - Getting ticks for '" + markets.Count + "' markets");
ConcurrentDictionary<string, List<MarketTick>> marketTicks = new ConcurrentDictionary<string, List<MarketTick>>();

int ParallelThrottle = 4;
if (systemConfiguration.AnalyzerSettings.MarketAnalyzer.StoreDataMaxHours > 50)
int ParallelThrottle = 2;
if (systemConfiguration.AnalyzerSettings.MarketAnalyzer.StoreDataMaxHours > 6)
{
ParallelThrottle = 2;
ParallelThrottle = 1;
log.DoLogInfo("----------------------------------------------------------------------------");
log.DoLogInfo("StoreDataMaxHours is greater than 50. Historical data requests will be");
log.DoLogInfo("StoreDataMaxHours is greater than 6. Historical data requests will be");
log.DoLogInfo("throttled to avoid exceeding exchange request limits. This initial ");
log.DoLogInfo("run could take more than 30 minutes. Please go outside for a walk...");
log.DoLogInfo("----------------------------------------------------------------------------");
Expand Down
19 changes: 13 additions & 6 deletions Core/MarketAnalyzer/BinanceFutures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static List<string> GetMarketData(string mainMarket, ConcurrentDictionary
//New variables for filtering out bad markets
float marketLastPrice = currencyTicker["lastPrice"].ToObject<float>();
float marketVolume = currencyTicker["volume"].ToObject<float>();
if (marketLastPrice > 0 && marketVolume > 0)
if (marketLastPrice > 0 && marketVolume > 0 && marketName.EndsWith(mainMarket))
{

// Set last values in case any error occurs
Expand All @@ -92,8 +92,15 @@ public static List<string> GetMarketData(string mainMarket, ConcurrentDictionary
}
else
{
//Let the user know that the problem market was ignored.
//Let the user know that a problem market was ignored.
if (!marketName.EndsWith(mainMarket))
{
log.DoLogInfo("BinanceFutures - Incorrect base currency: " + marketName + " ignored");
}
else
{
log.DoLogInfo("BinanceFutures - Ignoring bad market data for " + marketName);
}
}
}

Expand Down Expand Up @@ -357,12 +364,12 @@ public static void CheckForMarketDataRecreation(string mainMarket, Dictionary<st
log.DoLogDebug("BinanceFutures - Getting ticks for '" + markets.Count + "' markets");
ConcurrentDictionary<string, List<MarketTick>> marketTicks = new ConcurrentDictionary<string, List<MarketTick>>();

int ParallelThrottle = 4;
if (systemConfiguration.AnalyzerSettings.MarketAnalyzer.StoreDataMaxHours > 50)
int ParallelThrottle = 2;
if (systemConfiguration.AnalyzerSettings.MarketAnalyzer.StoreDataMaxHours > 6)
{
ParallelThrottle = 2;
ParallelThrottle = 1;
log.DoLogInfo("----------------------------------------------------------------------------");
log.DoLogInfo("StoreDataMaxHours is greater than 50. Historical data requests will be");
log.DoLogInfo("StoreDataMaxHours is greater than 6. Historical data requests will be");
log.DoLogInfo("throttled to avoid exceeding exchange data request limits. This initial ");
log.DoLogInfo("run could take more than 30 minutes. Please go outside for a walk...");
log.DoLogInfo("----------------------------------------------------------------------------");
Expand Down
8 changes: 4 additions & 4 deletions Core/MarketAnalyzer/BinanceUS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,12 @@ public static void CheckForMarketDataRecreation(string mainMarket, Dictionary<st
log.DoLogDebug("BinanceUS - Getting ticks for '" + markets.Count + "' markets");
ConcurrentDictionary<string, List<MarketTick>> marketTicks = new ConcurrentDictionary<string, List<MarketTick>>();

int ParallelThrottle = 4;
if (systemConfiguration.AnalyzerSettings.MarketAnalyzer.StoreDataMaxHours > 200)
int ParallelThrottle = 2;
if (systemConfiguration.AnalyzerSettings.MarketAnalyzer.StoreDataMaxHours > 6)
{
ParallelThrottle = 2;
ParallelThrottle = 1;
log.DoLogInfo("----------------------------------------------------------------------------");
log.DoLogInfo("StoreDataMaxHours is greater than 200. Historical data requests will be");
log.DoLogInfo("StoreDataMaxHours is greater than 6. Historical data requests will be");
log.DoLogInfo("throttled to avoid exceeding exchange data request limits. This initial ");
log.DoLogInfo("run could take more than 30 minutes. Please go outside for a walk...");
log.DoLogInfo("----------------------------------------------------------------------------");
Expand Down
4 changes: 2 additions & 2 deletions Monitor/Monitor.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp7.0</TargetFramework>
<!--<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>-->
</PropertyGroup>
<ItemGroup>
Expand All @@ -19,7 +19,7 @@
<None Include="nlog.config" CopyToOutputDirectory="Always" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions Monitor/Pages/MarketAnalyzer.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ else
</thead>
<tbody>
@foreach (string market in Model.Summary.MarketSummary.Keys.OrderBy(m => m)) {
if (market.EndsWith(Model.Summary.MainMarket))
{
Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = Model.Summary.MarketSummary[market];
int marketTrendsDisplayed = 0;
<tr>
Expand Down Expand Up @@ -294,6 +296,7 @@ else
<td></td>
}
</tr>
}
}
</tbody>
</table>
Expand Down
71 changes: 48 additions & 23 deletions Monitor/Pages/_get/DashboardTop.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
}

<div class="row">
<div class="col-md-5 px-1">
@if (Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries>0)
{
<div class="col-md-6 px-1">
<div class="card-box px-2">
<h4 class="m-t-0 m-b-20 header-title"><b>Possible Buys (@Model.PTData.BuyLog.Count)</b><small id="buylist-refresh-icon"></small><small class="pull-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)BuyAnalyzer">more</a></small></h4>
@if (Model.PTData.BuyLog.Count == 0)
Expand Down Expand Up @@ -79,8 +81,9 @@
}
</div>
</div>

<div class="col-md-7 px-1">
}

<div class="col-md px-1">
<div class="card-box px-2">
<h4 class="m-t-0 m-b-20 header-title"><b>Pairs / DCA / Pending (@Model.PTData.DCALog.Count)</b><small id="baglist-refresh-icon"></small><small class="pull-right"><a href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)BagAnalyzer">more</a></small></h4>

Expand Down Expand Up @@ -108,6 +111,7 @@
@foreach (Core.Main.DataObjects.PTMagicData.DCALogData dcaLogEntry in Model.PTData.DCALog.OrderByDescending(d => d.ProfitPercent).Take(Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries)) {
// Loop through the pairs preparing the data for display
Core.Main.DataObjects.PTMagicData.MarketPairSummary mps = null;

if (Model.Summary.MarketSummary.ContainsKey(dcaLogEntry.Market)) {
mps = Model.Summary.MarketSummary[dcaLogEntry.Market];
}
Expand Down Expand Up @@ -146,22 +150,26 @@

// Check for when PT loses the value of a pair
bool lostValue = false;
lostValue = (dcaLogEntry.TotalCost == 0.0) || (dcaLogEntry.AverageBuyPrice == 0.0);
lostValue = !(sellStrategyText.Contains("WATCHMODE")) && !(sellStrategyText.Contains("PENDING")) && ((dcaLogEntry.TotalCost == 0.0) || (dcaLogEntry.AverageBuyPrice == 0.0));

// Profit percentage
var profitPercentage = dcaLogEntry.ProfitPercent;

if (dcaLogEntry.SellStrategies != null)
{
var gainStrategy = dcaLogEntry.SellStrategies.FirstOrDefault(x => x.Name.Contains(" GAIN", StringComparison.InvariantCultureIgnoreCase));
if (gainStrategy != null)
{
// Use the gain percentage value as it is accurate to what can be achieved with the order book!
profitPercentage = gainStrategy.CurrentValue;
}
}
// if (dcaLogEntry.SellStrategies != null)
// {
// var gainStrategy = dcaLogEntry.SellStrategies.FirstOrDefault(x => x.Name.Contains(" GAIN", StringComparison.InvariantCultureIgnoreCase));
// if (gainStrategy != null)
// {
// // Use the gain percentage value as it is accurate to what can be achieved with the order book!
// profitPercentage = gainStrategy.CurrentValue;
// }
// }
// Render the row
if (!sellStrategyText.Contains("PENDING-BUY"))
{

<tr @(lostValue ? "class=errorRow" : "") >

<!-- Market -->
Expand Down Expand Up @@ -204,8 +212,8 @@
<!-- Target/Profit -->
@if (!@lostValue)
{
@if (!sellStrategyText.Contains("WATCHMODE"))
{
//@if (!sellStrategyText.Contains("WATCHMODE"))
//{
@if (sellStrategyText.Contains("CROSSED"))
// if leverage, recalculate profit target
{
Expand All @@ -219,17 +227,31 @@
leverage = leverageText.Remove(leverageText.IndexOf(".0)"), leverageText.Length - leverageText.IndexOf(".0)"));
leverageValue = double.Parse(leverage);
}
profitPercentage = profitPercentage * leverageValue;
double TargetGain = leverageValue * dcaLogEntry.TargetGainValue.Value;
<td>@TargetGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%
<br>
<div class="text-autocolor">@profitPercentage.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</div>
</td>
}
//profitPercentage = profitPercentage * leverageValue;
@if ( !(sellStrategyText.Contains("WATCHMODE")) && !(sellStrategyText.Contains("PENDING")))
{
double TargetGain = leverageValue * dcaLogEntry.TargetGainValue.Value;
<td>@TargetGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%
<br>
<div class="text-autocolor">@profitPercentage.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</div>
</td>
}
else
{
<td>
<div class="text-left">None</div>
<br>
<div class="text-autocolor">@profitPercentage.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))%</div>
</td>
}


//}
}
else
{
<td class="text-left">No Value!</td>
<td class="text-left">Lost Value!</td>
}
<!-- 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>
Expand All @@ -240,6 +262,9 @@
Model.TotalBagCost = Model.TotalBagCost + dcaLogEntry.TotalCost;
Model.TotalBagGain = Model.TotalBagGain + bagGain;
}

}

}
<td>Totals:</td>
<td></td>
Expand Down
2 changes: 1 addition & 1 deletion Monitor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Monitor
public class Program
{
// Main entry point
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
//[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
public static void Main(string[] args)
{
// Register a global exception handler
Expand Down
2 changes: 1 addition & 1 deletion PTMagic/PTMagic.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>netcoreapp7.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion PTMagic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Extensions.DependencyInjection;


[assembly: AssemblyVersion("2.5.12")]
[assembly: AssemblyVersion("2.6.1")]
[assembly: AssemblyProduct("PT Magic")]

namespace PTMagic
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Profit Trailer Magic

[Go here](https://github.com/PTMagicians/PTMagic/releases) to download the latest version.
[Visit the wiki](https://github.com/PTMagicians/PT-Magic/wiki) to learn about this project.

[Visit the wiki](https://github.com/PTMagicians/PT-Magic/wiki) for instructions, and to learn more about this project.
[Go here](https://github.com/PTMagicians/PTMagic/releases) to download the latest version.

0 comments on commit aaf8c2f

Please sign in to comment.