-
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.
- Loading branch information
Showing
4 changed files
with
33 additions
and
0 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
26 changes: 26 additions & 0 deletions
26
Samples/Playgrounds/FetchDailyCandles.playground/Contents.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,26 @@ | ||
import Cocoa | ||
import DXFeedFramework | ||
|
||
/// Fetches last N days of candles for a specified symbol, prints them, and exits. | ||
|
||
// await couldn't use directly in Playground(this is accompanied by errors like: execution stopped with unexpected state) | ||
Task { | ||
let baseSymbol = "AAPL{=d}" | ||
var to: Long = Long(Date.now.timeIntervalSince1970 * 1000) | ||
let from: Long = Long(Calendar.current.date(byAdding: .day, value: -20, to: Date())!.timeIntervalSince1970 * 1000) | ||
let endpoint = try DXEndpoint.getInstance().connect("demo.dxfeed.com:7300") | ||
let feed = endpoint.getFeed() | ||
guard let task = feed?.getTimeSeries(type: Candle.self, symbol: baseSymbol, fromTime: from, toTime: to) else { | ||
print("Async task is nil") | ||
exit(0) | ||
} | ||
let result = await task.result | ||
switch result { | ||
case .success(let value): | ||
value?.forEach({ event in | ||
print(event) | ||
}) | ||
case .failure(let error): | ||
print(error) | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
Samples/Playgrounds/FetchDailyCandles.playground/contents.xcplayground
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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<playground version='5.0' target-platform='macos' buildActiveScheme='true' importAppTypes='true'> | ||
<timeline fileName='timeline.xctimeline'/> | ||
</playground> |