-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Waiting graal struct and event type
- Loading branch information
Showing
6 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
DXFeedFramework/Native/Events/Markets/OtcMarketsOrderMapper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters