Skip to content

Commit

Permalink
remove wrong test(just copy from sample)
Browse files Browse the repository at this point in the history
remove copy of sample in tool
  • Loading branch information
kosyloa committed Dec 5, 2023
1 parent 30bf202 commit 3f35401
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 130 deletions.
41 changes: 0 additions & 41 deletions DXFeedFrameworkTests/DXConnectionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,45 +77,4 @@ final class DXConnectionTest: XCTestCase {
// Put the code you want to measure the time of here.
}
}

func testQuote() throws {
class DXConnectionTestListener: DXEventListener, Hashable {
static func == (lhs: DXConnectionTestListener, rhs: DXConnectionTestListener) -> Bool {
lhs === rhs
}

func hash(into hasher: inout Hasher) {
hasher.combine("\(self):\(stringReference(self))")
}
var callback: ([MarketEvent]) -> Void = { _ in }

func receiveEvents(_ events: [MarketEvent]) {
self.callback(events)
}

init(overrides: (DXConnectionTestListener) -> DXConnectionTestListener) {
_ = overrides(self)
}
}


let symbol = "AAPL"
let endpoint = try DXEndpoint.builder()
.withProperty("dxfeed.address", "demo.dxfeed.com:7300")
.build()
let subscription = try endpoint
.getFeed()?
.createSubscription(EventCode.trade)
let listener = DXConnectionTestListener { listener in
listener.callback = { events in
print(events)
}
return listener
}

try subscription?.add(listener: listener)
try subscription?.addSymbols(symbol)
wait(seconds: 10)
}

}
89 changes: 0 additions & 89 deletions Samples/Tools/ConnectTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,93 +104,4 @@ Where:
// Print till input new line
_ = readLine()
}

func testConverTapeFile() throws {
class Listener: DXEventListener, Hashable {

static func == (lhs: Listener, rhs: Listener) -> Bool {
lhs === rhs
}

func hash(into hasher: inout Hasher) {
hasher.combine("\(self):\(stringReference(self))")
}
var callback: ([MarketEvent]) -> Void = { _ in }

func receiveEvents(_ events: [MarketEvent]) {
self.callback(events)
}

init(overrides: (Listener) -> Listener) {
_ = overrides(self)
}
}


// Determine input and output tapes and specify appropriate configuration parameters.
let inputAddress = "file:/Users/akosylo/Projects/tapeK2.tape[readAs=stream_data,speed=max]"
let outputAddress = "tape:/Users/akosylo/Projects/tapeK21.tape[saveAs=stream_data,format=text]"

// Create input endpoint configured for tape reading.
let inputEndpoint = try DXEndpoint.builder()
.withRole(.streamFeed) // Prevents event conflation and loss due to buffer overflow.
.withProperty(DXEndpoint.Property.wildcardEnable.rawValue, "true") // Enables wildcard subscription.
.withProperty(DXEndpoint.Property.eventTime.rawValue, "true") // Use provided event times.
.build()

// Create output endpoint configured for tape writing.
var outputEndpoint = try DXEndpoint.builder()
.withRole(.streamPublisher) // Prevents event conflation and loss due to buffer overflow.
.withProperty(DXEndpoint.Property.wildcardEnable.rawValue, "true") // Enables wildcard subscription.
.withProperty(DXEndpoint.Property.eventTime.rawValue, "true") // Use provided event times.
.build()

// Create and link event processor for all types of events.
// Note: Set of processed event types could be limited if needed.
let eventTypes: [EventCode] = EventCode.allCases.compactMap { eventCode in
if EventCode.unsupported().contains(eventCode) {
return nil
} else {
return eventCode
}
}

let feed = inputEndpoint.getFeed()
let subscription = try feed?.createSubscription(eventTypes)

let listener = Listener { anonymCl in
anonymCl.callback = { events in
// Here event processing occurs. Events could be modified, removed, or new events added.
// For example, the below code adds 1 hour to event times:
// foreach (var e in events)
// {
// e.EventTime += 3600_000
// }

// Publish processed events
// let publisher = outputEndpoint.getPublisher()
// try? publisher?.publish(events: events)
}
return anonymCl
}

try subscription?.add(listener: listener)

// Subscribe to all symbols.
// Note: Set of processed symbols could be limited if needed.
try subscription?.addSymbols(WildcardSymbol.all)

// Connect output endpoint and start output tape writing BEFORE starting input tape reading.
try outputEndpoint.connect(outputAddress)
// Connect input endpoint and start input tape reading AFTER starting output tape writing.
try inputEndpoint.connect(inputAddress)

// Wait until all data is read and processed, and then gracefully close input endpoint.
try inputEndpoint.awaitNotConnected()
try inputEndpoint.closeAndAWaitTermination()

// Wait until all data is processed and written, and then gracefully close output endpoint.
try outputEndpoint.awaitProcessed()
try outputEndpoint.closeAndAWaitTermination()
}
}

0 comments on commit 3f35401

Please sign in to comment.