Skip to content

Instantly share code, notes, and snippets.

(defn wrapper
[cb]
(reify
com.ib.client.EWrapper
(^void tickOptionComputation [this ^int tickerId ^int field ^double
impliedVol ^double delta ^double optPrice
^double pvDividend ^double gamma ^double
vega ^double theta ^double undPrice]
(cb {:field field,
:type :tickOptionComputation,
(defn client
"Takes one or more message handler functions and returns a map which
represents an IB api client."
[& handlers]
(let [handlers (atom (set handlers))
handle-message (fn [msg]
(doseq [f @handlers]
(try (f (unqualify-msg msg))
(catch Throwable t
(log/error t "Error handling message")))))
(defn mkput [a p rf cbs]
(fn [x]
(if (realized? p)
false
(let [result (rf a x)]
(if (reduced? result)
(let [x @@result]
;;run callbacks then deliver
(doseq [cb @cbs] (cb x))
(require '[clojure.core.async :as a])
(do
(def conn1 {:handlers (atom #{})})
(def on? (atom true))
;;;keep passing random ints to every handler
(def process
(future (while @on?
@jjttjj
jjttjj / convert1.clj
Last active October 20, 2019 14:58
Convert 1
(ns iboga.impl.convert
(:require [clojure.string :as str]
[iboga.meta :as meta]
[iboga.util :as u]
[medley.core :as m])
(:import [java.time LocalDate LocalDateTime]
java.time.format.DateTimeFormatter))
(defmulti to-ib* (fn [k v] k))
(defmulti from-ib* (fn [k v] k))
(ns iboga.impl.convert-old
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]
[iboga.meta :as meta]
[iboga.util :as u]
[iboga.specs]
[medley.core :as m])
(:import [java.time LocalDate LocalDateTime]
java.time.format.DateTimeFormatter))
@jjttjj
jjttjj / app.cljs
Last active November 13, 2019 22:41
(ns app.index
(:require [cljs.core.async :as a]
[lib.dom :as d :refer-macros [tpl-let tpl-with tpl=]]))
;;EXAMPLE USAGE
(enable-console-print!)
(def todos-db (atom {}))
(ns mult
(:require[clojure.core.async :as a]))
(defprotocol MultFn
:extend-via-metadata true
(add-tap [this-fn f] [this-fn xf f]
"Adds a function `f` to 'tapset', a set of functions which are
each called on every value passed to `this-fn`. If a transducer `xf`
is supplied, subjects all values to `xf` before calling `f` on the
result. When a value is reduced, the function is removed from the
@jjttjj
jjttjj / mult.cljc
Last active December 2, 2019 19:24
(ns mult
(:require [clojure.core.async :as a]))
(defprotocol MultFn
:extend-via-metadata true
(add-tap [this-fn f] [this-fn xf f]
"Adds a function `f` to 'tapset', a set of functions which are
each called on every value passed to `this-fn`. If a transducer `xf`
is supplied, subjects all values to `xf` before calling `f` on the
result. When a value is reduced, the function is removed from the
@jjttjj
jjttjj / ts_query.clj
Last active January 30, 2020 16:36
A draft of a time series query language
;;The goal of this is to specify a query format which clients can use to request
;;time series data from a server. The two primary operations are `:seek`s, which
;;are database lookups, and `:calc`s which tell the server to calculate
;;something using a previous seek as an argument. The result of either a seek or
;;a calc can be either a vector of data points or a map of columns (column name
;;-> vector).
;;Queries are either maps of names to subqueries, or just a vector of
;;subqueries. In either case, the response mirrors the shape of the query, with