Last active
September 28, 2019 21:10
-
-
Save jonathak/a4548233b5a5ca0259e7ab525cc9da11 to your computer and use it in GitHub Desktop.
Extract Financial Data from iexcloud.io
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns iex.core | |
(:require [clj-http.client :as client]) | |
(:gen-class)) | |
(defn try-wrap [f] | |
(fn [x y] | |
(try (f x y) | |
(catch Exception e "http-error")))) | |
(defn iex-stock-api | |
"returns raw response body for a call to stock APIs" | |
([ticker path qstr] | |
(let [cp { :cookie-policy :standard }] | |
(-> (str "https://cloud.iexapis.com/beta/stock/" | |
ticker "/" path "?token=" | |
"-YOUR API TOKEN GOES HERE-" | |
"&" qstr) | |
((try-wrap client/get) cp) | |
((try-wrap :body) cp)))) | |
([ticker path] | |
(iex-stock-api ticker path ""))) | |
(defn cash-flow [ticker] | |
(iex-stock-api ticker "cash-flow" "last=12")) | |
(defn -main | |
[& args] | |
(println "use lein repl")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment