-
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.
FIX: missed eventsymbol, eventtime in to native convert
- Loading branch information
Showing
12 changed files
with
111 additions
and
9 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
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
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,26 @@ | ||
// | ||
// Summary+Ext.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 06.10.23. | ||
// | ||
|
||
import Foundation | ||
@_implementationOnly import graal_api | ||
|
||
extension Summary { | ||
convenience init(native: dxfg_summary_t) { | ||
self.init(String(pointee: native.market_event.event_symbol)) | ||
self.eventTime = native.market_event.event_time | ||
self.dayId = native.day_id | ||
self.dayOpenPrice = native.day_open_price | ||
self.dayHighPrice = native.day_high_price | ||
self.dayLowPrice = native.day_low_price | ||
self.dayClosePrice = native.day_close_price | ||
self.prevDayId = native.prev_day_id | ||
self.prevDayClosePrice = native.prev_day_close_price | ||
self.prevDayVolume = native.prev_day_volume | ||
self.openInterest = native.open_interest | ||
self.flags = native.flags | ||
} | ||
} |
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,45 @@ | ||
// | ||
// SummaryMapper.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 06.10.23. | ||
// | ||
|
||
import Foundation | ||
@_implementationOnly import graal_api | ||
|
||
class SummaryMapper: Mapper { | ||
var type = dxfg_summary_t.self | ||
|
||
func fromNative(native: UnsafeMutablePointer<dxfg_event_type_t>) -> MarketEvent? { | ||
let event = native.withMemoryRebound(to: type, capacity: 1) { native in | ||
return Summary(native: native.pointee) | ||
} | ||
return event | ||
} | ||
|
||
func toNative(event: MarketEvent) -> UnsafeMutablePointer<dxfg_event_type_t>? { | ||
let pointer = UnsafeMutablePointer<dxfg_summary_t>.allocate(capacity: 1) | ||
var pointee = pointer.pointee | ||
pointee.market_event.event_symbol = event.eventSymbol.toCStringRef() | ||
pointee.market_event.event_time = event.eventTime | ||
|
||
let summary = event.summary | ||
pointee.day_id = summary.dayId | ||
pointee.day_open_price = summary.dayOpenPrice | ||
pointee.day_high_price = summary.dayHighPrice | ||
pointee.day_low_price = summary.dayLowPrice | ||
pointee.day_close_price = summary.dayClosePrice | ||
pointee.prev_day_id = summary.prevDayId | ||
pointee.prev_day_close_price = summary.prevDayClosePrice | ||
pointee.prev_day_volume = summary.prevDayVolume | ||
pointee.open_interest = summary.openInterest | ||
pointee.flags = summary.flags | ||
|
||
let eventType = pointer.withMemoryRebound(to: dxfg_event_type_t.self, capacity: 1) { pointer in | ||
pointer.pointee.clazz = DXFG_EVENT_SUMMARY | ||
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
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