- Get evaluation license key : http://my.datomic.com/eval/request
- Download pro version : http://downloads.datomic.com/pro.html
- Dev mode setup
(defn validate-mappings | |
"Validates each mapped import is for an | |
existent field in the specified company" | |
[fields headers mappings] | |
(letfn [(found? [list element] (< (.indexOf list element) 0))] | |
(filter (fn [[header field]] | |
(or (found? headers header) | |
(found? fields field))) | |
mappings))) |
;; Datomic example code | |
(use '[datomic.api :only (db q) :as d]) | |
;; ?answer binds a scalar | |
(q '[:find ?answer :in ?answer] | |
42) | |
;; of course you can bind more than one of anything | |
(q '[:find ?last ?first :in ?last ?first] | |
"Doe" "John") |
(defmethod validation/valid-field? :document-MX | |
[{value :value}] | |
(let [match (re-find #"(?i)(^[a-z]{2})([a-z])([a-z])(\d{6})(H|M)([a-z]{2})([a-z]{3})(\d{2})$" value)] | |
match)) | |
(defmethod validation/valid-field? :document-UY | |
[{value :value}] | |
(when-let [[_ number digit] (re-find #"^(\d{7})-(\d)$" value)] | |
(let [m [2 9 8 7 6 3 4] | |
c (map #(utils/str->int (str %)) number) |
(defn get-NYSE-days | |
"Create a set of timestamps between startday and endday | |
that correspond to the days there was trading at the NYSE" | |
[start-date end-date time-of-day] | |
(let [dates-file (str *QS* "/qstkutil/NYSE_dates.txt") | |
NYSE-dates (incanter.io/read-dataset dates-file) | |
fmt (formatter "MM/dd/yyyy") | |
dates (incanter.core/$map #(parse fmt %) :col0 NYSE-dates)] | |
(set (filter (fn [d] (within? (interval start-date end-date) d)) | |
(map #(plus % time-of-day) dates))))) |
(defn select-value | |
"Given a dataset indexed by date, returns the value corresponding to a specified column | |
if existent for a specific date" | |
[ds column date] | |
(let [row (ds {:Date date})] | |
(when-not (nil? row) (incanter.core/$ 0 column row)))) | |
(defn get-data | |
"Given a list of `symbols`, its data and a list of specific `timestamps`, builds a matrix(sequence) | |
with each column corresponding to a stock and the value extracted using `column` |
(defmacro apply-filtered | |
"Given two sequences, apply a function to each pair of elements when condition is met | |
anaphoras n and m exists for each indexed element | |
e.g. (apply-filtered / [1 2 3] [1 0 3] when (> m 0)) => (1 nil 1) | |
" | |
[op a b & condition] | |
`(for [x# (range (count ~a))] | |
(let [n# (nth ~a x#) |
(defn run | |
[] | |
(let [symbols ["AAPL","GLD","GOOG","$SPX","XOM"] | |
start-day (date-time 2012 1 1) | |
end-day (date-time 2012 12 31) | |
time-of-day (hours 16) | |
timestamps (get-NYSE-days start-day end-day time-of-day) | |
symbols-data (read-symbols-data "Yahoo" symbols) | |
adj-close-data (incanter.core/to-dataset | |
(get-data timestamps symbols (keyword "Adj Close") symbols-data time-of-day))] |
DECLARE @tagname varchar(20) = ##language:string## | |
select DifficultyGroup, Count(1) Total, | |
avg(cast(ResponseTime as bigint)) as Average, | |
stdev(cast(ResponseTime as bigint)) as StandardDev | |
from | |
(SELECT | |
Questions.CreationDate, | |
Questions.Title, | |
Tags.TagName, |
DECLARE @tagname varchar(20) = ##language:string## | |
select ResponseHour, | |
avg(cast(ResponseTime as bigint)) as Average, | |
stdev(cast(ResponseTime as bigint)) as StandardDev | |
from | |
(SELECT | |
Questions.CreationDate, | |
Questions.Title, |