mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 12:38:06 +00:00
cleaned-up GBM, removed Python tests
This commit is contained in:
@@ -51,7 +51,7 @@ public class GBM_Feed : TBars
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static double GBM_value (double Seed, double Volatility, double Drift) {
|
private static double GBM_value (double Seed, double Volatility, double Drift) {
|
||||||
Random rnd = new((int)(DateTime.UtcNow.Ticks));
|
Random rnd = new();
|
||||||
double U1 = 1.0-rnd.NextDouble();
|
double U1 = 1.0-rnd.NextDouble();
|
||||||
double U2 = 1.0-rnd.NextDouble();
|
double U2 = 1.0-rnd.NextDouble();
|
||||||
double Z = Math.Sqrt(-2.0 * Math.Log(U1)) * Math.Sin(2.0 * Math.PI * U2);
|
double Z = Math.Sqrt(-2.0 * Math.Log(U1)) * Math.Sin(2.0 * Math.PI * U2);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>0.1.14</Version>
|
<Version>0.1.15</Version>
|
||||||
<releaseNotes>
|
<releaseNotes>
|
||||||
</releaseNotes>
|
</releaseNotes>
|
||||||
<Title>QuanTAlib</Title>
|
<Title>QuanTAlib</Title>
|
||||||
|
|||||||
+7
-14
@@ -28,24 +28,17 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Validations\Pandas_TA.cstemp" />
|
<PackageReference Include="JetBrains.dotCover.CommandLineTools" Version="2022.3.0-eap07">
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="Validations\Pandas_TA.cstemp" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="JetBrains.dotCover.CommandLineTools" Version="2022.1.0-eap10">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0-preview-20220401-08" />
|
<PackageReference Include="Microsoft.JSInterop.WebAssembly" Version="7.0.0-rc.2.22476.2" />
|
||||||
<PackageReference Include="Python.Included" Version="3.7.3.13" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
|
||||||
|
<PackageReference Include="Python.Included" Version="3.10.0-preview5" />
|
||||||
<PackageReference Include="TALib.NETCore" Version="0.4.4" />
|
<PackageReference Include="TALib.NETCore" Version="0.4.4" />
|
||||||
<PackageReference Include="Skender.Stock.Indicators" Version="1.23.0" />
|
<PackageReference Include="Skender.Stock.Indicators" Version="2.4.0" />
|
||||||
<PackageReference Include="xunit" Version="2.4.2-pre.12" />
|
<PackageReference Include="xunit" Version="2.4.2" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -1,120 +1,124 @@
|
|||||||
using Xunit;
|
/*
|
||||||
using System;
|
|
||||||
using QuanTAlib;
|
using Xunit;
|
||||||
using Python.Runtime;
|
using System;
|
||||||
using Python.Included;
|
using QuanTAlib;
|
||||||
|
using Python.Runtime;
|
||||||
namespace Validation;
|
using Python.Included;
|
||||||
public class PandasTA
|
|
||||||
{
|
namespace Validation;
|
||||||
private readonly RND_Feed bars;
|
public class PandasTA
|
||||||
private readonly Random rnd = new();
|
{
|
||||||
private readonly int period;
|
private readonly RND_Feed bars;
|
||||||
private readonly dynamic ta;
|
private readonly Random rnd = new();
|
||||||
private readonly dynamic df;
|
private readonly int period;
|
||||||
|
private readonly dynamic ta;
|
||||||
public PandasTA()
|
private readonly dynamic df;
|
||||||
{
|
|
||||||
this.bars = new(1000);
|
public PandasTA()
|
||||||
this.period = this.rnd.Next(28) + 3;
|
{
|
||||||
|
this.bars = new(1000);
|
||||||
Installer.SetupPython().Wait();
|
this.period = this.rnd.Next(28) + 3;
|
||||||
Installer.TryInstallPip();
|
|
||||||
Installer.PipInstallModule("numpy");
|
Installer.SetupPython().Wait();
|
||||||
Installer.PipInstallModule("pandas");
|
Installer.TryInstallPip();
|
||||||
Installer.PipInstallModule("pandas-ta");
|
Installer.PipInstallModule("numpy");
|
||||||
PythonEngine.Initialize();
|
Installer.PipInstallModule("pandas");
|
||||||
this.ta = Py.Import("pandas_ta");
|
Installer.PipInstallModule("pandas-ta");
|
||||||
this.df = this.ta.DataFrame(this.bars.Close.v);
|
PythonEngine.Initialize();
|
||||||
}
|
this.ta = Py.Import("pandas_ta");
|
||||||
|
this.df = this.ta.DataFrame(this.bars.Close.v);
|
||||||
~PandasTA()
|
}
|
||||||
{
|
|
||||||
PythonEngine.Shutdown();
|
~PandasTA()
|
||||||
}
|
{
|
||||||
|
PythonEngine.Shutdown();
|
||||||
[Fact]
|
}
|
||||||
void SMA()
|
|
||||||
{
|
[Fact]
|
||||||
SMA_Series QL = new(this.bars.Close, this.period, false);
|
void SMA()
|
||||||
var pta = this.ta.sma(close: this.df[0], length: this.period);
|
{
|
||||||
|
SMA_Series QL = new(this.bars.Close, this.period, false);
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
var pta = this.ta.sma(close: this.df[0], length: this.period);
|
||||||
}
|
|
||||||
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||||
/*
|
}
|
||||||
[Fact]
|
|
||||||
void EMA()
|
|
||||||
{
|
[Fact]
|
||||||
EMA_Series QL = new(this.bars.Close, this.period, false);
|
void EMA()
|
||||||
var pta = this.ta.ema(close: this.df[0], length: this.period);
|
{
|
||||||
|
EMA_Series QL = new(this.bars.Close, this.period, false);
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
var pta = this.ta.ema(close: this.df[0], length: this.period);
|
||||||
}
|
|
||||||
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||||
[Fact]
|
}
|
||||||
void TEMA()
|
|
||||||
{
|
|
||||||
TEMA_Series QL = new(this.bars.Close, this.period, false);
|
[Fact]
|
||||||
var pta = this.ta.tema(close: this.df[0], length: this.period);
|
void TEMA()
|
||||||
|
{
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
TEMA_Series QL = new(this.bars.Close, this.period, false);
|
||||||
}
|
var pta = this.ta.tema(close: this.df[0], length: this.period);
|
||||||
|
|
||||||
[Fact]
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||||
void ENTP()
|
}
|
||||||
{
|
|
||||||
ENTP_Series QL = new(this.bars.Close, this.period, useNaN:false);
|
[Fact]
|
||||||
var pta = this.ta.entropy(close: this.df[0], length: this.period);
|
void ENTP()
|
||||||
|
{
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
ENTP_Series QL = new(this.bars.Close, this.period, useNaN:false);
|
||||||
}
|
var pta = this.ta.entropy(close: this.df[0], length: this.period);
|
||||||
|
|
||||||
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||||
[Fact]
|
}
|
||||||
void WMA()
|
|
||||||
{
|
|
||||||
WMA_Series QL = new(this.bars.Close, this.period, false);
|
[Fact]
|
||||||
var pta = this.ta.wma(close: this.df[0], length: this.period);
|
void WMA()
|
||||||
|
{
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
WMA_Series QL = new(this.bars.Close, this.period, false);
|
||||||
}
|
var pta = this.ta.wma(close: this.df[0], length: this.period);
|
||||||
|
|
||||||
[Fact]
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||||
void DEMA()
|
}
|
||||||
{
|
|
||||||
DEMA_Series QL = new(this.bars.Close, this.period, false);
|
[Fact]
|
||||||
var pta = this.ta.dema(close: this.df[0], length: this.period);
|
void DEMA()
|
||||||
|
{
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
DEMA_Series QL = new(this.bars.Close, this.period, false);
|
||||||
}
|
var pta = this.ta.dema(close: this.df[0], length: this.period);
|
||||||
|
|
||||||
[Fact]
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||||
void BIAS()
|
}
|
||||||
{
|
|
||||||
BIAS_Series QL = new(this.bars.Close, this.period, false);
|
[Fact]
|
||||||
var pta = this.ta.bias(close: this.df[0], length: this.period);
|
void BIAS()
|
||||||
|
{
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
BIAS_Series QL = new(this.bars.Close, this.period, false);
|
||||||
}
|
var pta = this.ta.bias(close: this.df[0], length: this.period);
|
||||||
|
|
||||||
[Fact]
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||||
void KURT()
|
}
|
||||||
{
|
|
||||||
KURT_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
[Fact]
|
||||||
var pta = this.ta.kurtosis(close: this.df[0], length: this.period);
|
void KURT()
|
||||||
|
{
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 4), Math.Round(QL.Last().v, 4));
|
KURT_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||||
}
|
var pta = this.ta.kurtosis(close: this.df[0], length: this.period);
|
||||||
|
|
||||||
[Fact]
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 4), Math.Round(QL.Last().v, 4));
|
||||||
void MAD()
|
}
|
||||||
{
|
|
||||||
MAD_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
[Fact]
|
||||||
var pta = this.ta.mad(close: this.df[0], length: this.period);
|
void MAD()
|
||||||
|
{
|
||||||
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
MAD_Series QL = new(this.bars.Close, this.period, useNaN: false);
|
||||||
}
|
var pta = this.ta.mad(close: this.df[0], length: this.period);
|
||||||
*/
|
|
||||||
|
Assert.Equal(System.Math.Round((double)pta.tail(1), 7), Math.Round(QL.Last().v, 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -7,7 +7,7 @@ using Xunit;
|
|||||||
namespace Validation;
|
namespace Validation;
|
||||||
public class Skender_Stock
|
public class Skender_Stock
|
||||||
{
|
{
|
||||||
private readonly RND_Feed bars;
|
private readonly GBM_Feed bars;
|
||||||
private readonly Random rnd = new();
|
private readonly Random rnd = new();
|
||||||
private readonly int period;
|
private readonly int period;
|
||||||
private readonly IEnumerable<Quote> quotes;
|
private readonly IEnumerable<Quote> quotes;
|
||||||
@@ -32,7 +32,7 @@ public class Skender_Stock
|
|||||||
public void SMA()
|
public void SMA()
|
||||||
{
|
{
|
||||||
SMA_Series QL = new(this.bars.Close, this.period, false);
|
SMA_Series QL = new(this.bars.Close, this.period, false);
|
||||||
var SK = this.quotes.GetSma(this.period, CandlePart.Close);
|
var SK = this.quotes.GetSma(this.period);
|
||||||
|
|
||||||
Assert.Equal(Math.Round((double)SK.Last().Sma!, 8), Math.Round(QL.Last().v, 8));
|
Assert.Equal(Math.Round((double)SK.Last().Sma!, 8), Math.Round(QL.Last().v, 8));
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ public class Skender_Stock
|
|||||||
public void EMA()
|
public void EMA()
|
||||||
{
|
{
|
||||||
EMA_Series QL = new(this.bars.Close, this.period, false);
|
EMA_Series QL = new(this.bars.Close, this.period, false);
|
||||||
var SK = this.quotes.GetEma(this.period, CandlePart.Close);
|
var SK = this.quotes.GetEma(this.period);
|
||||||
|
|
||||||
Assert.Equal(Math.Round((double)SK.Last().Ema!, 8), Math.Round(QL.Last().v, 8));
|
Assert.Equal(Math.Round((double)SK.Last().Ema!, 8), Math.Round(QL.Last().v, 8));
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ public class Skender_Stock
|
|||||||
public void WMA()
|
public void WMA()
|
||||||
{
|
{
|
||||||
WMA_Series QL = new(this.bars.Close, this.period, false);
|
WMA_Series QL = new(this.bars.Close, this.period, false);
|
||||||
var SK = this.quotes.GetWma(this.period, CandlePart.Close);
|
var SK = this.quotes.GetWma(this.period);
|
||||||
|
|
||||||
Assert.Equal(Math.Round((double)SK.Last().Wma!, 8), Math.Round(QL.Last().v, 8));
|
Assert.Equal(Math.Round((double)SK.Last().Wma!, 8), Math.Round(QL.Last().v, 8));
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ public class Skender_Stock
|
|||||||
public void MAD()
|
public void MAD()
|
||||||
{
|
{
|
||||||
MAD_Series QL = new(this.bars.Close, this.period, false);
|
MAD_Series QL = new(this.bars.Close, this.period, false);
|
||||||
var SK = this.quotes.GetSmaExtended(this.period);
|
var SK = this.quotes.GetSmaAnalysis(this.period);
|
||||||
|
|
||||||
Assert.Equal(Math.Round((double)SK.Last().Mad!, 8), Math.Round(QL.Last().v, 8));
|
Assert.Equal(Math.Round((double)SK.Last().Mad!, 8), Math.Round(QL.Last().v, 8));
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ public class Skender_Stock
|
|||||||
public void MAPE()
|
public void MAPE()
|
||||||
{
|
{
|
||||||
MAPE_Series QL = new(this.bars.Close, this.period, false);
|
MAPE_Series QL = new(this.bars.Close, this.period, false);
|
||||||
var SK = this.quotes.GetSmaExtended(this.period);
|
var SK = this.quotes.GetSmaAnalysis(this.period);
|
||||||
|
|
||||||
Assert.Equal(Math.Round((double)SK.Last().Mape!, 8), Math.Round(QL.Last().v, 8));
|
Assert.Equal(Math.Round((double)SK.Last().Mape!, 8), Math.Round(QL.Last().v, 8));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using QuanTAlib;
|
|||||||
namespace Validation;
|
namespace Validation;
|
||||||
public class TA_LIB
|
public class TA_LIB
|
||||||
{
|
{
|
||||||
private readonly RND_Feed bars;
|
private readonly GBM_Feed bars;
|
||||||
private readonly Random rnd = new();
|
private readonly Random rnd = new();
|
||||||
private readonly int period;
|
private readonly int period;
|
||||||
private readonly double[] TALIB;
|
private readonly double[] TALIB;
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
|
||||||
|
## 1. Prepare the Peloton tablet
|
||||||
|
|
||||||
|
Stop Peloton overlay app:
|
||||||
|
- tap on Settings in the top right corner and select Device Settings
|
||||||
|
- tap Apps and scroll down to find and tap Peloton app (not Peloton Launcher, just Peloton)
|
||||||
|
- tap FORCE STOP to stop the app overlay
|
||||||
|
- confrm by tapping OK
|
||||||
|
|
||||||
|
Turn on developer mode
|
||||||
|
- return to Settings page
|
||||||
|
- tap About tablet in System section
|
||||||
|
- tap Build number repeatedly until you activate developer mode
|
||||||
|
|
||||||
|
Enable USB debugging
|
||||||
|
- return to Settings page
|
||||||
|
- tap (now visible) Developer options in System section
|
||||||
|
- scroll down to find USB Debugging option
|
||||||
|
- Enable USB debugging
|
||||||
|
- Confirm by tapping OK
|
||||||
|
|
||||||
|
## 3. Prepare the PC with Zwift/Rouvy
|
||||||
|
|
||||||
|
- Create your Splashtop account https://my.splashtop.com/login
|
||||||
|
- Download and install Splashtop Streamer https://www.splashtop.com/downloads#pers
|
||||||
|
- Download Android Platform Tools https://developer.android.com/studio/releases/platform-tools
|
||||||
|
- Download Nova launcher APK (or any other launcher that works on Android 7) https://apkpure.com/nova-launcher/com.teslacoilsw.launcher/download/62019-APK
|
||||||
|
- Download Splashtop APK https://apkpure.com/splashtop-personal-access/com.splashtop.remote.pad.v2
|
||||||
|
- Unzip Android tools into a new folder
|
||||||
|
- move both APKs to the same folder
|
||||||
|
- Run Command Prompt (CMD) and move to the same folder
|
||||||
|
- Launch Android Debuging Bridge: adb start-server
|
||||||
|
- Connect PC and Peloton tablet with USB cable
|
||||||
|
- Peloton tablet will check for confirmation; Accept debugging over USB
|
||||||
|
- Verify connectivity on PC in the Command window: adb devices
|
||||||
|
|
||||||
|
## 4. Side-load APKs
|
||||||
|
|
||||||
|
- Execute the following three commands on PC:
|
||||||
|
adb shell settings put secure install_non_market_apps 1
|
||||||
|
adb install <name_of_nova_launcher.apk>
|
||||||
|
adb install <name_of_splashtop.apk>
|
||||||
|
- Disconnect USB cable
|
||||||
|
- On Peloton tablet tap Peloton 'P' logo at the bottom
|
||||||
|
- Select Nova as a default launcher
|
||||||
|
- Accept all defaults for Nova launcher - you can customize it later
|
||||||
|
|
||||||
|
|
||||||
|
- (optional) Bring Peloton and Splashtop icons to the main page of Nova launcher
|
||||||
|
- Choosing Peloton launches Peloton app; Choosing Splashtop launches Splashtop app
|
||||||
|
- Swiping down from the top of the screen reveals the hidden 'P' launcher button
|
||||||
|
|
||||||
|
## 5. Connect Peloton tablet and PC
|
||||||
|
|
||||||
|
- Launch Splashtop app on Peloton tablet
|
||||||
|
- Login with Splashtop credentials
|
||||||
|
- Connect to PC that runs Splashtop streamer (and Zwift/Rouvy)
|
||||||
|
- Launch Zwift/Rouvy
|
||||||
|
|
||||||
|
## 5. Enable sensors
|
||||||
|
|
||||||
|
- (optional): buy ANT+ USB dongle https://www.amazon.com/s?k=ant%2B+USB+stick
|
||||||
|
|
||||||
|
Peloton Tread:
|
||||||
|
Speed: Runn https://npe-inc.com/runn-smart-treadmill-sensor-2/
|
||||||
|
(or Stryd https://www.stryd.com/us/en)
|
||||||
|
Cadence: Garmin foodpod (or Stryd)
|
||||||
|
Heartrate: any HR monitor (BT or ANT+) https://www.amazon.com/s?k=bluetooth+HR+monitor
|
||||||
|
Power: Stryd
|
||||||
|
|
||||||
|
Peloton Bike (gen1):
|
||||||
|
Power & Cadence: DFC (Data Fitness Connector) https://www.crowdsupply.com/intelligenate/data-fitness-connector
|
||||||
|
Heartrate:vany HR monitor (BT or ANT+)
|
||||||
|
|
||||||
|
## 6. Navigation
|
||||||
|
|
||||||
|
Nova is now a default launcher on Android tablet, but on Tread we need to run Peloton app in the background to prevent locking of treadmill:
|
||||||
|
|
||||||
|
- Launch Peloton app
|
||||||
|
- Swipe down from the top and return to Nova launcher
|
||||||
|
- Launch Splashtop app
|
||||||
|
- Connect to PC
|
||||||
|
- Launch Zwift or Rouvy
|
||||||
|
- Connect all sensors
|
||||||
|
- Run/Ride!
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user