├── IEX.cpp ├── IEX.h ├── README.md └── examples.cpp /IEX.cpp: -------------------------------------------------------------------------------- 1 | /* UNOFFICIAL IEX TRADING API for C++ 2 | BY: Justin Chudley 3 | https://github.com/Chudleyj/ 4 | OFFICIAL API: https://iextrading.com/developer/docs/ 5 | Refer to the official docs to understand the return of each function. 6 | GET examples and JSON examples commented above each function are from the offical API. 7 | ALL credit for those examples belongs to IEX. 8 | “Data provided for free by IEX (https://iextrading.com/developer/). 9 | View IEX’s Terms of Use (https://iextrading.com/api-exhibit-a/).” 10 | */ 11 | //TODO CHECK ALL SYMBOLS FOR VALID SYMBOL 12 | #include "IEX.h" 13 | 14 | void IEX::parseSymbolData(const Json::Value &IEXdata, std::vector &symbolVec) 15 | { 16 | int i = 0; 17 | 18 | //Step through JSON file until the end is reached 19 | while(i < IEXdata.size()) { 20 | symbolVec.push_back(IEXdata[i]["symbol"].asString()); 21 | i++; 22 | } 23 | } 24 | 25 | std::vector IEX::getSymbolList() 26 | { 27 | Json::Value jsonData; 28 | std::string url(IEX_ENDPOINT); 29 | std::vector symbolList; 30 | url += "/ref-data/symbols"; 31 | IEX::sendGetRequest(jsonData, url); 32 | assert(jsonData.isArray()); //Crash if not an array 33 | parseSymbolData(jsonData, symbolList); 34 | return symbolList; 35 | 36 | } 37 | 38 | bool IEX::isValidSymbol(const std::string &symbol) 39 | { 40 | std::vector symbolList = getSymbolList(); 41 | std::string symbolCopy = symbol; 42 | boost::to_upper(symbolCopy); 43 | if (std::find(symbolList.begin(), symbolList.end(), symbolCopy) != symbolList.end()) 44 | return true; 45 | 46 | return false; 47 | } 48 | //Callback function used by sendGetRequest to get the result from curl. 49 | std::size_t callback(const char* in, std::size_t size, std::size_t num, std::string* out) 50 | { 51 | const std::size_t totalBytes(size * num); 52 | out->append(in, totalBytes); 53 | return totalBytes; 54 | } 55 | 56 | //Use LIBCURL to send the GET requests 57 | void IEX::sendGetRequest(Json::Value &jsonData, const std::string url) 58 | { 59 | CURL* curl = curl_easy_init(); 60 | 61 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); 62 | curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); 63 | curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); 64 | curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 65 | long int httpCode(0); //Having this as a normal int will cause a segmentation fault for some requests being too large. 66 | std::unique_ptr httpData(new std::string()); 67 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback); 68 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get()); 69 | curl_easy_perform(curl); 70 | curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); 71 | curl_easy_cleanup(curl); 72 | 73 | Json::Reader jsonReader; 74 | jsonReader.parse(*httpData, jsonData); //TODO error handle 75 | } 76 | /* 77 | // .../market 78 | { 79 | "AAPL" : { 80 | "quote": {...}, 81 | "news": [...], 82 | "chart": [...] 83 | }, 84 | "FB" : { 85 | "quote": {...}, 86 | "news": [...], 87 | "chart": [...] 88 | }, 89 | } 90 | */ 91 | Json::Value IEX::stocks::batch(const std::string &symbol) 92 | { 93 | Json::Value jsonData; 94 | 95 | if(!isValidSymbol(symbol)){ 96 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 97 | return jsonData; 98 | } 99 | 100 | std::string url(IEX_ENDPOINT); 101 | url+="/stock/"+symbol+"/batch"; 102 | IEX::sendGetRequest(jsonData, url); 103 | assert(jsonData.isArray()); //Crash if not an array 104 | return jsonData; 105 | } 106 | 107 | /* GET /stock/{symbol}/book 108 | { 109 | "quote": {...}, 110 | "bids": [...], 111 | "asks": [...], 112 | "trades": [...], 113 | "systemEvent": {...}, 114 | } 115 | */ 116 | Json::Value IEX::stocks::book(const std::string &symbol) 117 | { 118 | Json::Value jsonData; 119 | 120 | if(!isValidSymbol(symbol)){ 121 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 122 | return jsonData; 123 | } 124 | 125 | std::string url(IEX_ENDPOINT); 126 | url+="/stock/"+symbol+"/book"; 127 | IEX::sendGetRequest(jsonData, url); 128 | assert(jsonData.isArray()); //Crash if not an array 129 | return jsonData; 130 | } 131 | 132 | /*GET /stock/{symbol}/chart/{range} 133 | // .../1d 134 | [ 135 | { 136 | "date": "20171215" 137 | "minute": "09:30", 138 | "label": "09:30 AM", 139 | "high": 143.98, 140 | "low": 143.775, 141 | "average": 143.889, 142 | "volume": 3070, 143 | "notional": 441740.275, 144 | "numberOfTrades": 20, 145 | "marktHigh": 143.98, 146 | "marketLow": 143.775, 147 | "marketAverage": 143.889, 148 | "marketVolume": 3070, 149 | "marketNotional": 441740.275, 150 | "marketNumberOfTrades": 20, 151 | "open": 143.98, 152 | "close": 143.775, 153 | "marktOpen": 143.98, 154 | "marketClose": 143.775, 155 | "changeOverTime": -0.0039, 156 | "marketChangeOverTime": -0.004 157 | } // , { ... } 158 | ] 159 | */ 160 | Json::Value IEX::stocks::chart(const std::string &symbol) 161 | { 162 | Json::Value jsonData; 163 | 164 | if(!isValidSymbol(symbol)){ 165 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 166 | return jsonData; 167 | } 168 | 169 | std::string url(IEX_ENDPOINT); 170 | url+="/stock/"+symbol+"/chart"; 171 | IEX::sendGetRequest(jsonData, url); 172 | assert(jsonData.isArray()); //Crash if not an array 173 | return jsonData; 174 | } 175 | 176 | //Same as chart function, except it takes a range in. 177 | //Range must be: 5y, 2y, 1y, ytd, 6m, 3m, 1m, 1d 178 | Json::Value IEX::stocks::chartRange(const std::string &symbol, const std::string &range) 179 | { 180 | Json::Value jsonData; 181 | 182 | if(!isValidSymbol(symbol)){ 183 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 184 | return jsonData; 185 | } 186 | 187 | if(range == "5y" || range == "2y" || range == "1y" || range == "ytd" || range == "6m" || range == "3m" || range == "1m" || range == "1d") { 188 | std::string url(IEX_ENDPOINT); 189 | url+="/stock/"+symbol+"/chart/"+range; 190 | IEX::sendGetRequest(jsonData, url); 191 | } 192 | else{ 193 | std::cout << std::endl << "Incorrect 'range' input in function chartRange. Exiting." << std::endl; 194 | exit(1); 195 | } 196 | assert(jsonData.isArray()); //Crash if not an array 197 | return jsonData; 198 | } 199 | 200 | //Specific date entry for chart, YYYYMMDD format, 30 trailing calander days 201 | Json::Value IEX::stocks::chartDate(const std::string &symbol, const std::string &date) 202 | { 203 | Json::Value jsonData; 204 | 205 | if(!isValidSymbol(symbol)){ 206 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 207 | return jsonData; 208 | } 209 | 210 | if(date.size() == 8) { 211 | std::string url(IEX_ENDPOINT); 212 | url+="/stock/"+symbol+"/chart/date/"+date; 213 | IEX::sendGetRequest(jsonData, url); 214 | 215 | } 216 | else{ 217 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 218 | exit(1); 219 | } 220 | assert(jsonData.isArray()); //Crash if not an array 221 | return jsonData; 222 | } 223 | 224 | //Dynamic chart. See offical API docs. 225 | Json::Value IEX::stocks::chartDynamic(const std::string &symbol) 226 | { 227 | Json::Value jsonData; 228 | 229 | if(!isValidSymbol(symbol)){ 230 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 231 | return jsonData; 232 | } 233 | 234 | std::string url(IEX_ENDPOINT); 235 | url += "/stock/"+symbol+"/chart/dynamic"; 236 | IEX::sendGetRequest(jsonData, url); 237 | assert(jsonData.isArray()); //Crash if not an array 238 | return jsonData; 239 | } 240 | 241 | /* 242 | GET /stock/{symbol}/company 243 | { 244 | "symbol": "AAPL", 245 | "companyName": "Apple Inc.", 246 | "exchange": "Nasdaq Global Select", 247 | "industry": "Computer Hardware", 248 | "website": "http://www.apple.com", 249 | "description": "Apple Inc is an American multinational technology company. It designs, manufactures, and markets mobile communication and media devices, personal computers, and portable digital music players.", 250 | "CEO": "Timothy D. Cook", 251 | "issueType": "cs", 252 | "sector": "Technology", 253 | }*/ 254 | Json::Value IEX::stocks::company(const std::string &symbol) 255 | { 256 | Json::Value jsonData; 257 | 258 | if(!isValidSymbol(symbol)){ 259 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 260 | return jsonData; 261 | } 262 | 263 | std::string url(IEX_ENDPOINT); 264 | url += "/stock/"+symbol+"/company"; 265 | IEX::sendGetRequest(jsonData, url); 266 | assert(jsonData.isArray()); //Crash if not an array 267 | return jsonData; 268 | } 269 | 270 | /* 271 | GET /stock/{symbol}/delayed-quote 272 | { 273 | "symbol": "AAPL", 274 | "delayedPrice": 143.08, 275 | "delayedSize": 200, 276 | "delayedPriceTime": 1498762739791, 277 | "processedTime": 1498763640156 278 | }*/ 279 | Json::Value IEX::stocks::delayedQuote(const std::string &symbol) 280 | { 281 | Json::Value jsonData; 282 | 283 | if(!isValidSymbol(symbol)){ 284 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 285 | return jsonData; 286 | } 287 | 288 | std::string url(IEX_ENDPOINT); 289 | url += "/stock/"+symbol+"/delayed-quote"; 290 | IEX::sendGetRequest(jsonData, url); 291 | assert(jsonData.isArray()); //Crash if not an array 292 | return jsonData; 293 | } 294 | 295 | /* 296 | GET /stock/{symbol}/dividends/{range} 297 | [ 298 | { 299 | "exDate": "2017-08-10", 300 | "paymentDate": "2017-08-17", 301 | "recordDate": "2017-08-14", 302 | "declaredDate": "2017-08-01", 303 | "amount": 0.63, 304 | "type": "Dividend income", 305 | "qualified": "Q" 306 | } // , { ... } 307 | ] 308 | REQUIRES a range: 5y,2y,1y,ytd,6m,3m,1m */ 309 | Json::Value IEX::stocks::dividends(const std::string &symbol, const std::string &range) 310 | { 311 | Json::Value jsonData; 312 | 313 | if(!isValidSymbol(symbol)){ 314 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 315 | return jsonData; 316 | } 317 | 318 | if(range == "5y" || range == "2y" || range == "1y" || range == "ytd" || range == "6m" || range == "3m" || range == "1m") { 319 | std::string url(IEX_ENDPOINT); 320 | url+="/stock/"+symbol+"/dividends/"+range; 321 | IEX::sendGetRequest(jsonData, url); 322 | } 323 | else{ 324 | std::cout << std::endl << "Incorrect 'range' input in function dividends. Exiting." << std::endl; 325 | exit(1); 326 | } 327 | assert(jsonData.isArray()); //Crash if not an array 328 | return jsonData; 329 | } 330 | 331 | /*GET /stock/{symbol}/earnings 332 | { 333 | "symbol": "AAPL", 334 | "earnings": [ 335 | { 336 | "actualEPS": 2.1, 337 | "consensusEPS": 2.02, 338 | "estimatedEPS": 2.02, 339 | "announceTime": "AMC", 340 | "numberOfEstimates": 14, 341 | "EPSSurpriseDollar": 0.08, 342 | "EPSReportDate": "2017-05-02", 343 | "fiscalPeriod": "Q2 2017", 344 | "fiscalEndDate": "2017-03-31", 345 | "yearAgo": 1.67, 346 | "yearAgoChangePercent": .30, 347 | "estimatedChangePercent": .28, 348 | "symbolId": 11 349 | }, 350 | { 351 | "actualEPS": 3.36, 352 | "consensusEPS": 3.22, 353 | "estimatedEPS": 3.22, 354 | "announceTime": "AMC", 355 | "numberOfEstimates": 15, 356 | "EPSSurpriseDollar": 0.14, 357 | "EPSReportDate": "2017-01-31", 358 | "fiscalPeriod": "Q1 2017", 359 | "fiscalEndDate": "2016-12-31", 360 | "yearAgo": 1.67, 361 | "yearAgoChangePercent": .30, 362 | "estimatedChangePercent": .28, 363 | "symbolId": 11 364 | }, 365 | ] 366 | }*/ 367 | Json::Value IEX::stocks::earnings(const std::string &symbol) 368 | { 369 | Json::Value jsonData; 370 | 371 | if(!isValidSymbol(symbol)){ 372 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 373 | return jsonData; 374 | } 375 | 376 | std::string url(IEX_ENDPOINT); 377 | url += "/stock/"+symbol+"/earnings"; 378 | IEX::sendGetRequest(jsonData, url); 379 | assert(jsonData.isArray()); //Crash if not an array 380 | return jsonData; 381 | } 382 | 383 | /*GET /stock/{symbol}/effective-spread 384 | [ 385 | { 386 | "volume": 4899, 387 | "venue": "XCHI", 388 | "venueName": "CHX", 389 | "effectiveSpread": 0.02253725, 390 | "effectiveQuoted": 0.9539362, 391 | "priceImprovement": 0.0008471116999999999 392 | }, 393 | { 394 | "volume": 9806133, 395 | "venue": "XBOS", 396 | "venueName": "NASDAQ BX", 397 | "effectiveSpread": 0.0127343, 398 | "effectiveQuoted": 0.9313967, 399 | "priceImprovement": 0.0007373158 400 | }, 401 | { 402 | "volume": 6102991, 403 | "venue": "IEXG", 404 | "venueName": "IEX", 405 | "effectiveSpread": 0.005881705, 406 | "effectiveQuoted": 0.4532043, 407 | "priceImprovement": 0.003949427 408 | } 409 | ]*/ 410 | Json::Value IEX::stocks::effectiveSpread(const std::string &symbol) 411 | { 412 | Json::Value jsonData; 413 | 414 | if(!isValidSymbol(symbol)){ 415 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 416 | return jsonData; 417 | } 418 | 419 | std::string url(IEX_ENDPOINT); 420 | url += "/stock/"+symbol+"/effective-spread"; 421 | IEX::sendGetRequest(jsonData, url); 422 | assert(jsonData.isArray()); //Crash if not an array 423 | return jsonData; 424 | } 425 | 426 | /*GET /stock/{symbol}/financials 427 | The above example will return JSON with the following keys 428 | { 429 | "symbol": "AAPL", 430 | "financials": [ 431 | { 432 | "reportDate": "2017-03-31", 433 | "grossProfit": 20591000000, 434 | "costOfRevenue": 32305000000, 435 | "operatingRevenue": 52896000000, 436 | "totalRevenue": 52896000000, 437 | "operatingIncome": 14097000000, 438 | "netIncome": 11029000000, 439 | "researchAndDevelopment": 2776000000, 440 | "operatingExpense": 6494000000, 441 | "currentAssets": 101990000000, 442 | "totalAssets": 334532000000, 443 | "totalLiabilities": 200450000000, 444 | "currentCash": 15157000000, 445 | "currentDebt": 13991000000, 446 | "totalCash": 67101000000, 447 | "totalDebt": 98522000000, 448 | "shareholderEquity": 134082000000, 449 | "cashChange": -1214000000, 450 | "cashFlow": 12523000000, 451 | "operatingGainsLosses": null 452 | } // , { ... } 453 | ] 454 | }*/ 455 | Json::Value IEX::stocks::financials(const std::string &symbol) 456 | { 457 | Json::Value jsonData; 458 | 459 | if(!isValidSymbol(symbol)){ 460 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 461 | return jsonData; 462 | } 463 | 464 | std::string url(IEX_ENDPOINT); 465 | url += "/stock/"+symbol+"/financials"; 466 | IEX::sendGetRequest(jsonData, url); 467 | assert(jsonData.isArray()); //Crash if not an array 468 | return jsonData; 469 | } 470 | 471 | /*GET /stock/{symbol}/stats 472 | { 473 | "companyName": "Apple Inc.", 474 | "marketcap": 760334287200, 475 | "beta": 1.295227, 476 | "week52high": 156.65, 477 | "week52low": 93.63, 478 | "week52change": 58.801903, 479 | "shortInterest": 55544287, 480 | "shortDate": "2017-06-15", 481 | "dividendRate": 2.52, 482 | "dividendYield": 1.7280395, 483 | "exDividendDate": "2017-05-11 00:00:00.0", 484 | "latestEPS": 8.29, 485 | "latestEPSDate": "2016-09-30", 486 | "sharesOutstanding": 5213840000, 487 | "float": 5203997571, 488 | "returnOnEquity": 0.08772939519857577, 489 | "consensusEPS": 3.22, 490 | "numberOfEstimates": 15, 491 | "symbol": "AAPL", 492 | "EBITDA": 73828000000, 493 | "revenue": 220457000000, 494 | "grossProfit": 84686000000, 495 | "cash": 256464000000, 496 | "debt": 358038000000, 497 | "ttmEPS": 8.55, 498 | "revenuePerShare": 42.2830389885382, 499 | "revenuePerEmployee": 1900491.3793103448, 500 | "peRatioHigh": 25.5, 501 | "peRatioLow": 8.7, 502 | "EPSSurpriseDollar": null, 503 | "EPSSurprisePercent": 3.9604, 504 | "returnOnAssets": 14.15, 505 | "returnOnCapital": null, 506 | "profitMargin": 20.73, 507 | "priceToSales": 3.6668503, 508 | "priceToBook": 6.19, 509 | "day200MovingAvg": 140.60541, 510 | "day50MovingAvg": 156.49678, 511 | "institutionPercent": 32.1, 512 | "insiderPercent": null, 513 | "shortRatio": 1.6915414, 514 | "year5ChangePercent": 0.5902546932200027, 515 | "year2ChangePercent": 0.3777449874142869, 516 | "year1ChangePercent": 0.39751716851558366, 517 | "ytdChangePercent": 0.36659492036160124, 518 | "month6ChangePercent": 0.12208398133748043, 519 | "month3ChangePercent": 0.08466584665846649, 520 | "month1ChangePercent": 0.009668596145283263, 521 | "day5ChangePercent": -0.005762605699968781 522 | }*/ 523 | Json::Value IEX::stocks::stats(const std::string &symbol) 524 | { 525 | Json::Value jsonData; 526 | 527 | if(!isValidSymbol(symbol)){ 528 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 529 | return jsonData; 530 | } 531 | 532 | std::string url(IEX_ENDPOINT); 533 | url += "/stock/"+symbol+"/stats"; 534 | IEX::sendGetRequest(jsonData, url); 535 | assert(jsonData.isArray()); //Crash if not an array 536 | return jsonData; 537 | } 538 | 539 | /*GET /stock/{symbol}/largest-trades 540 | [ 541 | { 542 | "price": 186.39, 543 | "size": 10000, 544 | "time": 1527090690175, 545 | "timeLabel": "11:51:30", 546 | "venue": "EDGX", 547 | "venueName": "Cboe EDGX" 548 | }, 549 | ... 550 | ] */ 551 | Json::Value IEX::stocks::largestTrades(const std::string &symbol) 552 | { 553 | Json::Value jsonData; 554 | 555 | if(!isValidSymbol(symbol)){ 556 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 557 | return jsonData; 558 | } 559 | 560 | std::string url(IEX_ENDPOINT); 561 | url += "/stock/"+symbol+"/largest-trades"; 562 | IEX::sendGetRequest(jsonData, url); 563 | assert(jsonData.isArray()); //Crash if not an array 564 | return jsonData; 565 | } 566 | 567 | /*GET /stock/market/list 568 | [ 569 | { 570 | "symbol": "AAPL", 571 | "companyName": "Apple Inc.", 572 | "primaryExchange": "Nasdaq Global Select", 573 | "sector": "Technology", 574 | "calculationPrice": "tops", 575 | "latestPrice": 158.73, 576 | "latestSource": "Previous close", 577 | "latestTime": "September 19, 2017", 578 | "latestUpdate": 1505779200000, 579 | "latestVolume": 20567140, 580 | "iexRealtimePrice": 158.71, 581 | "iexRealtimeSize": 100, 582 | "iexLastUpdated": 1505851198059, 583 | "delayedPrice": 158.71, 584 | "delayedPriceTime": 1505854782437, 585 | "previousClose": 158.73, 586 | "change": -1.67, 587 | "changePercent": -0.01158, 588 | "iexMarketPercent": 0.00948, 589 | "iexVolume": 82451, 590 | "avgTotalVolume": 29623234, 591 | "iexBidPrice": 153.01, 592 | "iexBidSize": 100, 593 | "iexAskPrice": 158.66, 594 | "iexAskSize": 100, 595 | "marketCap": 751627174400, 596 | "peRatio": 16.86, 597 | "week52High": 159.65, 598 | "week52Low": 93.63, 599 | "ytdChange": 0.3665, 600 | } // , { ... } 601 | ] 602 | LISTTYPE REQUIRED: mostactive, gainers, losers, iexvolume, or iexmarketpercent*/ 603 | Json::Value IEX::stocks::list(const std::string &listType) 604 | { 605 | Json::Value jsonData; 606 | if(listType == "mostactive" || listType == "gainers" || listType == "losers" || listType == "iexvolume" || listType == "iexmarketpercent") { 607 | std::string url(IEX_ENDPOINT); 608 | url+="/stock/market/list/"+listType; 609 | IEX::sendGetRequest(jsonData, url); 610 | } 611 | else{ 612 | std::cout << std::endl << "Incorrect 'listType' input in function list(). I am returning an uninitialized JSON object!" << std::endl; 613 | return jsonData; 614 | } 615 | assert(jsonData.isArray()); //Crash if not an array 616 | return jsonData; 617 | } 618 | 619 | /* 620 | GET /stock/{symbol}/logo 621 | { 622 | "url": "https://storage.googleapis.com/iex/api/logos/AAPL.png" 623 | }*/ 624 | Json::Value IEX::stocks::logo(const std::string &symbol) 625 | { 626 | Json::Value jsonData; 627 | 628 | if(!isValidSymbol(symbol)){ 629 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 630 | return jsonData; 631 | } 632 | 633 | std::string url(IEX_ENDPOINT); 634 | url += "/stock/"+symbol+"/logo"; 635 | IEX::sendGetRequest(jsonData, url); 636 | assert(jsonData.isArray()); //Crash if not an array 637 | return jsonData; 638 | } 639 | 640 | /* 641 | GET /stock/{symbol}/news/last/{last} 642 | [ 643 | { 644 | "datetime": "2017-06-29T13:14:22-04:00", 645 | "headline": "Voice Search Technology Creates A New Paradigm For Marketers", 646 | "source": "Benzinga via QuoteMedia", 647 | "url": "https://api.iextrading.com/1.0/stock/aapl/article/8348646549980454", 648 | "summary": "

