Skip to content

Commit

Permalink
Merge branch 'feature/missing_events' into swift
Browse files Browse the repository at this point in the history
# Conflicts:
#	DXFeedFramework.xcodeproj/project.pbxproj
#	DXFeedFramework.xcodeproj/xcshareddata/xcschemes/Tools.xcscheme
#	DXFeedFramework/Events/Market/TimeAndSale.swift
  • Loading branch information
kosyloa committed Oct 13, 2023
2 parents be83ada + 5e4e524 commit 065e137
Show file tree
Hide file tree
Showing 71 changed files with 3,099 additions and 70 deletions.
172 changes: 160 additions & 12 deletions DXFeedFramework.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
</CommandLineArgument>
<CommandLineArgument
argument = "DXFeedIpfConnect Quote https://demo:[email protected]/ipf"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "ScheduleSample /Users/akosylo/test_ipf/schedule.zip /Users/akosylo/test_ipf/sample.ipf.zip AAPL 2012-05-26-14:15:00"
argument = "ScheduleSample schedule.zip sample.ipf.zip AAPL 2012-05-26-14:15:00"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
Expand All @@ -72,8 +72,8 @@
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "Connect mddqa.in.devexperts.com:7400 Quote AAPL"
isEnabled = "NO">
argument = "Connect mddqa.in.devexperts.com:7400 OptionSale AAPL"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "LatencyTest mddqa.in.devexperts.com:7400 TimeAndSale ETH/USD:GDAX"
Expand Down
13 changes: 13 additions & 0 deletions DXFeedFramework/Events/EventCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,38 @@ public enum EventCode: CaseIterable {
case quote
/// See ``Profile``
case profile
/// See ``Summary``
case summary
/// See ``Greeks``
case greeks
/// See ``Candle``
case candle
/// **Deprecated. Doesn't need to be implemented**
case dailyCandle
/// See ``Underlying``
case underlying
/// See ``TheoPrice``
case theoPrice
/// See ``Trade``
case trade
/// See ``TradeETH``
case tradeETH
/// **Not implemented**
case configuration
/// **Not implemented**
case message
/// See ``TimeAndSale``
case timeAndSale
/// **Doesn't need to be implemented. Abstract class**
case orderBase
/// See ``AnalyticOrder``
case order
/// See ``AnalyticOrder``
case analyticOrder
/// See ``SpreadOrder``
case spreadOrder
/// See ``Series``
case series
/// See ``OptionSale``
case optionSale
}
73 changes: 73 additions & 0 deletions DXFeedFramework/Events/Market/AnalyticOrder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// AnalyticOrder.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 11.10.23.
//

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 {
public override var type: EventCode {
return .analyticOrder
}
/*
* 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 <see cref="AnalyticOrder"/> class.
public override init(_ eventSymbol: String) {
super.init(eventSymbol)
}

/// Returns string representation of this candle event.
public 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))
}
}
}
36 changes: 36 additions & 0 deletions DXFeedFramework/Events/Market/Extensions/MarketEvent+Access.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,40 @@ extension MarketEvent {
public var candle: Candle {
return (self as? Candle)!
}
/// Use only for event.type is ``EventCode/summary``
public var summary: Summary {
return (self as? Summary)!
}
/// Use only for event.type is ``EventCode/greeks``
public var greeks: Greeks {
return (self as? Greeks)!
}
/// Use only for event.type is ``EventCode/underlying``
public var underlying: Underlying {
return (self as? Underlying)!
}
/// Use only for event.type is ``EventCode/theoPrice``
public var theoPrice: TheoPrice {
return (self as? TheoPrice)!
}
/// Use only for event.type is ``EventCode/order``
public var order: Order {
return (self as? Order)!
}
/// Use only for event.type is ``EventCode/spreadOrder``
public var spreadOrder: SpreadOrder {
return (self as? SpreadOrder)!
}
/// Use only for event.type is ``EventCode/analyticOrder``
public var analyticOrder: AnalyticOrder {
return (self as? AnalyticOrder)!
}
/// Use only for event.type is ``EventCode/series``
public var series: Series {
return (self as? Series)!
}
/// Use only for event.type is ``EventCode/optionSale``
public var optionSale: OptionSale {
return (self as? OptionSale)!
}
}
32 changes: 32 additions & 0 deletions DXFeedFramework/Events/Market/Extra/IcebergType.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// 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]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class IndexedEventSource {
public let name: String

/// The default source with zero identifier for all events that do not support multiple sources.
static let defaultSource = IndexedEventSource(identifier: 0, name: "DEFAULT")
public static let defaultSource = IndexedEventSource( 0, "DEFAULT")

/// Initializes a new instance of the ``IndexedEventSource`` class.
///
/// - Parameters:
/// - identifier: The identifier
/// - name: The name of identifier
public init(identifier: Int, name: String) {
public init(_ identifier: Int, _ name: String) {
self.name = name
self.identifier = identifier
}
Expand Down
39 changes: 39 additions & 0 deletions DXFeedFramework/Events/Market/Extra/OrderAction.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// OrderAction.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 06.10.23.
//

import Foundation

public enum OrderAction: Int, CaseIterable {
/// Default enum value for orders that do not support "Full Order Book" and for backward compatibility -
/// action must be derived from other ``Order``
case undefined = 0
/// New Order is added to Order Book.
case new
/// Order is modified and price-time-priority is not maintained (i.e. order has re-entered Order Book).
case replace
/// Order is modified without changing its price-time-priority (usually due to partial cancel by user).
case modify
/// Order is fully canceled and removed from Order Book.
case delete
/// Size is changed (usually reduced) due to partial order execution.
case partial
/// Order is fully executed and removed from Order Book.
case execute
/// Non-Book Trade - this Trade not refers to any entry in Order Book.
case trade
/// Prior Trade/Order Execution bust
case bust
}

internal class OrderActionExt {
private static let values: [OrderAction] =
EnumUtil.createEnumBitMaskArrayByValue(defaultValue: .undefined, allCases: OrderAction.allCases)

public static func valueOf(value: Int) -> OrderAction {
return values[value]
}
}
Loading

0 comments on commit 065e137

Please sign in to comment.