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 ed7f403
Show file tree
Hide file tree
Showing 45 changed files with 4,250 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
10 changes: 9 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,14 @@ 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/UI/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/UI/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.
- [x] [MultipleMarketDepthSample](https://github.com/dxFeed/dxfeed-graal-net-api/tree/main/samples/MultipleMarketDepthSample)
is a simple demonstration of how to use the `MarketDepthModel` to manage and display order books for multiple symbols.

## Current State

Expand Down
7 changes: 7 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
* [MDAPI-115] [.NET] Add IncOrderSnapshot sample
* [MDAPI-81] [.NET] Add MultipleMarketDepth sample
* [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>
31 changes: 31 additions & 0 deletions dxfeed-graal-net-api.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ 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\UI\MarketDepthModelSample\MarketDepthModelSample.csproj", "{930B1039-B76C-42C5-AD0F-9FA1A1FC9D84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CandleChartSample", "samples\UI\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
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UI", "UI", "{5F74BD34-C2D4-436B-8243-FB0F3BB9F0AC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -112,6 +122,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 +155,10 @@ 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}
{9B758A5C-8AA1-4560-A7CF-EF375B9A1E4C} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{C8F5013F-7F40-46D2-92AD-6B593524A1D0} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{5F74BD34-C2D4-436B-8243-FB0F3BB9F0AC} = {C4490D74-2970-4A1B-8178-A724A06B140A}
{B74E8A86-1AB7-4B36-AED3-292CDD95BF90} = {5F74BD34-C2D4-436B-8243-FB0F3BB9F0AC}
{930B1039-B76C-42C5-AD0F-9FA1A1FC9D84} = {5F74BD34-C2D4-436B-8243-FB0F3BB9F0AC}
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
27 changes: 27 additions & 0 deletions samples/IncOrderSnapshotSample/IncOrderSnapshotSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>DxFeed.Graal.Net.Samples</RootNamespace>
<TargetFrameworks>net6.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>../../artifacts/Debug/Samples/</OutputPath>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>../../artifacts/Release/Samples/</OutputPath>
</PropertyGroup>

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

<ItemGroup>
<None Update="dxfeed.properties">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
84 changes: 84 additions & 0 deletions samples/IncOrderSnapshotSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// <copyright file="Program.cs" company="Devexperts LLC">
// Copyright © 2022 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 System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using DxFeed.Graal.Net.Api;
using DxFeed.Graal.Net.Events;
using DxFeed.Graal.Net.Events.Market;
using DxFeed.Graal.Net.Models;

namespace DxFeed.Graal.Net.Samples;

internal abstract class Program
{
public static async Task Main(string[] args)
{
// Set the dxFeed server address.
SystemProperty.SetProperty("dxfeed.address", "dxfeed.address.com:7300");
var symbol = "AAPL";
var recordPrintLimit = 10;

var eventPrinter = new EventPrinter(recordPrintLimit);

// Build the model with the specified configurations.
using var model = IndexedTxModel<Order>.NewBuilder()
.WithBatchProcessing(true) // Enable batch processing.
.WithSnapshotProcessing(true) // Enable snapshot processing.
.WithFeed(DXFeed.GetInstance()) // Attach the model to the DXFeed instance.
.WithSymbol(symbol) // Set the symbol to subscribe to.
.WithSources(OrderSource.NTV) // Set the source for indexed events.
.WithListener((source, events, isSnapshot) =>
eventPrinter.Print(symbol, source, events.ToList(), isSnapshot))
.Build();

Console.WriteLine($"Subscribed to market depth updates for {symbol}. Press Ctrl+C to exit.");

// Keep the application running indefinitely.
await Task.Delay(Timeout.Infinite);
}

private sealed class EventPrinter
{
private readonly int _recordsPrintLimit;

public EventPrinter(int recordsPrintLimit) =>
_recordsPrintLimit = recordsPrintLimit;

public void Print(string symbol, IndexedEventSource source, List<Order> events, bool isSnapshot)
{
Console.WriteLine(
"Snapshot {{Symbol: '{0}', Source: '{1}', Type: {2}}}",
symbol,
source,
isSnapshot ? "full" : "update");

var count = 0;
foreach (var order in events)
{
if (!EventFlags.IsRemove(order) && order.HasSize)
{
Console.WriteLine($" {order}");
}
else
{
Console.WriteLine($" REMOVAL {{ Index: 0x{order.Index:x} }}");
}

if (++count < _recordsPrintLimit || _recordsPrintLimit == 0)
{
continue;
}

Console.WriteLine(" {{ ... {0} records left ...}}", events.Count - count);
break;
}
}
}
}
Loading

0 comments on commit ed7f403

Please sign in to comment.