Voice search is likely to grow by leap and bounds, with technological advancements leading to better adoption and fueling the growth cycle, according to Lindsay Boyajian, a guest contributor at Loup Ventu...", 649 | "related": "AAPL,AMZN,GOOG,GOOGL,MSFT", 650 | "image": "https://api.iextrading.com/1.0/stock/aapl/news-image/7594023985414148" 651 | } 652 | ] 653 | EITHER PASS A SYMBOL OR A SYMOL AND A NUMBER FOR LAST X ARTICLES (SEE OFFICAL DOCS) 654 | OR PASS MARKET AS SYMBOL FOR MARKETWIDE NEWS*/ 655 | Json::Value IEX::stocks::news(const std::string &symbol, int last) 656 | { 657 | Json::Value jsonData; 658 | 659 | if(!isValidSymbol(symbol)){ 660 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 661 | return jsonData; 662 | } 663 | 664 | std::string url(IEX_ENDPOINT); 665 | last == 0 ? url += "/stock/"+symbol+"/news" : url += "/stock/"+symbol+"/news/last/"+std::to_string(last); 666 | IEX::sendGetRequest(jsonData, url); 667 | assert(jsonData.isArray()); //Crash if not an array 668 | return jsonData; 669 | } 670 | 671 | /*GET /stock/{symbol}/ohlc 672 | { 673 | "open": { 674 | "price": 154, 675 | "time": 1506605400394 676 | }, 677 | "close": { 678 | "price": 153.28, 679 | "time": 1506605400394 680 | }, 681 | "high": 154.80, 682 | "low": 153.25 683 | } 684 | Can take in a specific symbol OR market as symbol */ 685 | Json::Value IEX::stocks::OHLC(const std::string &symbol) 686 | { 687 | Json::Value jsonData; 688 | 689 | if(!isValidSymbol(symbol)){ 690 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 691 | return jsonData; 692 | } 693 | 694 | std::string url(IEX_ENDPOINT); 695 | url += "/stock/"+symbol+"/ohlc"; 696 | IEX::sendGetRequest(jsonData, url); 697 | assert(jsonData.isArray()); //Crash if not an array 698 | return jsonData; 699 | } 700 | 701 | /* 702 | GET /stock/{symbol}/peers 703 | [ 704 | "MSFT", 705 | "NOK", 706 | "IBM", 707 | "BBRY", 708 | "HPQ", 709 | "GOOGL", 710 | "XLK" 711 | ] */ 712 | Json::Value IEX::stocks::peers(const std::string &symbol) 713 | { 714 | Json::Value jsonData; 715 | 716 | if(!isValidSymbol(symbol)){ 717 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 718 | return jsonData; 719 | } 720 | 721 | std::string url(IEX_ENDPOINT); 722 | url += "/stock/"+symbol+"/peers"; 723 | IEX::sendGetRequest(jsonData, url); 724 | assert(jsonData.isArray()); //Crash if not an array 725 | return jsonData; 726 | } 727 | 728 | /* 729 | GET /stock/{symbol}/previous 730 | { 731 | "symbol": "AAPL", 732 | "date": "2017-09-19", 733 | "open": 159.51, 734 | "high": 159.77, 735 | "low": 158.44, 736 | "close": 158.73, 737 | "volume": 20810632, 738 | "unadjustedVolume": 20810632, 739 | "change": 0.06, 740 | "changePercent": 0.038, 741 | "vwap": 158.9944 742 | } 743 | Takes symbol or market as symbol */ 744 | Json::Value IEX::stocks::previous(const std::string &symbol) 745 | { 746 | Json::Value jsonData; 747 | 748 | if(!isValidSymbol(symbol)){ 749 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 750 | return jsonData; 751 | } 752 | 753 | std::string url(IEX_ENDPOINT); 754 | url += "/stock/"+symbol+"/previous"; 755 | IEX::sendGetRequest(jsonData, url); 756 | assert(jsonData.isArray()); //Crash if not an array 757 | return jsonData; 758 | } 759 | 760 | // GET /stock/{symbol}/price 761 | Json::Value IEX::stocks::price(const std::string &symbol) 762 | { 763 | Json::Value jsonData; 764 | 765 | if(!isValidSymbol(symbol)){ 766 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 767 | return jsonData; 768 | } 769 | 770 | std::string url(IEX_ENDPOINT); 771 | url += "/stock/"+symbol+"/price"; 772 | IEX::sendGetRequest(jsonData, url); 773 | assert(jsonData.isNumeric()); //Crash if not numeric 774 | return jsonData; 775 | } 776 | 777 | /* 778 | GET /stock/{symbol}/quote 779 | { 780 | "symbol": "AAPL", 781 | "companyName": "Apple Inc.", 782 | "primaryExchange": "Nasdaq Global Select", 783 | "sector": "Technology", 784 | "calculationPrice": "tops", 785 | "open": 154, 786 | "openTime": 1506605400394, 787 | "close": 153.28, 788 | "closeTime": 1506605400394, 789 | "high": 154.80, 790 | "low": 153.25, 791 | "latestPrice": 158.73, 792 | "latestSource": "Previous close", 793 | "latestTime": "September 19, 2017", 794 | "latestUpdate": 1505779200000, 795 | "latestVolume": 20567140, 796 | "iexRealtimePrice": 158.71, 797 | "iexRealtimeSize": 100, 798 | "iexLastUpdated": 1505851198059, 799 | "delayedPrice": 158.71, 800 | "delayedPriceTime": 1505854782437, 801 | "extendedPrice": 159.21, 802 | "extendedChange": -1.68, 803 | "extendedChangePercent": -0.0125, 804 | "extendedPriceTime": 1527082200361, 805 | "previousClose": 158.73, 806 | "change": -1.67, 807 | "changePercent": -0.01158, 808 | "iexMarketPercent": 0.00948, 809 | "iexVolume": 82451, 810 | "avgTotalVolume": 29623234, 811 | "iexBidPrice": 153.01, 812 | "iexBidSize": 100, 813 | "iexAskPrice": 158.66, 814 | "iexAskSize": 100, 815 | "marketCap": 751627174400, 816 | "peRatio": 16.86, 817 | "week52High": 159.65, 818 | "week52Low": 93.63, 819 | "ytdChange": 0.3665, 820 | } 821 | OPTIONAL VALUE TO DISPLAY PERCENT, SEE OFFICAL API */ 822 | Json::Value IEX::stocks::quote(const std::string &symbol, bool displayPercent) 823 | { 824 | Json::Value jsonData; 825 | 826 | if(!isValidSymbol(symbol)){ 827 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 828 | return jsonData; 829 | } 830 | 831 | std::string url(IEX_ENDPOINT); 832 | displayPercent ? url += "/stock/"+symbol+"/quote?displayPercent=true" : url += "/stock/"+symbol+"/quote"; 833 | IEX::sendGetRequest(jsonData, url); 834 | assert(jsonData.isArray()); //Crash if not an array 835 | return jsonData; 836 | } 837 | 838 | /* 839 | GET /stock/{symbol}/relevant 840 | { 841 | "peers": true, 842 | "symbols": [ 843 | "MSFT", 844 | "NOK", 845 | "IBM", 846 | "BBRY", 847 | "HPQ", 848 | "GOOGL", 849 | "XLK" 850 | ] 851 | }*/ 852 | Json::Value IEX::stocks::relevant(const std::string &symbol) 853 | { 854 | Json::Value jsonData; 855 | 856 | if(!isValidSymbol(symbol)){ 857 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 858 | return jsonData; 859 | } 860 | 861 | std::string url(IEX_ENDPOINT); 862 | url += "/stock/"+symbol+"/relevant"; 863 | IEX::sendGetRequest(jsonData, url); 864 | assert(jsonData.isArray()); //Crash if not an array 865 | return jsonData; 866 | } 867 | 868 | /* 869 | GET /stock/market/sector-performance 870 | [ 871 | { 872 | "type": "sector", 873 | "name": "Industrials", 874 | "performance": 0.00711, 875 | "lastUpdated": 1533672000437 876 | }, 877 | ... 878 | ]*/ 879 | Json::Value IEX::stocks::sectorPerformance() 880 | { 881 | Json::Value jsonData; 882 | std::string url(IEX_ENDPOINT); 883 | url += "/stock/market/sector-performance"; 884 | IEX::sendGetRequest(jsonData, url); 885 | assert(jsonData.isArray()); //Crash if not an array 886 | return jsonData; 887 | } 888 | 889 | /* 890 | GET /stock/{symbol}/splits/{range} 891 | [ 892 | { 893 | "exDate": "2017-08-10", 894 | "declaredDate": "2017-08-01", 895 | "recordDate": "2017-08-14", 896 | "paymentDate": "2017-08-17", 897 | "ratio": 0.142857, 898 | "toFactor": 7, 899 | "forFactor": 1 900 | } // , { ... } 901 | ]*/ 902 | Json::Value IEX::stocks::splits(const std::string &symbol, const std::string &range) 903 | { 904 | Json::Value jsonData; 905 | 906 | if(!isValidSymbol(symbol)){ 907 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 908 | return jsonData; 909 | } 910 | 911 | std::string url(IEX_ENDPOINT); 912 | 913 | if(range == "5y" || range == "2y" || range == "1y" || range == "ytd" || range == "6m" || range == "3m" || range == "1m" || range == "1d") { 914 | url += "/stock/"+symbol+"/splits/"+range; 915 | IEX::sendGetRequest(jsonData, url); 916 | } 917 | else{ 918 | std::cout << std::endl << "Incorrect 'range' input in function chartRange. Exiting." << std::endl; 919 | exit(1); 920 | } 921 | 922 | IEX::sendGetRequest(jsonData, url); 923 | assert(jsonData.isArray()); //Crash if not an array 924 | return jsonData; 925 | } 926 | 927 | //GET /stock/{symbol}/time-series 928 | Json::Value IEX::stocks::timeSeries(const std::string &symbol) 929 | { 930 | Json::Value jsonData; 931 | 932 | if(!isValidSymbol(symbol)){ 933 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 934 | return jsonData; 935 | } 936 | 937 | std::string url(IEX_ENDPOINT); 938 | url += "/stock/"+symbol+"/time-series"; 939 | IEX::sendGetRequest(jsonData, url); 940 | assert(jsonData.isArray()); //Crash if not an array 941 | return jsonData; 942 | } 943 | 944 | /* 945 | GET /stock/{symbol}/delayed-quote 946 | [ 947 | { 948 | "volume": 0, 949 | "venue": "XNYS", 950 | "venueName": "NYSE", 951 | "marketPercent": 0, 952 | "avgMarketPercent": 0, 953 | "date": "N/A" 954 | }, 955 | { 956 | "volume": 21655, 957 | "venue": "XASE", 958 | "venueName": "NYSE American", 959 | "date": "2017-09-19", 960 | "marketPercent": 0.0010540470343969304, 961 | "avgMarketPercent": 0.0021596513337820305 962 | }, 963 | { 964 | "volume": 164676, 965 | "venue": "EDGA", 966 | "venueName": "EDGA", 967 | "date": "2017-09-19", 968 | "marketPercent": 0.008015527565751508, 969 | "avgMarketPercent": 0.007070162857518009 970 | }, 971 | { 972 | "volume": 253600, 973 | "venue": "XCHI", 974 | "venueName": "CHX", 975 | "date": "2017-09-19", 976 | "marketPercent": 0.01234386182974193, 977 | "avgMarketPercent": 0.019123040706393757 978 | }, 979 | { 980 | "volume": 289791, 981 | "venue": "IEXG", 982 | "venueName": "IEX", 983 | "date": "2017-09-19", 984 | "marketPercent": 0.014105441890783691, 985 | "avgMarketPercent": 0.01080806673166022 986 | }, 987 | { 988 | "volume": 311580, 989 | "venue": "XPHL", 990 | "venueName": "NASDAQ PSX", 991 | "date": "2017-09-19", 992 | "marketPercent": 0.0151660113127405, 993 | "avgMarketPercent": 0.010991446666811688 994 | }, 995 | { 996 | "volume": 479457, 997 | "venue": "XBOS", 998 | "venueName": "NASDAQ BX", 999 | "date": "2017-09-19", 1000 | "marketPercent": 0.02333734606191868, 1001 | "avgMarketPercent": 0.016846380315025656 1002 | }, 1003 | { 1004 | "volume": 501842, 1005 | "venue": "BATY", 1006 | "venueName": "BATS BYX", 1007 | "date": "2017-09-19", 1008 | "marketPercent": 0.024426925506156744, 1009 | "avgMarketPercent": 0.020187355701732888 1010 | }, 1011 | { 1012 | "volume": 1242757, 1013 | "venue": "BATS", 1014 | "venueName": "BATS BZX", 1015 | "date": "2017-09-19", 1016 | "marketPercent": 0.06049061788621685, 1017 | "avgMarketPercent": 0.060993172098918684 1018 | }, 1019 | { 1020 | "volume": 1865376, 1021 | "venue": "ARCX", 1022 | "venueName": "NYSE Arca", 1023 | "date": "2017-09-19", 1024 | "marketPercent": 0.09079630758878819, 1025 | "avgMarketPercent": 0.07692002795005641 1026 | }, 1027 | { 1028 | "volume": 1951116, 1029 | "venue": "EDGX", 1030 | "venueName": "EDGX", 1031 | "date": "2017-09-19", 1032 | "marketPercent": 0.09496966213643043, 1033 | "avgMarketPercent": 0.09297590135910822 1034 | }, 1035 | { 1036 | "volume": 5882545, 1037 | "venue": "XNGS", 1038 | "venueName": "NASDAQ", 1039 | "date": "2017-09-19", 1040 | "marketPercent": 0.2863301367793346, 1041 | "avgMarketPercent": 0.27436519408402665 1042 | }, 1043 | { 1044 | "volume": 7580229, 1045 | "venue": "TRF", 1046 | "venueName": "Off Exchange", 1047 | "date": "2017-09-19", 1048 | "marketPercent": 0.36896411440773996, 1049 | "avgMarketPercent": 0.40847022134435956 1050 | } 1051 | ]*/ 1052 | Json::Value IEX::stocks::VolumeByVenue(const std::string &symbol) 1053 | { 1054 | Json::Value jsonData; 1055 | 1056 | if(!isValidSymbol(symbol)){ 1057 | std::cout << "Invalid Symbol! I am returning an uninitialized JSON object!"; 1058 | return jsonData; 1059 | } 1060 | 1061 | std::string url(IEX_ENDPOINT); 1062 | url += "/stock/"+symbol+"/volume-by-venue"; 1063 | IEX::sendGetRequest(jsonData, url); 1064 | assert(jsonData.isArray()); //Crash if not an array 1065 | return jsonData; 1066 | } 1067 | 1068 | /* 1069 | GET /ref-data/daily-list/symbol-directory 1070 | [ 1071 | { 1072 | "RecordID": " CA20171108153808144", 1073 | "DailyListTimestamp": "2017-11-08T17:00:00", 1074 | "EffectiveDate": "2017-11-10", 1075 | "IssueEvent": "AA", 1076 | "CurrentSymbolinINETSymbology": "ZEXIT-", 1077 | "CurrentSymbolinCQSSymbology": "ZEXITp", 1078 | "CurrentSymbolinCMSSymbology": "ZEXIT PR", 1079 | "NewSymbolinINETSymbology": "", 1080 | "NewSymbolinCQSSymbology": "", 1081 | "NewSymbolinCMSSymbology": "", 1082 | "CurrentSecurityName": "ZEXIT Preffered Stock", 1083 | "NewSecurityName": "", 1084 | "CurrentCompanyName": "ZEXIT Test Company", 1085 | "NewCompanyName": "", 1086 | "CurrentListingCenter": "", 1087 | "NewListingCenter": "V", 1088 | "DelistingReason": "", 1089 | "CurrentRoundLotSize": "100", 1090 | "NewRoundLotSize": "", 1091 | "CurrentLULDTierIndicator": "0", 1092 | "NewLULDTierIndicator": "", 1093 | "ExpirationDate": "0", 1094 | "SeparationDate": "0", 1095 | "SettlementDate": "0", 1096 | "MaturityDate": "0", 1097 | "RedemptionDate": "0", 1098 | "CurrentFinancialStatus": "0", 1099 | "NewFinancialStatus": "", 1100 | "WhenIssuedFlag": "N", 1101 | "WhenDistributedFlag": "N", 1102 | "IPOFlag": "N", 1103 | "NotesforEachEntry": "New preferred ZIEXT security", 1104 | "RecordUpdateTime": "2017-11-08T16:34:43" 1105 | }, 1106 | {...} 1107 | ]*/ 1108 | Json::Value IEX::refData::symbols() 1109 | { 1110 | Json::Value jsonData; 1111 | std::string url(IEX_ENDPOINT); 1112 | url += "/ref-data/symbols"; 1113 | IEX::sendGetRequest(jsonData, url); 1114 | assert(jsonData.isArray()); //Crash if not an array 1115 | return jsonData; 1116 | } 1117 | 1118 | /* 1119 | GET /ref-data/daily-list/symbol-directory 1120 | [ 1121 | { 1122 | "RecordID": " CA20171108153808144", 1123 | "DailyListTimestamp": "2017-11-08T17:00:00", 1124 | "EffectiveDate": "2017-11-10", 1125 | "IssueEvent": "AA", 1126 | "CurrentSymbolinINETSymbology": "ZEXIT-", 1127 | "CurrentSymbolinCQSSymbology": "ZEXITp", 1128 | "CurrentSymbolinCMSSymbology": "ZEXIT PR", 1129 | "NewSymbolinINETSymbology": "", 1130 | "NewSymbolinCQSSymbology": "", 1131 | "NewSymbolinCMSSymbology": "", 1132 | "CurrentSecurityName": "ZEXIT Preffered Stock", 1133 | "NewSecurityName": "", 1134 | "CurrentCompanyName": "ZEXIT Test Company", 1135 | "NewCompanyName": "", 1136 | "CurrentListingCenter": "", 1137 | "NewListingCenter": "V", 1138 | "DelistingReason": "", 1139 | "CurrentRoundLotSize": "100", 1140 | "NewRoundLotSize": "", 1141 | "CurrentLULDTierIndicator": "0", 1142 | "NewLULDTierIndicator": "", 1143 | "ExpirationDate": "0", 1144 | "SeparationDate": "0", 1145 | "SettlementDate": "0", 1146 | "MaturityDate": "0", 1147 | "RedemptionDate": "0", 1148 | "CurrentFinancialStatus": "0", 1149 | "NewFinancialStatus": "", 1150 | "WhenIssuedFlag": "N", 1151 | "WhenDistributedFlag": "N", 1152 | "IPOFlag": "N", 1153 | "NotesforEachEntry": "New preferred ZIEXT security", 1154 | "RecordUpdateTime": "2017-11-08T16:34:43" 1155 | }, 1156 | {...} 1157 | ]*/ 1158 | Json::Value IEX::refData::corporateActions(std::string date) 1159 | { 1160 | Json::Value jsonData; 1161 | std::string url(IEX_ENDPOINT); 1162 | 1163 | if(!date.empty()) { 1164 | if(date.size() == 8) { 1165 | url += "/ref-data/daily-list/corporate-actions/"+date; 1166 | IEX::sendGetRequest(jsonData, url); 1167 | } 1168 | else{ 1169 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1170 | exit(1); 1171 | } 1172 | } 1173 | 1174 | else{ 1175 | url += "/ref-data/daily-list/corporate-actions"; 1176 | IEX::sendGetRequest(jsonData, url); 1177 | } 1178 | assert(jsonData.isArray()); //Crash if not an array 1179 | return jsonData; 1180 | } 1181 | 1182 | /* 1183 | GET /ref-data/daily-list/dividends 1184 | [ 1185 | { 1186 | "RecordID": " DV20171108154436478", 1187 | "DailyListTimestamp": "2017-11-08T17:00:00", 1188 | "EventType": "CHANGE", 1189 | "SymbolinINETSymbology": "ZEXIT", 1190 | "SymbolinCQSSymbology": "ZEXIT", 1191 | "SymbolinCMSSymbology": "ZEXIT", 1192 | "SecurityName": "ZEXIT Common Stock", 1193 | "CompanyName": "ZEXIT Test Company", 1194 | "DeclarationDate": "2017-11-01", 1195 | "AmountDescription": "fnl", 1196 | "PaymentFrequency": "O", 1197 | "ExDate": "2017-11-09", 1198 | "RecordDate": "2017-11-13", 1199 | "PaymentDate": "2017-11-17", 1200 | "DividendTypeID": "XS", 1201 | "StockAdjustmentFactor": "1.1", 1202 | "StockAmount": ".1", 1203 | "CashAmount": "0", 1204 | "PostSplitShares": "0", 1205 | "PreSplitShares": "0", 1206 | "QualifiedDividend": "Y", 1207 | "ExercisePriceAmount": "0", 1208 | "ElectionorExpirationDate": "0", 1209 | "GrossAmount": "0", 1210 | "NetAmount": "0", 1211 | "BasisNotes": "", 1212 | "NotesforEachEntry": "ZEXIT is paying a 10% stock dividend", 1213 | "RecordUpdateTime": "2017-11-08T16:48:47" 1214 | }, 1215 | {...} 1216 | ]*/ 1217 | Json::Value IEX::refData::dividends(std::string date) 1218 | { 1219 | Json::Value jsonData; 1220 | std::string url(IEX_ENDPOINT); 1221 | if(!date.empty()) { 1222 | if(date.size() == 8) { 1223 | url += "/ref-data/daily-list/dividends/"+date; 1224 | IEX::sendGetRequest(jsonData, url); 1225 | } 1226 | else{ 1227 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1228 | exit(1); 1229 | } 1230 | } 1231 | 1232 | else{ 1233 | url += "/ref-data/daily-list/dividends"; 1234 | IEX::sendGetRequest(jsonData, url); 1235 | } 1236 | assert(jsonData.isArray()); //Crash if not an array 1237 | return jsonData; 1238 | } 1239 | 1240 | /* 1241 | GET /ref-data/daily-list/next-day-ex-date 1242 | [ 1243 | { 1244 | "RecordID": " DV20171108154436478", 1245 | "DailyListTimestamp": "2017-11-08T17:00:00", 1246 | "ExDate": "2017-11-09", 1247 | "SymbolinINETSymbology": "ZEXIT", 1248 | "SymbolinCQSSymbology": "ZEXIT", 1249 | "SymbolinCMSSymbology": "ZEXIT", 1250 | "SecurityName": "ZEXIT Common Stock", 1251 | "CompanyName": "ZEXIT Test Company", 1252 | "DividendTypeID": "XS", 1253 | "AmountDescription": "fnl", 1254 | "PaymentFrequency": "O", 1255 | "StockAdjustmentFactor": "1.1", 1256 | "StockAmount": ".1", 1257 | "CashAmount": "0", 1258 | "PostSplitShares": "0", 1259 | "PreSplitShares": "0", 1260 | "QualifiedDividend": "Y", 1261 | "ExercisePriceAmount": "0", 1262 | "ElectionorExpirationDate": "0", 1263 | "GrossAmount": "0", 1264 | "NetAmount": "0", 1265 | "BasisNotes": "", 1266 | "NotesforEachEntry": "ZEXIT is paying a 10% stock dividend", 1267 | "RecordUpdateTime": "2017-11-08T16:48:47" 1268 | }, 1269 | {...} 1270 | ]*/ 1271 | Json::Value IEX::refData::nextDayExDate(std::string date) 1272 | { 1273 | Json::Value jsonData; 1274 | std::string url(IEX_ENDPOINT); 1275 | if(!date.empty()) { 1276 | if(date.size() == 8) { 1277 | url += "/ref-data/daily-list/next-day-ex-date/"+date; 1278 | IEX::sendGetRequest(jsonData, url); 1279 | } 1280 | else{ 1281 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1282 | exit(1); 1283 | } 1284 | } 1285 | 1286 | else{ 1287 | url += "/ref-data/daily-list/next-day-ex-date"; 1288 | IEX::sendGetRequest(jsonData, url); 1289 | } 1290 | assert(jsonData.isArray()); //Crash if not an array 1291 | return jsonData; 1292 | } 1293 | 1294 | /* 1295 | GET /ref-data/daily-list/symbol-directory 1296 | [ 1297 | { 1298 | "RecordID": "SD20171020161150890", 1299 | "DailyListTimestamp": "2017-12-18T09:00:00", 1300 | "SymbolinINETSymbology": "ZEXIT", 1301 | "SymbolinCQSSymbology": "ZEXIT", 1302 | "SymbolinCMSSymbology": "ZEXIT", 1303 | "SecurityName": "ZEXIT Common Stock", 1304 | "CompanyName": "ZEXIT Test Company", 1305 | "TestIssue": "Y", 1306 | "IssueDescription": "Common Stock", 1307 | "IssueType": "C", 1308 | "IssueSubType": "C", 1309 | "SICCode": "5678", 1310 | "TransferAgent": "American Stock Transfer", 1311 | "FinancialStatus": "0", 1312 | "RoundLotSize": "100", 1313 | "PreviousOfficialClosingPrice": "10.00", 1314 | "AdjustedPreviousOfficialClosingPrice": "10.00", 1315 | "WhenIssuedFlag": "N", 1316 | "WhenDistributedFlag": "N", 1317 | "IPOFlag": "N", 1318 | "FirstDateListed": "2017-09-15", 1319 | "LULDTierIndicator": "1", 1320 | "CountryofIncorporation": "USA", 1321 | "LeveragedETPFlag": "N", 1322 | "LeveragedETPRatio": "0", 1323 | "InverseETPFlag": "N", 1324 | "RecordUpdateTime": "2017-11-10T16:28:56" 1325 | }, 1326 | {...} 1327 | ]*/ 1328 | Json::Value IEX::refData::symbolDirectory(std::string date) 1329 | { 1330 | Json::Value jsonData; 1331 | std::string url(IEX_ENDPOINT); 1332 | if(!date.empty()) { 1333 | if(date.size() == 8) { 1334 | url += "/ref-data/daily-list/symbol-directory/"+date; 1335 | IEX::sendGetRequest(jsonData, url); 1336 | } 1337 | else{ 1338 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1339 | exit(1); 1340 | } 1341 | } 1342 | 1343 | else{ 1344 | url += "/ref-data/daily-list/symbol-directory"; 1345 | IEX::sendGetRequest(jsonData, url); 1346 | } 1347 | assert(jsonData.isArray()); //Crash if not an array 1348 | return jsonData; 1349 | } 1350 | 1351 | /* 1352 | GET /stats/intraday 1353 | { 1354 | "volume": { 1355 | "value": 26908038, 1356 | "lastUpdated": 1480433817323 1357 | }, 1358 | "symbolsTraded": { 1359 | "value": 4089, 1360 | "lastUpdated": 1480433817323 1361 | }, 1362 | "routedVolume": { 1363 | "value": 10879651, 1364 | "lastUpdated": 1480433816891 1365 | }, 1366 | "notional": { 1367 | "value": 1090683735, 1368 | "lastUpdated": 1480433817323 1369 | }, 1370 | "marketShare": { 1371 | "value": 0.01691, 1372 | "lastUpdated": 1480433817336 1373 | } 1374 | }*/ 1375 | Json::Value IEX::stats::intraday() 1376 | { 1377 | Json::Value jsonData; 1378 | std::string url(IEX_ENDPOINT); 1379 | url += "/stats/intraday"; 1380 | IEX::sendGetRequest(jsonData, url); 1381 | assert(jsonData.isArray()); //Crash if not an array 1382 | return jsonData; 1383 | } 1384 | 1385 | /* 1386 | GET /stats/recent 1387 | [ 1388 | { 1389 | "date": "2017-01-11", 1390 | "volume": 128048723, 1391 | "routedVolume": 38314207, 1392 | "marketShare": 0.01769, 1393 | "isHalfday": false, 1394 | "litVolume": 30520534 1395 | }, 1396 | { 1397 | "date": "2017-01-10", 1398 | "volume": 135116521, 1399 | "routedVolume": 39329019, 1400 | "marketShare": 0.01999, 1401 | "isHalfday": false, 1402 | "litVolume": 29721789 1403 | }, 1404 | { 1405 | "date": "2017-01-09", 1406 | "volume": 109850518, 1407 | "routedVolume": 31283422, 1408 | "marketShare": 0.01704, 1409 | "isHalfday": false, 1410 | "litVolume": 27699365 1411 | }, 1412 | { 1413 | "date": "2017-01-06", 1414 | "volume": 116680433, 1415 | "routedVolume": 29528471, 1416 | "marketShare": 0.01805, 1417 | "isHalfday": false, 1418 | "litVolume": 29357729 1419 | }, 1420 | { 1421 | "date": "2017-01-05", 1422 | "volume": 130389657, 1423 | "routedVolume": 40977180, 1424 | "marketShare": 0.01792, 1425 | "isHalfday": false, 1426 | "litVolume": 33169236 1427 | }, 1428 | { 1429 | "date": "2017-01-04", 1430 | "volume": 124428433, 1431 | "routedVolume": 38859989, 1432 | "marketShare": 0.01741, 1433 | "isHalfday": false, 1434 | "litVolume": 31563256 1435 | }, 1436 | { 1437 | "date": "2017-01-03", 1438 | "volume": 130195733, 1439 | "routedVolume": 34990159, 1440 | "marketShare": 0.01733, 1441 | "isHalfday": false, 1442 | "litVolume": 34150804 1443 | } 1444 | ]*/ 1445 | Json::Value IEX::stats::recent() 1446 | { 1447 | Json::Value jsonData; 1448 | std::string url(IEX_ENDPOINT); 1449 | url += "/stats/recent"; 1450 | IEX::sendGetRequest(jsonData, url); 1451 | assert(jsonData.isArray()); //Crash if not an array 1452 | return jsonData; 1453 | } 1454 | 1455 | /* 1456 | GET /stats/records 1457 | { 1458 | "volume": { 1459 | "recordValue": 233000477, 1460 | "recordDate": "2016-01-20", 1461 | "previousDayValue": 99594714, 1462 | "avg30Value": 138634204.5 1463 | }, 1464 | "symbolsTraded": { 1465 | "recordValue": 6046, 1466 | "recordDate": "2016-11-10", 1467 | "previousDayValue": 5500, 1468 | "avg30Value": 5617 1469 | }, 1470 | "routedVolume": { 1471 | "recordValue": 74855222, 1472 | "recordDate": "2016-11-10", 1473 | "previousDayValue": 29746476, 1474 | "avg30Value": 44520084 1475 | }, 1476 | "notional": { 1477 | "recordValue": 9887832327.8355, 1478 | "recordDate": "2016-11-10", 1479 | "previousDayValue": 4175710684.3897, 1480 | "avg30Value": 5771412969.2662 1481 | } 1482 | }*/ 1483 | Json::Value IEX::stats::records() 1484 | { 1485 | Json::Value jsonData; 1486 | std::string url(IEX_ENDPOINT); 1487 | url += "/stats/records"; 1488 | IEX::sendGetRequest(jsonData, url); 1489 | assert(jsonData.isArray()); //Crash if not an array 1490 | return jsonData; 1491 | } 1492 | 1493 | /* 1494 | GET /stats/historical?date=201605 1495 | [ 1496 | { 1497 | "averageDailyVolume": 112247378.5, 1498 | "averageDailyRoutedVolume": 34282226.24, 1499 | "averageMarketShare": 0, 1500 | "averageOrderSize": 493, 1501 | "averageFillSize": 287, 1502 | "bin100Percent": 0.61559, 1503 | "bin101Percent": 0.61559, 1504 | "bin200Percent": 0.61559, 1505 | "bin300Percent": 0.61559, 1506 | "bin400Percent": 0.61559, 1507 | "bin500Percent": 0.61559, 1508 | "bin1000Percent": 0.61559, 1509 | "bin5000Percent": 0.61559, 1510 | "bin10000Percent": 0.61559, 1511 | "bin10000Trades": 4666, 1512 | "bin20000Trades": 1568, 1513 | "bin50000Trades": 231, 1514 | "uniqueSymbolsTraded": 7419, 1515 | "blockPercent": 0.08159, 1516 | "selfCrossPercent": 0.02993, 1517 | "etfPercent": 0.12646, 1518 | "largeCapPercent": 0.40685, 1519 | "midCapPercent": 0.2806, 1520 | "smallCapPercent": 0.18609, 1521 | "venueARCXFirstWaveWeight": 0.22063, 1522 | "venueBATSFirstWaveWeight": 0.06249, 1523 | "venueBATYFirstWaveWeight": 0.07361, 1524 | "venueEDGAFirstWaveWeight": 0.01083, 1525 | "venueEDGXFirstWaveWeight": 0.0869, 1526 | "venueOverallFirstWaveWeight": 1, 1527 | "venueXASEFirstWaveWeight": 0.00321, 1528 | "venueXBOSFirstWaveWeight": 0.02935, 1529 | "venueXCHIFirstWaveWeight": 0.00108, 1530 | "venueXCISFirstWaveWeight": 0.00008, 1531 | "venueXNGSFirstWaveWeight": 0.20358, 1532 | "venueXNYSFirstWaveWeight": 0.29313, 1533 | "venueXPHLFirstWaveWeight": 0.01511, 1534 | "venueARCXFirstWaveRate": 0.97737, 1535 | "venueBATSFirstWaveRate": 0.99357, 1536 | "venueBATYFirstWaveRate": 0.99189, 1537 | "venueEDGAFirstWaveRate": 0.98314, 1538 | "venueEDGXFirstWaveRate": 0.99334, 1539 | "venueOverallFirstWaveRate": 0.98171, 1540 | "venueXASEFirstWaveRate": 0.94479, 1541 | "venueXBOSFirstWaveRate": 0.97829, 1542 | "venueXCHIFirstWaveRate": 0.65811, 1543 | "venueXCISFirstWaveRate": 0.9468, 1544 | "venueXNGSFirstWaveRate": 0.98174, 1545 | "venueXNYSFirstWaveRate": 0.98068, 1546 | "venueXPHLFirstWaveRate": 0.93629 1547 | } 1548 | ]*/ 1549 | Json::Value IEX::stats::historical(std::string date) 1550 | { 1551 | Json::Value jsonData; 1552 | std::string url(IEX_ENDPOINT); 1553 | if(!date.empty()) { 1554 | if(date.size() == 8) { 1555 | url += "/stats/historical/"+date; 1556 | IEX::sendGetRequest(jsonData, url); 1557 | } 1558 | else{ 1559 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1560 | exit(1); 1561 | } 1562 | } 1563 | 1564 | else{ 1565 | url += "/stats/historical/"; 1566 | IEX::sendGetRequest(jsonData, url); 1567 | } 1568 | assert(jsonData.isArray()); //Crash if not an array 1569 | return jsonData; 1570 | } 1571 | 1572 | /* 1573 | GET /stats/historical/daily?last=5 1574 | [ 1575 | { 1576 | "date": "2017-05-09", 1577 | "volume": 152907569, 1578 | "routedVolume": 46943802, 1579 | "marketShare": 0.02246, 1580 | "isHalfday": 0, 1581 | "litVolume": 35426666 1582 | }, 1583 | { 1584 | "date": "2017-05-08", 1585 | "volume": 142923030, 1586 | "routedVolume": 39507295, 1587 | "marketShare": 0.02254, 1588 | "isHalfday": 0, 1589 | "litVolume": 32404585 1590 | }, 1591 | { 1592 | "date": "2017-05-05", 1593 | "volume": 155118117, 1594 | "routedVolume": 39974788, 1595 | "marketShare": 0.02358, 1596 | "isHalfday": 0, 1597 | "litVolume": 35124994 1598 | }, 1599 | { 1600 | "date": "2017-05-04", 1601 | "volume": 185715463, 1602 | "routedVolume": 56264408, 1603 | "marketShare": 0.02352, 1604 | "isHalfday": 0, 1605 | "litVolume": 40634976 1606 | }, 1607 | { 1608 | "date": "2017-05-03", 1609 | "volume": 183103198, 1610 | "routedVolume": 50953175, 1611 | "marketShare": 0.025009999999999998, 1612 | "isHalfday": 0, 1613 | "litVolume": 40296158 1614 | } 1615 | ] 1616 | EITHER TAKES JUST A SYMBOL, OR SYMBOL AND DATE, OR SYMBOL AND LAST X (UP TO 90)*/ 1617 | Json::Value IEX::stats::historicalDaily(std::string date) 1618 | { 1619 | Json::Value jsonData; 1620 | std::string url(IEX_ENDPOINT); 1621 | std::locale loc; //For isdigit 1622 | if(!date.empty()) { 1623 | if(date.size() == 8) { 1624 | url += "/stats/historical/daily?date="+date; 1625 | IEX::sendGetRequest(jsonData, url); 1626 | } 1627 | else if(isdigit(date[0],loc)) { 1628 | url += "/stats/historical/daily?last="+date; 1629 | IEX::sendGetRequest(jsonData, url); 1630 | } 1631 | else{ 1632 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1633 | exit(1); 1634 | } 1635 | } 1636 | 1637 | else{ 1638 | url += "/stats/historical/daily"; 1639 | IEX::sendGetRequest(jsonData, url); 1640 | } 1641 | assert(jsonData.isArray()); //Crash if not an array 1642 | return jsonData; 1643 | } 1644 | 1645 | /* 1646 | GET /market 1647 | [ 1648 | { 1649 | "mic": "TRF", 1650 | "tapeId": "-", 1651 | "venueName": "TRF Volume", 1652 | "volume": 589171705, 1653 | "tapeA": 305187928, 1654 | "tapeB": 119650027, 1655 | "tapeC": 164333750, 1656 | "marketPercent": 0.37027, 1657 | "lastUpdated": 1480433817317 1658 | }, 1659 | { 1660 | "mic": "XNGS", 1661 | "tapeId": "Q", 1662 | "venueName": "NASDAQ", 1663 | "volume": 213908393, 1664 | "tapeA": 90791123, 1665 | "tapeB": 30731818, 1666 | "tapeC": 92385452, 1667 | "marketPercent": 0.13443, 1668 | "lastUpdated": 1480433817311 1669 | }, 1670 | { 1671 | "mic": "XNYS", 1672 | "tapeId": "N", 1673 | "venueName": "NYSE", 1674 | "volume": 204280163, 1675 | "tapeA": 204280163, 1676 | "tapeB": 0, 1677 | "tapeC": 0, 1678 | "marketPercent": 0.12838, 1679 | "lastUpdated": 1480433817336 1680 | }, 1681 | { 1682 | "mic": "ARCX", 1683 | "tapeId": "P", 1684 | "venueName": "NYSE Arca", 1685 | "volume": 180301371, 1686 | "tapeA": 64642458, 1687 | "tapeB": 78727208, 1688 | "tapeC": 36931705, 1689 | "marketPercent": 0.11331, 1690 | "lastUpdated": 1480433817305 1691 | }, 1692 | { 1693 | "mic": "EDGX", 1694 | "tapeId": "K", 1695 | "venueName": "EDGX", 1696 | "volume": 137022822, 1697 | "tapeA": 58735505, 1698 | "tapeB": 32753903, 1699 | "tapeC": 45533414, 1700 | "marketPercent": 0.08611, 1701 | "lastUpdated": 1480433817310 1702 | }, 1703 | { 1704 | "mic": "BATS", 1705 | "tapeId": "Z", 1706 | "venueName": "BATS BZX", 1707 | "volume": 100403461, 1708 | "tapeA": 52509859, 1709 | "tapeB": 25798360, 1710 | "tapeC": 22095242, 1711 | "marketPercent": 0.0631, 1712 | "lastUpdated": 1480433817311 1713 | }, 1714 | { 1715 | "mic": "BATY", 1716 | "tapeId": "Y", 1717 | "venueName": "BATS BYX", 1718 | "volume": 54413196, 1719 | "tapeA": 28539960, 1720 | "tapeB": 13638779, 1721 | "tapeC": 12234457, 1722 | "marketPercent": 0.03419, 1723 | "lastUpdated": 1480433817310 1724 | }, 1725 | { 1726 | "mic": "XBOS", 1727 | "tapeId": "B", 1728 | "venueName": "NASDAQ BX", 1729 | "volume": 31417461, 1730 | "tapeA": 16673166, 1731 | "tapeB": 5875538, 1732 | "tapeC": 8868757, 1733 | "marketPercent": 0.01974, 1734 | "lastUpdated": 1480433817311 1735 | }, 1736 | { 1737 | "mic": "EDGA", 1738 | "tapeId": "J", 1739 | "venueName": "EDGA", 1740 | "volume": 30670687, 1741 | "tapeA": 15223428, 1742 | "tapeB": 8276375, 1743 | "tapeC": 7170884, 1744 | "marketPercent": 0.01927, 1745 | "lastUpdated": 1480433817311 1746 | }, 1747 | { 1748 | "mic": "IEXG", 1749 | "tapeId": "V", 1750 | "venueName": "IEX", 1751 | "volume": 26907838, 1752 | "tapeA": 16578501, 1753 | "tapeB": 3889245, 1754 | "tapeC": 6440092, 1755 | "marketPercent": 0.01691, 1756 | "lastUpdated": 1480433817235 1757 | }, 1758 | { 1759 | "mic": "XPHL", 1760 | "tapeId": "X", 1761 | "venueName": "NASDAQ PSX", 1762 | "volume": 13334403, 1763 | "tapeA": 5802294, 1764 | "tapeB": 4239741, 1765 | "tapeC": 3292368, 1766 | "marketPercent": 0.00838, 1767 | "lastUpdated": 1480433817071 1768 | }, 1769 | { 1770 | "mic": "XCHI", 1771 | "tapeId": "M", 1772 | "venueName": "CHX", 1773 | "volume": 4719854, 1774 | "tapeA": 834762, 1775 | "tapeB": 3168434, 1776 | "tapeC": 716658, 1777 | "marketPercent": 0.00296, 1778 | "lastUpdated": 1480433814711 1779 | }, 1780 | { 1781 | "mic": "XASE", 1782 | "tapeId": "A", 1783 | "venueName": "NYSE MKT", 1784 | "volume": 4419196, 1785 | "tapeA": 0, 1786 | "tapeB": 4419196, 1787 | "tapeC": 0, 1788 | "marketPercent": 0.00277, 1789 | "lastUpdated": 1480433816276 1790 | }, 1791 | { 1792 | "mic": "XCIS", 1793 | "tapeId": "C", 1794 | "venueName": "NSX", 1795 | "volume": 187785, 1796 | "tapeA": 39923, 1797 | "tapeB": 62191, 1798 | "tapeC": 85671, 1799 | "marketPercent": 0.00011, 1800 | "lastUpdated": 1480433816141 1801 | } 1802 | ]*/ 1803 | Json::Value IEX::markets::market() 1804 | { 1805 | Json::Value jsonData; 1806 | std::string url(IEX_ENDPOINT); 1807 | url += "/market"; 1808 | IEX::sendGetRequest(jsonData, url); 1809 | assert(jsonData.isArray()); //Crash if not an array 1810 | return jsonData; 1811 | } 1812 | 1813 | //GET /stock/market/crypto 1814 | Json::Value IEX::stocks::crypto() 1815 | { 1816 | Json::Value jsonData; 1817 | std::string url(IEX_ENDPOINT); 1818 | url += "/stock/market/crypto"; 1819 | IEX::sendGetRequest(jsonData, url); 1820 | assert(jsonData.isArray()); //Crash if not an array 1821 | return jsonData; 1822 | } 1823 | 1824 | /* 1825 | GET /stock/market/today-earnings 1826 | { 1827 | "bto": [ 1828 | { 1829 | "actualEPS": 2.1, 1830 | "consensusEPS": 2.02, 1831 | "estimatedEPS": 2.02, 1832 | "announceTime": "BTO", 1833 | "numberOfEstimates": 14, 1834 | "EPSSurpriseDollar": 0.08, 1835 | "EPSReportDate": "2017-05-02", 1836 | "fiscalPeriod": "Q2 2017", 1837 | "fiscalEndDate": "2017-03-31", 1838 | "yearAgo": 1.67, 1839 | "yearAgoChangePercent": .30, 1840 | "estimatedChangePercent": .28, 1841 | "symbolId": 11, 1842 | "symbol": "AAPL", 1843 | "quote": { 1844 | ... 1845 | }, 1846 | "headline": "" 1847 | }, 1848 | ... 1849 | ], 1850 | "amc": [ 1851 | { 1852 | "actualEPS": 3.36, 1853 | "consensusEPS": 3.22, 1854 | "estimatedEPS": 3.22, 1855 | "announceTime": "AMC", 1856 | "numberOfEstimates": 15, 1857 | "EPSSurpriseDollar": 0.14, 1858 | "EPSReportDate": "2017-05-02", 1859 | "fiscalPeriod": "Q2 2017", 1860 | "fiscalEndDate": "2017-03-31", 1861 | "yearAgo": 1.67, 1862 | "yearAgoChangePercent": .30, 1863 | "estimatedChangePercent": .28, 1864 | "symbolId": 1, 1865 | "symbol": "A", 1866 | "quote": { 1867 | ... 1868 | }, 1869 | "headline": "" 1870 | }, 1871 | ... 1872 | ] 1873 | }*/ 1874 | Json::Value IEX::stocks::earningsToday() 1875 | { 1876 | Json::Value jsonData; 1877 | std::string url(IEX_ENDPOINT); 1878 | url += "/stock/market/today-earnings"; 1879 | IEX::sendGetRequest(jsonData, url); 1880 | assert(jsonData.isArray()); //Crash if not an array 1881 | return jsonData; 1882 | } 1883 | 1884 | /* 1885 | GET /stock/market/upcoming-ipos 1886 | The above example will return JSON with the following keys 1887 | { 1888 | "rawData": [ 1889 | { 1890 | "symbol": "VCNX", 1891 | "companyName": "VACCINEX, INC.", 1892 | "expectedDate": "2018-08-09", 1893 | "leadUnderwriters": [ 1894 | "BTIG, LLC", 1895 | "Oppenheimer & Co. Inc." 1896 | ], 1897 | "underwriters": [ 1898 | "Ladenburg Thalmann & Co. Inc." 1899 | ], 1900 | "companyCounsel": [ 1901 | "Hogan Lovells US LLP and Harter Secrest & Emery LLP" 1902 | ], 1903 | "underwriterCounsel": [ 1904 | "Mintz, Levin, Cohn, Ferris, Glovsky and Popeo, P.C." 1905 | ], 1906 | "auditor": "Computershare Trust Company, N.A", 1907 | "market": "NASDAQ Global", 1908 | "cik": "0001205922", 1909 | "address": "1895 MOUNT HOPE AVE", 1910 | "city": "ROCHESTER", 1911 | "state": "NY", 1912 | "zip": "14620", 1913 | "phone": "585-271-2700", 1914 | "ceo": "Maurice Zauderer", 1915 | "employees": 44, 1916 | "url": "www.vaccinex.com", 1917 | "status": "Filed", 1918 | "sharesOffered": 3333000, 1919 | "priceLow": 12, 1920 | "priceHigh": 15, 1921 | "offerAmount": null, 1922 | "totalExpenses": 2400000, 1923 | "sharesOverAlloted": 499950, 1924 | "shareholderShares": null, 1925 | "sharesOutstanding": 11474715, 1926 | "lockupPeriodExpiration": "", 1927 | "quietPeriodExpiration": "", 1928 | "revenue": 206000, 1929 | "netIncome": -7862000, 1930 | "totalAssets": 4946000, 1931 | "totalLiabilities": 6544000, 1932 | "stockholderEquity": -133279000, 1933 | "companyDescription": "", 1934 | "businessDescription": "", 1935 | "useOfProceeds": "", 1936 | "competition": "", 1937 | "amount": 44995500, 1938 | "percentOffered": "29.05" 1939 | }, 1940 | ... 1941 | ], 1942 | "viewData": [ 1943 | { 1944 | "Company": "VACCINEX, INC.", 1945 | "Symbol": "VCNX", 1946 | "Price": "$12.00 - 15.00", 1947 | "Shares": "3,333,000", 1948 | "Amount": "44,995,500", 1949 | "Float": "11,474,715", 1950 | "Percent": "29.05%", 1951 | "Market": "NASDAQ Global", 1952 | "Expected": "2018-08-09" 1953 | }, 1954 | ... 1955 | ] 1956 | }*/ 1957 | Json::Value IEX::stocks::upcomingIPOS() 1958 | { 1959 | Json::Value jsonData; 1960 | std::string url(IEX_ENDPOINT); 1961 | url += "/stock/market/upcoming-ipos"; 1962 | IEX::sendGetRequest(jsonData, url); 1963 | assert(jsonData.isArray()); //Crash if not an array 1964 | return jsonData; 1965 | } 1966 | 1967 | 1968 | /* 1969 | GET /stock/market/today-ipos 1970 | The above example will return JSON with the following keys 1971 | { 1972 | "rawData": [ 1973 | { 1974 | "symbol": "VCNX", 1975 | "companyName": "VACCINEX, INC.", 1976 | "expectedDate": "2018-08-09", 1977 | "leadUnderwriters": [ 1978 | "BTIG, LLC", 1979 | "Oppenheimer & Co. Inc." 1980 | ], 1981 | "underwriters": [ 1982 | "Ladenburg Thalmann & Co. Inc." 1983 | ], 1984 | "companyCounsel": [ 1985 | "Hogan Lovells US LLP and Harter Secrest & Emery LLP" 1986 | ], 1987 | "underwriterCounsel": [ 1988 | "Mintz, Levin, Cohn, Ferris, Glovsky and Popeo, P.C." 1989 | ], 1990 | "auditor": "Computershare Trust Company, N.A", 1991 | "market": "NASDAQ Global", 1992 | "cik": "0001205922", 1993 | "address": "1895 MOUNT HOPE AVE", 1994 | "city": "ROCHESTER", 1995 | "state": "NY", 1996 | "zip": "14620", 1997 | "phone": "585-271-2700", 1998 | "ceo": "Maurice Zauderer", 1999 | "employees": 44, 2000 | "url": "www.vaccinex.com", 2001 | "status": "Filed", 2002 | "sharesOffered": 3333000, 2003 | "priceLow": 12, 2004 | "priceHigh": 15, 2005 | "offerAmount": null, 2006 | "totalExpenses": 2400000, 2007 | "sharesOverAlloted": 499950, 2008 | "shareholderShares": null, 2009 | "sharesOutstanding": 11474715, 2010 | "lockupPeriodExpiration": "", 2011 | "quietPeriodExpiration": "", 2012 | "revenue": 206000, 2013 | "netIncome": -7862000, 2014 | "totalAssets": 4946000, 2015 | "totalLiabilities": 6544000, 2016 | "stockholderEquity": -133279000, 2017 | "companyDescription": "", 2018 | "businessDescription": "", 2019 | "useOfProceeds": "", 2020 | "competition": "", 2021 | "amount": 44995500, 2022 | "percentOffered": "29.05" 2023 | }, 2024 | ... 2025 | ], 2026 | "viewData": [ 2027 | { 2028 | "Company": "VACCINEX, INC.", 2029 | "Symbol": "VCNX", 2030 | "Price": "$12.00 - 15.00", 2031 | "Shares": "3,333,000", 2032 | "Amount": "44,995,500", 2033 | "Float": "11,474,715", 2034 | "Percent": "29.05%", 2035 | "Market": "NASDAQ Global", 2036 | "Expected": "2018-08-09" 2037 | }, 2038 | ... 2039 | ] 2040 | }*/ 2041 | Json::Value IEX::stocks::todayIPOS() 2042 | { 2043 | Json::Value jsonData; 2044 | std::string url(IEX_ENDPOINT); 2045 | url += "/stock/market/today-ipos"; 2046 | IEX::sendGetRequest(jsonData, url); 2047 | assert(jsonData.isArray()); //Crash if not an array 2048 | return jsonData; 2049 | } 2050 | 2051 | -------------------------------------------------------------------------------- /IEX.h: -------------------------------------------------------------------------------- 1 | #ifndef IEX_h 2 | #define IEX_h 3 | 4 | #include 5 | #include 6 | #include //std::locale, std::isdigit 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #define IEX_ENDPOINT "https://api.iextrading.com/1.0" 15 | 16 | namespace IEX { 17 | void sendGetRequest(Json::Value &data, const std::string url); 18 | bool isValidSymbol(const std::string &); 19 | std::vector getSymbolList(); 20 | void parseSymbolData(const Json::Value &, std::vector &); 21 | namespace stocks { 22 | Json::Value batch(const std::string &); 23 | Json::Value book(const std::string &); 24 | Json::Value chart(const std::string &); 25 | Json::Value chartRange(const std::string &, const std::string &); 26 | Json::Value chartDate(const std::string &, const std::string &); 27 | Json::Value chartDynamic(const std::string &); 28 | Json::Value company(const std::string &); 29 | Json::Value crypto(); 30 | Json::Value delayedQuote(const std::string &); 31 | Json::Value dividends(const std::string &, const std::string &); 32 | Json::Value earnings(const std::string &); 33 | Json::Value earningsToday(); 34 | Json::Value effectiveSpread(const std::string &); 35 | Json::Value financials(const std::string &); 36 | Json::Value upcomingIPOS(); 37 | Json::Value todayIPOS(); 38 | Json::Value stats(const std::string &); 39 | Json::Value largestTrades(const std::string &); 40 | Json::Value list(const std::string &); 41 | Json::Value logo(const std::string &); 42 | Json::Value news(const std::string &, int last = 0); 43 | Json::Value OHLC(const std::string &); 44 | Json::Value peers(const std::string &); 45 | Json::Value previous(const std::string &); 46 | Json::Value price(const std::string &); 47 | Json::Value quote(const std::string &, bool displayPercent = false); 48 | Json::Value relevant(const std::string &); 49 | Json::Value sectorPerformance(); 50 | Json::Value splits(const std::string &, const std::string &); 51 | Json::Value relevant(const std::string &); 52 | Json::Value timeSeries(const std::string &); 53 | Json::Value VolumeByVenue(const std::string &); 54 | } 55 | 56 | namespace refData { 57 | Json::Value symbols(); 58 | Json::Value corporateActions(std::string date = ""); 59 | Json::Value dividends(std::string date = ""); 60 | Json::Value nextDayExDate(std::string date = ""); 61 | Json::Value symbolDirectory(std::string date = ""); 62 | } 63 | 64 | namespace marketData { 65 | 66 | } 67 | 68 | namespace stats { 69 | Json::Value intraday(); 70 | Json::Value recent(); 71 | Json::Value records(); 72 | Json::Value historical(std::string date = ""); 73 | Json::Value historicalDaily(std::string date = ""); 74 | } 75 | 76 | namespace markets { 77 | Json::Value market(); 78 | } 79 | } 80 | 81 | #endif 82 | 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IEX_CPP_API 2 | Unofficial C++ Lib for the IEXtrading API 3 | 4 | For the OFFICIAL API and its docs and all credit to the data pulled by this program go to: https://iextrading.com/developer/docs/ 5 | 6 | This lib will allow for easier use of IEXtrading GET requests in C++ through the use of prebuilt functions. 7 | 8 | As it stands currently, the dependancies used in this lib will need to be manually installed: 9 | 10 | Libcurl: https://curl.haxx.se/docs/install.html 11 | 12 | Jsoncpp: https://github.com/open-source-parsers/jsoncpp 13 | 14 | **_Why use this lib over official API?_** 15 | 16 | **C++ code with the official API:** 17 | 18 | namespace 19 | { 20 | std::size_t callback( 21 | const char* in, 22 | std::size_t size, 23 | std::size_t num, 24 | std::string* out) 25 | { 26 | const std::size_t totalBytes(size * num); 27 | out->append(in, totalBytes); 28 | return totalBytes; 29 | } 30 | } 31 | 32 | Json::Value acquireJSONofAAPLchart{ 33 | const std::string url("https://api.iextrading.com/1.0/stock/aapl/chart"); 34 | 35 | CURL* curl = curl_easy_init(); 36 | 37 | // Set remote URL. 38 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); 39 | 40 | // Don't bother trying IPv6, which would increase DNS resolution time. 41 | curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); 42 | 43 | // Don't wait forever, time out after 10 seconds. 44 | curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); 45 | 46 | // Follow HTTP redirects if necessary. 47 | curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 48 | 49 | // Response information. 50 | int httpCode(0); 51 | std::unique_ptr httpData(new std::string()); 52 | 53 | // Hook up data handling function. 54 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback); 55 | 56 | // Hook up data container (will be passed as the last parameter to the 57 | // callback handling function). Can be any pointer type, since it will 58 | // internally be passed as a void pointer. 59 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get()); 60 | 61 | // Run our HTTP GET command, capture the HTTP response code, and clean up. 62 | curl_easy_perform(curl); 63 | curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); 64 | curl_easy_cleanup(curl); 65 | 66 | JSONdata parsedData; 67 | if (httpCode == 200) 68 | { 69 | std::cout << "\nGot successful response from " << url << std::endl; 70 | 71 | // Response looks good - done using Curl now. 72 | Json::Reader jsonReader; 73 | Json::Value jsonData; 74 | jsonReader.parse(*httpData, jsonData); //TODO error handle 75 | 76 | return jsonValue; 77 | 78 | 79 | } 80 | 81 | **C++ code with IEX_CPP_API:** 82 | 83 | IEX::stocks::chart("aapl"); 84 | 85 | 86 | **NOTE:** 87 | 88 | The code currently in "int main()" is simply test cases as this is still in dev. The final product would not use an "int main()", it just shows examples of how to use each function currently in the lib. 89 | 90 | **Using the lib:** 91 | 92 | Formal docs to be added when this project gets closer to done, however some basic examples plus the offical docs should make this easy to use. See the int main() code for examples on using each currently supported function. Each function returns a JSON data type. This lib uses the Jsoncpp API for its' JSON data types. See the Jsoncpp docs linked above for info on how to use the JSON objects. 93 | 94 | 95 | 96 | **_To Do:_** 97 | 98 | **Stocks:** 99 | - ~~Batch Requests~~ (Half implemented, still needs parameteres) 100 | - ~~Book~~ 101 | - ~~Chart~~ (Completed all range options, some additional params not in yet) 102 | - ~~Company~~ 103 | - ~~Crypto~~ 104 | - ~~Delayed Quote~~ 105 | - ~~Dividends~~ 106 | - ~~Earnings~~ 107 | - ~~Earnings Today~~ 108 | - ~~Effective Spread~~ 109 | - ~~Financials~~ 110 | - ~~Historical Prices~~ (Done VIA "Chart" as the official API does.) 111 | - ~~Upcoming IPOS~~ 112 | - ~~Today's IPOS~~ 113 | - IEX Regulation SHO Threshold Securities List (Can't get this to return anything, unsure if not supported or me being dumb, will revisit later) 114 | - IEX Short Interest List(Can't get this to return anything, unsure if not supported or me being dumb, will revisit later) 115 | - ~~Key Stats~~ 116 | - ~~Largest Trades~~ 117 | - ~~List~~ 118 | - ~~Logo~~ 119 | - ~~News~~ 120 | - ~~OHLC~~ 121 | - ~~Open/Close~~ (OHLC function per offical API docs) 122 | - ~~Peers~~ 123 | - ~~Previous~~ 124 | - ~~Price~~ 125 | - ~~Quote~~ 126 | - ~~Relevant~~ 127 | - ~~Splits~~ 128 | - ~~Time Series~~ 129 | - ~~Volume by Venue~~ 130 | 131 | **Reference Data:** 132 | - ~~Symbols~~ 133 | - ~~IEX Corporate Actions~~ 134 | - ~~IEX Dividends~~ 135 | - ~~IEX Next Day Ex Date~~ 136 | - ~~IEX Listed Symbol Directory~~ 137 | 138 | **IEX Market Data:** 139 | - TOPS 140 | - Last 141 | - HIST 142 | - DEEP 143 | - Book 144 | - Trades 145 | - System Event 146 | - Trading Status 147 | - Operational Hault Status 148 | - Short Sale Price Test Status 149 | - Security Event 150 | - Trade Break 151 | - Auction 152 | - Official Price 153 | 154 | **IEX Stats:** 155 | - ~~Intraday~~ 156 | - ~~Recent~~ 157 | - ~~Records~~ 158 | - ~~Historical Summary~~ 159 | - ~~Historical Daily~~ 160 | 161 | **Markets** 162 | - ~~Market~~ 163 | -------------------------------------------------------------------------------- /examples.cpp: -------------------------------------------------------------------------------- 1 | /* UNOFFICIAL IEX TRADING API WITH EXAMPLES for C++ 2 | BY: Justin Chudley 3 | https://github.com/Chudleyj/ 4 | OFFICIAL API: https://iextrading.com/developer/docs/ 5 | Refer to the official docs to understand the return of each function. 6 | GET examples and JSON examples commented above each function are from the offical API. 7 | ALL credit for those examples belongs to IEX. 8 | 9 | “Data provided for free by IEX (https://iextrading.com/developer/). 10 | View IEX’s Terms of Use (https://iextrading.com/api-exhibit-a/).” 11 | 12 | */ 13 | //TODO CHECK ALL SYMBOLS FOR VALID SYMBOL 14 | #include "IEX.h" 15 | 16 | /*THIS MAIN FUNCTION SHOULD NOT BE HERE, IF YOU ARE TRYING TO USE THE REAL API THEN DO NOT USE THIS FILE 17 | THIS IS FOR SHOWING EXAMPLES OF EACH FUNCTION ONLY */ 18 | int main(){ 19 | // curl_global_init(CURL_GLOBAL_DEFAULT); //TODO auto execute somewhere? 20 | Json::Value test; 21 | test = IEX::stocks::batch("aapl"); 22 | test = IEX::stocks::book("aapl"); 23 | test = IEX::stocks::chart("aapl"); 24 | test = IEX::stocks::chartRange("aapl", "1m"); 25 | test = IEX::stocks::chartDate("aapl", "20180801"); 26 | test = IEX::stocks::chartDynamic("aapl"); 27 | test = IEX::stocks::company("aapl"); 28 | test = IEX::stocks::delayedQuote("aapl"); 29 | test = IEX::stocks::dividends("aapl", "5y"); 30 | test = IEX::stocks::earnings("aapl"); 31 | test = IEX::stocks::effectiveSpread("aapl"); 32 | test = IEX::stocks::financials("aapl"); 33 | test = IEX::stocks::stats("aapl"); 34 | test = IEX::stocks::largestTrades("aapl"); 35 | test = IEX::stocks::list("gainers"); 36 | test = IEX::stocks::logo("aapl"); 37 | test = IEX::stocks::news("market", 5); 38 | test = IEX::stocks::news("market"); 39 | test = IEX::stocks::news("aapl"); 40 | test = IEX::stocks::OHLC("aapl"); 41 | test = IEX::stocks::OHLC("market"); 42 | test = IEX::stocks::peers("aapl"); 43 | test = IEX::stocks::previous("aapl"); 44 | test = IEX::stocks::previous("market"); 45 | test = IEX::stocks::price("aapl"); 46 | test = IEX::stocks::quote("aapl"); 47 | test = IEX::stocks::quote("aapl", true); 48 | test = IEX::stocks::relevant("aapl"); 49 | test = IEX::stocks::sectorPerformance(); 50 | test = IEX::stocks::relevant("aapl"); 51 | test = IEX::stocks::splits("aapl","5y"); 52 | test = IEX::stocks::timeSeries("aapl"); 53 | test = IEX::stocks::VolumeByVenue("aapl"); 54 | test = IEX::refData::symbols(); 55 | test = IEX::refData::corporateActions("20180907"); 56 | test = IEX::refData::corporateActions(); 57 | test = IEX::refData::dividends("20180907"); 58 | test = IEX::refData::dividends(); 59 | test = IEX::refData::nextDayExDate("20180907"); 60 | test = IEX::refData::nextDayExDate(); 61 | test = IEX::refData::symbolDirectory("20180907"); 62 | test = IEX::refData::symbolDirectory(); 63 | test = IEX::stats::intraday(); 64 | test = IEX::stats::recent(); 65 | test = IEX::stats::records(); 66 | test = IEX::stats::historical("20180907"); 67 | test = IEX::stats::historicalDaily("20180907"); 68 | test = IEX::stats::historicalDaily("5"); 69 | test = IEX::stats::historicalDaily(); 70 | test = IEX::markets::market(); 71 | test = IEX::stocks::crypto(); 72 | test = IEX::stocks::earningsToday(); 73 | test = IEX::stocks::upcomingIPOS(); 74 | test = IEX::stocks::todayIPOS(); 75 | std:: cout << test << std::endl << "DONE"; 76 | //curl_global_cleanup(); //TODO auto execute somewhere? 77 | } 78 | 79 | //Callback function used by sendGetRequest to get the result from curl. 80 | std::size_t callback(const char* in, std::size_t size, std::size_t num, std::string* out){ 81 | const std::size_t totalBytes(size * num); 82 | out->append(in, totalBytes); 83 | return totalBytes; 84 | } 85 | 86 | //Use LIBCURL to send the GET requests 87 | void IEX::sendGetRequest(Json::Value &jsonData, const std::string url){ 88 | CURL* curl = curl_easy_init(); 89 | 90 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); 91 | curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); 92 | curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); 93 | curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 94 | long int httpCode(0); //Having this as a normal int will cause a segmentation fault for some requests being too large. 95 | std::unique_ptr httpData(new std::string()); 96 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback); 97 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get()); 98 | curl_easy_perform(curl); 99 | curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode); 100 | curl_easy_cleanup(curl); 101 | 102 | Json::Reader jsonReader; 103 | jsonReader.parse(*httpData, jsonData); //TODO error handle 104 | } 105 | /* 106 | // .../market 107 | { 108 | "AAPL" : { 109 | "quote": {...}, 110 | "news": [...], 111 | "chart": [...] 112 | }, 113 | "FB" : { 114 | "quote": {...}, 115 | "news": [...], 116 | "chart": [...] 117 | }, 118 | } 119 | */ 120 | Json::Value IEX::stocks::batch(const std::string &symbol){ 121 | Json::Value jsonData; 122 | std::string url(IEX_ENDPOINT); 123 | url+="/stock/"+symbol+"/batch"; 124 | IEX::sendGetRequest(jsonData, url); 125 | assert(jsonData.isArray()); //Crash if not an array 126 | return jsonData; 127 | } 128 | 129 | /* GET /stock/{symbol}/book 130 | { 131 | "quote": {...}, 132 | "bids": [...], 133 | "asks": [...], 134 | "trades": [...], 135 | "systemEvent": {...}, 136 | } 137 | */ 138 | Json::Value IEX::stocks::book(const std::string &symbol){ 139 | Json::Value jsonData; 140 | std::string url(IEX_ENDPOINT); 141 | url+="/stock/"+symbol+"/book"; 142 | IEX::sendGetRequest(jsonData, url); 143 | assert(jsonData.isArray()); //Crash if not an array 144 | return jsonData; 145 | } 146 | 147 | /*GET /stock/{symbol}/chart/{range} 148 | // .../1d 149 | 150 | [ 151 | { 152 | "date": "20171215" 153 | "minute": "09:30", 154 | "label": "09:30 AM", 155 | "high": 143.98, 156 | "low": 143.775, 157 | "average": 143.889, 158 | "volume": 3070, 159 | "notional": 441740.275, 160 | "numberOfTrades": 20, 161 | "marktHigh": 143.98, 162 | "marketLow": 143.775, 163 | "marketAverage": 143.889, 164 | "marketVolume": 3070, 165 | "marketNotional": 441740.275, 166 | "marketNumberOfTrades": 20, 167 | "open": 143.98, 168 | "close": 143.775, 169 | "marktOpen": 143.98, 170 | "marketClose": 143.775, 171 | "changeOverTime": -0.0039, 172 | "marketChangeOverTime": -0.004 173 | } // , { ... } 174 | ] 175 | */ 176 | Json::Value IEX::stocks::chart(const std::string &symbol){ 177 | Json::Value jsonData; 178 | std::string url(IEX_ENDPOINT); 179 | url+="/stock/"+symbol+"/chart"; 180 | IEX::sendGetRequest(jsonData, url); 181 | assert(jsonData.isArray()); //Crash if not an array 182 | return jsonData; 183 | } 184 | 185 | //Same as chart function, except it takes a range in. 186 | //Range must be: 5y, 2y, 1y, ytd, 6m, 3m, 1m, 1d 187 | Json::Value IEX::stocks::chartRange(const std::string symbol, const std::string range){ 188 | Json::Value jsonData; 189 | if(range == "5y" || range == "2y" || range == "1y" || range == "ytd" || range == "6m" || range == "3m" || range == "1m" || range == "1d"){ 190 | std::string url(IEX_ENDPOINT); 191 | url+="/stock/"+symbol+"/chart/"+range; 192 | IEX::sendGetRequest(jsonData, url); 193 | } 194 | else{ 195 | std::cout << std::endl << "Incorrect 'range' input in function chartRange. Exiting." << std::endl; 196 | exit(1); 197 | } 198 | assert(jsonData.isArray()); //Crash if not an array 199 | return jsonData; 200 | } 201 | 202 | //Specific date entry for chart, YYYYMMDD format, 30 trailing calander days 203 | Json::Value IEX::stocks::chartDate(const std::string &symbol, const std::string &date){ 204 | Json::Value jsonData; 205 | if(date.size() == 8){ 206 | std::string url(IEX_ENDPOINT); 207 | url+="/stock/"+symbol+"/chart/date/"+date; 208 | IEX::sendGetRequest(jsonData, url); 209 | 210 | } 211 | else{ 212 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 213 | exit(1); 214 | } 215 | assert(jsonData.isArray()); //Crash if not an array 216 | return jsonData; 217 | } 218 | 219 | //Dynamic chart. See offical API docs. 220 | Json::Value IEX::stocks::chartDynamic(const std::string &symbol){ 221 | Json::Value jsonData; 222 | std::string url(IEX_ENDPOINT); 223 | url += "/stock/"+symbol+"/chart/dynamic"; 224 | IEX::sendGetRequest(jsonData, url); 225 | assert(jsonData.isArray()); //Crash if not an array 226 | return jsonData; 227 | } 228 | 229 | /* 230 | GET /stock/{symbol}/company 231 | { 232 | "symbol": "AAPL", 233 | "companyName": "Apple Inc.", 234 | "exchange": "Nasdaq Global Select", 235 | "industry": "Computer Hardware", 236 | "website": "http://www.apple.com", 237 | "description": "Apple Inc is an American multinational technology company. It designs, manufactures, and markets mobile communication and media devices, personal computers, and portable digital music players.", 238 | "CEO": "Timothy D. Cook", 239 | "issueType": "cs", 240 | "sector": "Technology", 241 | }*/ 242 | Json::Value IEX::stocks::company(const std::string &symbol){ 243 | Json::Value jsonData; 244 | std::string url(IEX_ENDPOINT); 245 | url += "/stock/"+symbol+"/company"; 246 | IEX::sendGetRequest(jsonData, url); 247 | assert(jsonData.isArray()); //Crash if not an array 248 | return jsonData; 249 | } 250 | 251 | /* 252 | GET /stock/{symbol}/delayed-quote 253 | { 254 | "symbol": "AAPL", 255 | "delayedPrice": 143.08, 256 | "delayedSize": 200, 257 | "delayedPriceTime": 1498762739791, 258 | "processedTime": 1498763640156 259 | }*/ 260 | Json::Value IEX::stocks::delayedQuote(const std::string &symbol){ 261 | Json::Value jsonData; 262 | std::string url(IEX_ENDPOINT); 263 | url += "/stock/"+symbol+"/delayed-quote"; 264 | IEX::sendGetRequest(jsonData, url); 265 | assert(jsonData.isArray()); //Crash if not an array 266 | return jsonData; 267 | } 268 | 269 | /* 270 | GET /stock/{symbol}/dividends/{range} 271 | [ 272 | { 273 | "exDate": "2017-08-10", 274 | "paymentDate": "2017-08-17", 275 | "recordDate": "2017-08-14", 276 | "declaredDate": "2017-08-01", 277 | "amount": 0.63, 278 | "type": "Dividend income", 279 | "qualified": "Q" 280 | } // , { ... } 281 | ] 282 | REQUIRES a range: 5y,2y,1y,ytd,6m,3m,1m */ 283 | Json::Value IEX::stocks::dividends(const std::string &symbol, const std::string &range){ 284 | Json::Value jsonData; 285 | if(range == "5y" || range == "2y" || range == "1y" || range == "ytd" || range == "6m" || range == "3m" || range == "1m"){ 286 | std::string url(IEX_ENDPOINT); 287 | url+="/stock/"+symbol+"/dividends/"+range; 288 | IEX::sendGetRequest(jsonData, url); 289 | } 290 | else{ 291 | std::cout << std::endl << "Incorrect 'range' input in function dividends. Exiting." << std::endl; 292 | exit(1); 293 | } 294 | assert(jsonData.isArray()); //Crash if not an array 295 | return jsonData; 296 | } 297 | 298 | /*GET /stock/{symbol}/earnings 299 | { 300 | "symbol": "AAPL", 301 | "earnings": [ 302 | { 303 | "actualEPS": 2.1, 304 | "consensusEPS": 2.02, 305 | "estimatedEPS": 2.02, 306 | "announceTime": "AMC", 307 | "numberOfEstimates": 14, 308 | "EPSSurpriseDollar": 0.08, 309 | "EPSReportDate": "2017-05-02", 310 | "fiscalPeriod": "Q2 2017", 311 | "fiscalEndDate": "2017-03-31", 312 | "yearAgo": 1.67, 313 | "yearAgoChangePercent": .30, 314 | "estimatedChangePercent": .28, 315 | "symbolId": 11 316 | }, 317 | { 318 | "actualEPS": 3.36, 319 | "consensusEPS": 3.22, 320 | "estimatedEPS": 3.22, 321 | "announceTime": "AMC", 322 | "numberOfEstimates": 15, 323 | "EPSSurpriseDollar": 0.14, 324 | "EPSReportDate": "2017-01-31", 325 | "fiscalPeriod": "Q1 2017", 326 | "fiscalEndDate": "2016-12-31", 327 | "yearAgo": 1.67, 328 | "yearAgoChangePercent": .30, 329 | "estimatedChangePercent": .28, 330 | "symbolId": 11 331 | }, 332 | ] 333 | }*/ 334 | Json::Value IEX::stocks::earnings(const std::string &symbol){ 335 | Json::Value jsonData; 336 | std::string url(IEX_ENDPOINT); 337 | url += "/stock/"+symbol+"/earnings"; 338 | IEX::sendGetRequest(jsonData, url); 339 | assert(jsonData.isArray()); //Crash if not an array 340 | return jsonData; 341 | } 342 | 343 | /*GET /stock/{symbol}/effective-spread 344 | [ 345 | { 346 | "volume": 4899, 347 | "venue": "XCHI", 348 | "venueName": "CHX", 349 | "effectiveSpread": 0.02253725, 350 | "effectiveQuoted": 0.9539362, 351 | "priceImprovement": 0.0008471116999999999 352 | }, 353 | { 354 | "volume": 9806133, 355 | "venue": "XBOS", 356 | "venueName": "NASDAQ BX", 357 | "effectiveSpread": 0.0127343, 358 | "effectiveQuoted": 0.9313967, 359 | "priceImprovement": 0.0007373158 360 | }, 361 | { 362 | "volume": 6102991, 363 | "venue": "IEXG", 364 | "venueName": "IEX", 365 | "effectiveSpread": 0.005881705, 366 | "effectiveQuoted": 0.4532043, 367 | "priceImprovement": 0.003949427 368 | } 369 | ]*/ 370 | Json::Value IEX::stocks::effectiveSpread(const std::string &symbol){ 371 | Json::Value jsonData; 372 | std::string url(IEX_ENDPOINT); 373 | url += "/stock/"+symbol+"/effective-spread"; 374 | IEX::sendGetRequest(jsonData, url); 375 | assert(jsonData.isArray()); //Crash if not an array 376 | return jsonData; 377 | } 378 | 379 | /*GET /stock/{symbol}/financials 380 | The above example will return JSON with the following keys 381 | 382 | { 383 | "symbol": "AAPL", 384 | "financials": [ 385 | { 386 | "reportDate": "2017-03-31", 387 | "grossProfit": 20591000000, 388 | "costOfRevenue": 32305000000, 389 | "operatingRevenue": 52896000000, 390 | "totalRevenue": 52896000000, 391 | "operatingIncome": 14097000000, 392 | "netIncome": 11029000000, 393 | "researchAndDevelopment": 2776000000, 394 | "operatingExpense": 6494000000, 395 | "currentAssets": 101990000000, 396 | "totalAssets": 334532000000, 397 | "totalLiabilities": 200450000000, 398 | "currentCash": 15157000000, 399 | "currentDebt": 13991000000, 400 | "totalCash": 67101000000, 401 | "totalDebt": 98522000000, 402 | "shareholderEquity": 134082000000, 403 | "cashChange": -1214000000, 404 | "cashFlow": 12523000000, 405 | "operatingGainsLosses": null 406 | } // , { ... } 407 | ] 408 | }*/ 409 | Json::Value IEX::stocks::financials(const std::string &symbol){ 410 | Json::Value jsonData; 411 | std::string url(IEX_ENDPOINT); 412 | url += "/stock/"+symbol+"/financials"; 413 | IEX::sendGetRequest(jsonData, url); 414 | assert(jsonData.isArray()); //Crash if not an array 415 | return jsonData; 416 | } 417 | 418 | /*GET /stock/{symbol}/stats 419 | { 420 | "companyName": "Apple Inc.", 421 | "marketcap": 760334287200, 422 | "beta": 1.295227, 423 | "week52high": 156.65, 424 | "week52low": 93.63, 425 | "week52change": 58.801903, 426 | "shortInterest": 55544287, 427 | "shortDate": "2017-06-15", 428 | "dividendRate": 2.52, 429 | "dividendYield": 1.7280395, 430 | "exDividendDate": "2017-05-11 00:00:00.0", 431 | "latestEPS": 8.29, 432 | "latestEPSDate": "2016-09-30", 433 | "sharesOutstanding": 5213840000, 434 | "float": 5203997571, 435 | "returnOnEquity": 0.08772939519857577, 436 | "consensusEPS": 3.22, 437 | "numberOfEstimates": 15, 438 | "symbol": "AAPL", 439 | "EBITDA": 73828000000, 440 | "revenue": 220457000000, 441 | "grossProfit": 84686000000, 442 | "cash": 256464000000, 443 | "debt": 358038000000, 444 | "ttmEPS": 8.55, 445 | "revenuePerShare": 42.2830389885382, 446 | "revenuePerEmployee": 1900491.3793103448, 447 | "peRatioHigh": 25.5, 448 | "peRatioLow": 8.7, 449 | "EPSSurpriseDollar": null, 450 | "EPSSurprisePercent": 3.9604, 451 | "returnOnAssets": 14.15, 452 | "returnOnCapital": null, 453 | "profitMargin": 20.73, 454 | "priceToSales": 3.6668503, 455 | "priceToBook": 6.19, 456 | "day200MovingAvg": 140.60541, 457 | "day50MovingAvg": 156.49678, 458 | "institutionPercent": 32.1, 459 | "insiderPercent": null, 460 | "shortRatio": 1.6915414, 461 | "year5ChangePercent": 0.5902546932200027, 462 | "year2ChangePercent": 0.3777449874142869, 463 | "year1ChangePercent": 0.39751716851558366, 464 | "ytdChangePercent": 0.36659492036160124, 465 | "month6ChangePercent": 0.12208398133748043, 466 | "month3ChangePercent": 0.08466584665846649, 467 | "month1ChangePercent": 0.009668596145283263, 468 | "day5ChangePercent": -0.005762605699968781 469 | }*/ 470 | Json::Value IEX::stocks::stats(const std::string &symbol){ 471 | Json::Value jsonData; 472 | std::string url(IEX_ENDPOINT); 473 | url += "/stock/"+symbol+"/stats"; 474 | IEX::sendGetRequest(jsonData, url); 475 | assert(jsonData.isArray()); //Crash if not an array 476 | return jsonData; 477 | } 478 | 479 | /*GET /stock/{symbol}/largest-trades 480 | [ 481 | { 482 | "price": 186.39, 483 | "size": 10000, 484 | "time": 1527090690175, 485 | "timeLabel": "11:51:30", 486 | "venue": "EDGX", 487 | "venueName": "Cboe EDGX" 488 | }, 489 | ... 490 | ] */ 491 | Json::Value IEX::stocks::largestTrades(const std::string &symbol){ 492 | Json::Value jsonData; 493 | std::string url(IEX_ENDPOINT); 494 | url += "/stock/"+symbol+"/largest-trades"; 495 | IEX::sendGetRequest(jsonData, url); 496 | assert(jsonData.isArray()); //Crash if not an array 497 | return jsonData; 498 | } 499 | 500 | /*GET /stock/market/list 501 | [ 502 | { 503 | "symbol": "AAPL", 504 | "companyName": "Apple Inc.", 505 | "primaryExchange": "Nasdaq Global Select", 506 | "sector": "Technology", 507 | "calculationPrice": "tops", 508 | "latestPrice": 158.73, 509 | "latestSource": "Previous close", 510 | "latestTime": "September 19, 2017", 511 | "latestUpdate": 1505779200000, 512 | "latestVolume": 20567140, 513 | "iexRealtimePrice": 158.71, 514 | "iexRealtimeSize": 100, 515 | "iexLastUpdated": 1505851198059, 516 | "delayedPrice": 158.71, 517 | "delayedPriceTime": 1505854782437, 518 | "previousClose": 158.73, 519 | "change": -1.67, 520 | "changePercent": -0.01158, 521 | "iexMarketPercent": 0.00948, 522 | "iexVolume": 82451, 523 | "avgTotalVolume": 29623234, 524 | "iexBidPrice": 153.01, 525 | "iexBidSize": 100, 526 | "iexAskPrice": 158.66, 527 | "iexAskSize": 100, 528 | "marketCap": 751627174400, 529 | "peRatio": 16.86, 530 | "week52High": 159.65, 531 | "week52Low": 93.63, 532 | "ytdChange": 0.3665, 533 | } // , { ... } 534 | ] 535 | LISTTYPE REQUIRED: mostactive, gainers, losers, iexvolume, or iexmarketpercent*/ 536 | Json::Value IEX::stocks::list(const std::string &listType){ 537 | Json::Value jsonData; 538 | if(listType == "mostactive" || listType == "gainers" || listType == "losers" || listType == "iexvolume" || listType == "iexmarketpercent"){ 539 | std::string url(IEX_ENDPOINT); 540 | url+="/stock/market/list/"+listType; 541 | IEX::sendGetRequest(jsonData, url); 542 | } 543 | else{ 544 | std::cout << std::endl << "Incorrect 'listType' input in function list. Exiting." << std::endl; 545 | exit(1); 546 | } 547 | assert(jsonData.isArray()); //Crash if not an array 548 | return jsonData; 549 | } 550 | 551 | /* 552 | GET /stock/{symbol}/logo 553 | { 554 | "url": "https://storage.googleapis.com/iex/api/logos/AAPL.png" 555 | }*/ 556 | Json::Value IEX::stocks::logo(const std::string &symbol){ 557 | Json::Value jsonData; 558 | std::string url(IEX_ENDPOINT); 559 | url += "/stock/"+symbol+"/logo"; 560 | IEX::sendGetRequest(jsonData, url); 561 | assert(jsonData.isArray()); //Crash if not an array 562 | return jsonData; 563 | } 564 | 565 | /* 566 | GET /stock/{symbol}/news/last/{last} 567 | 568 | [ 569 | { 570 | "datetime": "2017-06-29T13:14:22-04:00", 571 | "headline": "Voice Search Technology Creates A New Paradigm For Marketers", 572 | "source": "Benzinga via QuoteMedia", 573 | "url": "https://api.iextrading.com/1.0/stock/aapl/article/8348646549980454", 574 | "summary": "

