Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3cfde1a
Added 4 New Plugins,
Jan 27, 2025
0014bc3
nuget components upgrade
Jan 27, 2025
83eba18
Settings APIs help URL
Jan 27, 2025
a488c4f
updated nuget packages.
Feb 8, 2025
8b911cf
Refactor and enhance trading analytics and testing
Feb 11, 2025
ff9f050
Update packages, add tests, and enhance order handling
Feb 13, 2025
6877038
Add validation, new tests, and fix issues in tests
Feb 14, 2025
fec8a17
Merge branch 'new-plugins' of https://github.com/silahian/VisualHFT i…
Feb 14, 2025
c3ab70a
adjustments
Feb 14, 2025
138edb0
Fixed Kraken plugin to comply with testing framework
Feb 17, 2025
1141e59
Refactor and enhance order book handling and tests
Feb 18, 2025
55da24f
Refactor and update order book handling and tests
Feb 19, 2025
d2914c2
- Add logging and thread safety improvements to tests
Feb 19, 2025
e7b242f
Added Private Messages for Binance
Feb 24, 2025
436ac04
Implemented Testing Framework in Gemini
Feb 24, 2025
2fc2a33
Updated Scenario 5 Private Messages JSON for Binance, BitFinex & Kraken.
Mar 3, 2025
7e9ad5c
test case 5 updated
Mar 4, 2025
48294a0
websocket data
Mar 4, 2025
7038ceb
binance tests
Mar 4, 2025
8047c05
tests
Mar 4, 2025
6fea180
updated Binance JSON Scenario 8
Mar 5, 2025
95472f5
Karken JSON Messages & Private messages
Mar 5, 2025
53506e4
Kucoin JSON Private Messages
Mar 5, 2025
9a6b8c7
updated Kucoin Private Messaged.
Mar 5, 2025
0e7e8e5
Kucoin Private Message Test Case 8
Mar 5, 2025
dcf66e9
updated gemini test case 8 JSON
Mar 5, 2025
961bcc9
test cases
Mar 6, 2025
c59a661
updated events
Mar 9, 2025
e01a600
test cases
Mar 11, 2025
4ab690c
Kucoin test cases
Mar 11, 2025
746ca8e
demo app packages
Mar 11, 2025
b633cb0
kraken packages
Mar 11, 2025
c8059ef
Refactor tests and enhance project structure
Mar 13, 2025
51dcbdb
Enhance OrderBook functionality and update dependencies
Mar 13, 2025
dda55af
Update order book data structures and log4net version
Mar 13, 2025
1115d70
null check
Mar 13, 2025
2f8fa51
Gemini and Bitstam libs updated (subscriptions requests)
Mar 16, 2025
8a93b5b
Fixed Bitfinex marketdata handling
Mar 16, 2025
804b791
Fixed Binance marketdata handling
Mar 16, 2025
e4ec30f
Fixed Bitstamp marketdata handling
Mar 16, 2025
00c4198
Fixed Coinbase marketdata handling
Mar 16, 2025
59748e4
Fixed Kraken marketdata handling
Mar 16, 2025
999d189
Fixed KuCoin marketdata handling
Mar 16, 2025
9752c84
Fixed Gemini marketdata handling
Mar 16, 2025
78093dc
MarketResiliecence null checks
Mar 16, 2025
5544e98
Add truncation method and improve resource management
Mar 16, 2025
4b3d75d
Refactor error handling in tests and update dependencies
Mar 16, 2025
4acdb1e
Packages updated
Mar 16, 2025
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
2 changes: 1 addition & 1 deletion AnalyticReports/AnalyticReports.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private void LoadMM()
private void LoadData()
{
if (this.Signals != null)
this.Signals = this.Signals.OrderBy(x => x.CreationTimeStamp).ToList();
this.Signals = this.Signals; //.OrderBy(x => x.CreationTimeStamp).ToList();
if (this.Signals.Count > 0)
{
this.Title = "HFT Analytics";
Expand Down
3 changes: 2 additions & 1 deletion AnalyticReports/ViewModel/vmCharts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ public void LoadData(List<VisualHFT.Model.Position> signals)

//#region Hours of the day
//var HourSerieTotal = HelperAnalytics.GetEquityCurveByHour(signals, initialDeposit);
/*
HourSerieWins = (from x in signals.Where(X => X.PipsPnLInCurrency.Value >= 0)
group x by new { date = new DateTime(x.CreationTimeStamp.Year, x.CreationTimeStamp.Month, x.CreationTimeStamp.Day, x.CreationTimeStamp.Hour, 0, 0) } into g
select new cHourSerie { Date = g.Key.date.ToDateTime(), PLAmount = g.Sum(s => s.PipsPnLInCurrency.ToDouble()), VolumeQty = g.Count() }).ToList();
HourSerieLosses = (from x in signals.Where(X => X.PipsPnLInCurrency.Value < 0)
group x by new { date = new DateTime(x.CreationTimeStamp.Year, x.CreationTimeStamp.Month, x.CreationTimeStamp.Day, x.CreationTimeStamp.Hour, 0, 0) } into g
select new cHourSerie { Date = g.Key.date.ToDateTime(), PLAmount = g.Sum(s => Math.Abs(s.PipsPnLInCurrency.ToDouble())), VolumeQty = g.Count() }).ToList();

*/


//#region Hour QTY
Expand Down
9 changes: 5 additions & 4 deletions AnalyticReports/ViewModel/vmChartsStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class vmChartsStatistics : BindableBase

public void LoadData(List<VisualHFT.Model.Position> signals)
{
heldBars = (from x in signals.Where(s => s.CloseTimeStamp != null)
/*heldBars = (from x in signals.Where(s => s.CloseTimeStamp != null)
group x by x.CloseTimeStamp.Subtract(x.CreationTimeStamp).TotalSeconds.ToInt() into m
select new cheldBars(
m.Key,
Expand All @@ -45,6 +45,7 @@ group x by x.Symbol into m
m.Count(y => y.PipsPnLInCurrency < 0),
m.Count()
)).ToList().OrderByDescending(x => x.TotalCount).Take(20).ToList();
*/

List<double[]> aRanges = new List<double[]>();
aRanges.Add(new double[] { double.MinValue, 0 });
Expand Down Expand Up @@ -72,7 +73,7 @@ group x by x.Symbol into m
_label = r[0].ToString() + "-" + r[1].ToString();

var tempVal = (from x in signals
where (double)x.PipsPnLInCurrency >= r[0] && (double)x.PipsPnLInCurrency < r[1]
//where (double)x.PipsPnLInCurrency >= r[0] && (double)x.PipsPnLInCurrency < r[1]
group x by _label into m
select new cListPLRanges(
m.Key,
Expand All @@ -81,7 +82,7 @@ group x by _label into m
ListPLRanges.AddRange(tempVal);
}

PLRangeDuration = signals.OrderBy(x => x.CloseTimeStamp.Subtract(x.CreationTimeStamp).TotalSeconds).Select(x => new cPLRangeDuration(x.CloseTimeStamp.Subtract(x.CreationTimeStamp).TotalSeconds, (double)x.PipsPnLInCurrency)).ToList();
/*PLRangeDuration = signals.OrderBy(x => x.CloseTimeStamp.Subtract(x.CreationTimeStamp).TotalSeconds).Select(x => new cPLRangeDuration(x.CloseTimeStamp.Subtract(x.CreationTimeStamp).TotalSeconds, (double)x.PipsPnLInCurrency)).ToList();

regressionLineData = HelperMath.LinearRegression((from x in signals select new System.Drawing.PointF((float)x.CloseTimeStamp.Subtract(x.CreationTimeStamp).TotalSeconds, (float)x.PipsPnLInCurrency)).ToList());

Expand All @@ -91,7 +92,7 @@ group x by _label into m

MFE = (from x in HelperAnalytics.GetMaximumFavorableExcursion(signals) select new ScatterChartData(x.Key.ToDouble(), (double)x.Value.GetPipsPnL, "")).ToList();

regressionLineDataMFE = HelperMath.LinearRegression((from x in MFE select new System.Drawing.PointF((float)x.XValue, (float)x.YValue)).ToList());
regressionLineDataMFE = HelperMath.LinearRegression((from x in MFE select new System.Drawing.PointF((float)x.XValue, (float)x.YValue)).ToList());*/

RaisePropertyChanged(String.Empty);
}
Expand Down
4 changes: 2 additions & 2 deletions AnalyticReports/ViewModel/vmOverview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void LoadData(List<VisualHFT.Model.Position> signals)
else
return;
Position oSignal = this.Signals[0];
if (oSignal != null)
/*if (oSignal != null)
{
double totalCount = this.Signals.Count;
decimal totalReturn = this.Signals.Sum(s => s.PipsPnLInCurrency.Value);
Expand Down Expand Up @@ -82,7 +82,7 @@ public void LoadData(List<VisualHFT.Model.Position> signals)
tTestValue = (Math.Sqrt(totalCount) * tradesPnL.Average() / tradesPnL.StdDev()).ToString("n2");

RaisePropertyChanged(String.Empty);
}
}*/

}
}
Expand Down
4 changes: 2 additions & 2 deletions AnalyticReports/ViewModel/vmStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void LoadData(List<VisualHFT.Model.Position> signals)
throw new Exception("No signals found.");

Position oSignal = this.Signals[0];
if (oSignal != null)
/*if (oSignal != null)
{
double totalCount = this.Signals.Count;
decimal totalReturn = this.Signals.Sum(s => s.GetPipsPnL);
Expand Down Expand Up @@ -146,7 +146,7 @@ public void LoadData(List<VisualHFT.Model.Position> signals)
#endregion

RaisePropertyChanged(String.Empty);
}
}*/
}
}
}
29 changes: 15 additions & 14 deletions Helpers/HelperAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static List<cBalance> GetBalanceCurve(List<VisualHFT.Model.Position> aSig
List<KeyValuePair<decimal, VisualHFT.Model.Position>> aRet = new List<KeyValuePair<decimal, VisualHFT.Model.Position>>();
foreach (VisualHFT.Model.Position s in aSignal)
{
aRet.Add(new KeyValuePair<decimal, VisualHFT.Model.Position>(s.MaxDrowdown, s));
//aRet.Add(new KeyValuePair<decimal, VisualHFT.Model.Position>(s.MaxDrowdown, s));
}
return aRet;
}
Expand All @@ -38,7 +38,7 @@ public static List<cBalance> GetBalanceCurve(List<VisualHFT.Model.Position> aSig
List<KeyValuePair<decimal, VisualHFT.Model.Position>> aRet = new List<KeyValuePair<decimal, VisualHFT.Model.Position>>();
foreach (VisualHFT.Model.Position s in aSignal)
{
aRet.Add(new KeyValuePair<decimal, VisualHFT.Model.Position>(s.UnrealizedPnL, s));
//aRet.Add(new KeyValuePair<decimal, VisualHFT.Model.Position>(s.UnrealizedPnL, s));
}
return aRet;
}
Expand Down Expand Up @@ -177,8 +177,8 @@ public static double GetSharpeRatio(List<VisualHFT.Model.Position> aSignal)
public static double GetIntradaySharpeRatio(List<VisualHFT.Model.Position> aSignal)
{
double qtyTrades = aSignal.Count();
double meanPnL = aSignal.Average(x => (double)x.PipsPnLInCurrency.Value);
double stdev = aSignal.Select(x => (double)x.PipsPnLInCurrency.Value).StdDev();
double meanPnL = 0; //aSignal.Average(x => (double)x.PipsPnLInCurrency.Value);
double stdev = 0; //aSignal.Select(x => (double)x.PipsPnLInCurrency.Value).StdDev();

double SHARPE = Math.Sqrt(qtyTrades) * (meanPnL / stdev);
return SHARPE;
Expand Down Expand Up @@ -207,13 +207,13 @@ public static double GetZScore(List<VisualHFT.Model.Position> aSignal)
* METHOD from
* http://www.wisestocktrader.com/indicators/1784-z-score-for-backtesting
*/
double winCount = aSignal.Where(s => s.PipsPnLInCurrency.Value >= 0).Count();
double lossCount = aSignal.Where(s => s.PipsPnLInCurrency.Value < 0).Count();
double winCount = aSignal.Count; //.Where(s => s.PipsPnLInCurrency.Value >= 0).Count();
double lossCount = aSignal.Count; //.Where(s => s.PipsPnLInCurrency.Value < 0).Count();
double totalRuns = 0, w = 0, l = 0;

foreach (Position s in aSignal)
{
if (s.GetPipsPnL > 0)
/*if (s.GetPipsPnL > 0)
{
if (w == 0) totalRuns++;
w++;
Expand All @@ -224,7 +224,7 @@ public static double GetZScore(List<VisualHFT.Model.Position> aSignal)
if (l == 0) totalRuns++;
l++;
w = 0;
}
}*/
}

double N = aSignal.Count;
Expand Down Expand Up @@ -287,7 +287,7 @@ public static double GetZProbability(List<VisualHFT.Model.Position> aSignal)
public static List<int> GetConsecutiveWins(List<VisualHFT.Model.Position> aSignal)
{
List<int> aRet = new List<int>();
int iCount = 0;
/*int iCount = 0;
bool lastWasWin = false;
foreach (Position s in aSignal)
{
Expand All @@ -300,14 +300,14 @@ public static List<int> GetConsecutiveWins(List<VisualHFT.Model.Position> aSigna
iCount = 0;
}
lastWasWin = s.PipsPnLInCurrency.Value >= 0;
}
}*/
return aRet;
}
public static List<int> GetConsecutiveLosses(List<VisualHFT.Model.Position> aSignal)
{
List<int> aRet = new List<int>();
int iCount = 0;
bool lastWasLoss = false;
/*bool lastWasLoss = false;
foreach (Position s in aSignal)
{
if (lastWasLoss && s.PipsPnLInCurrency.Value < 0)
Expand All @@ -319,18 +319,19 @@ public static List<int> GetConsecutiveLosses(List<VisualHFT.Model.Position> aSig
iCount = 0;
}
lastWasLoss = s.PipsPnLInCurrency.Value < 0;
}
}*/
return aRet;
}
public static double GetExpectancy(List<VisualHFT.Model.Position> aSignal)
{
//(Average Winner x Win Rate) – (Average Loser x Loss Rate)
var avgWinner = (double)aSignal.Where(x => x.PipsPnLInCurrency.HasValue && x.PipsPnLInCurrency.Value >= 0).DefaultIfEmpty(new VisualHFT.Model.Position() { PipsPnLInCurrency = 0 }).Average(x => x.PipsPnLInCurrency.Value);
/*var avgWinner = (double)aSignal.Where(x => x.PipsPnLInCurrency.HasValue && x.PipsPnLInCurrency.Value >= 0).DefaultIfEmpty(new VisualHFT.Model.Position() { PipsPnLInCurrency = 0 }).Average(x => x.PipsPnLInCurrency.Value);
var avgLosser = (double) aSignal.Where(x => x.PipsPnLInCurrency.HasValue && x.PipsPnLInCurrency.Value < 0).DefaultIfEmpty(new VisualHFT.Model.Position() { PipsPnLInCurrency = 0 }).Average(x => Math.Abs(x.PipsPnLInCurrency.Value));
var winRate = (double)aSignal.Where(x => x.PipsPnLInCurrency.HasValue && x.PipsPnLInCurrency.Value >= 0).Count() / aSignal.Count();
var lossRate = (double)aSignal.Where(x => x.PipsPnLInCurrency.HasValue && x.PipsPnLInCurrency.Value < 0).Count() / aSignal.Count();

return (avgWinner * winRate) - (avgLosser * lossRate);
return (avgWinner * winRate) - (avgLosser * lossRate);*/
return 0;
}

public static cEquity GetAverageProfitByHour(List<VisualHFT.Model.Position> aSignal)
Expand Down
84 changes: 0 additions & 84 deletions Helpers/HelperPnLCalculator.cs

This file was deleted.

8 changes: 4 additions & 4 deletions Helpers/HelperPositionAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static List<cEquity> GetEquityCurve(List<VisualHFT.Model.Position> aPosit

//MAKE cummulative
decimal dEquity = 0; // aPositions.First().GetOpenAvgPrice * aPositions.First().GetOpenQuantity;
foreach (var p in aPositions.Where(x => x.PipsPnLInCurrency.HasValue).OrderBy(x => x.CreationTimeStamp))
/*foreach (var p in aPositions.Where(x => x.PipsPnLInCurrency.HasValue).OrderBy(x => x.CreationTimeStamp))
{
dEquity += p.PipsPnLInCurrency.Value;
cEquity e = new cEquity();
Expand All @@ -24,7 +24,7 @@ public static List<cEquity> GetEquityCurve(List<VisualHFT.Model.Position> aPosit
e.Equity = dEquity;
e.VolumeQty = p.OrderQuantity;
dRet.Add(e);
}
}*/
return dRet;
}
public static List<cEquity> GetEquityCurveByHour(List<VisualHFT.Model.Position> aPositions)
Expand Down Expand Up @@ -62,14 +62,14 @@ public static List<cBalance> GetBalanceCurve(List<VisualHFT.Model.Position> aPos
if (aPositions == null || aPositions.Count == 0)
return null;
List<cBalance> dRet = new List<cBalance>();
foreach (var p in aPositions.Where(x => x.PipsPnLInCurrency.HasValue).OrderBy(x => x.CreationTimeStamp))
/*foreach (var p in aPositions.Where(x => x.PipsPnLInCurrency.HasValue).OrderBy(x => x.CreationTimeStamp))
{
//OPEN
dRet.Add(new cBalance() { Date = p.CreationTimeStamp, Balance = -(p.GetOpenAvgPrice * p.GetOpenQuantity) });
//CLOSE
if (p.CloseTimeStamp > p.CreationTimeStamp)
dRet.Add(new cBalance() { Date = p.CloseTimeStamp, Balance = -(p.GetCloseAvgPrice * p.GetCloseQuantity) });
}
}*/
//MAKE IT cummulative
decimal dBalance = 0;
foreach(var b in dRet)
Expand Down
Loading