Skip to content

Commit

Permalink
add otc source
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Mar 13, 2024
1 parent bc075bd commit 26291cb
Showing 1 changed file with 54 additions and 40 deletions.
94 changes: 54 additions & 40 deletions DXFeedFramework/Events/Market/Extra/OrderSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}

Expand All @@ -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
Expand Down

0 comments on commit 26291cb

Please sign in to comment.