diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..37f0d820 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "gitversion.tool": { + "version": "5.12.0", + "commands": [ + "dotnet-gitversion" + ] + } + } +} diff --git a/.gitignore b/.gitignore index dc4496da..28750fdb 100644 --- a/.gitignore +++ b/.gitignore @@ -395,4 +395,7 @@ FodyWeavers.xsd *.msp # JetBrains Rider -*.sln.iml \ No newline at end of file +*.sln.iml + +# Cline Memory Bank - exclude from git +memory-bank/ diff --git a/.vscode/settings.json b/.vscode/settings.json index e27b36ee..970bdfa4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,23 +1,10 @@ { - "sonarlint.connectedMode.connections.sonarcloud": [ - { - "organizationKey": "mihakralj", - "token": "6df7cd62a17dc4e1c5532df1da2f49d5a977dd50", - "connectionId": "mihakralj" - } - ], - "sarif-viewer.connectToGithubCodeScanning": "on", - "omnisharp.useModernNet": true, - "sonarlint.connectedMode.project": { - "connectionId": "mihakralj", - "projectKey": "mihakralj_QuanTAlib" - }, - "dotnet.backgroundAnalysis.analyzerDiagnosticsScope": "fullSolution", - "dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true, - "dotnetAcquisitionExtension.enableTelemetry": false, - "dotnet-test-explorer.testProjectPath": "Tests", - "dotnet-test-explorer.autoWatch": true, - "dotnet-test-explorer.showCodeLens": true, - "dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=./TestResults/coverage.cobertura.xml" - + "terminal.integrated.defaultProfile.windows": "PowerShell", + "terminal.integrated.profiles.windows": { + "PowerShell": { + "source": "PowerShell", + "icon": "terminal-powershell" + } + }, + "terminal.integrated.shellIntegration.enabled": true } diff --git a/Directory.Build.props b/Directory.Build.props index a201aae9..3e313696 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - net9.0 + net8.0 preview $(NoWarn);NU1903;NU5104;NETSDK1057 enable @@ -50,11 +50,11 @@ - + - D:\Quantower + Z:\Quantower $([System.IO.Directory]::GetDirectories("$(QuantowerRoot)\TradingPlatform", "v1*")[0]) diff --git a/GitVersion.yml b/GitVersion.yml index d89b5d96..2f3c6554 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,4 +1,3 @@ -workflow: GitHubFlow/v1 assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch major-version-bump-message: '\+semver:\s?(breaking|major)' @@ -6,34 +5,22 @@ minor-version-bump-message: '\+semver:\s?(feature|minor)' patch-version-bump-message: '\+semver:\s?(fix|patch)' no-bump-message: '\+semver:\s?(none|skip)' tag-prefix: '[vV]' -semantic-version-format: Strict - branches: main: - label: '' regex: ^main$ mode: ContinuousDeployment increment: Patch - prevent-increment: - of-merged-branch: true track-merge-target: false - track-merge-message: true is-release-branch: true pre-release-weight: 0 - - - dev: - label: beta + develop: regex: ^dev(elop)?(ment)?$ mode: ContinuousDelivery increment: Patch - prevent-increment: - when-current-commit-tagged: false track-merge-target: true is-release-branch: false source-branches: ['main'] pre-release-weight: 30000 - ignore: sha: [] merge-message-formats: {} diff --git a/QuanTAlib.sln b/QuanTAlib.sln index 561c1471..63971a37 100644 --- a/QuanTAlib.sln +++ b/QuanTAlib.sln @@ -1,80 +1,87 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 +VisualStudioVersion = 17.5.2.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "quantalib", "lib\quantalib.csproj", "{1E050FA4-630E-4801-9DE9-D2536DACA9B0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{9CF47860-2CEA-F379-09D8-9AEF27965D12}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "quantower", "quantower", "{1B9AC248-76F8-44DD-958D-F1DC08EE1E87}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "quantalib", "lib\quantalib.csproj", "{F455234B-2A3C-140A-17C3-683D7820A733}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Statistics", "quantower\Statistics\_Statistics.csproj", "{2E9427C7-144F-488E-A29D-789ACC1C32AE}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "quantower", "quantower", "{6CF592EE-4302-E72F-3CB4-AB1D314DD5A8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Averages", "quantower\Averages\_Averages.csproj", "{6BE10C39-4127-446C-818B-7976FCDD51D5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Averages", "quantower\Averages\_Averages.csproj", "{F6651413-2F44-2F7B-EBE6-A300E8655AFD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volatility", "quantower\Volatility\_Volatility.csproj", "{B7DC44F7-D3A3-4C70-9025-513E0182B646}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Experiments", "quantower\Experiments\_Experiments.csproj", "{87051F5D-8006-0241-4339-A1B2D29EA094}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Oscillators", "quantower\Oscillators\_Oscillators.csproj", "{C4D8F5D0-E6A7-4B7D-B8E9-F55C3F8D9D01}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Momentum", "quantower\Momentum\_Momentum.csproj", "{2D6628C9-C059-15E9-F3A0-C50F1BCCADA0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volume", "quantower\Volume\_Volume.csproj", "{D5E9F6D1-B8A8-4C7E-9FA0-F66C3F8D9D02}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Oscillators", "quantower\Oscillators\_Oscillators.csproj", "{A95DA667-23DF-4067-A173-E9C7FC430D09}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Momentum", "quantower\Momentum\_Momentum.csproj", "{E6F0F7D2-C9B9-4D8F-0FA1-F77C4F9D9D03}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Statistics", "quantower\Statistics\_Statistics.csproj", "{556D8C92-E3DD-F64A-53B1-D741A96888F2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Experiments", "quantower\Experiments\_Experiments.csproj", "{F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Volatility", "quantower\Volatility\_Volatility.csproj", "{4FAD1FB1-4696-ABF4-50D9-162F81114A20}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{2D97C971-20BF-40DB-94AA-3279F787D3CB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_Volume", "quantower\Volume\_Volume.csproj", "{03C2D1D7-AB94-445B-2127-285A367DC6A6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {908D03EE-717E-7E8C-7EAA-0DF14BA8C45E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {908D03EE-717E-7E8C-7EAA-0DF14BA8C45E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {908D03EE-717E-7E8C-7EAA-0DF14BA8C45E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {908D03EE-717E-7E8C-7EAA-0DF14BA8C45E}.Release|Any CPU.Build.0 = Release|Any CPU + {9CF47860-2CEA-F379-09D8-9AEF27965D12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9CF47860-2CEA-F379-09D8-9AEF27965D12}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9CF47860-2CEA-F379-09D8-9AEF27965D12}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9CF47860-2CEA-F379-09D8-9AEF27965D12}.Release|Any CPU.Build.0 = Release|Any CPU + {F455234B-2A3C-140A-17C3-683D7820A733}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F455234B-2A3C-140A-17C3-683D7820A733}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F455234B-2A3C-140A-17C3-683D7820A733}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F455234B-2A3C-140A-17C3-683D7820A733}.Release|Any CPU.Build.0 = Release|Any CPU + {F6651413-2F44-2F7B-EBE6-A300E8655AFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6651413-2F44-2F7B-EBE6-A300E8655AFD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6651413-2F44-2F7B-EBE6-A300E8655AFD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6651413-2F44-2F7B-EBE6-A300E8655AFD}.Release|Any CPU.Build.0 = Release|Any CPU + {87051F5D-8006-0241-4339-A1B2D29EA094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87051F5D-8006-0241-4339-A1B2D29EA094}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87051F5D-8006-0241-4339-A1B2D29EA094}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87051F5D-8006-0241-4339-A1B2D29EA094}.Release|Any CPU.Build.0 = Release|Any CPU + {2D6628C9-C059-15E9-F3A0-C50F1BCCADA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D6628C9-C059-15E9-F3A0-C50F1BCCADA0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D6628C9-C059-15E9-F3A0-C50F1BCCADA0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D6628C9-C059-15E9-F3A0-C50F1BCCADA0}.Release|Any CPU.Build.0 = Release|Any CPU + {A95DA667-23DF-4067-A173-E9C7FC430D09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A95DA667-23DF-4067-A173-E9C7FC430D09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A95DA667-23DF-4067-A173-E9C7FC430D09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A95DA667-23DF-4067-A173-E9C7FC430D09}.Release|Any CPU.Build.0 = Release|Any CPU + {556D8C92-E3DD-F64A-53B1-D741A96888F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {556D8C92-E3DD-F64A-53B1-D741A96888F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {556D8C92-E3DD-F64A-53B1-D741A96888F2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {556D8C92-E3DD-F64A-53B1-D741A96888F2}.Release|Any CPU.Build.0 = Release|Any CPU + {4FAD1FB1-4696-ABF4-50D9-162F81114A20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4FAD1FB1-4696-ABF4-50D9-162F81114A20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4FAD1FB1-4696-ABF4-50D9-162F81114A20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4FAD1FB1-4696-ABF4-50D9-162F81114A20}.Release|Any CPU.Build.0 = Release|Any CPU + {03C2D1D7-AB94-445B-2127-285A367DC6A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03C2D1D7-AB94-445B-2127-285A367DC6A6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03C2D1D7-AB94-445B-2127-285A367DC6A6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03C2D1D7-AB94-445B-2127-285A367DC6A6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1E050FA4-630E-4801-9DE9-D2536DACA9B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1E050FA4-630E-4801-9DE9-D2536DACA9B0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1E050FA4-630E-4801-9DE9-D2536DACA9B0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1E050FA4-630E-4801-9DE9-D2536DACA9B0}.Release|Any CPU.Build.0 = Release|Any CPU - {2E9427C7-144F-488E-A29D-789ACC1C32AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E9427C7-144F-488E-A29D-789ACC1C32AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E9427C7-144F-488E-A29D-789ACC1C32AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E9427C7-144F-488E-A29D-789ACC1C32AE}.Release|Any CPU.Build.0 = Release|Any CPU - {6BE10C39-4127-446C-818B-7976FCDD51D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6BE10C39-4127-446C-818B-7976FCDD51D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6BE10C39-4127-446C-818B-7976FCDD51D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6BE10C39-4127-446C-818B-7976FCDD51D5}.Release|Any CPU.Build.0 = Release|Any CPU - {B7DC44F7-D3A3-4C70-9025-513E0182B646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7DC44F7-D3A3-4C70-9025-513E0182B646}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B7DC44F7-D3A3-4C70-9025-513E0182B646}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7DC44F7-D3A3-4C70-9025-513E0182B646}.Release|Any CPU.Build.0 = Release|Any CPU - {C4D8F5D0-E6A7-4B7D-B8E9-F55C3F8D9D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C4D8F5D0-E6A7-4B7D-B8E9-F55C3F8D9D01}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C4D8F5D0-E6A7-4B7D-B8E9-F55C3F8D9D01}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C4D8F5D0-E6A7-4B7D-B8E9-F55C3F8D9D01}.Release|Any CPU.Build.0 = Release|Any CPU - {D5E9F6D1-B8A8-4C7E-9FA0-F66C3F8D9D02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D5E9F6D1-B8A8-4C7E-9FA0-F66C3F8D9D02}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D5E9F6D1-B8A8-4C7E-9FA0-F66C3F8D9D02}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D5E9F6D1-B8A8-4C7E-9FA0-F66C3F8D9D02}.Release|Any CPU.Build.0 = Release|Any CPU - {E6F0F7D2-C9B9-4D8F-0FA1-F77C4F9D9D03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E6F0F7D2-C9B9-4D8F-0FA1-F77C4F9D9D03}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E6F0F7D2-C9B9-4D8F-0FA1-F77C4F9D9D03}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E6F0F7D2-C9B9-4D8F-0FA1-F77C4F9D9D03}.Release|Any CPU.Build.0 = Release|Any CPU - {F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04}.Release|Any CPU.Build.0 = Release|Any CPU - {2D97C971-20BF-40DB-94AA-3279F787D3CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2D97C971-20BF-40DB-94AA-3279F787D3CB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2D97C971-20BF-40DB-94AA-3279F787D3CB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2D97C971-20BF-40DB-94AA-3279F787D3CB}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection GlobalSection(NestedProjects) = preSolution - {2E9427C7-144F-488E-A29D-789ACC1C32AE} = {1B9AC248-76F8-44DD-958D-F1DC08EE1E87} - {6BE10C39-4127-446C-818B-7976FCDD51D5} = {1B9AC248-76F8-44DD-958D-F1DC08EE1E87} - {B7DC44F7-D3A3-4C70-9025-513E0182B646} = {1B9AC248-76F8-44DD-958D-F1DC08EE1E87} - {C4D8F5D0-E6A7-4B7D-B8E9-F55C3F8D9D01} = {1B9AC248-76F8-44DD-958D-F1DC08EE1E87} - {D5E9F6D1-B8A8-4C7E-9FA0-F66C3F8D9D02} = {1B9AC248-76F8-44DD-958D-F1DC08EE1E87} - {E6F0F7D2-C9B9-4D8F-0FA1-F77C4F9D9D03} = {1B9AC248-76F8-44DD-958D-F1DC08EE1E87} - {F7F1F8D3-DAC0-4E9F-1FB2-F88D5F0E0E04} = {1B9AC248-76F8-44DD-958D-F1DC08EE1E87} + {F6651413-2F44-2F7B-EBE6-A300E8655AFD} = {6CF592EE-4302-E72F-3CB4-AB1D314DD5A8} + {87051F5D-8006-0241-4339-A1B2D29EA094} = {6CF592EE-4302-E72F-3CB4-AB1D314DD5A8} + {2D6628C9-C059-15E9-F3A0-C50F1BCCADA0} = {6CF592EE-4302-E72F-3CB4-AB1D314DD5A8} + {A95DA667-23DF-4067-A173-E9C7FC430D09} = {6CF592EE-4302-E72F-3CB4-AB1D314DD5A8} + {556D8C92-E3DD-F64A-53B1-D741A96888F2} = {6CF592EE-4302-E72F-3CB4-AB1D314DD5A8} + {4FAD1FB1-4696-ABF4-50D9-162F81114A20} = {6CF592EE-4302-E72F-3CB4-AB1D314DD5A8} + {03C2D1D7-AB94-445B-2127-285A367DC6A6} = {6CF592EE-4302-E72F-3CB4-AB1D314DD5A8} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E6DB434C-508E-4231-B8A6-5EDD7FF87E22} EndGlobalSection EndGlobal diff --git a/SyntheticVendor/SyntheticVendor.cs b/SyntheticVendor/SyntheticVendor.cs deleted file mode 100644 index 89033c94..00000000 --- a/SyntheticVendor/SyntheticVendor.cs +++ /dev/null @@ -1,1105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using TradingPlatform.BusinessLayer; -using TradingPlatform.BusinessLayer.Integration; -using System.Diagnostics.CodeAnalysis; - -namespace SyntheticVendorNamespace; - -public class SyntheticVendor : Vendor -{ - private readonly List exchanges; - private readonly List assets; - private readonly List symbols; - - public SyntheticVendor() - { - exchanges = new List - { - //Spike, - //Impulse, - //Triangle, - //Sawtooth - //Sine - //Chirp - //White - //Gauss - //B - //HF - //Impulse+HF, - //Sawtooth+HF - //Sine+G - //Chirp+G - //Complex - //Market - - new MessageExchange { Id = "PU", ExchangeName = "1 Pulse" }, - new MessageExchange { Id = "WA", ExchangeName = "2 Wave" }, - new MessageExchange { Id = "MD", ExchangeName = "3 Modulation" }, - new MessageExchange { Id = "NO", ExchangeName = "4 Noise" }, - new MessageExchange { Id = "BR", ExchangeName = "5 Brownian" }, - new MessageExchange { Id = "QT", ExchangeName = "6 QuanTAlib" } - }; - - assets = new List - { - new MessageAsset { Id = "USD", Name = "USD" }, - }; - - symbols = new List - { - CreateMessageSymbol(id: "W1", name: "1 Digital spike", exchangeId: "QT", assetId: "USD", type: SymbolType.Crypto, - description: "Sudden sharp spike in the signal"), - CreateMessageSymbol("W2", "2 Dirac delta spike", "QT", "USD", SymbolType.Crypto), - CreateMessageSymbol("W8", "4 Sinc pulse", "QT", "USD", SymbolType.Crypto), - - CreateMessageSymbol("W3", "1 Square Wave", "QT", "USD", SymbolType.ETF), - CreateMessageSymbol("W4", "2 Sawtooth Wave", "QT", "USD", SymbolType.ETF), - CreateMessageSymbol("W5", "3 Inverse sawtooth Wave", "QT", "USD", SymbolType.ETF), - CreateMessageSymbol("W6", "4 Triangle Wave", "QT", "USD", SymbolType.ETF), - CreateMessageSymbol("W7", "5 Sine Wave", "QT", "USD", SymbolType.ETF), - - CreateMessageSymbol("W11", "1 Amplitude modulation", "QT", "USD", SymbolType.Forex), - CreateMessageSymbol("W10", "2 Frequency sweep", "QT", "USD", SymbolType.Forex), - CreateMessageSymbol("W12", "3 Frequency modulation", "QT", "USD", SymbolType.Forex), - - CreateMessageSymbol("W13", "1 White noise", "QT", "USD", SymbolType.Indexes), - CreateMessageSymbol("W14", "2 Pink noise", "QT", "USD", SymbolType.Indexes), - CreateMessageSymbol("W15", "3 Brown noise", "QT", "USD", SymbolType.Indexes), - - CreateMessageSymbol("W16", "1 Fractional Brownian motion", "QT", "USD", SymbolType.Synthetic), - CreateMessageSymbol("W17", "2 Geometric Brownian motion", "QT", "USD", SymbolType.Synthetic) - }; - - /* - Bond, - CFD, - Crypto, - Debentures, - Equities, - ETF, - FixedIncome, - Forex, - Forward, - Futures, - Indexes, - Options, - Spot, - Synthetic, - Swap, - Warrants, - - */ - } - - public static VendorMetaData GetVendorMetaData() - { - return new VendorMetaData() - { - VendorName = "Synthetic Vendor", - VendorDescription = "A synthetic vendor for testing and demonstration purposes", - GetDefaultConnections = () => - { - var defaultConnection = Vendor.CreateDefaultConnectionInfo( - "Synthetic Connection", - "Synthetic Vendor", - "", // Replace with actual path if you have a logo - allowCreateCustomConnections: true - ); - return new List { defaultConnection }; - } - }; - } - - private MessageSymbol CreateMessageSymbol( - string id, - string name, - string exchangeId, - string assetId, - SymbolType type, - string description) - { - var messageSymbol = new MessageSymbol(id) - { - Name = name, - Description = description, - SymbolType = type, - ExchangeId = exchangeId, - ProductAssetId = assetId, - - // Setting some default values - QuotingCurrencyAssetID = "USD", - HistoryType = HistoryType.Last, - DeltaCalculationType = DeltaCalculationType.TickDirection, - LotSize = 1, - VariableTickList = new List - { - new VariableTick(0.01) // Default tick size - } - }; - - return messageSymbol; - } - - - - - private MessageSymbol CreateMessageSymbol(string id, string name, string exchangeId, string assetId, SymbolType type) - { - return new MessageSymbol(id) - { - Name = name, - ExchangeId = exchangeId, - ProductAssetId = assetId, - QuotingCurrencyAssetID = "USD", - QuotingType = SymbolQuotingType.LotSize, - LotSize = 1, - NettingType = NettingType.OnePosition, - VolumeType = SymbolVolumeType.Volume, - AllowCalculateRealtimeTicks = true, - AllowCalculateRealtimeTrades = false, - AllowCalculateRealtimeVolume = true, - AllowCalculateRealtimeChange = true, - AllowAbbreviatePriceByTickSize = false, - NotionalValueStep = 0.01, - DeltaCalculationType = DeltaCalculationType.AggressorFlag, // Changed from None to AggressorFlag - MinVolumeAnalysisTickSize = 0.01, - MaturityDate = DateTime.MaxValue, // Set to max value for non-expiring symbols - HistoryType = HistoryType.Last, - MinLot = 0.01, - LotStep = 0.01, - MaxLot = 1000000, - SymbolType = type - /* - SymbolType.Unknown, - [EnumMember] Forex, - [EnumMember] Equities, - [EnumMember] CFD, - [EnumMember] Indexes, - [EnumMember] Futures, - [EnumMember] Options, - [EnumMember] ETF, - [EnumMember] Crypto, - [EnumMember] Synthetic, - [EnumMember] Spot, - [EnumMember] Forward, - [EnumMember] FixedIncome, - [EnumMember] Warrants, - - [EnumMember] Debentures, - [EnumMember] Bond, - [EnumMember] Swap, - */ - }; - } - - public override ConnectionResult Connect(ConnectRequestParameters connectRequestParameters) - { - // Simulating connection process - Thread.Sleep(100); // Simulate some connection delay - - return ConnectionResult.CreateSuccess("Successfully connected to Synthetic Vendor"); - } - - public override void Disconnect() - { - // Simulating disconnection process - Thread.Sleep(500); // Simulate some disconnection delay - } - - public override PingResult Ping() - { - return new PingResult() - { - State = PingEnum.Connected, - PingTime = TimeSpan.FromMilliseconds(2), - RoundTripTime = TimeSpan.FromMilliseconds(2) - }; - } - - - public override IList GetExchanges(CancellationToken token) - { - return exchanges; - } - - public override IList GetAssets(CancellationToken token) - { - return assets; - } - - public override IList GetSymbols(CancellationToken token) - { - return symbols; - } - - public override void SubscribeSymbol(SubscribeQuotesParameters parameters) - { - // Empty method for data subscription to be filled later - } - - public override void UnSubscribeSymbol(SubscribeQuotesParameters parameters) - { - // Empty method for data unsubscription to be filled later - } - - - public override IList LoadHistory(HistoryRequestParameters requestParameters) - { - var historyItems = new List(); - var symbolId = requestParameters.SymbolId; - - if (string.IsNullOrEmpty(symbolId)) return historyItems; - - DateTime from = requestParameters.FromTime; - DateTime to = requestParameters.ToTime; - - TimeSpan periodTimeSpan = requestParameters.Aggregation.GetPeriod.Duration; - - // Define the maximum number of items to generate per request - const int MAX_ITEMS_PER_REQUEST = 10000; - - Func waveGenerator = GetWaveGenerator(symbolId); - - DateTime currentTime = from; - while (currentTime < to) - { - DateTime intervalEnd = currentTime.AddTicks(periodTimeSpan.Ticks * MAX_ITEMS_PER_REQUEST); - if (intervalEnd > to) - intervalEnd = to; - - while (currentTime <= intervalEnd) - { - var historyItem = waveGenerator(currentTime, periodTimeSpan); //calling generator fuction - historyItems.Add(historyItem); - - currentTime = currentTime.Add(periodTimeSpan); - - if (requestParameters.CancellationToken.IsCancellationRequested) return historyItems; - } - - currentTime = intervalEnd; - } - - return historyItems; - } - - private Func GetWaveGenerator(string symbolId) - { - switch (symbolId) - { - case "W1": return GenerateSpike; - case "W2": return GenerateDiracDelta; - case "W3": return GenerateSquareWave; - case "W4": return GenerateSawtoothWave; - case "W5": return GenerateInverseSawtoothWave; - case "W6": return GenerateTriangleWave; - case "W7": return GenerateSineWave; - case "W8": return GenerateSincWave; - case "W9": return GenerateGaussianPulse; - case "W10": return GenerateFrequencySweep; - case "W11": return GenerateAMSignal; - case "W12": return GenerateFMSignal; - case "W13": return GenerateWhiteNoise; - case "W14": return GeneratePinkNoise; - case "W15": return GenerateBrownNoise; - case "W16": return GenerateFBM; - case "W17": return GenerateGBM; - - default: return GenerateSineWave; - } - } - -/* - public override HistoryMetadata GetHistoryMetadata(CancellationToken cancellationToken) - { - return new HistoryMetadata - { - AllowedAggregations = new string[] { "Time", "Tick" }, - AllowedPeriodsHistoryAggregationTime = new Period[] - { - Period.SECOND1, Period.SECOND5, Period.SECOND10, Period.SECOND15, Period.SECOND30, - Period.MIN1, Period.MIN2, Period.MIN3, Period.MIN4, Period.MIN5, - Period.MIN10, Period.MIN15, Period.MIN30, - Period.HOUR1, Period.HOUR2, Period.HOUR3, Period.HOUR4, - Period.HOUR6, Period.HOUR8, Period.HOUR12, - Period.DAY1, - Period.WEEK1, - Period.MONTH1, - Period.YEAR1 - }, - AllowedBasePeriodsHistoryAggregationTime = new BasePeriod[] - { - BasePeriod.Second, BasePeriod.Minute, BasePeriod.Hour, BasePeriod.Day, BasePeriod.Week, BasePeriod.Month, BasePeriod.Year - }, - AllowedHistoryTypesHistoryAggregationTime = new HistoryType[] - { - HistoryType.Bid, - HistoryType.Ask, - HistoryType.Midpoint, - HistoryType.Last, - HistoryType.BidAsk, - HistoryType.Mark - }, - AllowedHistoryTypesHistoryAggregationTick = new HistoryType[] - { - HistoryType.Bid, - HistoryType.Ask, - HistoryType.Midpoint, - HistoryType.Last, - HistoryType.BidAsk, - HistoryType.Mark - }, - DegreeOfParallelism = 1, - UseHistoryLocalCache = false, - BuildUncompletedBars = true - }; - } -*/ - - /*******************************************************************************************************************************************/ - /*******************************************************************************************************************************************/ - /*******************************************************************************************************************************************/ - /*******************************************************************************************************************************************/ - /*******************************************************************************************************************************************/ - /*******************************************************************************************************************************************/ - /*******************************************************************************************************************************************/ - - private HistoryItemBar GenerateSpike(DateTime time, TimeSpan slice) - { - // Ensure we're working with UTC time - DateTime utcTime = time.ToUniversalTime(); - - // Calculate the number of hours since the epoch - double hoursSinceEpoch = (utcTime - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalHours; - - // Calculate the position within the 25-hour cycle - int cyclePosition = (int)Math.Floor(hoursSinceEpoch % 25); - - // Determine if this is a spike hour (hour 24 in the cycle) or the hour after - bool isSpike = cyclePosition == 24; - bool isAfterSpike = cyclePosition == 0; - - double openValue, closeValue; - if (isSpike) - { - openValue = 0; - closeValue = 100; - } - else if (isAfterSpike) - { - openValue = 100; - closeValue = 0; - } - else - { - openValue = closeValue = 0.000001; - } - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = openValue, - High = Math.Max(openValue, closeValue), - Low = Math.Min(openValue, closeValue), - Close = closeValue, - Volume = Math.Abs(closeValue - openValue), - Ticks = time.Add(slice).Ticks - time.Ticks - }; - } - - - - private HistoryItemBar GenerateDiracDelta(DateTime time, TimeSpan slice) - { - // Ensure we're working with UTC time - DateTime utcTime = time.ToUniversalTime(); - - // Calculate the start of the current day - DateTime dayStart = utcTime.Date; - - // Determine which bar of the day we're on - int barOfDay = (int)((utcTime - dayStart).Ticks / slice.Ticks); - - double openValue, closeValue; - double scaleFactor = 100; // Scale factor to convert to percentage - - // Generate the spike pattern for the first 4 bars of each day - switch (barOfDay) - { - case 0: - openValue = 0.000001 * scaleFactor; - closeValue = 0.05 * scaleFactor; - break; - case 1: - openValue = 0.05 * scaleFactor; - closeValue = 0.50 * scaleFactor; - break; - case 2: - openValue = 0.50 * scaleFactor; - closeValue = 0.05 * scaleFactor; - break; - case 3: - openValue = 0.05 * scaleFactor; - closeValue = 0.0000001 * scaleFactor; - break; - default: - // Outside of the spike period, use baseline value - openValue = closeValue = 0.000001; - break; - } - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = openValue, - High = Math.Max(openValue, closeValue), - Low = Math.Min(openValue, closeValue), - Close = closeValue, - Volume = Math.Abs(closeValue - openValue), - Ticks = time.Add(slice).Ticks - time.Ticks - }; - } - - - - private HistoryItemBar GenerateSineWave(DateTime time, TimeSpan slice) - { - // Ensure we're working with UTC time - DateTime utcTime = time.ToUniversalTime(); - - // Calculate the number of hours since the epoch - double minutesSinceEpoch = (utcTime - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMinutes; - - // Calculate the position within the 25-hour cycle - double cyclePosition = minutesSinceEpoch % 1500; - - - // Calculate the sine wave values - double frequency = 2 * Math.PI / 1500; // Complete cycle over 25 hours - double value = 50 + (50 * Math.Sin(cyclePosition * frequency)); // Oscillate between 0 and 100 - double nextValue = 50 + (50 * Math.Sin((cyclePosition + slice.TotalMinutes) * frequency)); - - double factor = 0.6 * Math.Abs(nextValue - value); - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = value, - - High = Math.Max(value, nextValue) + factor, - Low = Math.Min(value, nextValue) - factor, - - Close = nextValue, - Volume = Math.Abs(nextValue - value) * 100, // Volume proportional to price change - Ticks = time.Add(slice).Ticks - time.Ticks - }; - } - - - private HistoryItemBar GenerateSquareWave(DateTime time, TimeSpan slice) - { - // Ensure we're working with UTC time - DateTime utcTime = time.ToUniversalTime(); - - // Calculate the time within the day (in hours) - double hoursInDay = utcTime.TimeOfDay.TotalHours; - - double openValue, closeValue; - - if (hoursInDay < 12) - { - // First half of the day - openValue = 99; - closeValue = 100; - } - else - { - // Second half of the day - openValue = 1; - closeValue = 0.0001; - } - - // Handle transition bars - if (Math.Abs(hoursInDay - 12) < slice.TotalHours / 2) - { - // Transition from 100 to 0 at noon - openValue = 100; - closeValue = 0.0001; - } - else if (hoursInDay < slice.TotalHours / 2 || hoursInDay > 24 - (slice.TotalHours / 2)) - { - // Transition from 0 to 100 at midnight - openValue = 0.0001; - closeValue = 100; - } - else - { - // No action - } - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = openValue, - High = Math.Max(openValue, closeValue), - Low = Math.Min(openValue, closeValue), - Close = closeValue, - Volume = Math.Abs(closeValue - openValue), - Ticks = time.Add(slice).Ticks - time.Ticks - }; - } - - private HistoryItemBar GenerateSawtoothWave(DateTime time, TimeSpan slice) - { - double hours = (time - DateTime.UnixEpoch).TotalHours; - double period = 24; // 24-hour period - double position = hours % period; - double value = (200 * (position / period)) - 100; - double nextValue = (200 * (((position + slice.TotalHours) % period) / period)) - 100; - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = value, - High = Math.Max(value, nextValue), - Low = Math.Min(value, nextValue), - Close = nextValue, - Volume = 100, - Ticks = 100 - }; - } - - private HistoryItemBar GenerateInverseSawtoothWave(DateTime time, TimeSpan slice) - { - double hours = (time - DateTime.UnixEpoch).TotalHours; - double period = 24; // 24-hour period - double position = hours % period; - double value = 100 - (200 * (position / period)); - double nextValue = 100 - (200 * (((position + slice.TotalHours) % period) / period)); - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = value, - High = Math.Max(value, nextValue), - Low = Math.Min(value, nextValue), - Close = nextValue, - Volume = 100, - Ticks = 100 - }; - } - - - private HistoryItemBar GenerateTriangleWave(DateTime time, TimeSpan slice) - { - double hours = (time - DateTime.UnixEpoch).TotalHours; - double period = 24; - double position = hours % period; - double value = 200 * (Math.Abs((position / period) - 0.5) - 0.25) * 100; - double nextValue = 200 * (Math.Abs((((position + slice.TotalHours) % period) / period) - 0.5) - 0.25) * 100; - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = value, - High = Math.Max(value, nextValue), - Low = Math.Min(value, nextValue), - Close = nextValue, - Volume = 100, - Ticks = 100 - }; - } - - private HistoryItemBar GenerateSincWave(DateTime time, TimeSpan slice) - { - double minutes = (time - DateTime.UnixEpoch).TotalMinutes; - double period = 1500.0; // 24-hour period - double frequency = 2 * Math.PI / period; // Full cycle over 24 hours - - // Adjust time to center the main peak at 12 hours - double t = (minutes % period) - (period / 2); - - // Scale factor - double scaleFactor = 7.0; - - // Calculate Sinc value - double x = scaleFactor * frequency * t; - double sincValue = x != 0 ? 100 * Math.Sin(x) / x : 100; - - // Calculate next value - double nextT = ((minutes + slice.TotalMinutes) % period) - (period / 2); - double nextX = scaleFactor * frequency * nextT; - double nextSincValue = nextX != 0 ? 100 * Math.Sin(nextX) / nextX : 100; - - // Ensure minimum value - double minValue = 0.00001; - sincValue = Math.Sign(sincValue) * Math.Max(Math.Abs(sincValue), minValue); - nextSincValue = Math.Sign(nextSincValue) * Math.Max(Math.Abs(nextSincValue), minValue); - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = sincValue, - High = Math.Max(sincValue, nextSincValue), - Low = Math.Min(sincValue, nextSincValue), - Close = nextSincValue, - Volume = Math.Abs(nextSincValue - sincValue), // Volume as the change in value - Ticks = slice.Ticks - }; - } - - private HistoryItemBar GenerateGaussianPulse(DateTime time, TimeSpan slice) - { - double hours = (time - DateTime.UnixEpoch).TotalHours; - double totalPeriod = 24.0; // 24-hour total cycle - double pulsePeriod = 12.0; // 12-hour pulse duration - double position = hours % totalPeriod; - - // Parameters for the Gaussian pulse - double amplitude = 100.0; // Maximum amplitude - double center = pulsePeriod / 2.0; // Center of the pulse (at 6 hours within the pulse period) - double width = pulsePeriod / 6.0; // Width of the pulse (adjusts the spread) - - double baselineValue = 0.00001; // Value outside the pulse period - - // Calculate the Gaussian pulse value - double value; - if (position < pulsePeriod) - { - value = (amplitude * Math.Exp(-Math.Pow(position - center, 2) / (2 * Math.Pow(width, 2)))) + baselineValue; - } - else - { - value = baselineValue; - } - - // Calculate the next value for the slice - double nextPosition = (hours + slice.TotalHours) % totalPeriod; - double nextValue; - if (nextPosition < pulsePeriod) - { - nextValue = (amplitude * Math.Exp(-Math.Pow(nextPosition - center, 2) / (2 * Math.Pow(width, 2)))) + baselineValue; - } - else - { - nextValue = baselineValue; - } - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = value, - High = Math.Max(value, nextValue), - Low = Math.Min(value, nextValue), - Close = nextValue, - Volume = Math.Abs(nextValue - value), // Volume as the change in value - Ticks = slice.Ticks - }; - } - - private HistoryItemBar GenerateFrequencySweep(DateTime time, TimeSpan slice) - { - double hours = (time - DateTime.UnixEpoch).TotalHours; - double sweepPeriod = 48.0; // 48-hour period - - // Starting frequency (very low) - double minFreq = Math.PI / 48.0; - - // Calculate the ending frequency to ensure continuity - double maxFreq = Math.PI * 1.0 * Math.Exp(2 * Math.PI / sweepPeriod); - - // Calculate the exponential factor for frequency sweep - double expFactor = Math.Log(maxFreq / minFreq) / sweepPeriod; - - // Calculate the overall phase up to the current time - double totalPhase = (minFreq / expFactor) * (Math.Exp(expFactor * (hours % sweepPeriod)) - 1); - - // Shift the phase to start the cycle at 100 (cosine-like behavior) - totalPhase += Math.PI / 2; - - // Calculate the value of the signal at the current time - double value = 100.0 * Math.Sin(totalPhase); - - // Calculate the value of the signal at the end of the slice - double nextPhase = (minFreq / expFactor) * (Math.Exp(expFactor * ((hours + slice.TotalHours) % sweepPeriod)) - 1); - nextPhase += Math.PI / 2; // Apply the same phase shift - double nextValue = 100.0 * Math.Sin(nextPhase); - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = value, - High = Math.Max(value, nextValue), - Low = Math.Min(value, nextValue), - Close = nextValue, - Volume = Math.Abs(nextValue - value), // Volume as the change in value - Ticks = slice.Ticks - }; - } - -#pragma warning disable S2245 - // NOSONAR - readonly Random random = new Random(); -#pragma warning restore S2245 - private double currentAmplitude = 100; - private HistoryItemBar GenerateAMSignal(DateTime time, TimeSpan slice) - { - double hours = (time - DateTime.UnixEpoch).TotalHours; - double period = 12.0; - double frequency = 2 * Math.PI / period; // Frequency for a 5-hour period - - // Determine the start of the current 5-hour cycle - double cycleStartTime = Math.Floor(hours / period) * period; - - // Calculate the phase of the signal within the current 5-hour cycle - double phase = frequency * (hours % period); - - // If we're at the start of a new 5-hour cycle, generate a new amplitude - if (hours % period == 0) - { - currentAmplitude = random.NextDouble() * 100; - } - - // Calculate the value of the signal at the current time - double value = currentAmplitude * Math.Sin(phase); - - // Calculate the value of the signal at the end of the slice - double nextPhase = frequency * ((hours + slice.TotalHours) % period); - double nextValue = currentAmplitude * Math.Sin(nextPhase); - - // Create the HistoryItemBar - var historyItem = new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = value, - High = Math.Max(value, nextValue), - Low = Math.Min(value, nextValue), - Close = nextValue, // Set Close to the newly calculated value - Volume = Math.Abs(nextValue), // Volume as the change in value - Ticks = slice.Ticks - }; - - return historyItem; - } - - - private double currentFrequency = Math.PI / 220.0; // Initial frequency - private double accumulatedPhase = 0; - private double lastCloseValue = 0; // To store the last close value - - private HistoryItemBar GenerateFMSignal(DateTime time, TimeSpan slice) - { - double amplitude = 100.0; // Maximum amplitude - double minFreq = Math.PI / 256.0; - double maxFreq = Math.PI / 32.0; - - // Randomly adjust the frequency - double frequencyStep = (maxFreq - minFreq) * 0.2; // 20% of the frequency range - currentFrequency += (random.NextDouble() - 0.5) * 2 * frequencyStep; - currentFrequency = Math.Max(minFreq, Math.Min(maxFreq, currentFrequency)); // Clamp frequency - - // Calculate phase increment for this slice - double phaseIncrement = currentFrequency * slice.TotalHours; - - // Calculate the open value (which is the last close value) - double openValue = lastCloseValue; - - // Calculate the close value - accumulatedPhase += phaseIncrement; - double closeValue = amplitude * Math.Sin(2 * Math.PI * accumulatedPhase); - - // Determine high and low values - double midPhase = accumulatedPhase - (phaseIncrement / 2); - double midValue = amplitude * Math.Sin(2 * Math.PI * midPhase); - double highValue = Math.Max(Math.Max(openValue, closeValue), midValue); - double lowValue = Math.Min(Math.Min(openValue, closeValue), midValue); - - // Store the close value for the next iteration - lastCloseValue = closeValue; - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = openValue, - High = highValue, - Low = lowValue, - Close = closeValue, - Volume = Math.Abs(closeValue - openValue), // Volume as the change in value - Ticks = slice.Ticks - }; - } - - - private HistoryItemBar GenerateWhiteNoise(DateTime time, TimeSpan slice) - { - double volatility = 2; - double meanReversionStrength = 0.1; - - double openNoise = random.NextDouble(); - double open = previousClose + (volatility * openNoise) + (meanReversionStrength * (meanPrice - previousClose)); - double closeNoise = random.NextDouble(); - double close = open + (volatility * closeNoise) + (meanReversionStrength * (meanPrice - open)); - - // Determine High and Low - double high = Math.Max(open, close); - double low = Math.Min(open, close); - - // Add variation to High and Low - double highNoise = Math.Abs(random.NextDouble()); - high += volatility * highNoise; - - double lowNoise = Math.Abs(random.NextDouble()); - low -= volatility * lowNoise; - - double volume = (Math.Abs(random.NextDouble()) * 1000) + 100; - - previousClose = close; - - - // Create the HistoryItemBar - var historyItem = new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = open, - High = high, - Low = low, - Close = close, - Volume = volume, - Ticks = slice.Ticks - }; - - return historyItem; - } - - - - private double previousClose = 50; - private const double meanPrice = 50; - - private HistoryItemBar GeneratePinkNoise(DateTime time, TimeSpan slice) - { - double volatility = 2; - double meanReversionStrength = 0.1; - - // Generate open price - double openNoise = GeneratePinkNoiseValue(); - double open = previousClose + (volatility * openNoise) + (meanReversionStrength * (meanPrice - previousClose)); - - // Generate close price - double closeNoise = GeneratePinkNoiseValue(); - double close = open + (volatility * closeNoise) + (meanReversionStrength * (meanPrice - open)); - - // Determine High and Low - double high = Math.Max(open, close); - double low = Math.Min(open, close); - - // Add variation to High and Low - double highNoise = Math.Abs(GeneratePinkNoiseValue()); - high += volatility * highNoise; - - double lowNoise = Math.Abs(GeneratePinkNoiseValue()); - low -= volatility * lowNoise; - - double volume = (Math.Abs(GeneratePinkNoiseValue()) * 1000) + 100; - - // Update previous close for the next iteration - previousClose = close; - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = open, - High = high, - Low = low, - Close = close, - Volume = volume, - Ticks = slice.Ticks - }; - } - - - private const int NumOctaves = 6; - private readonly double[] pinkNoiseState = new double[NumOctaves]; - private double GeneratePinkNoiseValue() - { - double total = 0; - - for (int i = 0; i < NumOctaves; i++) - { - double white = (random.NextDouble() * 2) - 1; - pinkNoiseState[i] = (pinkNoiseState[i] + white) * 0.5; - total += pinkNoiseState[i] * Math.Pow(2, -i); - } - - // Normalize - return total / NumOctaves; - } - - - - private double lastValue = 0; - - private HistoryItemBar GenerateBrownNoise(DateTime time, TimeSpan slice) - { - double dt = slice.TotalDays / 365.0; // Time step in years - double sigma = 25.0; // Annual volatility - - double increment = GenerateGaussian(0, sigma * Math.Sqrt(dt)); - double open = lastValue * (1 + GenerateGaussian(0, 0.05)); - double close = open + increment; - - // Simulate intra-period high and low - double high = Math.Max(open, close); - high += high * Math.Abs(GenerateGaussian(0, 0.06)); - double low = Math.Min(open, close); - low -= low * Math.Abs(GenerateGaussian(0, 0.06)); - - lastValue = close; - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = open, - High = high, - Low = low, - Close = close, - Volume = Math.Abs(close - open) * 1000, // Simplified volume calculation - Ticks = slice.Ticks - }; - } - // Helper method to generate Gaussian distributed random numbers - private double GenerateGaussian(double mean, double stdDev) - { - double u1 = 1.0 - random.NextDouble(); // Uniform(0,1] random doubles - double u2 = 1.0 - random.NextDouble(); - double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2); - return mean + (stdDev * randStdNormal); - } - - - - private double GBMLastClose = 100; // Starting price - private readonly double GBMMu = 0.05; // Annual drift - private readonly double GBMSigma = 0.2; // Annual volatility - - private HistoryItemBar GenerateGBM(DateTime time, TimeSpan slice) - { - // Convert time slice to years - double dt = slice.TotalDays / 365.0; - - // Generate a random normal variable for the main price movement - double epsilon = GenerateGaussian(0, 1); - - // Calculate the price movement using GBM equation - double drift = (GBMMu - (0.5 * GBMSigma * GBMSigma)) * dt; - double diffusion = GBMSigma * Math.Sqrt(dt) * epsilon; - double returnValue = Math.Exp(drift + diffusion); - - // Add variability between previous close and current open - double openVariability = GBMLastClose * GBMSigma * Math.Sqrt(dt) * GenerateGaussian(0, 1) * 0.1; - double open = GBMLastClose + openVariability; - - // Calculate new close price - double close = open * returnValue; - - // Generate High and Low values - double highLowRange = Math.Max(Math.Abs(close - open), GBMLastClose * GBMSigma * Math.Sqrt(dt) * Math.Abs(GenerateGaussian(0, 1))); - double high = Math.Max(open, close) + (highLowRange * 0.5); - double low = Math.Min(open, close) - (highLowRange * 0.5); - - // Generate volume (you may want to adjust this based on your needs) - double volume = Math.Max(100, (1000 * Math.Abs(close - open)) + (500 * GenerateGaussian(0, 1))); - - // Update last close for next iteration - GBMLastClose = close; - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = open, - High = high, - Low = low, - Close = close, - Volume = volume, - Ticks = slice.Ticks - }; - } - - private double FBMLastClose = 100; // Starting price - private readonly double FBMHurst = 0.85; // Hurst parameter (0.5 < H < 1 for persistent fBm) - private readonly double FBMSigma = 0.25; // Volatility parameter - private readonly double FBMDrift = 0.001; // drift - - private HistoryItemBar GenerateFBM(DateTime time, TimeSpan slice) - { - double dt = Math.Pow(slice.TotalDays / 365.0, 0.5); - - double epsilon = GenerateFractionalGaussianNoise(FBMHurst); - - double drift = FBMDrift * dt; - double diffusion = FBMSigma * Math.Pow(dt, FBMHurst) * epsilon; - - double openVariability = FBMLastClose * FBMSigma * Math.Pow(dt, FBMHurst) * GenerateFractionalGaussianNoise(FBMHurst) * 0.1; - double open = FBMLastClose + openVariability; - - double close = open * Math.Exp(drift + diffusion); - - double highLowRange = Math.Max(Math.Abs(close - open), - FBMLastClose * FBMSigma * Math.Pow(dt, FBMHurst) * Math.Abs(GenerateFractionalGaussianNoise(FBMHurst)) * 2); - double high = Math.Max(open, close) + (highLowRange * 0.5); - double low = Math.Min(open, close) - (highLowRange * 0.5); - - double volume = Math.Max(100, (2000 * Math.Abs(close - open)) + - (1000 * Math.Abs(GenerateFractionalGaussianNoise(FBMHurst)))); - - FBMLastClose = close; - - return new HistoryItemBar - { - TicksLeft = time.Ticks, - TicksRight = time.Add(slice).Ticks - 1, - Open = open, - High = high, - Low = low, - Close = close, - Volume = volume, - Ticks = slice.Ticks - }; - } - - private double GenerateFractionalGaussianNoise(double hurst) - { - double sum = 0; - int n = 1000; // Number of terms in the approximation - - for (int i = 1; i <= n; i++) - { - double ri = GenerateGaussian(0, 1); - sum += (Math.Pow(i, hurst - 0.5) - Math.Pow(i - 1, hurst - 0.5)) * ri; - } - - return sum / Math.Sqrt(n); - } - - - - // Add other necessary overrides and implementations as needed -} diff --git a/SyntheticVendor/SyntheticVendor.csproj b/SyntheticVendor/SyntheticVendor.csproj deleted file mode 100644 index e853d674..00000000 --- a/SyntheticVendor/SyntheticVendor.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - Vendor - 0.0.0.0 - - - - - ..\.github\TradingPlatform.BusinessLayer.dll - - - TradingPlatform.BusinessLayer.xml - - - - \ No newline at end of file diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 2ab29a94..9b508306 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -9,7 +9,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/build.sh b/build.sh new file mode 100644 index 00000000..835802bf --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash +dotnet gitversion . /output buildserver +dotnet build diff --git a/lib/quantalib.csproj b/lib/quantalib.csproj index 4b482556..61ca345c 100644 --- a/lib/quantalib.csproj +++ b/lib/quantalib.csproj @@ -30,9 +30,8 @@ - - + @@ -49,4 +48,4 @@ - \ No newline at end of file + diff --git a/quantower/Averages/_Averages.csproj b/quantower/Averages/_Averages.csproj index 836c3d7e..db8b5c11 100644 --- a/quantower/Averages/_Averages.csproj +++ b/quantower/Averages/_Averages.csproj @@ -8,7 +8,7 @@ - + @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/quantower/Experiments/_Experiments.csproj b/quantower/Experiments/_Experiments.csproj index 17ca5ef7..fc59e16d 100644 --- a/quantower/Experiments/_Experiments.csproj +++ b/quantower/Experiments/_Experiments.csproj @@ -8,7 +8,7 @@ - + diff --git a/quantower/Momentum/_Momentum.csproj b/quantower/Momentum/_Momentum.csproj index 7c3eef77..8a50319a 100644 --- a/quantower/Momentum/_Momentum.csproj +++ b/quantower/Momentum/_Momentum.csproj @@ -8,7 +8,7 @@ - + diff --git a/quantower/Oscillators/_Oscillators.csproj b/quantower/Oscillators/_Oscillators.csproj index 100d818e..67da1dbe 100644 --- a/quantower/Oscillators/_Oscillators.csproj +++ b/quantower/Oscillators/_Oscillators.csproj @@ -8,7 +8,7 @@ - + @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/quantower/Statistics/_Statistics.csproj b/quantower/Statistics/_Statistics.csproj index 9a381189..b4c639d9 100644 --- a/quantower/Statistics/_Statistics.csproj +++ b/quantower/Statistics/_Statistics.csproj @@ -8,7 +8,7 @@ - + diff --git a/quantower/Volatility/_Volatility.csproj b/quantower/Volatility/_Volatility.csproj index e836fbbd..c6badb70 100644 --- a/quantower/Volatility/_Volatility.csproj +++ b/quantower/Volatility/_Volatility.csproj @@ -8,7 +8,7 @@ - + @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/quantower/Volume/_Volume.csproj b/quantower/Volume/_Volume.csproj index ba33b124..9443c8f6 100644 --- a/quantower/Volume/_Volume.csproj +++ b/quantower/Volume/_Volume.csproj @@ -8,7 +8,7 @@ - +