Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/get indexed if subscribed #7

Merged
merged 10 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions DXFeedFramework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
642DC93C2AAA22D900974F5C /* DXFeedFramework.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 803BAC0D29BFA50700FFAB1C /* DXFeedFramework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
642DC9432AAA299800974F5C /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 646979712A3B5AF60003A9BA /* Colors.xcassets */; };
642DC9442AAA29EA00974F5C /* IpfCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 642DC9402AAA290300974F5C /* IpfCell.swift */; };
6433B12D2BCE7ADD004EFED7 /* DXFeed+LastEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6433B12C2BCE7ADD004EFED7 /* DXFeed+LastEvents.swift */; };
6433B1322BCFC01F004EFED7 /* DXLastEventsSubscribedTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6433B1312BCFC01F004EFED7 /* DXLastEventsSubscribedTest.swift */; };
643A329B2BD0137000F6F790 /* Optional+Ext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 643A329A2BD0137000F6F790 /* Optional+Ext.swift */; };
64437A8F2A9DEE6F005929B2 /* InstrumentProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64437A8E2A9DEE6F005929B2 /* InstrumentProfile.swift */; };
64437A922A9DF1DE005929B2 /* NativeInstrumentProfileReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64437A912A9DF1DE005929B2 /* NativeInstrumentProfileReader.swift */; };
6447A5DB2A8E559000739CCF /* ILastingEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6447A5DA2A8E559000739CCF /* ILastingEvent.swift */; };
Expand Down Expand Up @@ -355,7 +358,7 @@
64DA26C02AA224EB005B1757 /* NativeIPFConnectionListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DA26BF2AA224EB005B1757 /* NativeIPFConnectionListener.swift */; };
64DB79342A376E1B00229597 /* DXFeedFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 803BAC0D29BFA50700FFAB1C /* DXFeedFramework.framework */; };
64DB79352A376E1B00229597 /* DXFeedFramework.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 803BAC0D29BFA50700FFAB1C /* DXFeedFramework.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
64DF09332BC80DBB009F1486 /* DXFeed+LastEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DF09322BC80DBB009F1486 /* DXFeed+LastEvent.swift */; };
64DF09332BC80DBB009F1486 /* DXFeed+Promises.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DF09322BC80DBB009F1486 /* DXFeed+Promises.swift */; };
64DF09352BC924AB009F1486 /* DXAsyncLastTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64DF09342BC924AB009F1486 /* DXAsyncLastTest.swift */; };
64E342502AAB083700457994 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6469F8D22A3B401700846831 /* Colors.swift */; };
64E342522AAB29CF00457994 /* InstrumentProfileType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64E342512AAB29CF00457994 /* InstrumentProfileType.swift */; };
Expand Down Expand Up @@ -662,7 +665,11 @@
642DC9332AAA21C300974F5C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
642DC9352AAA21C300974F5C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
642DC9402AAA290300974F5C /* IpfCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IpfCell.swift; sourceTree = "<group>"; };
6433B12C2BCE7ADD004EFED7 /* DXFeed+LastEvents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DXFeed+LastEvents.swift"; sourceTree = "<group>"; };
6433B1302BCE87D4004EFED7 /* RequestProfile.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = RequestProfile.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
6433B1312BCFC01F004EFED7 /* DXLastEventsSubscribedTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXLastEventsSubscribedTest.swift; sourceTree = "<group>"; };
6435EE3C2B1F1E9200E8496C /* PrintQuoteEvents.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = PrintQuoteEvents.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
643A329A2BD0137000F6F790 /* Optional+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Optional+Ext.swift"; sourceTree = "<group>"; };
64437A8E2A9DEE6F005929B2 /* InstrumentProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstrumentProfile.swift; sourceTree = "<group>"; };
64437A912A9DF1DE005929B2 /* NativeInstrumentProfileReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeInstrumentProfileReader.swift; sourceTree = "<group>"; };
644551C92B973A0D0069E3A2 /* FetchDailyCandles.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = FetchDailyCandles.playground; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
Expand Down Expand Up @@ -884,7 +891,7 @@
64DA26BB2AA20B66005B1757 /* InstrumentProfileConnectionState+ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InstrumentProfileConnectionState+ext.swift"; sourceTree = "<group>"; };
64DA26BD2AA20EDB005B1757 /* DXInstrumentProfileConnectionListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXInstrumentProfileConnectionListener.swift; sourceTree = "<group>"; };
64DA26BF2AA224EB005B1757 /* NativeIPFConnectionListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeIPFConnectionListener.swift; sourceTree = "<group>"; };
64DF09322BC80DBB009F1486 /* DXFeed+LastEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DXFeed+LastEvent.swift"; sourceTree = "<group>"; };
64DF09322BC80DBB009F1486 /* DXFeed+Promises.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DXFeed+Promises.swift"; sourceTree = "<group>"; };
64DF09342BC924AB009F1486 /* DXAsyncLastTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXAsyncLastTest.swift; sourceTree = "<group>"; };
64E342512AAB29CF00457994 /* InstrumentProfileType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstrumentProfileType.swift; sourceTree = "<group>"; };
64E3637A2AD83459002E2B0D /* SeriesMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeriesMapper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1095,6 +1102,7 @@
641C64AE2B344E770023CFAD /* PublishProfiles.playground */,
64F9C6C12B4BFD8F003ED014 /* DXFeedconnect.playground */,
644551C92B973A0D0069E3A2 /* FetchDailyCandles.playground */,
6433B1302BCE87D4004EFED7 /* RequestProfile.playground */,
);
path = Playgrounds;
sourceTree = "<group>";
Expand Down Expand Up @@ -1258,6 +1266,7 @@
6464074E2A9F62D4006FF769 /* Date+Ext.swift */,
64A42F3A2B07A7A3001C3ACC /* SymbolParser.swift */,
640885C92B1F7EE700E6CF88 /* QdsUtils.swift */,
643A329A2BD0137000F6F790 /* Optional+Ext.swift */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -1637,6 +1646,7 @@
641C64B32B347C430023CFAD /* DXObservableSubscriptionTest.swift */,
6423E4682B457000006B208D /* DXTimeSeriesSubscriptionTest.swift */,
646064E92B4D8973009201E2 /* DXLastEventTest.swift */,
6433B1312BCFC01F004EFED7 /* DXLastEventsSubscribedTest.swift */,
64EAA1A12B7A38F8005087BC /* DXPromiseTest.swift */,
64DF09342BC924AB009F1486 /* DXAsyncLastTest.swift */,
64EAA1A52B838ED3005087BC /* DXSnapshotProcessorTest.swift */,
Expand Down Expand Up @@ -1703,7 +1713,8 @@
64ACBCDB2A28974900032C53 /* Osub */,
80FC415829C8EE8B00E6B611 /* DXEndpoint.swift */,
64656F5A2A1B9784006A0B19 /* DXFeed.swift */,
64DF09322BC80DBB009F1486 /* DXFeed+LastEvent.swift */,
64DF09322BC80DBB009F1486 /* DXFeed+Promises.swift */,
6433B12C2BCE7ADD004EFED7 /* DXFeed+LastEvents.swift */,
64656F662A1CCFC2006A0B19 /* DXPublisher.swift */,
64656F6C2A1CFB10006A0B19 /* DXEndpointState.swift */,
641BCBBB2A20ED8100FE23C2 /* DXEndpointListener.swift */,
Expand Down Expand Up @@ -2171,6 +2182,7 @@
/* Begin PBXShellScriptBuildPhase section */
64656F632A1BB22E006A0B19 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -2387,6 +2399,7 @@
64BA92652A306E0200BE26A0 /* Trade.swift in Sources */,
6486B9752AD0493F00D8D5FA /* TheoPrice+Ext.swift in Sources */,
6464074B2A9DFAF7006FF769 /* InstrumentProfile+Ext.swift in Sources */,
643A329B2BD0137000F6F790 /* Optional+Ext.swift in Sources */,
64C771F22A94A224009868C2 /* Character+Ext.swift in Sources */,
8088D77129C3A25D00F240CB /* SystemProperty.swift in Sources */,
640C3FD42A6179AB00555161 /* CandlePeriod.swift in Sources */,
Expand Down Expand Up @@ -2508,7 +2521,7 @@
80FC415F29CA2C5100E6B611 /* NativeProperty.swift in Sources */,
64656F622A1B9FF7006A0B19 /* EnumException.swift in Sources */,
641BCBC12A21077800FE23C2 /* EventCode.swift in Sources */,
64DF09332BC80DBB009F1486 /* DXFeed+LastEvent.swift in Sources */,
64DF09332BC80DBB009F1486 /* DXFeed+Promises.swift in Sources */,
64ACBCE82A28CF9700032C53 /* IndexedEventSubscriptionSymbol.swift in Sources */,
64C004782BA1C25C0009F7C9 /* OtcMarketsOrderMapper.swift in Sources */,
649F48882A615BED0016FDD1 /* CandleType.swift in Sources */,
Expand All @@ -2531,6 +2544,7 @@
64656F6B2A1CFAC2006A0B19 /* BridgeUtil.swift in Sources */,
64A42F3E2B07A807001C3ACC /* NativeSymbolParser.swift in Sources */,
8088D77329C3A2F400F240CB /* GraalException.swift in Sources */,
6433B12D2BCE7ADD004EFED7 /* DXFeed+LastEvents.swift in Sources */,
64C004742BA09C110009F7C9 /* OtcMarketsOrder+Ext.swift in Sources */,
64C771FF2A9504ED009868C2 /* SnapshotProcessor.swift in Sources */,
64C771F82A94B88C009868C2 /* TimeAndSaleType.swift in Sources */,
Expand Down Expand Up @@ -2585,6 +2599,7 @@
649813C42ADD5CB2003CE3B3 /* TestEndpoointStateListener.swift in Sources */,
641C64B42B347C430023CFAD /* DXObservableSubscriptionTest.swift in Sources */,
64ACBCEC2A29FE2300032C53 /* XCTestCase+Utils.swift in Sources */,
6433B1322BCFC01F004EFED7 /* DXLastEventsSubscribedTest.swift in Sources */,
6423E4692B457000006B208D /* DXTimeSeriesSubscriptionTest.swift in Sources */,
64ECD67F2A9CF4CB00B36935 /* IPFTests.swift in Sources */,
64ACBCD52A2789EF00032C53 /* TestListener.swift in Sources */,
Expand Down
82 changes: 82 additions & 0 deletions DXFeedFramework/Api/DXFeed+LastEvents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
//
// 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

public extension DXFeed {

/// Returns the last event for the specified event instance.
///
/// This method works only for event types that implement ``ILastingEvent`` marker interface.
/// This method **does not** make any remote calls to the uplink data provider.
/// It just retrieves last received event from the local cache of this feed.
/// - Parameters:
/// - type: Type of MarketEvent.
/// - Returns: ``ILastingEvent``
/// - Throws: ``GraalException``. Rethrows exception from Java.
func getLastEvent(type: MarketEvent) throws -> ILastingEvent? {
return try nativeFeed.getLastEvent(type: type)
}

/// Returns the last events for the specified list of event instances.
///
/// This is a bulk version of ``getLastEvent(type:)`` method.
/// - Parameters:
/// - types: The list of MarketEvent.
/// - Returns: The list of ``ILastingEvent``
/// - Throws: ``GraalException``. Rethrows exception from Java.
func getLastEvents(types: [MarketEvent]) throws -> [ILastingEvent] {
return try nativeFeed.getLastEvents(types: types)
}
}

public extension DXFeed {
/// Returns the last event for the specified event type and symbol if there is a subscription for it.
///
/// This method works only for event types that implement ``ILastingEvent`` marker interface.
/// This method **does not** make any remote calls to the uplink data provider.
/// It just retrieves last received event from the local cache of this feed.
/// The events are stored in the cache only if there is some
/// attached ``DXFeedSubscription`` that is subscribed to the corresponding event type and symbol.
/// - Parameters:
/// - type: The event type ``IEventType``.
/// - symbol: The ``Symbol``.
/// - Returns: The list of ``ILastingEvent``
/// - Throws: ``GraalException``. Rethrows exception from Java.
func getLastEventIfSubscribed(type: IEventType.Type, symbol: Symbol) throws -> ILastingEvent? {
return try nativeFeed.getLastEventIfSubscribed(type: type, symbol: symbol)
}

// Returns a list of indexed events for the specified event type, symbol, and source
/// if there is a subscription for it.
///
/// This method works only for event types that implement ``IIndexedEvent``interface.
/// This method **does not** make any remote calls to the uplink data provider.
/// It just retrieves last received events from the local cache of this feed.
/// The events are stored in the cache only if there is some
/// attached ``DXFeedSubscription`` that is subscribed to the corresponding event type, symbol, and source.
/// - Parameters:
/// - type: The event type ``IEventType``.
/// - symbol: The ``Symbol``.
/// - source: The ``IndexedEventSource``.
/// - Returns: The list of ``IIndexedEvent``
/// - Throws: ``GraalException``. Rethrows exception from Java.
func getIndexedEventsIfSubscribed(type: IEventType.Type,
symbol: Symbol,
source: IndexedEventSource) throws -> [IIndexedEvent]? {
return try nativeFeed.getIndexedEventsIfSubscribed(type: type,
symbol: symbol,
source: source)
}

func getTimeSeriesIfSubscribed(type: IEventType.Type,
symbol: Symbol,
fromTime: Long,
toTime: Long) throws -> [ITimeSeriesEvent]? {
return try nativeFeed.getTimeSeriesIfSubscribed(type: type, symbol: symbol, fromTime: fromTime, toTime: toTime)
}
}
42 changes: 0 additions & 42 deletions DXFeedFramework/Api/DXFeed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,48 +78,6 @@ public class DXFeed {
}
}

public extension DXFeed {

/// Returns the last event for the specified event instance.
///
/// This method works only for event types that implement ``ILastingEvent`` marker interface.
/// This method **does not** make any remote calls to the uplink data provider.
/// It just retrieves last received event from the local cache of this feed.
/// - Parameters:
/// - type: Type of MarketEvent.
/// - Returns: ``ILastingEvent``
/// - Throws: ``GraalException``. Rethrows exception from Java.
func getLastEvent(type: MarketEvent) throws -> ILastingEvent? {
return try native.getLastEvent(type: type)
}

/// Returns the last event for the specified event type and symbol if there is a subscription for it.
/// This method works only for event types that implement ``ILastingEvent`` marker interface.
/// This method **does not** make any remote calls to the uplink data provider.
/// It just retrieves last received event from the local cache of this feed.
/// The events are stored in the cache only if there is some
/// attached ``DXFeedSubscription`` that is subscribed to the corresponding event type and symbol.
/// - Parameters:
/// - type: The event type ``IEventType``.
/// - symbol: The ``Symbol``.
/// - Returns: The list of ``ILastingEvent``
/// - Throws: ``GraalException``. Rethrows exception from Java.
func getLastEventIfSubscribed(type: IEventType.Type, symbol: Symbol) throws -> ILastingEvent? {
return try native.getLastEventIfSubscribed(type: type, symbol: symbol)
}

/// Returns the last events for the specified list of event instances.
///
/// This is a bulk version of ``getLastEvent(type:)`` method.
/// - Parameters:
/// - types: The list of MarketEvent.
/// - Returns: The list of ``ILastingEvent``
/// - Throws: ``GraalException``. Rethrows exception from Java.
func getLastEvents(types: [MarketEvent]) throws -> [ILastingEvent] {
return try native.getLastEvents(types: types)
}
}

