Last active
September 5, 2016 16:27
-
-
Save lispyclouds/9c56c2e00150cc4d17f5f66990061aa2 to your computer and use it in GitHub Desktop.
Code to fetch the highest stock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns stocks.core | |
(:gen-class) | |
(:require [clj-http.client :as client]) | |
(:require [cheshire.core :refer :all])) | |
(def url "http://dev.markitondemand.com/MODApis/Api/v2/Quote/json?symbol=%s") | |
(defn get-stock-value-of | |
[symbol] | |
(let [response (-> ((client/get (format url symbol)) :body) | |
(parse-string true))] | |
{:name (response :Name) :price (response :LastPrice)})) | |
(defn find-higest-stock | |
[stocks] | |
(first (sort-by :price #(> %1 %2) (pmap get-stock-value-of stocks)))) | |
(defn -main | |
[& args] | |
(println (find-higest-stock ["AMZN" "YHOO" "FB" "GOOGL" "MSFT"])) | |
(shutdown-agents)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment