diff --git a/DXFeedFramework.xcodeproj/xcshareddata/xcschemes/Tools.xcscheme b/DXFeedFramework.xcodeproj/xcshareddata/xcschemes/Tools.xcscheme index 54dde0326..6e8141b4a 100644 --- a/DXFeedFramework.xcodeproj/xcshareddata/xcschemes/Tools.xcscheme +++ b/DXFeedFramework.xcodeproj/xcshareddata/xcschemes/Tools.xcscheme @@ -73,7 +73,7 @@ + isEnabled = "NO"> + isEnabled = "YES"> : Symbol { +public class GenericIndexedEventSubscriptionSymbol: Symbol { /// Gets event symbol. let symbol: T /// Gets indexed event source. ``IndexedEventSource`` @@ -39,8 +39,39 @@ public class IndexedEventSubscriptionSymbol: Symbol { } } -extension IndexedEventSubscriptionSymbol: Equatable { - public static func == (lhs: IndexedEventSubscriptionSymbol, rhs: IndexedEventSubscriptionSymbol) -> Bool { +extension GenericIndexedEventSubscriptionSymbol: Equatable { + public static func == (lhs: GenericIndexedEventSubscriptionSymbol, + rhs: GenericIndexedEventSubscriptionSymbol) -> Bool { return lhs === rhs || (lhs.symbol == rhs.symbol && lhs.source == rhs.source) } } + +/// Non-generic version, for using with Symbol protocol without equatable T +public class IndexedEventSubscriptionSymbol: Symbol { + /// Gets event symbol. + let symbol: Symbol + /// Gets indexed event source. ``IndexedEventSource`` + let source: IndexedEventSource + /// Initializes a new instance of the ``IndexedEventSubscriptionSymbol`` class + /// with a specified event symbol and source. + /// + /// - Parameters: + /// - symbol: The event symbol. + /// - source: The event source. + public init(symbol: Symbol, source: IndexedEventSource) { + self.symbol = symbol + self.source = source + } + + /// Custom symbol has to return string representation. + public var stringValue: String { + return "\(symbol.stringValue)source=\(source.toString())" + } +} + +extension IndexedEventSubscriptionSymbol: Equatable { + public static func == (lhs: IndexedEventSubscriptionSymbol, + rhs: IndexedEventSubscriptionSymbol) -> Bool { + return lhs === rhs || (lhs.symbol.stringValue == rhs.symbol.stringValue && lhs.source == rhs.source) + } +} diff --git a/DXFeedFramework/Api/Osub/TimeSeriesSubscriptionSymbol.swift b/DXFeedFramework/Api/Osub/TimeSeriesSubscriptionSymbol.swift index d634f1019..b0cfcad3a 100644 --- a/DXFeedFramework/Api/Osub/TimeSeriesSubscriptionSymbol.swift +++ b/DXFeedFramework/Api/Osub/TimeSeriesSubscriptionSymbol.swift @@ -15,7 +15,7 @@ import Foundation /// [Javadoc](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/osub/TimeSeriesSubscriptionSymbol.html) /// /// `T`: The type of event symbol. -public class TimeSeriesSubscriptionSymbol: IndexedEventSubscriptionSymbol { +public class TimeSeriesSubscriptionSymbol: GenericIndexedEventSubscriptionSymbol { let fromTime: Long /// Initializes a new instance of the ``TimeSeriesSubscriptionSymbol`` class /// with a specified event symbol and from time in milliseconds since Unix epoch. diff --git a/DXFeedFramework/Events/Market/Extra/OrderSource.swift b/DXFeedFramework/Events/Market/Extra/OrderSource.swift index 71199b8c7..3f676be16 100644 --- a/DXFeedFramework/Events/Market/Extra/OrderSource.swift +++ b/DXFeedFramework/Events/Market/Extra/OrderSource.swift @@ -11,13 +11,13 @@ import Foundation /// /// There are the following kinds of order sources: /// -/// Synthetic sources ``COMPOSITE_BID``, ``COMPOSITE_ASK``, -/// ``REGIONAL_BID``, and ``REGIONAL_ASK`` are provided for convenience of a consolidated +/// Synthetic sources ``compsoiteBid``, ``compsoiteAsk``, +/// ``regionalBid``, and ``regionalAsk`` are provided for convenience of a consolidated /// order book and are automatically generated based on the corresponding ``Quote`` events. -/// Aggregate sources ``AGGREGATE_BID`` and ``AGGREGATE_ASK`` provide +/// Aggregate sources ``agregateBid`` and ``agregateAsk`` provide /// futures depth (aggregated by price level) and NASDAQ Level II (top of book for each market maker). /// These source cannot be directly published to via dxFeed API. -/// ``isPublishable(Class) Publishable`` sources ``DEFAULT``, ``NTV``, and ``ISE`` +/// ``isPublishable(eventType:)`` sources ``defaultOrderSource``, ``NTV``, and ``ISE`` /// support full range of dxFeed API features. /// /// @@ -294,7 +294,7 @@ public class OrderSource: IndexedEventSource { /// Gets a value indicating whether the given event type can be directly published with this source. /// /// Subscription on such sources can be observed directly via ``DXPublisher`` - /// Subscription on such sources is observed via instances of ``IndexedEventSubscriptionSymbol`` + /// Subscription on such sources is observed via instances of ``GenericIndexedEventSubscriptionSymbol`` /// - Parameters: /// - eventype : Possible values ``Order``, ``AnalyticOrder``, ``SpreadOrder`` /// - Returns: true- events can be directly published with this source diff --git a/Samples/Tools/ConnectTool.swift b/Samples/Tools/ConnectTool.swift index f05be7cb2..3e89956a4 100644 --- a/Samples/Tools/ConnectTool.swift +++ b/Samples/Tools/ConnectTool.swift @@ -75,7 +75,8 @@ Where: types: arguments.parseTypes(at: 2), listener: self, properties: arguments.properties, - time: arguments.time) + time: arguments.time, + source: arguments.source) // Print till input new line _ = readLine() diff --git a/Samples/Tools/LiveIpfSample.swift b/Samples/Tools/LiveIpfSample.swift index 30b3e0895..58eb15ec4 100644 --- a/Samples/Tools/LiveIpfSample.swift +++ b/Samples/Tools/LiveIpfSample.swift @@ -52,7 +52,9 @@ class LiveIpfSample: ToolsCommand { func execute() { do { collector = try DXInstrumentProfileCollector() - connection = try DXInstrumentProfileConnection(arguments.count > 1 ? arguments[1] : LiveIpfSample.defaultIpfUrl, collector!) + connection = try DXInstrumentProfileConnection(arguments.count > 1 ? + arguments[1] : + LiveIpfSample.defaultIpfUrl, collector!) // Update period can be used to re-read IPF files, not needed for services supporting IPF "live-update" try connection?.setUpdatePeriod(60000) connection?.add(listener: self) diff --git a/Samples/Tools/SubscriptionUtils.swift b/Samples/Tools/SubscriptionUtils.swift index d582741d9..4948e8e72 100644 --- a/Samples/Tools/SubscriptionUtils.swift +++ b/Samples/Tools/SubscriptionUtils.swift @@ -17,7 +17,8 @@ class Subscription { types: [EventCode], listener: O, properties: [String: String], - time: String?) + time: String?, + source: String? = nil) where O: DXEventListener, O: Hashable { print(""" Create subscription to \(address) for \(types):\(symbols) with properties:\(properties) and time \(time ?? "---") @@ -40,6 +41,13 @@ Create subscription to \(address) for \(types):\(symbols) with properties:\(prop TimeSeriesSubscriptionSymbol(symbol: symbol, date: date) } try? subscription?.addSymbols(timeSubscriptionSymbols) + } else if source != nil { + if let source = try? OrderSource.valueOf(name: source!) { + let indexedEventSubscriptionSymbols = symbols.map { symbol in + IndexedEventSubscriptionSymbol(symbol: symbol, source: source) + } + try? subscription?.addSymbols(indexedEventSubscriptionSymbols) + } } else { try? subscription?.addSymbols(symbols) } @@ -49,3 +57,4 @@ Create subscription to \(address) for \(types):\(symbols) with properties:\(prop } } } +