Voice search is likely to grow by leap and bounds, with technological advancements leading to better adoption and fueling the growth cycle, according to Lindsay Boyajian, a guest contributor at Loup Ventu...", 575 | "related": "AAPL,AMZN,GOOG,GOOGL,MSFT", 576 | "image": "https://api.iextrading.com/1.0/stock/aapl/news-image/7594023985414148" 577 | } 578 | ] 579 | EITHER PASS A SYMBOL OR A SYMOL AND A NUMBER FOR LAST X ARTICLES (SEE OFFICAL DOCS) 580 | OR PASS MARKET AS SYMBOL FOR MARKETWIDE NEWS*/ 581 | Json::Value IEX::stocks::news(const std::string &symbol, int last){ 582 | Json::Value jsonData; 583 | std::string url(IEX_ENDPOINT); 584 | last == 0 ? url += "/stock/"+symbol+"/news" : url += "/stock/"+symbol+"/news/last/"+std::to_string(last); 585 | IEX::sendGetRequest(jsonData, url); 586 | assert(jsonData.isArray()); //Crash if not an array 587 | return jsonData; 588 | } 589 | 590 | /*GET /stock/{symbol}/ohlc 591 | { 592 | "open": { 593 | "price": 154, 594 | "time": 1506605400394 595 | }, 596 | "close": { 597 | "price": 153.28, 598 | "time": 1506605400394 599 | }, 600 | "high": 154.80, 601 | "low": 153.25 602 | } 603 | Can take in a specific symbol OR market as symbol */ 604 | Json::Value IEX::stocks::OHLC(const std::string &symbol){ 605 | Json::Value jsonData; 606 | std::string url(IEX_ENDPOINT); 607 | url += "/stock/"+symbol+"/ohlc"; 608 | IEX::sendGetRequest(jsonData, url); 609 | assert(jsonData.isArray()); //Crash if not an array 610 | return jsonData; 611 | } 612 | 613 | /* 614 | GET /stock/{symbol}/peers 615 | [ 616 | "MSFT", 617 | "NOK", 618 | "IBM", 619 | "BBRY", 620 | "HPQ", 621 | "GOOGL", 622 | "XLK" 623 | ] */ 624 | Json::Value IEX::stocks::peers(const std::string &symbol){ 625 | Json::Value jsonData; 626 | std::string url(IEX_ENDPOINT); 627 | url += "/stock/"+symbol+"/peers"; 628 | IEX::sendGetRequest(jsonData, url); 629 | assert(jsonData.isArray()); //Crash if not an array 630 | return jsonData; 631 | } 632 | 633 | /* 634 | GET /stock/{symbol}/previous 635 | { 636 | "symbol": "AAPL", 637 | "date": "2017-09-19", 638 | "open": 159.51, 639 | "high": 159.77, 640 | "low": 158.44, 641 | "close": 158.73, 642 | "volume": 20810632, 643 | "unadjustedVolume": 20810632, 644 | "change": 0.06, 645 | "changePercent": 0.038, 646 | "vwap": 158.9944 647 | } 648 | Takes symbol or market as symbol */ 649 | Json::Value IEX::stocks::previous(const std::string &symbol){ 650 | Json::Value jsonData; 651 | std::string url(IEX_ENDPOINT); 652 | url += "/stock/"+symbol+"/previous"; 653 | IEX::sendGetRequest(jsonData, url); 654 | assert(jsonData.isArray()); //Crash if not an array 655 | return jsonData; 656 | } 657 | 658 | // GET /stock/{symbol}/price 659 | Json::Value IEX::stocks::price(const std::string &symbol){ 660 | Json::Value jsonData; 661 | std::string url(IEX_ENDPOINT); 662 | url += "/stock/"+symbol+"/price"; 663 | IEX::sendGetRequest(jsonData, url); 664 | assert(jsonData.isArray()); //Crash if not an array 665 | return jsonData; 666 | } 667 | 668 | /* 669 | GET /stock/{symbol}/quote 670 | { 671 | "symbol": "AAPL", 672 | "companyName": "Apple Inc.", 673 | "primaryExchange": "Nasdaq Global Select", 674 | "sector": "Technology", 675 | "calculationPrice": "tops", 676 | "open": 154, 677 | "openTime": 1506605400394, 678 | "close": 153.28, 679 | "closeTime": 1506605400394, 680 | "high": 154.80, 681 | "low": 153.25, 682 | "latestPrice": 158.73, 683 | "latestSource": "Previous close", 684 | "latestTime": "September 19, 2017", 685 | "latestUpdate": 1505779200000, 686 | "latestVolume": 20567140, 687 | "iexRealtimePrice": 158.71, 688 | "iexRealtimeSize": 100, 689 | "iexLastUpdated": 1505851198059, 690 | "delayedPrice": 158.71, 691 | "delayedPriceTime": 1505854782437, 692 | "extendedPrice": 159.21, 693 | "extendedChange": -1.68, 694 | "extendedChangePercent": -0.0125, 695 | "extendedPriceTime": 1527082200361, 696 | "previousClose": 158.73, 697 | "change": -1.67, 698 | "changePercent": -0.01158, 699 | "iexMarketPercent": 0.00948, 700 | "iexVolume": 82451, 701 | "avgTotalVolume": 29623234, 702 | "iexBidPrice": 153.01, 703 | "iexBidSize": 100, 704 | "iexAskPrice": 158.66, 705 | "iexAskSize": 100, 706 | "marketCap": 751627174400, 707 | "peRatio": 16.86, 708 | "week52High": 159.65, 709 | "week52Low": 93.63, 710 | "ytdChange": 0.3665, 711 | } 712 | OPTIONAL VALUE TO DISPLAY PERCENT, SEE OFFICAL API */ 713 | Json::Value IEX::stocks::quote(const std::string &symbol, bool displayPercent){ 714 | Json::Value jsonData; 715 | std::string url(IEX_ENDPOINT); 716 | displayPercent ? url += "/stock/"+symbol+"/quote?displayPercent=true" : url += "/stock/"+symbol+"/quote"; 717 | IEX::sendGetRequest(jsonData, url); 718 | assert(jsonData.isArray()); //Crash if not an array 719 | return jsonData; 720 | } 721 | 722 | /* 723 | GET /stock/{symbol}/relevant 724 | { 725 | "peers": true, 726 | "symbols": [ 727 | "MSFT", 728 | "NOK", 729 | "IBM", 730 | "BBRY", 731 | "HPQ", 732 | "GOOGL", 733 | "XLK" 734 | ] 735 | }*/ 736 | Json::Value IEX::stocks::relevant(const std::string &symbol){ 737 | Json::Value jsonData; 738 | std::string url(IEX_ENDPOINT); 739 | url += "/stock/"+symbol+"/relevant"; 740 | IEX::sendGetRequest(jsonData, url); 741 | assert(jsonData.isArray()); //Crash if not an array 742 | return jsonData; 743 | } 744 | 745 | /* 746 | GET /stock/market/sector-performance 747 | [ 748 | { 749 | "type": "sector", 750 | "name": "Industrials", 751 | "performance": 0.00711, 752 | "lastUpdated": 1533672000437 753 | }, 754 | ... 755 | ]*/ 756 | Json::Value IEX::stocks::sectorPerformance(){ 757 | Json::Value jsonData; 758 | std::string url(IEX_ENDPOINT); 759 | url += "/stock/market/sector-performance"; 760 | IEX::sendGetRequest(jsonData, url); 761 | assert(jsonData.isArray()); //Crash if not an array 762 | return jsonData; 763 | } 764 | 765 | /* 766 | GET /stock/{symbol}/splits/{range} 767 | [ 768 | { 769 | "exDate": "2017-08-10", 770 | "declaredDate": "2017-08-01", 771 | "recordDate": "2017-08-14", 772 | "paymentDate": "2017-08-17", 773 | "ratio": 0.142857, 774 | "toFactor": 7, 775 | "forFactor": 1 776 | } // , { ... } 777 | ]*/ 778 | Json::Value IEX::stocks::splits(const std::string &symbol, const std::string &range){ 779 | Json::Value jsonData; 780 | std::string url(IEX_ENDPOINT); 781 | 782 | if(range == "5y" || range == "2y" || range == "1y" || range == "ytd" || range == "6m" || range == "3m" || range == "1m" || range == "1d"){ 783 | url += "/stock/"+symbol+"/splits/"+range; 784 | IEX::sendGetRequest(jsonData, url); 785 | } 786 | else{ 787 | std::cout << std::endl << "Incorrect 'range' input in function chartRange. Exiting." << std::endl; 788 | exit(1); 789 | } 790 | 791 | IEX::sendGetRequest(jsonData, url); 792 | assert(jsonData.isArray()); //Crash if not an array 793 | return jsonData; 794 | } 795 | 796 | //GET /stock/{symbol}/time-series 797 | Json::Value IEX::stocks::timeSeries(const std::string &symbol){ 798 | Json::Value jsonData; 799 | std::string url(IEX_ENDPOINT); 800 | url += "/stock/"+symbol+"/time-series"; 801 | IEX::sendGetRequest(jsonData, url); 802 | assert(jsonData.isArray()); //Crash if not an array 803 | return jsonData; 804 | } 805 | 806 | /* 807 | GET /stock/{symbol}/delayed-quote 808 | [ 809 | { 810 | "volume": 0, 811 | "venue": "XNYS", 812 | "venueName": "NYSE", 813 | "marketPercent": 0, 814 | "avgMarketPercent": 0, 815 | "date": "N/A" 816 | }, 817 | { 818 | "volume": 21655, 819 | "venue": "XASE", 820 | "venueName": "NYSE American", 821 | "date": "2017-09-19", 822 | "marketPercent": 0.0010540470343969304, 823 | "avgMarketPercent": 0.0021596513337820305 824 | }, 825 | { 826 | "volume": 164676, 827 | "venue": "EDGA", 828 | "venueName": "EDGA", 829 | "date": "2017-09-19", 830 | "marketPercent": 0.008015527565751508, 831 | "avgMarketPercent": 0.007070162857518009 832 | }, 833 | { 834 | "volume": 253600, 835 | "venue": "XCHI", 836 | "venueName": "CHX", 837 | "date": "2017-09-19", 838 | "marketPercent": 0.01234386182974193, 839 | "avgMarketPercent": 0.019123040706393757 840 | }, 841 | { 842 | "volume": 289791, 843 | "venue": "IEXG", 844 | "venueName": "IEX", 845 | "date": "2017-09-19", 846 | "marketPercent": 0.014105441890783691, 847 | "avgMarketPercent": 0.01080806673166022 848 | }, 849 | { 850 | "volume": 311580, 851 | "venue": "XPHL", 852 | "venueName": "NASDAQ PSX", 853 | "date": "2017-09-19", 854 | "marketPercent": 0.0151660113127405, 855 | "avgMarketPercent": 0.010991446666811688 856 | }, 857 | { 858 | "volume": 479457, 859 | "venue": "XBOS", 860 | "venueName": "NASDAQ BX", 861 | "date": "2017-09-19", 862 | "marketPercent": 0.02333734606191868, 863 | "avgMarketPercent": 0.016846380315025656 864 | }, 865 | { 866 | "volume": 501842, 867 | "venue": "BATY", 868 | "venueName": "BATS BYX", 869 | "date": "2017-09-19", 870 | "marketPercent": 0.024426925506156744, 871 | "avgMarketPercent": 0.020187355701732888 872 | }, 873 | { 874 | "volume": 1242757, 875 | "venue": "BATS", 876 | "venueName": "BATS BZX", 877 | "date": "2017-09-19", 878 | "marketPercent": 0.06049061788621685, 879 | "avgMarketPercent": 0.060993172098918684 880 | }, 881 | { 882 | "volume": 1865376, 883 | "venue": "ARCX", 884 | "venueName": "NYSE Arca", 885 | "date": "2017-09-19", 886 | "marketPercent": 0.09079630758878819, 887 | "avgMarketPercent": 0.07692002795005641 888 | }, 889 | { 890 | "volume": 1951116, 891 | "venue": "EDGX", 892 | "venueName": "EDGX", 893 | "date": "2017-09-19", 894 | "marketPercent": 0.09496966213643043, 895 | "avgMarketPercent": 0.09297590135910822 896 | }, 897 | { 898 | "volume": 5882545, 899 | "venue": "XNGS", 900 | "venueName": "NASDAQ", 901 | "date": "2017-09-19", 902 | "marketPercent": 0.2863301367793346, 903 | "avgMarketPercent": 0.27436519408402665 904 | }, 905 | { 906 | "volume": 7580229, 907 | "venue": "TRF", 908 | "venueName": "Off Exchange", 909 | "date": "2017-09-19", 910 | "marketPercent": 0.36896411440773996, 911 | "avgMarketPercent": 0.40847022134435956 912 | } 913 | ]*/ 914 | Json::Value IEX::stocks::VolumeByVenue(const std::string &symbol){ 915 | Json::Value jsonData; 916 | std::string url(IEX_ENDPOINT); 917 | url += "/stock/"+symbol+"/volume-by-venue"; 918 | IEX::sendGetRequest(jsonData, url); 919 | assert(jsonData.isArray()); //Crash if not an array 920 | return jsonData; 921 | } 922 | 923 | /* 924 | GET /ref-data/daily-list/symbol-directory 925 | [ 926 | { 927 | "RecordID": " CA20171108153808144", 928 | "DailyListTimestamp": "2017-11-08T17:00:00", 929 | "EffectiveDate": "2017-11-10", 930 | "IssueEvent": "AA", 931 | "CurrentSymbolinINETSymbology": "ZEXIT-", 932 | "CurrentSymbolinCQSSymbology": "ZEXITp", 933 | "CurrentSymbolinCMSSymbology": "ZEXIT PR", 934 | "NewSymbolinINETSymbology": "", 935 | "NewSymbolinCQSSymbology": "", 936 | "NewSymbolinCMSSymbology": "", 937 | "CurrentSecurityName": "ZEXIT Preffered Stock", 938 | "NewSecurityName": "", 939 | "CurrentCompanyName": "ZEXIT Test Company", 940 | "NewCompanyName": "", 941 | "CurrentListingCenter": "", 942 | "NewListingCenter": "V", 943 | "DelistingReason": "", 944 | "CurrentRoundLotSize": "100", 945 | "NewRoundLotSize": "", 946 | "CurrentLULDTierIndicator": "0", 947 | "NewLULDTierIndicator": "", 948 | "ExpirationDate": "0", 949 | "SeparationDate": "0", 950 | "SettlementDate": "0", 951 | "MaturityDate": "0", 952 | "RedemptionDate": "0", 953 | "CurrentFinancialStatus": "0", 954 | "NewFinancialStatus": "", 955 | "WhenIssuedFlag": "N", 956 | "WhenDistributedFlag": "N", 957 | "IPOFlag": "N", 958 | "NotesforEachEntry": "New preferred ZIEXT security", 959 | "RecordUpdateTime": "2017-11-08T16:34:43" 960 | }, 961 | {...} 962 | ]*/ 963 | Json::Value IEX::refData::symbols(){ 964 | Json::Value jsonData; 965 | std::string url(IEX_ENDPOINT); 966 | url += "/ref-data/symbols"; 967 | IEX::sendGetRequest(jsonData, url); 968 | assert(jsonData.isArray()); //Crash if not an array 969 | return jsonData; 970 | } 971 | 972 | /* 973 | GET /ref-data/daily-list/symbol-directory 974 | [ 975 | { 976 | "RecordID": " CA20171108153808144", 977 | "DailyListTimestamp": "2017-11-08T17:00:00", 978 | "EffectiveDate": "2017-11-10", 979 | "IssueEvent": "AA", 980 | "CurrentSymbolinINETSymbology": "ZEXIT-", 981 | "CurrentSymbolinCQSSymbology": "ZEXITp", 982 | "CurrentSymbolinCMSSymbology": "ZEXIT PR", 983 | "NewSymbolinINETSymbology": "", 984 | "NewSymbolinCQSSymbology": "", 985 | "NewSymbolinCMSSymbology": "", 986 | "CurrentSecurityName": "ZEXIT Preffered Stock", 987 | "NewSecurityName": "", 988 | "CurrentCompanyName": "ZEXIT Test Company", 989 | "NewCompanyName": "", 990 | "CurrentListingCenter": "", 991 | "NewListingCenter": "V", 992 | "DelistingReason": "", 993 | "CurrentRoundLotSize": "100", 994 | "NewRoundLotSize": "", 995 | "CurrentLULDTierIndicator": "0", 996 | "NewLULDTierIndicator": "", 997 | "ExpirationDate": "0", 998 | "SeparationDate": "0", 999 | "SettlementDate": "0", 1000 | "MaturityDate": "0", 1001 | "RedemptionDate": "0", 1002 | "CurrentFinancialStatus": "0", 1003 | "NewFinancialStatus": "", 1004 | "WhenIssuedFlag": "N", 1005 | "WhenDistributedFlag": "N", 1006 | "IPOFlag": "N", 1007 | "NotesforEachEntry": "New preferred ZIEXT security", 1008 | "RecordUpdateTime": "2017-11-08T16:34:43" 1009 | }, 1010 | {...} 1011 | ]*/ 1012 | Json::Value IEX::refData::corporateActions(std::string date){ 1013 | Json::Value jsonData; 1014 | std::string url(IEX_ENDPOINT); 1015 | 1016 | if(!date.empty()){ 1017 | if(date.size() == 8){ 1018 | url += "/ref-data/daily-list/corporate-actions/"+date; 1019 | IEX::sendGetRequest(jsonData, url); 1020 | } 1021 | else{ 1022 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1023 | exit(1); 1024 | } 1025 | } 1026 | 1027 | else{ 1028 | url += "/ref-data/daily-list/corporate-actions"; 1029 | IEX::sendGetRequest(jsonData, url); 1030 | } 1031 | assert(jsonData.isArray()); //Crash if not an array 1032 | return jsonData; 1033 | } 1034 | 1035 | /* 1036 | GET /ref-data/daily-list/dividends 1037 | [ 1038 | { 1039 | "RecordID": " DV20171108154436478", 1040 | "DailyListTimestamp": "2017-11-08T17:00:00", 1041 | "EventType": "CHANGE", 1042 | "SymbolinINETSymbology": "ZEXIT", 1043 | "SymbolinCQSSymbology": "ZEXIT", 1044 | "SymbolinCMSSymbology": "ZEXIT", 1045 | "SecurityName": "ZEXIT Common Stock", 1046 | "CompanyName": "ZEXIT Test Company", 1047 | "DeclarationDate": "2017-11-01", 1048 | "AmountDescription": "fnl", 1049 | "PaymentFrequency": "O", 1050 | "ExDate": "2017-11-09", 1051 | "RecordDate": "2017-11-13", 1052 | "PaymentDate": "2017-11-17", 1053 | "DividendTypeID": "XS", 1054 | "StockAdjustmentFactor": "1.1", 1055 | "StockAmount": ".1", 1056 | "CashAmount": "0", 1057 | "PostSplitShares": "0", 1058 | "PreSplitShares": "0", 1059 | "QualifiedDividend": "Y", 1060 | "ExercisePriceAmount": "0", 1061 | "ElectionorExpirationDate": "0", 1062 | "GrossAmount": "0", 1063 | "NetAmount": "0", 1064 | "BasisNotes": "", 1065 | "NotesforEachEntry": "ZEXIT is paying a 10% stock dividend", 1066 | "RecordUpdateTime": "2017-11-08T16:48:47" 1067 | }, 1068 | {...} 1069 | ]*/ 1070 | Json::Value IEX::refData::dividends(std::string date){ 1071 | Json::Value jsonData; 1072 | std::string url(IEX_ENDPOINT); 1073 | if(!date.empty()){ 1074 | if(date.size() == 8){ 1075 | url += "/ref-data/daily-list/dividends/"+date; 1076 | IEX::sendGetRequest(jsonData, url); 1077 | } 1078 | else{ 1079 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1080 | exit(1); 1081 | } 1082 | } 1083 | 1084 | else{ 1085 | url += "/ref-data/daily-list/dividends"; 1086 | IEX::sendGetRequest(jsonData, url); 1087 | } 1088 | assert(jsonData.isArray()); //Crash if not an array 1089 | return jsonData; 1090 | } 1091 | 1092 | /* 1093 | GET /ref-data/daily-list/next-day-ex-date 1094 | [ 1095 | { 1096 | "RecordID": " DV20171108154436478", 1097 | "DailyListTimestamp": "2017-11-08T17:00:00", 1098 | "ExDate": "2017-11-09", 1099 | "SymbolinINETSymbology": "ZEXIT", 1100 | "SymbolinCQSSymbology": "ZEXIT", 1101 | "SymbolinCMSSymbology": "ZEXIT", 1102 | "SecurityName": "ZEXIT Common Stock", 1103 | "CompanyName": "ZEXIT Test Company", 1104 | "DividendTypeID": "XS", 1105 | "AmountDescription": "fnl", 1106 | "PaymentFrequency": "O", 1107 | "StockAdjustmentFactor": "1.1", 1108 | "StockAmount": ".1", 1109 | "CashAmount": "0", 1110 | "PostSplitShares": "0", 1111 | "PreSplitShares": "0", 1112 | "QualifiedDividend": "Y", 1113 | "ExercisePriceAmount": "0", 1114 | "ElectionorExpirationDate": "0", 1115 | "GrossAmount": "0", 1116 | "NetAmount": "0", 1117 | "BasisNotes": "", 1118 | "NotesforEachEntry": "ZEXIT is paying a 10% stock dividend", 1119 | "RecordUpdateTime": "2017-11-08T16:48:47" 1120 | }, 1121 | {...} 1122 | ]*/ 1123 | Json::Value IEX::refData::nextDayExDate(std::string date){ 1124 | Json::Value jsonData; 1125 | std::string url(IEX_ENDPOINT); 1126 | if(!date.empty()){ 1127 | if(date.size() == 8){ 1128 | url += "/ref-data/daily-list/next-day-ex-date/"+date; 1129 | IEX::sendGetRequest(jsonData, url); 1130 | } 1131 | else{ 1132 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1133 | exit(1); 1134 | } 1135 | } 1136 | 1137 | else{ 1138 | url += "/ref-data/daily-list/next-day-ex-date"; 1139 | IEX::sendGetRequest(jsonData, url); 1140 | } 1141 | assert(jsonData.isArray()); //Crash if not an array 1142 | return jsonData; 1143 | } 1144 | 1145 | /* 1146 | GET /ref-data/daily-list/symbol-directory 1147 | [ 1148 | { 1149 | "RecordID": "SD20171020161150890", 1150 | "DailyListTimestamp": "2017-12-18T09:00:00", 1151 | "SymbolinINETSymbology": "ZEXIT", 1152 | "SymbolinCQSSymbology": "ZEXIT", 1153 | "SymbolinCMSSymbology": "ZEXIT", 1154 | "SecurityName": "ZEXIT Common Stock", 1155 | "CompanyName": "ZEXIT Test Company", 1156 | "TestIssue": "Y", 1157 | "IssueDescription": "Common Stock", 1158 | "IssueType": "C", 1159 | "IssueSubType": "C", 1160 | "SICCode": "5678", 1161 | "TransferAgent": "American Stock Transfer", 1162 | "FinancialStatus": "0", 1163 | "RoundLotSize": "100", 1164 | "PreviousOfficialClosingPrice": "10.00", 1165 | "AdjustedPreviousOfficialClosingPrice": "10.00", 1166 | "WhenIssuedFlag": "N", 1167 | "WhenDistributedFlag": "N", 1168 | "IPOFlag": "N", 1169 | "FirstDateListed": "2017-09-15", 1170 | "LULDTierIndicator": "1", 1171 | "CountryofIncorporation": "USA", 1172 | "LeveragedETPFlag": "N", 1173 | "LeveragedETPRatio": "0", 1174 | "InverseETPFlag": "N", 1175 | "RecordUpdateTime": "2017-11-10T16:28:56" 1176 | }, 1177 | {...} 1178 | ]*/ 1179 | Json::Value IEX::refData::symbolDirectory(std::string date){ 1180 | Json::Value jsonData; 1181 | std::string url(IEX_ENDPOINT); 1182 | if(!date.empty()){ 1183 | if(date.size() == 8){ 1184 | url += "/ref-data/daily-list/symbol-directory/"+date; 1185 | IEX::sendGetRequest(jsonData, url); 1186 | } 1187 | else{ 1188 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1189 | exit(1); 1190 | } 1191 | } 1192 | 1193 | else{ 1194 | url += "/ref-data/daily-list/symbol-directory"; 1195 | IEX::sendGetRequest(jsonData, url); 1196 | } 1197 | assert(jsonData.isArray()); //Crash if not an array 1198 | return jsonData; 1199 | } 1200 | 1201 | /* 1202 | GET /stats/intraday 1203 | { 1204 | "volume": { 1205 | "value": 26908038, 1206 | "lastUpdated": 1480433817323 1207 | }, 1208 | "symbolsTraded": { 1209 | "value": 4089, 1210 | "lastUpdated": 1480433817323 1211 | }, 1212 | "routedVolume": { 1213 | "value": 10879651, 1214 | "lastUpdated": 1480433816891 1215 | }, 1216 | "notional": { 1217 | "value": 1090683735, 1218 | "lastUpdated": 1480433817323 1219 | }, 1220 | "marketShare": { 1221 | "value": 0.01691, 1222 | "lastUpdated": 1480433817336 1223 | } 1224 | }*/ 1225 | Json::Value IEX::stats::intraday(){ 1226 | Json::Value jsonData; 1227 | std::string url(IEX_ENDPOINT); 1228 | url += "/stats/intraday"; 1229 | IEX::sendGetRequest(jsonData, url); 1230 | assert(jsonData.isArray()); //Crash if not an array 1231 | return jsonData; 1232 | } 1233 | 1234 | /* 1235 | GET /stats/recent 1236 | [ 1237 | { 1238 | "date": "2017-01-11", 1239 | "volume": 128048723, 1240 | "routedVolume": 38314207, 1241 | "marketShare": 0.01769, 1242 | "isHalfday": false, 1243 | "litVolume": 30520534 1244 | }, 1245 | { 1246 | "date": "2017-01-10", 1247 | "volume": 135116521, 1248 | "routedVolume": 39329019, 1249 | "marketShare": 0.01999, 1250 | "isHalfday": false, 1251 | "litVolume": 29721789 1252 | }, 1253 | { 1254 | "date": "2017-01-09", 1255 | "volume": 109850518, 1256 | "routedVolume": 31283422, 1257 | "marketShare": 0.01704, 1258 | "isHalfday": false, 1259 | "litVolume": 27699365 1260 | }, 1261 | { 1262 | "date": "2017-01-06", 1263 | "volume": 116680433, 1264 | "routedVolume": 29528471, 1265 | "marketShare": 0.01805, 1266 | "isHalfday": false, 1267 | "litVolume": 29357729 1268 | }, 1269 | { 1270 | "date": "2017-01-05", 1271 | "volume": 130389657, 1272 | "routedVolume": 40977180, 1273 | "marketShare": 0.01792, 1274 | "isHalfday": false, 1275 | "litVolume": 33169236 1276 | }, 1277 | { 1278 | "date": "2017-01-04", 1279 | "volume": 124428433, 1280 | "routedVolume": 38859989, 1281 | "marketShare": 0.01741, 1282 | "isHalfday": false, 1283 | "litVolume": 31563256 1284 | }, 1285 | { 1286 | "date": "2017-01-03", 1287 | "volume": 130195733, 1288 | "routedVolume": 34990159, 1289 | "marketShare": 0.01733, 1290 | "isHalfday": false, 1291 | "litVolume": 34150804 1292 | } 1293 | ]*/ 1294 | Json::Value IEX::stats::recent(){ 1295 | Json::Value jsonData; 1296 | std::string url(IEX_ENDPOINT); 1297 | url += "/stats/recent"; 1298 | IEX::sendGetRequest(jsonData, url); 1299 | assert(jsonData.isArray()); //Crash if not an array 1300 | return jsonData; 1301 | } 1302 | 1303 | /* 1304 | GET /stats/records 1305 | { 1306 | "volume": { 1307 | "recordValue": 233000477, 1308 | "recordDate": "2016-01-20", 1309 | "previousDayValue": 99594714, 1310 | "avg30Value": 138634204.5 1311 | }, 1312 | "symbolsTraded": { 1313 | "recordValue": 6046, 1314 | "recordDate": "2016-11-10", 1315 | "previousDayValue": 5500, 1316 | "avg30Value": 5617 1317 | }, 1318 | "routedVolume": { 1319 | "recordValue": 74855222, 1320 | "recordDate": "2016-11-10", 1321 | "previousDayValue": 29746476, 1322 | "avg30Value": 44520084 1323 | }, 1324 | "notional": { 1325 | "recordValue": 9887832327.8355, 1326 | "recordDate": "2016-11-10", 1327 | "previousDayValue": 4175710684.3897, 1328 | "avg30Value": 5771412969.2662 1329 | } 1330 | }*/ 1331 | Json::Value IEX::stats::records(){ 1332 | Json::Value jsonData; 1333 | std::string url(IEX_ENDPOINT); 1334 | url += "/stats/records"; 1335 | IEX::sendGetRequest(jsonData, url); 1336 | assert(jsonData.isArray()); //Crash if not an array 1337 | return jsonData; 1338 | } 1339 | 1340 | /* 1341 | GET /stats/historical?date=201605 1342 | [ 1343 | { 1344 | "averageDailyVolume": 112247378.5, 1345 | "averageDailyRoutedVolume": 34282226.24, 1346 | "averageMarketShare": 0, 1347 | "averageOrderSize": 493, 1348 | "averageFillSize": 287, 1349 | "bin100Percent": 0.61559, 1350 | "bin101Percent": 0.61559, 1351 | "bin200Percent": 0.61559, 1352 | "bin300Percent": 0.61559, 1353 | "bin400Percent": 0.61559, 1354 | "bin500Percent": 0.61559, 1355 | "bin1000Percent": 0.61559, 1356 | "bin5000Percent": 0.61559, 1357 | "bin10000Percent": 0.61559, 1358 | "bin10000Trades": 4666, 1359 | "bin20000Trades": 1568, 1360 | "bin50000Trades": 231, 1361 | "uniqueSymbolsTraded": 7419, 1362 | "blockPercent": 0.08159, 1363 | "selfCrossPercent": 0.02993, 1364 | "etfPercent": 0.12646, 1365 | "largeCapPercent": 0.40685, 1366 | "midCapPercent": 0.2806, 1367 | "smallCapPercent": 0.18609, 1368 | "venueARCXFirstWaveWeight": 0.22063, 1369 | "venueBATSFirstWaveWeight": 0.06249, 1370 | "venueBATYFirstWaveWeight": 0.07361, 1371 | "venueEDGAFirstWaveWeight": 0.01083, 1372 | "venueEDGXFirstWaveWeight": 0.0869, 1373 | "venueOverallFirstWaveWeight": 1, 1374 | "venueXASEFirstWaveWeight": 0.00321, 1375 | "venueXBOSFirstWaveWeight": 0.02935, 1376 | "venueXCHIFirstWaveWeight": 0.00108, 1377 | "venueXCISFirstWaveWeight": 0.00008, 1378 | "venueXNGSFirstWaveWeight": 0.20358, 1379 | "venueXNYSFirstWaveWeight": 0.29313, 1380 | "venueXPHLFirstWaveWeight": 0.01511, 1381 | "venueARCXFirstWaveRate": 0.97737, 1382 | "venueBATSFirstWaveRate": 0.99357, 1383 | "venueBATYFirstWaveRate": 0.99189, 1384 | "venueEDGAFirstWaveRate": 0.98314, 1385 | "venueEDGXFirstWaveRate": 0.99334, 1386 | "venueOverallFirstWaveRate": 0.98171, 1387 | "venueXASEFirstWaveRate": 0.94479, 1388 | "venueXBOSFirstWaveRate": 0.97829, 1389 | "venueXCHIFirstWaveRate": 0.65811, 1390 | "venueXCISFirstWaveRate": 0.9468, 1391 | "venueXNGSFirstWaveRate": 0.98174, 1392 | "venueXNYSFirstWaveRate": 0.98068, 1393 | "venueXPHLFirstWaveRate": 0.93629 1394 | } 1395 | ]*/ 1396 | Json::Value IEX::stats::historical(std::string date){ 1397 | Json::Value jsonData; 1398 | std::string url(IEX_ENDPOINT); 1399 | if(!date.empty()){ 1400 | if(date.size() == 8){ 1401 | url += "/stats/historical/"+date; 1402 | IEX::sendGetRequest(jsonData, url); 1403 | } 1404 | else{ 1405 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1406 | exit(1); 1407 | } 1408 | } 1409 | 1410 | else{ 1411 | url += "/stats/historical/"; 1412 | IEX::sendGetRequest(jsonData, url); 1413 | } 1414 | assert(jsonData.isArray()); //Crash if not an array 1415 | return jsonData; 1416 | } 1417 | 1418 | /* 1419 | GET /stats/historical/daily?last=5 1420 | [ 1421 | { 1422 | "date": "2017-05-09", 1423 | "volume": 152907569, 1424 | "routedVolume": 46943802, 1425 | "marketShare": 0.02246, 1426 | "isHalfday": 0, 1427 | "litVolume": 35426666 1428 | }, 1429 | { 1430 | "date": "2017-05-08", 1431 | "volume": 142923030, 1432 | "routedVolume": 39507295, 1433 | "marketShare": 0.02254, 1434 | "isHalfday": 0, 1435 | "litVolume": 32404585 1436 | }, 1437 | { 1438 | "date": "2017-05-05", 1439 | "volume": 155118117, 1440 | "routedVolume": 39974788, 1441 | "marketShare": 0.02358, 1442 | "isHalfday": 0, 1443 | "litVolume": 35124994 1444 | }, 1445 | { 1446 | "date": "2017-05-04", 1447 | "volume": 185715463, 1448 | "routedVolume": 56264408, 1449 | "marketShare": 0.02352, 1450 | "isHalfday": 0, 1451 | "litVolume": 40634976 1452 | }, 1453 | { 1454 | "date": "2017-05-03", 1455 | "volume": 183103198, 1456 | "routedVolume": 50953175, 1457 | "marketShare": 0.025009999999999998, 1458 | "isHalfday": 0, 1459 | "litVolume": 40296158 1460 | } 1461 | ] 1462 | EITHER TAKES JUST A SYMBOL, OR SYMBOL AND DATE, OR SYMBOL AND LAST X (UP TO 90)*/ 1463 | Json::Value IEX::stats::historicalDaily(std::string date){ 1464 | Json::Value jsonData; 1465 | std::string url(IEX_ENDPOINT); 1466 | std::locale loc; //For isdigit 1467 | if(!date.empty()){ 1468 | if(date.size() == 8){ 1469 | url += "/stats/historical/daily?date="+date; 1470 | IEX::sendGetRequest(jsonData, url); 1471 | } 1472 | else if(isdigit(date[0],loc)){ 1473 | url += "/stats/historical/daily?last="+date; 1474 | IEX::sendGetRequest(jsonData, url); 1475 | } 1476 | else{ 1477 | std::cout << std::endl << "Incorrect 'date' input in function chartDate. Exiting." << std::endl; 1478 | exit(1); 1479 | } 1480 | } 1481 | 1482 | else{ 1483 | url += "/stats/historical/daily"; 1484 | IEX::sendGetRequest(jsonData, url); 1485 | } 1486 | assert(jsonData.isArray()); //Crash if not an array 1487 | return jsonData; 1488 | } 1489 | 1490 | /* 1491 | GET /market 1492 | [ 1493 | { 1494 | "mic": "TRF", 1495 | "tapeId": "-", 1496 | "venueName": "TRF Volume", 1497 | "volume": 589171705, 1498 | "tapeA": 305187928, 1499 | "tapeB": 119650027, 1500 | "tapeC": 164333750, 1501 | "marketPercent": 0.37027, 1502 | "lastUpdated": 1480433817317 1503 | }, 1504 | { 1505 | "mic": "XNGS", 1506 | "tapeId": "Q", 1507 | "venueName": "NASDAQ", 1508 | "volume": 213908393, 1509 | "tapeA": 90791123, 1510 | "tapeB": 30731818, 1511 | "tapeC": 92385452, 1512 | "marketPercent": 0.13443, 1513 | "lastUpdated": 1480433817311 1514 | }, 1515 | { 1516 | "mic": "XNYS", 1517 | "tapeId": "N", 1518 | "venueName": "NYSE", 1519 | "volume": 204280163, 1520 | "tapeA": 204280163, 1521 | "tapeB": 0, 1522 | "tapeC": 0, 1523 | "marketPercent": 0.12838, 1524 | "lastUpdated": 1480433817336 1525 | }, 1526 | { 1527 | "mic": "ARCX", 1528 | "tapeId": "P", 1529 | "venueName": "NYSE Arca", 1530 | "volume": 180301371, 1531 | "tapeA": 64642458, 1532 | "tapeB": 78727208, 1533 | "tapeC": 36931705, 1534 | "marketPercent": 0.11331, 1535 | "lastUpdated": 1480433817305 1536 | }, 1537 | { 1538 | "mic": "EDGX", 1539 | "tapeId": "K", 1540 | "venueName": "EDGX", 1541 | "volume": 137022822, 1542 | "tapeA": 58735505, 1543 | "tapeB": 32753903, 1544 | "tapeC": 45533414, 1545 | "marketPercent": 0.08611, 1546 | "lastUpdated": 1480433817310 1547 | }, 1548 | { 1549 | "mic": "BATS", 1550 | "tapeId": "Z", 1551 | "venueName": "BATS BZX", 1552 | "volume": 100403461, 1553 | "tapeA": 52509859, 1554 | "tapeB": 25798360, 1555 | "tapeC": 22095242, 1556 | "marketPercent": 0.0631, 1557 | "lastUpdated": 1480433817311 1558 | }, 1559 | { 1560 | "mic": "BATY", 1561 | "tapeId": "Y", 1562 | "venueName": "BATS BYX", 1563 | "volume": 54413196, 1564 | "tapeA": 28539960, 1565 | "tapeB": 13638779, 1566 | "tapeC": 12234457, 1567 | "marketPercent": 0.03419, 1568 | "lastUpdated": 1480433817310 1569 | }, 1570 | { 1571 | "mic": "XBOS", 1572 | "tapeId": "B", 1573 | "venueName": "NASDAQ BX", 1574 | "volume": 31417461, 1575 | "tapeA": 16673166, 1576 | "tapeB": 5875538, 1577 | "tapeC": 8868757, 1578 | "marketPercent": 0.01974, 1579 | "lastUpdated": 1480433817311 1580 | }, 1581 | { 1582 | "mic": "EDGA", 1583 | "tapeId": "J", 1584 | "venueName": "EDGA", 1585 | "volume": 30670687, 1586 | "tapeA": 15223428, 1587 | "tapeB": 8276375, 1588 | "tapeC": 7170884, 1589 | "marketPercent": 0.01927, 1590 | "lastUpdated": 1480433817311 1591 | }, 1592 | { 1593 | "mic": "IEXG", 1594 | "tapeId": "V", 1595 | "venueName": "IEX", 1596 | "volume": 26907838, 1597 | "tapeA": 16578501, 1598 | "tapeB": 3889245, 1599 | "tapeC": 6440092, 1600 | "marketPercent": 0.01691, 1601 | "lastUpdated": 1480433817235 1602 | }, 1603 | { 1604 | "mic": "XPHL", 1605 | "tapeId": "X", 1606 | "venueName": "NASDAQ PSX", 1607 | "volume": 13334403, 1608 | "tapeA": 5802294, 1609 | "tapeB": 4239741, 1610 | "tapeC": 3292368, 1611 | "marketPercent": 0.00838, 1612 | "lastUpdated": 1480433817071 1613 | }, 1614 | { 1615 | "mic": "XCHI", 1616 | "tapeId": "M", 1617 | "venueName": "CHX", 1618 | "volume": 4719854, 1619 | "tapeA": 834762, 1620 | "tapeB": 3168434, 1621 | "tapeC": 716658, 1622 | "marketPercent": 0.00296, 1623 | "lastUpdated": 1480433814711 1624 | }, 1625 | { 1626 | "mic": "XASE", 1627 | "tapeId": "A", 1628 | "venueName": "NYSE MKT", 1629 | "volume": 4419196, 1630 | "tapeA": 0, 1631 | "tapeB": 4419196, 1632 | "tapeC": 0, 1633 | "marketPercent": 0.00277, 1634 | "lastUpdated": 1480433816276 1635 | }, 1636 | { 1637 | "mic": "XCIS", 1638 | "tapeId": "C", 1639 | "venueName": "NSX", 1640 | "volume": 187785, 1641 | "tapeA": 39923, 1642 | "tapeB": 62191, 1643 | "tapeC": 85671, 1644 | "marketPercent": 0.00011, 1645 | "lastUpdated": 1480433816141 1646 | } 1647 | ]*/ 1648 | Json::Value IEX::markets::market(){ 1649 | Json::Value jsonData; 1650 | std::string url(IEX_ENDPOINT); 1651 | url += "/market"; 1652 | IEX::sendGetRequest(jsonData, url); 1653 | assert(jsonData.isArray()); //Crash if not an array 1654 | return jsonData; 1655 | } 1656 | 1657 | //GET /stock/market/crypto 1658 | Json::Value IEX::stocks::crypto(){ 1659 | Json::Value jsonData; 1660 | std::string url(IEX_ENDPOINT); 1661 | url += "/stock/market/crypto"; 1662 | IEX::sendGetRequest(jsonData, url); 1663 | assert(jsonData.isArray()); //Crash if not an array 1664 | return jsonData; 1665 | } 1666 | 1667 | /* 1668 | GET /stock/market/today-earnings 1669 | { 1670 | "bto": [ 1671 | { 1672 | "actualEPS": 2.1, 1673 | "consensusEPS": 2.02, 1674 | "estimatedEPS": 2.02, 1675 | "announceTime": "BTO", 1676 | "numberOfEstimates": 14, 1677 | "EPSSurpriseDollar": 0.08, 1678 | "EPSReportDate": "2017-05-02", 1679 | "fiscalPeriod": "Q2 2017", 1680 | "fiscalEndDate": "2017-03-31", 1681 | "yearAgo": 1.67, 1682 | "yearAgoChangePercent": .30, 1683 | "estimatedChangePercent": .28, 1684 | "symbolId": 11, 1685 | "symbol": "AAPL", 1686 | "quote": { 1687 | ... 1688 | }, 1689 | "headline": "" 1690 | }, 1691 | ... 1692 | ], 1693 | "amc": [ 1694 | { 1695 | "actualEPS": 3.36, 1696 | "consensusEPS": 3.22, 1697 | "estimatedEPS": 3.22, 1698 | "announceTime": "AMC", 1699 | "numberOfEstimates": 15, 1700 | "EPSSurpriseDollar": 0.14, 1701 | "EPSReportDate": "2017-05-02", 1702 | "fiscalPeriod": "Q2 2017", 1703 | "fiscalEndDate": "2017-03-31", 1704 | "yearAgo": 1.67, 1705 | "yearAgoChangePercent": .30, 1706 | "estimatedChangePercent": .28, 1707 | "symbolId": 1, 1708 | "symbol": "A", 1709 | "quote": { 1710 | ... 1711 | }, 1712 | "headline": "" 1713 | }, 1714 | ... 1715 | ] 1716 | }*/ 1717 | Json::Value IEX::stocks::earningsToday(){ 1718 | Json::Value jsonData; 1719 | std::string url(IEX_ENDPOINT); 1720 | url += "/stock/market/today-earnings"; 1721 | IEX::sendGetRequest(jsonData, url); 1722 | assert(jsonData.isArray()); //Crash if not an array 1723 | return jsonData; 1724 | } 1725 | 1726 | /* 1727 | GET /stock/market/upcoming-ipos 1728 | The above example will return JSON with the following keys 1729 | 1730 | { 1731 | "rawData": [ 1732 | { 1733 | "symbol": "VCNX", 1734 | "companyName": "VACCINEX, INC.", 1735 | "expectedDate": "2018-08-09", 1736 | "leadUnderwriters": [ 1737 | "BTIG, LLC", 1738 | "Oppenheimer & Co. Inc." 1739 | ], 1740 | "underwriters": [ 1741 | "Ladenburg Thalmann & Co. Inc." 1742 | ], 1743 | "companyCounsel": [ 1744 | "Hogan Lovells US LLP and Harter Secrest & Emery LLP" 1745 | ], 1746 | "underwriterCounsel": [ 1747 | "Mintz, Levin, Cohn, Ferris, Glovsky and Popeo, P.C." 1748 | ], 1749 | "auditor": "Computershare Trust Company, N.A", 1750 | "market": "NASDAQ Global", 1751 | "cik": "0001205922", 1752 | "address": "1895 MOUNT HOPE AVE", 1753 | "city": "ROCHESTER", 1754 | "state": "NY", 1755 | "zip": "14620", 1756 | "phone": "585-271-2700", 1757 | "ceo": "Maurice Zauderer", 1758 | "employees": 44, 1759 | "url": "www.vaccinex.com", 1760 | "status": "Filed", 1761 | "sharesOffered": 3333000, 1762 | "priceLow": 12, 1763 | "priceHigh": 15, 1764 | "offerAmount": null, 1765 | "totalExpenses": 2400000, 1766 | "sharesOverAlloted": 499950, 1767 | "shareholderShares": null, 1768 | "sharesOutstanding": 11474715, 1769 | "lockupPeriodExpiration": "", 1770 | "quietPeriodExpiration": "", 1771 | "revenue": 206000, 1772 | "netIncome": -7862000, 1773 | "totalAssets": 4946000, 1774 | "totalLiabilities": 6544000, 1775 | "stockholderEquity": -133279000, 1776 | "companyDescription": "", 1777 | "businessDescription": "", 1778 | "useOfProceeds": "", 1779 | "competition": "", 1780 | "amount": 44995500, 1781 | "percentOffered": "29.05" 1782 | }, 1783 | ... 1784 | ], 1785 | "viewData": [ 1786 | { 1787 | "Company": "VACCINEX, INC.", 1788 | "Symbol": "VCNX", 1789 | "Price": "$12.00 - 15.00", 1790 | "Shares": "3,333,000", 1791 | "Amount": "44,995,500", 1792 | "Float": "11,474,715", 1793 | "Percent": "29.05%", 1794 | "Market": "NASDAQ Global", 1795 | "Expected": "2018-08-09" 1796 | }, 1797 | ... 1798 | ] 1799 | }*/ 1800 | Json::Value IEX::stocks::upcomingIPOS(){ 1801 | Json::Value jsonData; 1802 | std::string url(IEX_ENDPOINT); 1803 | url += "/stock/market/upcoming-ipos"; 1804 | IEX::sendGetRequest(jsonData, url); 1805 | assert(jsonData.isArray()); //Crash if not an array 1806 | return jsonData; 1807 | } 1808 | 1809 | 1810 | /* 1811 | GET /stock/market/today-ipos 1812 | The above example will return JSON with the following keys 1813 | 1814 | { 1815 | "rawData": [ 1816 | { 1817 | "symbol": "VCNX", 1818 | "companyName": "VACCINEX, INC.", 1819 | "expectedDate": "2018-08-09", 1820 | "leadUnderwriters": [ 1821 | "BTIG, LLC", 1822 | "Oppenheimer & Co. Inc." 1823 | ], 1824 | "underwriters": [ 1825 | "Ladenburg Thalmann & Co. Inc." 1826 | ], 1827 | "companyCounsel": [ 1828 | "Hogan Lovells US LLP and Harter Secrest & Emery LLP" 1829 | ], 1830 | "underwriterCounsel": [ 1831 | "Mintz, Levin, Cohn, Ferris, Glovsky and Popeo, P.C." 1832 | ], 1833 | "auditor": "Computershare Trust Company, N.A", 1834 | "market": "NASDAQ Global", 1835 | "cik": "0001205922", 1836 | "address": "1895 MOUNT HOPE AVE", 1837 | "city": "ROCHESTER", 1838 | "state": "NY", 1839 | "zip": "14620", 1840 | "phone": "585-271-2700", 1841 | "ceo": "Maurice Zauderer", 1842 | "employees": 44, 1843 | "url": "www.vaccinex.com", 1844 | "status": "Filed", 1845 | "sharesOffered": 3333000, 1846 | "priceLow": 12, 1847 | "priceHigh": 15, 1848 | "offerAmount": null, 1849 | "totalExpenses": 2400000, 1850 | "sharesOverAlloted": 499950, 1851 | "shareholderShares": null, 1852 | "sharesOutstanding": 11474715, 1853 | "lockupPeriodExpiration": "", 1854 | "quietPeriodExpiration": "", 1855 | "revenue": 206000, 1856 | "netIncome": -7862000, 1857 | "totalAssets": 4946000, 1858 | "totalLiabilities": 6544000, 1859 | "stockholderEquity": -133279000, 1860 | "companyDescription": "", 1861 | "businessDescription": "", 1862 | "useOfProceeds": "", 1863 | "competition": "", 1864 | "amount": 44995500, 1865 | "percentOffered": "29.05" 1866 | }, 1867 | ... 1868 | ], 1869 | "viewData": [ 1870 | { 1871 | "Company": "VACCINEX, INC.", 1872 | "Symbol": "VCNX", 1873 | "Price": "$12.00 - 15.00", 1874 | "Shares": "3,333,000", 1875 | "Amount": "44,995,500", 1876 | "Float": "11,474,715", 1877 | "Percent": "29.05%", 1878 | "Market": "NASDAQ Global", 1879 | "Expected": "2018-08-09" 1880 | }, 1881 | ... 1882 | ] 1883 | }*/ 1884 | Json::Value IEX::stocks::todayIPOS(){ 1885 | Json::Value jsonData; 1886 | std::string url(IEX_ENDPOINT); 1887 | url += "/stock/market/today-ipos"; 1888 | IEX::sendGetRequest(jsonData, url); 1889 | assert(jsonData.isArray()); //Crash if not an array 1890 | return jsonData; 1891 | } 1892 | 1893 | 1894 | --------------------------------------------------------------------------------