Skip to content

Performance improvements ariel #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions AnalyticReports/ReportDictionary.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:oxy="http://oxyplot.org/wpf"
xmlns:contrib="http://oxyplot.org/wpf/contrib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Formatters="clr-namespace:VisualHFT.Converters">

Expand Down Expand Up @@ -33,14 +32,14 @@
</Style>

<Style x:Key="ExpanderHeaderStyle" TargetType="TextBlock">
<Setter Property="Height" Value="30" />
<Setter Property="Height" Value="30" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#898a75" />
<Setter Property="FontWeight" Value="100" />
<Setter Property="FontFamily" Value="Myriad Pro" />
<Setter Property="Padding" Value="10,6,0,0" />
<Setter Property="Padding" Value="10,6,0,0" />
</Style>

<Style x:Key="DataTitleStyle" TargetType="Label">
<Setter Property="FontWeight" Value="300" />
<Setter Property="Foreground" Value="#4d4e3a" />
Expand All @@ -61,7 +60,7 @@
<Setter Property="Foreground" Value="#4d4e3a" />
<Setter Property="FontSize" Value="12" />
</Style>

<Style x:Key="GridDataStyle" TargetType="Label">
<Setter Property="Template">
<Setter.Value>
Expand All @@ -71,7 +70,7 @@
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Setter>
<Setter Property="Background" Value="#fff" />
<Setter Property="Foreground" Value="#4d4e3a" />
<Setter Property="FontSize" Value="12" />
Expand All @@ -97,12 +96,12 @@
<Setter Property="Background" Value="GhostWhite" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="FontFamily" Value="Segoe UI" />
<Setter Property="ToolTipService.ShowDuration" Value="10000"/>
<Setter Property="TextBlock.TextWrapping" Value="Wrap" />
</Style>
<!--CHARTS-->

<Style x:Key="ChartTitleStyle" TargetType="Label">
<Setter Property="FontWeight" Value="300" />
<Setter Property="Foreground" Value="#4d4e3a" />
Expand All @@ -118,18 +117,5 @@
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<Style x:Key="PlotStyle" TargetType="{x:Type contrib:Plot}">
<Setter Property="DefaultTrackerTemplate">
<Setter.Value>
<ControlTemplate>
<oxy:TrackerControl Position="{Binding Position}" LineExtents="{Binding PlotModel.PlotArea}">
<oxy:TrackerControl.Content>
<TextBlock Text="{Binding}" Margin="7" />
</oxy:TrackerControl.Content>
</oxy:TrackerControl>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

4 changes: 2 additions & 2 deletions AnalyticReports/View/ucCharts.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<UserControl x:Class="VisualHFT.AnalyticReports.View.ucCharts"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:contrib="http://oxyplot.org/wpf/contrib"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -22,6 +21,7 @@
<ColumnDefinition Width="*" SharedSizeGroup="A"/>
<ColumnDefinition Width="*" SharedSizeGroup="A"/>
</Grid.ColumnDefinitions>
<!--
<contrib:Plot x:Name="chart1" Title="By Hour Win/Loss | Qty of Trades" Grid.Column="0" Grid.Row="0" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10" >
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
Expand Down Expand Up @@ -65,6 +65,6 @@
<contrib:BarSeries Title="Losses" ItemsSource="{Binding HourSerieLosses}" ValueField="PLAmount" Color="Red"/>
</contrib:Plot.Series>
</contrib:Plot>

