Skip to content

Commit

Permalink
[MDAPI-67] [.NET] Integrate IndexedEventTxModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Ivaschenko committed Jul 26, 2024
1 parent a775236 commit 335a14e
Show file tree
Hide file tree
Showing 45 changed files with 4,234 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ dotnet_diagnostic.CA1861.severity = none
dotnet_diagnostic.CA1846.severity = none
# CA1845 : Use span-based 'string.Concat' and 'AsSpan' instead of 'Substring'
dotnet_diagnostic.CA1845.severity = none
dotnet_diagnostic.cs0693.severity=none
dotnet_diagnostic.CA1000.severity=none
##########################################
# Formatting Rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules
Expand Down Expand Up @@ -361,7 +363,7 @@ dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_accessibi
dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_kinds = field
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.symbols = stylecop_fields_must_be_private_group
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.style = disallowed_style
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.severity = error
dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.severity = none

# Private fields must be camelCase
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1306.md
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ready to answer any questions and help with the transition.
| 3 | How to subscribe to `Order`, `SpreadOrder`, `Candle`, `TimeAndSale`, `Greeks`, `Series` snapshots | [dxf_snapshot_sample](https://github.com/dxFeed/dxfeed-net-api/tree/master/samples/dxf_snapshot_sample) | *Q2’2024*, please see [TBD](#future-development) section |
| 4 | How to subscribe to depth of market | [dxf_price_level_book_sample](https://github.com/dxFeed/dxfeed-net-api/tree/master/samples/dxf_price_level_book_sample) | *Q2’2024*, please see [TBD](#future-development) section |
| 5 | How to receive snapshots of `TimeAndSale`, `Candle`, `Series`, `Greeks` events on a given time interval without live subscription | [dxf_simple_data_retrieving_sample](https://github.com/dxFeed/dxfeed-net-api/tree/master/samples/dxf_simple_data_retrieving_sample) | [FetchDailyCandles](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/FetchDailyCandles) |
| 6 | How to subscribe to order snapshot with incremental updates | [dxf_inc_order_snapshot_sample](https://github.com/dxFeed/dxfeed-net-api/tree/master/samples/dxf_inc_order_snapshot_sample) | *Q2’2024*, please see [TBD](#future-development) section |
| 6 | How to subscribe to order snapshot with incremental updates | [dxf_inc_order_snapshot_sample](https://github.com/dxFeed/dxfeed-net-api/tree/master/samples/dxf_inc_order_snapshot_sample) | [IncOrderSnapshotSample](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/IncOrderSnapshotSample) |
| 7 | How to retrieve `Candle` data from the candle web service | [dxf_candle_data_retrieving_sample](https://github.com/dxFeed/dxfeed-net-api/tree/master/samples/dxf_candle_data_retrieving_sample) | [CandleDataResponseReader](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/CandleDataResponseReader) | |
| 8 | How to retrieve `TimeAndSale` data from the candle web service | [dxf_tns_data_retrieving_sample](https://github.com/dxFeed/dxfeed-net-api/tree/master/samples/dxf_tns_data_retrieving_sample) | [CandleDataResponseReader](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/CandleDataResponseReader) | |

Expand Down Expand Up @@ -398,6 +398,12 @@ sudo /usr/bin/xattr -r -d com.apple.quarantine <directory_with_tools>
and re-subscribing.
- [x] [CandleDataResponseReader](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/CandleDataResponseReader)
is a simple demonstration of how to parse response from CandleData service.
- [x] [MarketDepthModelSample](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/MarketDepthModelSample)
is a simple demonstration of how to draw a Market Depth using Avalonia UI.
- [x] [CandleChartSample](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/CandleChartSample)
is a simple demonstration of how to draw a Candlestick Chart using Avalonia UI.
- [x] [IncOrderSnapshotSample](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/IncOrderSnapshotSample)
is a simple demonstration of how to subscribe to the Order event and handle snapshots and updates.

## Current State

Expand Down
6 changes: 6 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

* [MDAPI-93] [.NET] Add DxFeedMarketDepth sample
* [MDAPI-109] [.NET] Add DxFeedCandleChart API sample
* [MDAPI-107] [.NET] Implement TimeSeriesTxModel
* [MDAPI-106] [.NET] Implement IndexedTxModel
* [MDAPI-92] [.NET] Implement MarketDepthModel
* [MDAPI-66] [.NET] Failed to build solution on Visual Studio 2022

## Version 2.2.0
Expand Down
1 change: 1 addition & 0 deletions StyleCop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<Rule Id="SA1649" Action="None"/><!-- FileNameMustMatchTypeName -->
<Rule Id="SA1310" Action="None"/><!-- FieldNamesMustNotContainUnderscore -->
<Rule Id="SA1629" Action="None"/><!-- DocumentationTextMustEndWithAPeriod -->
<Rule Id="SA1401" Action="None"/><!-- FieldsMustBePrivate -->
</Rules>
</RuleSet>
28 changes: 28 additions & 0 deletions dxfeed-graal-net-api.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleAuthSample", "samples
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CandleDataResponseReader", "samples\CandleDataResponseReader\CandleDataResponseReader.csproj", "{2567935E-FEFB-470A-BF17-7A883735C4BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarketDepthModelSample", "samples\MarketDepthModelSample\MarketDepthModelSample.csproj", "{930B1039-B76C-42C5-AD0F-9FA1A1FC9D84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CandleChartSample", "samples\CandleChartSample\CandleChartSample.csproj", "{B74E8A86-1AB7-4B36-AED3-292CDD95BF90}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IncOrderSnapshotSample", "samples\IncOrderSnapshotSample\IncOrderSnapshotSample.csproj", "{9B758A5C-8AA1-4560-A7CF-EF375B9A1E4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultipleMarketDepthSample", "samples\MultipleMarketDepthSample\MultipleMarketDepthSample.csproj", "{C8F5013F-7F40-46D2-92AD-6B593524A1D0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -112,6 +120,22 @@ Global
{2567935E-FEFB-470A-BF17-7A883735C4BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2567935E-FEFB-470A-BF17-7A883735C4BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2567935E-FEFB-470A-BF17-7A883735C4BF}.Release|Any CPU.Build.0 = Release|Any CPU
{930B1039-B76C-42C5-AD0F-9FA1A1FC9D84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{930B1039-B76C-42C5-AD0F-9FA1A1FC9D84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{930B1039-B76C-42C5-AD0F-9FA1A1FC9D84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{930B1039-B76C-42C5-AD0F-9FA1A1FC9D84}.Release|Any CPU.Build.0 = Release|Any CPU
{B74E8A86-1AB7-4B36-AED3-292CDD95BF90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B74E8A86-1AB7-4B36-AED3-292CDD95BF90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B74E8A86-1AB7-4B36-AED3-292CDD95BF90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B74E8A86-1AB7-4B36-AED3-292CDD95BF90}.Release|Any CPU.Build.0 = Release|Any CPU
{9B758A5C-8AA1-4560-A7CF-EF375B9A1E4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B758A5C-8AA1-4560-A7CF-EF375B9A1E4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B758A5C-8AA1-4560-A7CF-EF375B9A1E4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B758A5C-8AA1-4560-A7CF-EF375B9A1E4C}.Release|Any CPU.Build.0 = Release|Any CPU
{C8F5013F-7F40-46D2-92AD-6B593524A1D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8F5013F-7F40-46D2-92AD-6B593524A1D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8F5013F-7F40-46D2-92AD-6B593524A1D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8F5013F-7F40-46D2-92AD-6B593524A1D0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{73597E04-D8A8-4991-A759-7F886CBE2A8F} = {C4490D74-2970-4A1B-8178-A724A06B140A}
Expand All @@ -129,5 +153,9 @@ Global
{C457D53F-A033-465C-B250-A6CC60D02F98} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{B9088D14-10F6-4D88-876D-062B9F6494AB} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{2567935E-FEFB-470A-BF17-7A883735C4BF} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{930B1039-B76C-42C5-AD0F-9FA1A1FC9D84} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{B74E8A86-1AB7-4B36-AED3-292CDD95BF90} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{9B758A5C-8AA1-4560-A7CF-EF375B9A1E4C} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{C8F5013F-7F40-46D2-92AD-6B593524A1D0} = {C4490D74-2970-4A1B-8178-A724A06B140A}
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions dxfeed-graal-net-api.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=affinitized/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Antici/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ARCX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=axaml/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=BINY/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=CBSX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coeff/@EntryIndexedValue">True</s:Boolean>
Expand Down Expand Up @@ -30,6 +31,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=multiplexor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dkey/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ddxfeed/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ohlc/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=OPASPS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=opol/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Osub/@EntryIndexedValue">True</s:Boolean>
Expand Down
10 changes: 10 additions & 0 deletions samples/CandleChartSample/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="CandleChartSample.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
23 changes: 23 additions & 0 deletions samples/CandleChartSample/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;

namespace CandleChartSample;

public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
}

base.OnFrameworkInitializationCompleted();
}
}
26 changes: 26 additions & 0 deletions samples/CandleChartSample/CandleChartSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.10"/>
<PackageReference Include="Avalonia.Desktop" Version="11.0.10"/>
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.10"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.10"/>
<PackageReference Include="ScottPlot.Avalonia" Version="5.0.36"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\DxFeed.Graal.Net\DxFeed.Graal.Net.csproj"/>
</ItemGroup>

</Project>
57 changes: 57 additions & 0 deletions samples/CandleChartSample/CandleExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// <copyright file="CandleExtension.cs" company="Devexperts LLC">
// Copyright © 2024 Devexperts LLC. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// </copyright>

using System;
using DxFeed.Graal.Net.Events.Candles;
using ScottPlot;

namespace CandleChartSample;

/// <summary>
/// Provides extension methods for converting <see cref="Candle"/> objects to <see cref="OHLC"/> objects.
/// </summary>
public static class CandleExtension
{
/// <summary>
/// Converts a <see cref="Candle"/> object to an <see cref="OHLC"/> object.
/// </summary>
/// <param name="candle">The candle to convert.</param>
/// <returns>An <see cref="OHLC"/> object representing the candle.</returns>
public static OHLC ToOHLC(this Candle candle)
{
var open = GetValueWithPriority(candle.Open, candle.High, candle.Low, candle.Close);
var high = GetValueWithPriority(candle.High, candle.Open, candle.Low, candle.Close);
var low = GetValueWithPriority(candle.Low, candle.Close, candle.Open, candle.High);
var close = GetValueWithPriority(candle.Close, candle.Low, candle.Open, candle.High);

return new OHLC
{
Open = open,
High = high,
Low = low,
Close = close,
DateTime = DateTimeOffset.FromUnixTimeMilliseconds(candle.Time).DateTime.ToLocalTime(),
TimeSpan = TimeSpan.FromMilliseconds(candle.CandleSymbol!.Period!.PeriodIntervalMillis)
};
}

/// <summary>
/// Returns the first non-NaN value from the provided list of values.
/// </summary>
/// <param name="values">An array of double values to check.</param>
/// <returns>The first non-NaN value, or NaN if all values are NaN.</returns>
private static double GetValueWithPriority(params double[] values)
{
foreach (var value in values)
{
if (!double.IsNaN(value))
{
return value;
}
}
return double.NaN;
}
}
Loading

0 comments on commit 335a14e

Please sign in to comment.