Connecting C# libraries

To write trading robots, you can use the functionality of third-party C# libraries. Before using, copy the required dll to the folder ..\BotAssemblies\

 The Math.NET Numerics library that has methods and algorithms for numerical computations in science, technology and everyday use was included in the distribution.

Topics covered include Special Functions, Linear Algebra, Probabilistic Models, Random Numbers, Interpolation, Integral Transforms, and more. For more information, visit the official website https://numerics.mathdotnet.com/

MathNet.Numerics

An example of using mathematical statistics functions:

using System;
using TraderAPI;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Collections.Generic;

using MathNet.Numerics.Statistics;


namespace uAlgo.Bots
{
 public class NewBot : Bot
 {
 
 //------------------------------------------------
 //
 //------------------------------------------------
 private void Print(string f, string l)
 {
 // get the path to the folder with our robot
 string AssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar.ToString(); 
 // full path to the file for recording service information 
 string mLog = AssemblyPath + f;

 using (StreamWriter sw = new StreamWriter(mLog, true))
 sw.WriteLine(l);
 }
 //------------------------------------------------
 //
 //------------------------------------------------
 public void OnTick()
 {

 }

 public void OnStart()
 {
 IEnumerable<double> data = new double[] {
 7,
 2,
 3,
 4,
 5
 };

 IEnumerable<double> data2 = new double[] {
 4,
 5,
 5,
 5,
 5
 };

 double minimum = data.Minimum();
 double maximum = data.Maximum();
 double mean = data.Mean();
 double sd = data.StandardDeviation();
 double median = data.Median();
 double gmean = data.GeometricMean();
 double covar = data.Covariance(data2);

 
 Print("result.txt",
 "\nMean = " + mean.ToString() +
 "\nMinimum = " + minimum.ToString() +
 "\nMaximum = " + maximum.ToString() +
 "\nSD = " + sd.ToString() +
 "\nMedian = " + median.ToString() +
 "\ngMean = " + gmean.ToString() +
 "\nCovar = " + covar.ToString() 
 );
 }

 public void OnStop()
 {
 // Put your deinitialization logic here
 }
 }
}

// Result:

// Mean = 4.2
// Minimumu = 2
// Maximum = 7
// SD = 1.92353840616713
// Median = 4
// gMean = 3ю844641568
// Covar = -0.7