-->
</Grid>
</UserControl>
29 changes: 14 additions & 15 deletions AnalyticReports/View/ucChartsStatistics.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<UserControl x:Class="VisualHFT.AnalyticReports.View.ucChartsStatistics"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:contrib="http://oxyplot.org/wpf/contrib"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -26,7 +25,7 @@
<ColumnDefinition Width="*" SharedSizeGroup="A"/>
</Grid.ColumnDefinitions>
<!--Trade Duration (Qty trades by holding period)-->
<contrib:Plot x:Name="chart1" Title="Trade Duration (Qty trades by holding period)" Grid.Column="0" Grid.Row="0" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10">
<!--<contrib:Plot x:Name="chart1" Title="Trade Duration (Qty trades by holding period)" Grid.Column="0" Grid.Row="0" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10">
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
<SolidColorBrush x:Key="PlotTextBrush" Color="{DynamicResource PrimaryHueMid}" />
Expand All @@ -47,9 +46,9 @@
<contrib:BarSeries Title="Wins" ItemsSource="{Binding heldBars}" ValueField="WinPnLCount" Color="Green"/>
<contrib:BarSeries Title="Losses" ItemsSource="{Binding heldBars}" ValueField="LossPnlCount" Color="Red"/>
</contrib:Plot.Series>
</contrib:Plot>
</contrib:Plot>-->
<!--Trade Duration (PnL by holding period)-->
<contrib:Plot x:Name="chart2" Title="Trade Duration (PnL by holding period)" Grid.Column="1" Grid.Row="0" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10">
<!--<contrib:Plot x:Name="chart2" Title="Trade Duration (PnL by holding period)" Grid.Column="1" Grid.Row="0" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10">
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
<SolidColorBrush x:Key="PlotTextBrush" Color="{DynamicResource PrimaryHueMid}" />
Expand All @@ -70,9 +69,9 @@
<contrib:BarSeries Title="Wins" ItemsSource="{Binding heldBars}" ValueField="TotalWinPnL" Color="Green"/>
<contrib:BarSeries Title="Losses" ItemsSource="{Binding heldBars}" ValueField="TotalLossPnl" Color="Red"/>
</contrib:Plot.Series>
</contrib:Plot>
</contrib:Plot>-->
<!--Top 20 Symbols (by PL)-->
<contrib:Plot x:Name="chart3" Title="Top 20 Symbols (by PL)" Grid.Column="0" Grid.Row="1" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10">
<!--<contrib:Plot x:Name="chart3" Title="Top 20 Symbols (by PL)" Grid.Column="0" Grid.Row="1" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10">
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
<SolidColorBrush x:Key="PlotTextBrush" Color="{DynamicResource PrimaryHueMid}" />
Expand All @@ -93,9 +92,9 @@
<contrib:BarSeries Title="Wins" ItemsSource="{Binding Top20}" ValueField="WinsPnL" Color="Green"/>
<contrib:BarSeries Title="Losses" ItemsSource="{Binding Top20}" ValueField="LossesPnL" Color="Red"/>
</contrib:Plot.Series>
</contrib:Plot>
</contrib:Plot>-->
<!--PL Ranges-->
<contrib:Plot x:Name="chart4" Title="PL Ranges" Grid.Column="1" Grid.Row="1" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10">
<!--<contrib:Plot x:Name="chart4" Title="PL Ranges" Grid.Column="1" Grid.Row="1" IsEnabled="True" Style="{StaticResource PlotStyle}" Margin="0,0,0,10">
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
<SolidColorBrush x:Key="PlotTextBrush" Color="{DynamicResource PrimaryHueMid}" />
Expand All @@ -115,9 +114,9 @@
<contrib:Plot.Series>
<contrib:BarSeries Title="Qty Trades" ItemsSource="{Binding ListPLRanges}" ValueField="Qty" Color="Blue"/>
</contrib:Plot.Series>
</contrib:Plot>
</contrib:Plot>-->
<!--PL Range($) vs Duration-->
<contrib:Plot x:Name="chart5" Title="PL Range($) vs Duration" Grid.ColumnSpan="2" Grid.Row="2" IsEnabled="True" Margin="0,0,0,10">
<!--<contrib:Plot x:Name="chart5" Title="PL Range($) vs Duration" Grid.ColumnSpan="2" Grid.Row="2" IsEnabled="True" Margin="0,0,0,10">
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
<SolidColorBrush x:Key="PlotTextBrush" Color="{DynamicResource PrimaryHueMid}" />
Expand All @@ -138,9 +137,9 @@
<contrib:ScatterSeries ItemsSource="{Binding PLRangeDuration}" DataFieldX="Duration" DataFieldY="PLRange" MarkerType="Circle" MarkerSize="2"/>
<contrib:LineSeries Title="Regression" ItemsSource="{Binding regressionLineData}" DataFieldX="X" DataFieldY="Y" Color="Blue"/>
</contrib:Plot.Series>
</contrib:Plot>
</contrib:Plot>-->
<!--Maximum Adverse Excursion (MAE)-->
<contrib:Plot x:Name="chart6" Title="Maximum Adverse Excursion (MAE)" Grid.Column="0" Grid.Row="3" IsEnabled="True" Margin="0,0,0,10">
<!--<contrib:Plot x:Name="chart6" Title="Maximum Adverse Excursion (MAE)" Grid.Column="0" Grid.Row="3" IsEnabled="True" Margin="0,0,0,10">
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
<SolidColorBrush x:Key="PlotTextBrush" Color="{DynamicResource PrimaryHueMid}" />
Expand All @@ -161,9 +160,9 @@
<contrib:ScatterSeries ItemsSource="{Binding MAE}" DataFieldX="XValue" DataFieldY="YValue" MarkerType="Circle" MarkerSize="2"/>
<contrib:LineSeries Title="Regression" ItemsSource="{Binding regressionLineDataMAE}" DataFieldX="X" DataFieldY="Y" Color="Blue"/>
</contrib:Plot.Series>
</contrib:Plot>
</contrib:Plot>-->
<!--Maximum Favorable Excursion (MFE)-->
<contrib:Plot x:Name="chart7" Title="Maximum Favorable Excursion (MFE)" Grid.Column="1" Grid.Row="3" IsEnabled="True" Margin="0,0,0,10">
<!--<contrib:Plot x:Name="chart7" Title="Maximum Favorable Excursion (MFE)" Grid.Column="1" Grid.Row="3" IsEnabled="True" Margin="0,0,0,10">
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
<SolidColorBrush x:Key="PlotTextBrush" Color="{DynamicResource PrimaryHueMid}" />
Expand All @@ -184,6 +183,6 @@
<contrib:ScatterSeries ItemsSource="{Binding MFE}" DataFieldX="XValue" DataFieldY="YValue" MarkerType="Circle" MarkerSize="2"/>
<contrib:LineSeries Title="Regression" ItemsSource="{Binding regressionLineDataMFE}" DataFieldX="X" DataFieldY="Y" Color="Blue"/>
</contrib:Plot.Series>
</contrib:Plot>
</contrib:Plot>-->
</Grid>
</UserControl>
5 changes: 3 additions & 2 deletions AnalyticReports/View/ucEquityChart.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<UserControl x:Class="VisualHFT.AnalyticReports.View.ucEquityChart"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:contrib="http://oxyplot.org/wpf/contrib"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -12,7 +11,7 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../ReportDictionary.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</ResourceDictionary>
</UserControl.Resources>

