From 26291cb6b717158e4b2e416ce03c0f89fed74a8b Mon Sep 17 00:00:00 2001 From: Aleksey Kosylo Date: Wed, 13 Mar 2024 13:37:50 +0100 Subject: [PATCH] add otc source --- .../Events/Market/Extra/OrderSource.swift | 94 +++++++++++-------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/DXFeedFramework/Events/Market/Extra/OrderSource.swift b/DXFeedFramework/Events/Market/Extra/OrderSource.swift index a17f67449..0ea1a5a3f 100644 --- a/DXFeedFramework/Events/Market/Extra/OrderSource.swift +++ b/DXFeedFramework/Events/Market/Extra/OrderSource.swift @@ -161,46 +161,53 @@ public class OrderSource: IndexedEventSource { /// Members Exchange. Record for price level book. public static let memx = try? OrderSource("memx", pubOrder) + /// Pink Sheets. Record for price level book. + /// Pink sheets are listings for stocks that trade over-the-counter (OTC). + /// ``Order`` and ``OtcMarketsOrder`` events are publishable on this + /// source and the corresponding subscription can be observed via ``DXPublisher`` + public static let pink = try? OrderSource("pink", pubOrder | pubOtcMarketsOrder) + /// Don't use it. Just for initialization all static variable. /// static let - is always lazy initialized fileprivate static let allValues = [OrderSource.defaultOrderSource, - OrderSource.compsoiteBid, - OrderSource.compsoiteAsk, - OrderSource.regionalBid, - OrderSource.regionalAsk, - OrderSource.agregateBid, - OrderSource.agregateAsk, - OrderSource.NTV, - OrderSource.ntv, - OrderSource.NFX, - OrderSource.ESPD, - OrderSource.XNFI, - OrderSource.ICE, - OrderSource.ISE, - OrderSource.DEA, - OrderSource.DEX, - OrderSource.BYX, - OrderSource.BZX, - OrderSource.BATE, - OrderSource.CHIX, - OrderSource.CEUX, - OrderSource.BXTR, - OrderSource.IST, - OrderSource.BI20, - OrderSource.ABE, - OrderSource.FAIR, - OrderSource.GLBX, - OrderSource.glbx, - OrderSource.ERIS, - OrderSource.XEUR, - OrderSource.xeur, - OrderSource.CFE, - OrderSource.C2OX, - OrderSource.SMFE, - OrderSource.smfe, - OrderSource.iex, - OrderSource.MEMX, - OrderSource.memx] + OrderSource.compsoiteBid, + OrderSource.compsoiteAsk, + OrderSource.regionalBid, + OrderSource.regionalAsk, + OrderSource.agregateBid, + OrderSource.agregateAsk, + OrderSource.NTV, + OrderSource.ntv, + OrderSource.NFX, + OrderSource.ESPD, + OrderSource.XNFI, + OrderSource.ICE, + OrderSource.ISE, + OrderSource.DEA, + OrderSource.DEX, + OrderSource.BYX, + OrderSource.BZX, + OrderSource.BATE, + OrderSource.CHIX, + OrderSource.CEUX, + OrderSource.BXTR, + OrderSource.IST, + OrderSource.BI20, + OrderSource.ABE, + OrderSource.FAIR, + OrderSource.GLBX, + OrderSource.glbx, + OrderSource.ERIS, + OrderSource.XEUR, + OrderSource.xeur, + OrderSource.CFE, + OrderSource.C2OX, + OrderSource.SMFE, + OrderSource.smfe, + OrderSource.iex, + OrderSource.MEMX, + OrderSource.memx, + OrderSource.pink] override init(_ identifier: Int, _ name: String) { self.pubFlags = 0 @@ -229,8 +236,7 @@ public class OrderSource: IndexedEventSource { default: break } // Flag FullOrderBook requires that source must be publishable. - if (pubFlags & OrderSource.fullOrderBook) != 0 && - (pubFlags & (OrderSource.pubOrder | OrderSource.pubAnalyticOrder | OrderSource.pubSpreadOrder)) == 0 { + if OrderSource.isFullOrderBookFlag(pubFlags) && OrderSource.isPublishableFlag(pubFlags) { throw ArgumentException.exception("Unpublishable full order book order") } @@ -241,8 +247,16 @@ public class OrderSource: IndexedEventSource { throw ArgumentException.exception("duplicate name \(name)") } } + + private static func isFullOrderBookFlag(_ pubFlags: Int) -> Bool { + return (pubFlags & OrderSource.fullOrderBook) != 0 + } + + private static func isPublishableFlag(_ pubFlags: Int) -> Bool { + return (pubFlags & (OrderSource.pubOrder | OrderSource.pubAnalyticOrder | OrderSource.pubOtcMarketsOrder | OrderSource.pubSpreadOrder)) == 0 + } - /// Determines whether specified source identifier refers to special order source. + /// Determines whether specified source identifier refers to special order source. /// Special order sources are used for wrapping non-order events into order events. internal static func isSpecialSourceId(sourceId: Int) -> Bool { return sourceId >= 1 && sourceId <= 6