Skip to content

Commit

Permalink
add OtcMarkets Mapper
Browse files Browse the repository at this point in the history
Waiting graal struct and event type
  • Loading branch information
kosyloa committed Mar 13, 2024
1 parent 7ac81c2 commit 084813f
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
4 changes: 4 additions & 0 deletions DXFeedFramework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
64C004722BA074500009F7C9 /* OtcMarketsOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64C004712BA074500009F7C9 /* OtcMarketsOrder.swift */; };
64C004742BA09C110009F7C9 /* OtcMarketsOrder+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64C004732BA09C110009F7C9 /* OtcMarketsOrder+Ext.swift */; };
64C004762BA09FDC0009F7C9 /* OtcMarketsPriceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64C004752BA09FDC0009F7C9 /* OtcMarketsPriceType.swift */; };
64C004782BA1C25C0009F7C9 /* OtcMarketsOrderMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64C004772BA1C25C0009F7C9 /* OtcMarketsOrderMapper.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 */; };
Expand Down Expand Up @@ -839,6 +840,7 @@
64C004712BA074500009F7C9 /* OtcMarketsOrder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OtcMarketsOrder.swift; sourceTree = "<group>"; };
64C004732BA09C110009F7C9 /* OtcMarketsOrder+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OtcMarketsOrder+Ext.swift"; sourceTree = "<group>"; };
64C004752BA09FDC0009F7C9 /* OtcMarketsPriceType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OtcMarketsPriceType.swift; sourceTree = "<group>"; };
64C004772BA1C25C0009F7C9 /* OtcMarketsOrderMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OtcMarketsOrderMapper.swift; sourceTree = "<group>"; };
64C771F12A94A224009868C2 /* Character+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Character+Ext.swift"; sourceTree = "<group>"; };
64C771F32A94A86E009868C2 /* Side.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Side.swift; sourceTree = "<group>"; };
64C771F52A94ADDA009868C2 /* Direction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Direction.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1124,6 +1126,7 @@
64AF04422AE6AA230091F6F1 /* TradeETH+Ext.swift */,
64AF04402AE6A9E90091F6F1 /* TradeETHMapper.swift */,
64EAA1A32B7B4DA1005087BC /* IndexedEventSource+Ext.swift */,
64C004772BA1C25C0009F7C9 /* OtcMarketsOrderMapper.swift */,
64C004732BA09C110009F7C9 /* OtcMarketsOrder+Ext.swift */,
);
path = Markets;
Expand Down Expand Up @@ -2464,6 +2467,7 @@
64656F622A1B9FF7006A0B19 /* EnumException.swift in Sources */,
641BCBC12A21077800FE23C2 /* EventCode.swift in Sources */,
64ACBCE82A28CF9700032C53 /* IndexedEventSubscriptionSymbol.swift in Sources */,
64C004782BA1C25C0009F7C9 /* OtcMarketsOrderMapper.swift in Sources */,
649F48882A615BED0016FDD1 /* CandleType.swift in Sources */,
64BDDB2E2AD7DC5E00694210 /* OrderMapper.swift in Sources */,
649706842AD82B070068FF88 /* Series.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions DXFeedFramework/Events/EventCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ public enum EventCode: CaseIterable {
case series
/// See ``OptionSale``
case optionSale
/// See ``OtcMarketsOrder``
case otcMarketsOrder
}
1 change: 0 additions & 1 deletion DXFeedFramework/Events/Market/OtcMarketsOrder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public class OtcMarketsOrder: Order {
return (otcMarketsFlags & OtcMarketsOrder.NMS_CONDITIONAL) != 0
}


/// Changes whether this event represents a NMS conditional.
/// - Parameters:
/// - nmsConditional: true if this event represents a NMS conditional.
Expand Down
3 changes: 2 additions & 1 deletion DXFeedFramework/Native/Events/EventMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class EventMapper: Mapper {
.analyticOrder: AnalyticOrderMapper(),
.spreadOrder: SpreadOrderMapper(),
.series: SeriesMapper(),
.optionSale: OptionSaleMapper()]
.optionSale: OptionSaleMapper(),
.otcMarketsOrder: OtcMarketsOrderMapper()]

func fromNative(native: UnsafeMutablePointer<dxfg_event_type_t>) throws -> MarketEvent? {
let code = try EnumUtil.valueOf(value: EventCode.convert(native.pointee.clazz))
Expand Down
53 changes: 53 additions & 0 deletions DXFeedFramework/Native/Events/Markets/OtcMarketsOrderMapper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
//
// Copyright (C) 2024 Devexperts LLC. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
//

import Foundation
@_implementationOnly import graal_api

class OtcMarketsOrderMapper: Mapper {
let type = dxfg_order_t.self

func fromNative(native: UnsafeMutablePointer<dxfg_event_type_t>) -> MarketEvent? {
let event = native.withMemoryRebound(to: type, capacity: 1) { native in
return OtcMarketsOrder(native: native.pointee)
}
return event
}

func toNative(event: MarketEvent) -> UnsafeMutablePointer<dxfg_event_type_t>? {
let pointer = UnsafeMutablePointer<TypeAlias>.allocate(capacity: 1)
pointer.pointee.order_base.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointer.pointee.order_base.market_event.event_time = event.eventTime

let order = event.order

pointer.pointee.order_base.market_event.event_time = order.eventTime
pointer.pointee.order_base.event_flags = order.eventFlags
pointer.pointee.order_base.index = order.index
pointer.pointee.order_base.time_sequence = order.timeSequence
pointer.pointee.order_base.time_nano_part = order.timeNanoPart
pointer.pointee.order_base.action_time = order.actionTime
pointer.pointee.order_base.order_id = order.orderId
pointer.pointee.order_base.aux_order_id = order.auxOrderId
pointer.pointee.order_base.price = order.price
pointer.pointee.order_base.size = order.size
pointer.pointee.order_base.executed_size = order.executedSize
pointer.pointee.order_base.count = order.count
pointer.pointee.order_base.flags = order.flags
pointer.pointee.order_base.trade_id = order.tradeId
pointer.pointee.order_base.trade_price = order.tradePrice
pointer.pointee.order_base.trade_size = order.tradeSize

pointer.pointee.market_maker = order.marketMaker?.toCStringRef()

let eventType = pointer.withMemoryRebound(to: dxfg_event_type_t.self, capacity: 1) { pointer in
pointer.pointee.clazz = DXFG_EVENT_ORDER
return pointer
}
return eventType
}
}
2 changes: 2 additions & 0 deletions DXFeedFramework/Native/Feed/EventCode+Native.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ extension EventCode {
return DXFG_EVENT_SERIES
case .optionSale:
return DXFG_EVENT_OPTION_SALE
case .otcMarketsOrder:
return DXFG_EVENT_ORDER;
}
}
}

0 comments on commit 084813f

Please sign in to comment.