<Grid>
Expand All @@ -26,6 +25,7 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<!--
<contrib:Plot x:Name="chartEquity" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Grid.ColumnSpan="2" IsEnabled="True" Style="{StaticResource PlotStyle}" >
<contrib:Plot.Resources>
<SolidColorBrush x:Key="PlotBackgroundBrush" Color="{DynamicResource PrimaryHueLight}" />
Expand Down Expand Up @@ -70,6 +70,7 @@
<contrib:BarSeries Title="Ammount" ItemsSource="{Binding DrawDowns}" ValueField="DrawDownAmmount" Color="Green" />
</contrib:Plot.Series>
</contrib:Plot>
-->
<StackPanel Grid.Row="2" Grid.Column="1" Width="770" HorizontalAlignment="Center" >
<Label Content="Monthly Performance" TextBlock.TextAlignment="Center" TextElement.FontWeight="Bold"></Label>
<DataGrid AutoGenerateColumns="False" Name="dataGrid1" ItemsSource="{Binding}" VerticalAlignment="Stretch" IsReadOnly="True" UseLayoutRounding="True" FontSize="11"
Expand Down
4 changes: 0 additions & 4 deletions App.config
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<!--LOCAL-->
<add name="HFTEntities" connectionString="metadata=res://*/Model.hftModel.csdl|res://*/Model.hftModel.ssdl|res://*/Model.hftModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=HFT;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
</connectionStrings>
<appSettings>

<!--LOCAL -->
<add key="ConnectionString" value="Data Source=(local);Initial Catalog=HFT;Trusted_Connection=True"/>
<add key="RestFullConnection" value="http://localhost:6800/"/>
<add key="WSorderBook" value="ws://localhost:6900/"/>

<add key="log4net.Internal.Debug" value="true"/>

Expand Down
21 changes: 3 additions & 18 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
<Application x:Class="VisualHFT.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VisualHFT"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
StartupUri="View/Dashboard.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

<!--
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />



<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Indigo.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Red.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
-->
<materialDesign:BundledTheme BaseTheme="Dark" PrimaryColor="Indigo" SecondaryColor="Red" />


<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />

<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Indigo.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Red.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign2.Defaults.xaml" />

</ResourceDictionary.MergedDictionaries>

Expand Down
34 changes: 21 additions & 13 deletions App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Runtime;
using System.Threading.Tasks;
using System.Windows;
using VisualHFT.PluginManager;
using System.Windows.Interop;
using System.Windows.Media;

namespace VisualHFT
{
Expand All @@ -22,7 +19,19 @@ protected override void OnStartup(StartupEventArgs e)
//Initialize logging
log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

//Launch the GC cleanup thread
/*----------------------------------------------------------------------------------------------------------------------*/
/* This is to avoid errors when rendering too much in short times
*
* Exception thrown: 'System.Runtime.InteropServices.COMException' in PresentationCore.dll
* An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
* UCEERR_RENDERTHREADFAILURE (0x88980406)
*
*/
//RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
/*----------------------------------------------------------------------------------------------------------------------*/


//Launch the GC cleanup thread ==> *** Since using Object Pools, we improved a lot the memory prints. So We commented this out.
Task.Run(async () => { await GCCleanupAsync(); });

//Load Plugins
Expand All @@ -35,26 +44,25 @@ protected override void OnStartup(StartupEventArgs e)
catch (Exception ex)
{
// Handle the exception
Application.Current.Dispatcher.Invoke(() =>
Application.Current.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("ERROR LOADING Plugins: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
});
}
});

}

protected override void OnExit(ExitEventArgs e)
{
PluginManager.PluginManager.UnloadPlugins();

base.OnExit(e);
}

private async Task LoadPlugins()
{
PluginManager.PluginManager.AllPluginsReloaded = false;
PluginManager.PluginManager.LoadPlugins();
PluginManager.PluginManager.StartPlugins();
await PluginManager.PluginManager.LoadPlugins();
await PluginManager.PluginManager.StartPlugins();
PluginManager.PluginManager.AllPluginsReloaded = true;
}
private async Task GCCleanupAsync()
Expand All @@ -64,7 +72,7 @@ private async Task GCCleanupAsync()
while (true)
{
await Task.Delay(5000);
GC.Collect(); //force garbage collection
GC.Collect(0, GCCollectionMode.Forced, false); //force garbage collection
};

}
Expand Down
Loading