So, when I execute this code:
let now = NSDate()
let yesterday = NSDate(timeIntervalSinceNow: -1*24*60*60)
gdaxClient.public.getProductHistoricRates(productID: "ETH-USD", start: yesterday as Date, end: now as Date, granularity: 200, completionHandler: {(history, response, error) in
print(history)
})
I get this in the console:
Optional([GDAXSwift.GDAXHistoricRate(time: 1503083200, low: 1503083200.0, high: 1503083200.0, open: 1503083200.0, close: 1503083200.0, volume: 1503083200.0), GDAXSwift.GDAXHistoricRate(time: 1503083000, low: 1503083000.0, high: 1503083000.0, open: 1503083000.0, close: 1503083000.0, volume: 1503083000.0), GDAXSwift.GDAXHistoricRate(time: 1503082800, low: 1503082800.0, high: 1503082800.0, open: 1503082800.0, close: 1503082800.0, volume: 1503082800.0), GDAXSwift.GDAXHistoricRate(time: 1503082600, low: 1503082600.0, high: 1503082600.0, open: 1503082600.0, close: 1503082600.0, volume: 1503082600.0), GDAXSwift.GDAXHistoricRate(time: 1503082400, low: 1503082400.0, high: 1503082400.0, open: 1503082400.0, close: 1503082400.0, volume: 1503082400.0), GDAXSwift.GDAXHistoricRate(time: 1503082200, low: 1503082200.0, high: 1503082200.0, open: 1503082200.0, close: 1503082200.0, volume: 1503082200.0), GDAXSwift.GDAXHistoricRate(time: 1503082000, low: 1503082000.0, high: 1503082000.0, open: 1503082000.0, close: 1503082000.0, volume: 1503082000.0), GDAXSwift.GDAXHistoricRate(time: 1503081800, low: 1503081800.0, high: 1503081800.0, open: 1503081800.0, close: 1503081800.0, volume: 1503081800.0),
etc...etc...etc
Also receive the same result with the other HistoricRate function...
the issue is in GDAXPublicClient.swift:
When parsing the returned data only rates[0] is accessed, solved the issue by modifying code to this:
var rates = [GDAXHistoricRate]()
for rate in json {
guard rate.count == 6 else {
completionHandler(nil, nil, GDAXError.responseParsingFailure("One or more rates did not have an array length of 6"))
return
}
guard let time = rate[0] as? Int else {
completionHandler(nil, nil, GDAXError.responseParsingFailure("time"))
return
}
guard let low = rate[1] as? Double else {
completionHandler(nil, nil, GDAXError.responseParsingFailure("low"))
return
}
guard let high = rate[2] as? Double else {
completionHandler(nil, nil, GDAXError.responseParsingFailure("high"))
return
}
guard let open = rate[3] as? Double else {
completionHandler(nil, nil, GDAXError.responseParsingFailure("open"))
return
}
guard let close = rate[4] as? Double else {
completionHandler(nil, nil, GDAXError.responseParsingFailure("close"))
return
}
guard let volume = rate[5] as? Double else {
completionHandler(nil, nil, GDAXError.responseParsingFailure("volume"))
return
}