diff --git a/DXFeedFramework.xcodeproj/project.pbxproj b/DXFeedFramework.xcodeproj/project.pbxproj index 8105d68aa..2a6c8798e 100644 --- a/DXFeedFramework.xcodeproj/project.pbxproj +++ b/DXFeedFramework.xcodeproj/project.pbxproj @@ -280,6 +280,7 @@ 64BDDB202AD6CC8300694210 /* AnalyticOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64BDDB1F2AD6CC8300694210 /* AnalyticOrder.swift */; }; 64BDDB222AD6CC9A00694210 /* SpreadOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64BDDB212AD6CC9A00694210 /* SpreadOrder.swift */; }; 64BDDB242AD6F10200694210 /* Scope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64BDDB232AD6F10200694210 /* Scope.swift */; }; + 64BDDB262AD6F6B500694210 /* IcebergType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64BDDB252AD6F6B500694210 /* IcebergType.swift */; }; 64C771F22A94A224009868C2 /* Character+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64C771F12A94A224009868C2 /* Character+Ext.swift */; }; 64C771F42A94A86E009868C2 /* Side.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64C771F32A94A86E009868C2 /* Side.swift */; }; 64C771F62A94ADDA009868C2 /* Direction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64C771F52A94ADDA009868C2 /* Direction.swift */; }; @@ -723,6 +724,7 @@ 64BDDB1F2AD6CC8300694210 /* AnalyticOrder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticOrder.swift; sourceTree = ""; }; 64BDDB212AD6CC9A00694210 /* SpreadOrder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpreadOrder.swift; sourceTree = ""; }; 64BDDB232AD6F10200694210 /* Scope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Scope.swift; sourceTree = ""; }; + 64BDDB252AD6F6B500694210 /* IcebergType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IcebergType.swift; sourceTree = ""; }; 64C771F12A94A224009868C2 /* Character+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Character+Ext.swift"; sourceTree = ""; }; 64C771F32A94A86E009868C2 /* Side.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Side.swift; sourceTree = ""; }; 64C771F52A94ADDA009868C2 /* Direction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Direction.swift; sourceTree = ""; }; @@ -1133,6 +1135,7 @@ 6486B97A2AD0517A00D8D5FA /* OrderAction.swift */, 6486B97C2AD057F200D8D5FA /* OrderSource.swift */, 64BDDB232AD6F10200694210 /* Scope.swift */, + 64BDDB252AD6F6B500694210 /* IcebergType.swift */, ); path = Extra; sourceTree = ""; @@ -2120,6 +2123,7 @@ 6469F8C82A3B25C900846831 /* MarketEvent+Access.swift in Sources */, 640C3FD22A6178D200555161 /* CandleSession.swift in Sources */, 6498E6BD2AB1E0510093A065 /* ScheduleSession.swift in Sources */, + 64BDDB262AD6F6B500694210 /* IcebergType.swift in Sources */, 8088D76529C0FBCE00F240CB /* ThreadManager.swift in Sources */, 64DA26BE2AA20EDB005B1757 /* DXInstrumentProfileConnectionObserver.swift in Sources */, 64656F732A1D0A84006A0B19 /* EndpointListener.swift in Sources */, diff --git a/DXFeedFramework/Events/Market/Extra/IcebergType.swift b/DXFeedFramework/Events/Market/Extra/IcebergType.swift new file mode 100644 index 000000000..9e0b12479 --- /dev/null +++ b/DXFeedFramework/Events/Market/Extra/IcebergType.swift @@ -0,0 +1,33 @@ +// +// IcebergType.swift +// DXFeedFramework +// +// Created by Aleksey Kosylo on 11.10.23. +// + +import Foundation + +/// Type of an iceberg order. +public enum IcebergType: Int, CaseIterable { + /// Iceberg type is undefined, unknown or inapplicable. + case undefined = 0 + /// Represents native (exchange-managed) iceberg type. + case native + /// Represents synthetic (managed outside of the exchange) iceberg type. + case synthetic +} + +/// Class extension for ``IcebergType`` enum. +public class IcebergTypeExt { + private static let values: [IcebergType] = + EnumUtil.createEnumBitMaskArrayByValue(defaultValue: .undefined, allCases: IcebergType.allCases) + + + /// Returns an enum constant of the``IcebergType`` by integer code bit pattern. + /// - Parameters: + /// - value: Property value + /// - Returns: The enum constant of the specified enum type with the specified value + public static func valueOf(value: Int) -> IcebergType { + return values[value] + } +} diff --git a/DXFeedFramework/Events/Market/Extra/OrderBase.swift b/DXFeedFramework/Events/Market/Extra/OrderBase.swift index 229836e04..3901ae186 100644 --- a/DXFeedFramework/Events/Market/Extra/OrderBase.swift +++ b/DXFeedFramework/Events/Market/Extra/OrderBase.swift @@ -154,12 +154,15 @@ tradePrice: \(tradePrice), \ tradeSize: \(tradeSize) """ } - + /// Returns string representation of this candle event. + func toString() -> String { + return "OrderBase{\(baseFieldsToString())}" + } } extension OrderBase { /// Gets a value indicating whether this order has some size - func hsaSize() -> Bool { + public func hsaSize() -> Bool { return size != 0 && !size.isNaN } /// Gets exchange code of this order. @@ -273,11 +276,6 @@ extension OrderBase { } } - /// Returns string representation of this candle event. - func toString() -> String { - return "OrderBase{\(baseFieldsToString())}" - } - /// Returns string representation of this candle fields. func baseFieldsToString() -> String { return diff --git a/DXFeedFramework/Events/Market/Extra/Scope.swift b/DXFeedFramework/Events/Market/Extra/Scope.swift index 24976c604..8becbec2f 100644 --- a/DXFeedFramework/Events/Market/Extra/Scope.swift +++ b/DXFeedFramework/Events/Market/Extra/Scope.swift @@ -23,10 +23,16 @@ public enum Scope: Int, CaseIterable { case order } + +/// Class extension for ``ScopeExt`` enum. public class ScopeExt { private static let values: [Scope] = EnumUtil.createEnumBitMaskArrayByValue(defaultValue: .composite, allCases: Scope.allCases) + /// Returns an enum constant of the``ScopeExt`` by integer code bit pattern. + /// - Parameters: + /// - value: Property value + /// - Returns: The enum constant of the specified enum type with the specified value public static func valueOf(value: Int) -> Scope { return values[value] } diff --git a/DXFeedFramework/Native/Events/Markets/AnalyticOrder.swift b/DXFeedFramework/Native/Events/Markets/AnalyticOrder.swift index d8c14c7fe..5649767df 100644 --- a/DXFeedFramework/Native/Events/Markets/AnalyticOrder.swift +++ b/DXFeedFramework/Native/Events/Markets/AnalyticOrder.swift @@ -6,7 +6,67 @@ // import Foundation - +/// Represents an extension of ``Order`` introducing analytics information, +/// e.g. adding to this order iceberg related information ``icebergPeakSize``, ``IcebergHiddenSize``, ``IcebergExecutedSize`` +/// +/// The collection of analytic order events of a symbol represents the most recent analytic information +/// that is available about orders on the market at any given moment of time. +/// +/// [For more details see](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/event/market/AnalyticOrder.html) public class AnalyticOrder: OrderBase { - + /* + * Analytic flags property has several significant bits that are packed into an integer in the following way: + * 31...2 1 0 + * +--------------+-------+-------+ + * | | IcebergType | + * +--------------+-------+-------+ + */ + + // TYPE values are taken from Type enum. + private let icebergTypeMask = 3 + private let icebergTypeShift = 0 + + /// Gets or sets iceberg peak size of this analytic order. + public var icebergPeakSize: Double = .nan + /// Gets or sets iceberg hidden size of this analytic order. + public var icebergHiddenSize: Double = .nan + /// Gets or sets iceberg executed size of this analytic order. + public var icebergExecutedSize: Double = .nan + /// Gets or sets iceberg type of this analytic order. + public var icebergFlags: Int32 = 0 + /// Initializes a new instance of the class. + public override init(_ eventSymbol: String) { + super.init(eventSymbol) + } + + /// Returns string representation of this candle event. + override func toString() -> String { + return +""" +AnalyticOrder{\(baseFieldsToString()), \ +icebergPeakSize=\(icebergPeakSize), \ +icebergHiddenSize=\(icebergHiddenSize) + +icebergExecutedSize=\(icebergExecutedSize) + +icebergType=\(icebergType)} +""" + } } + +extension AnalyticOrder { + /// Gets or sets iceberg type of this analytic order. + public var icebergType: IcebergType { + get { + IcebergTypeExt.valueOf(value: BitUtil.getBits(flags: Int(icebergFlags), + mask: icebergTypeMask, + shift: icebergTypeShift)) + } + set { + icebergFlags = Int32(BitUtil.setBits(flags: Int(icebergFlags), + mask: icebergTypeMask, + shift: icebergTypeShift, + bits: newValue.rawValue)) + } + } +} + +