Skip to main content

iOS Integration Tutorial

Overview

This tutorial guides you through the process of creating an iOS app using the dxFeed Swift API to display real-time stock market quotes in a dynamic quote table. You'll learn how to integrate the dxFeed API, and allow users to customize symbol sets.

Below is a demo of the iOS quote table app:

ios_tut2-ezgif_com-video-to-gif-converter.gif

Installation

To build the iOS app, you'll need:

To install the dependency via Swift package manager, get the Swift package from GitHub.

Usages

Receiving market events

Basic usage for receiving dxFeed API Market Events:

import
DXFeedFramework

extension YourViewController: DXEventListener {
    public func receiveEvents(_ events:
[MarketEvent]) {
        events.forEach { events in
        // refresh UI
        }
    }
}

let endpoint = try
DXEndpoint.builder().withProperty(DXEndpoint.Property.aggregationPeriod.rawValue,
"1").build()
try endpoint.connect("demo.dxfeed.com:7300")
let subscription = try endpoint.getFeed()?.createSubscription(EventCode.quote)
try subscription?.add(listener: yourViewController)
try subscription?.addSymbols("AAPL", "IBM")

Reading instrument profiles

Usage instrument profiles to fetch available symbols:

import
DXFeedFramework

let reader = DXInstrumentProfileReader()
let result =
try reader.readFromFile(address:
"https://demo:demo@tools.dxfeed.com/ipf?TYPE=FOREX,STOCK&compression=zip")
// reading stocks and forex instruments
result?.forEach { instrument in
    // refresh UI
}

The corresponding file format is explained in detail in the Instrument Profile Format document. There is a corresponding Instrument Profile API to compose and parse them.

dxFeed symbology is explained in the Symbology Guide.