How slavakuntsov/hyper-quant-api-connector works
Project Overview & Core Purpose
• The project is centered on connecting to external cryptocurrency market data using Bitfinex’s API. It offers two major modes of operation: REST-based data retrieval and WebSocket-based real-time event processing.
• In addition, there is a currency conversion service that integrates with CryptAPI to convert between currencies.
• Although a ConsoleApp exists, the primary application user interface is the WPF application (built with an MVVM pattern) which consumes the API connector functionality.
Main Components
a. API Connector Module:
• Contains submodules for the REST API and WebSocket connections.
• REST API Connector:
• Implements IRestApiConnector with methods to retrieve candle series, trades, and ticker data.
• Uses HttpClient (see DI registration example with a base address of https://api-pub.bitfinex.com).
• WebSocket Connector:
• Implements IWebSocketConnector.
• Manages subscriptions, event handling, and real-time incoming messages (candle updates, trade data).
• DTOs, Interfaces, and Models:
• DTOs such as CurrencyConvertDTO and RequestMessageDTO handle data packaging.
• Models like Candle, Trade, Ticker, etc., represent domain objects.
b. Cryptocurrency Converter:
• Implements ICryptocurrencyConverter to convert cryptocurrency amounts using CryptAPI.
c. UI (WPF Application):
• Follows the MVVM pattern.
• Contains Model (Portfolio), View (MainWindow), and ViewModel (MainViewModel).
• Acts as a client consuming the API connectors via dependency injection (DI).
d. External Dependencies:
• Bitfinex APIs (for both REST and WebSocket endpoints).
• CryptAPI for currency conversion.
• Microsoft.Extensions.DependencyInjection for DI and HttpClient configuration.
Architectural Patterns & Design Principles
• Use of the Interface Segregation Principle: how ITestConnector was split into IRestApiConnector and IWebSocketConnector.
• DI approach (the code snippets for registering services are a key part of the architecture).
• Mention that the REST methods yield results as asynchronous enumerables to optimize memory usage when dealing with large data sets.
• That the WPF application follows the MVVM pattern (so separate presentation, logic, and data concerns).