Skip to main content

Data Provider

You should implement a data provider that conforms to the DataProvider protocol to provide the necessary dependencies for ChartScreenConfigurator.

DataProvider protocol acts as a central place to access different data providers such as candles, quotes, IPF, schedule, news, orders, and studies.

Types conforming to DataProvider must provide access to a variety of services via properties, with some being optional depending on the implementation.

/// A protocol that defines the necessary data providers for a system.
///
/// This protocol acts as a central place to access different data providers
/// such as candles, quotes, IPF, schedule, news, orders, and studies.
///
/// Types conforming to `DataProvider` must provide access to a variety of services
/// via properties, with some being optional depending on the implementation.
public protocol DataProvider {
/// Provides access to the candle data for a specific instrument.
/// Used for fetching and streaming historical and real-time candle data.
var candlesProvider: CandlesProvider { get }
/// Provides access to the quotes data for a specific instrument.
/// Facilitates fetching bid, ask, and last price data for the selected symbol.
var quotesDataProvider: QuotesDataProvider { get }
/// Provides access to the IPF (Instrument Price Flow) data.
/// Used for tracking and visualizing instrument price flow information.
var ipfDataProvider: IPFDataProvider { get }
/// Provides access to the instrument's trading schedule.
/// Useful for aligning data with trading session start times and identifying trading windows.
var scheduleProvider: ScheduleProvider { get }
/// Provides access to news data for the selected symbol, including corporate actions, earnings, and conference calls.
/// May be `nil` if news functionality is not supported or not required.
var newsProvider: NewsProvider? { get }
/// Provides access to orders data and operations for the selected symbol.
/// May be `nil` if order functionality is not supported or not required.
var ordersProvider: OrdersProvider? { get }
/// Provides access to the studies data for technical analysis.
///
/// The `StudiesProvider` is essential for users who rely on technical analysis to make informed trading decisions.
/// It allows for the calculation, visualization, and streaming of various technical indicators based on historical and real-time market data.
///
/// This property is required and must be implemented.
var studiesProvider: StudiesProvider { get }
}

Available providers​

Default implementation​

If you haven’t implemented data providers before and are using DXFeedFramework to retrieve data, you can use our default provider. To work with it and DXFeedFramework, you will need a Quote Address to obtain candles and quotes data, and an IPF Address to obtain instrument information. Additionally, a default implementation of the Studies Provider is available if you are using the DXStudies framework. For assistance, please contact your DXFeed or DXStudies sales manager or visit https://dxfeed.com/contact-sales/ for assistance.

Default implementation code:

import DXChart
import DXFeedFramework
final class DataProvider: DXChart.DataProvider {
var candlesProvider: DXChart.CandlesProvider
var quotesDataProvider: DXChart.QuotesDataProvider
var ipfDataProvider: DXChart.IPFDataProvider
var scheduleProvider: DXChart.ScheduleProvider
var newsProvider: DXChart.NewsProvider?
var ordersProvider: DXChart.OrdersProvider?
var studiesProvider: DXChart.StudiesProvider
init(
quoteAddress: String,
ipfAddress: String,
dataStorage: DXChart.DataStorage = DXChartApp.dataStorage,
settingsManager: DXChart.SettingsManager = DXChartApp.settingsManager
) {
let currentSymbol = dataStorage.instrument.symbol
candlesProvider = DXFeedCandlesProvider(address: quoteAddress, dataStorage: dataStorage, settingsManager: settingsManager)
quotesDataProvider = DXFeedQuotesDataProvider(address: quoteAddress, symbol: currentSymbol)
ipfDataProvider = DXFeedIPFDataProvider(ipfAddress)
scheduleProvider = DXFeedScheduleProvider()
newsProvider = DXFeedNewsProvider(currentSymbol: currentSymbol)
ordersProvider = nil
#if targetEnvironment(simulator)
// A mock implementation of the provider is used for running the app on the simulator.
// This is particularly useful for development on Apple Silicon Macs,
// where the simulator may not support some features available on real devices.
// IMPORTANT: This applies only to providers based on the DXStudies framework.
studiesProvider = MockStudiesProvider()
#else
// The actual implementation of the provider is used for running on physical devices.
studiesProvider = DXStudiesProvider()
#endif
}
}