public extension DXFeed {
/// Attaches the given subscription to this feed. This method does nothing if the
/// corresponding subscription is already attached to this feed.
Expand Down
4 changes: 3 additions & 1 deletion DXFeedFramework/Api/Osub/TimeSeriesSubscriptionSymbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public class TimeSeriesSubscriptionSymbol: GenericIndexedEventSubscriptionSymbol

/// Custom symbol has to return string representation.
public override var stringValue: String {
return "\(symbol.description){fromTime=\((try? DXTimeFormat.defaultTimeFormat?.withMillis?.format(value: fromTime)) ?? "")}"
return """
\(symbol.description){fromTime=\((try? DXTimeFormat.defaultTimeFormat?.withMillis?.format(value: fromTime)) ?? "")}
"""
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,12 @@ extension MarketEvent {
return nil
}
}

public var indexedEvent: IIndexedEvent? {
return self as? IIndexedEvent
}

public var timeSeriesEvent: ITimeSeriesEvent? {
return self as? ITimeSeriesEvent
}
}
2 changes: 1 addition & 1 deletion DXFeedFramework/Native/Endpoint/NativeBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class NativeBuilder {

func build() throws -> NativeEndpoint {
let thread = currentThread()
let value = try ErrorCheck.nativeCall(thread, dxfg_DXEndpoint_Builder_build(thread, builder))
let value = try ErrorCheck.nativeCall(thread, dxfg_DXEndpoint_Builder_build(thread, builder)).value()
return NativeEndpoint(value)
}
}
Loading