SwiftStock icon indicating copy to clipboard operation
SwiftStock copied to clipboard

Fetch Stock For List of Symbols

Open OptTrader opened this issue 10 years ago • 0 comments

Hey Mike,

Awesome work on SwiftStock. I'm trying to play around with this to add fetch quotes for an array of symbols. I tried to add/modify fetchStockForSymbol method with the following:

class func fetchStockForListOfSymbols(#symbols: Array<String>, completion:(stock: Stock) -> ()) {

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {

  let symbolsString:String = "\", \"".join(symbols)
  let encodedQuery = symbolsString.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())
  let stockURL = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22" + encodedQuery! + "%22)&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&format=json%22"

But I'm getting an Optional value found nil error under the NSCocoaErrorDomain? Any thought? Or does this require a complete new setup?

I want to get the data for tableView and PageViewController where each ViewController has its own quotes. Appreciate any advice.

Chris

OptTrader avatar Aug 13 '15 15:08 OptTrader