Skip to content

Instantly share code, notes, and snippets.

@aredington
Forked from hmanish/output.clj
Last active August 29, 2015 14:09
Show Gist options
  • Save aredington/eff4fd6bfed36b0bd6fa to your computer and use it in GitHub Desktop.
Save aredington/eff4fd6bfed36b0bd6fa to your computer and use it in GitHub Desktop.
(defn compute-position
"returns a map
key is a vector -[ <settlement index name> <power primitive name>]
value is a map - {<Date representing yyyy-MM> <Double: the positon> }
For non power trades, primitive name will be nil"
[trade]
;;compute postion code)
;;;;;;;;;;;;;;;;;;;;;;;;;;;; Sample Outputs ;;;;;;;;;;;;;
;; sample output for a gas trade
{["NG NYMEX" nil] {#inst "2014-12" {:long 6000 :short 2000} ;; net long 4000
#inst "2015-01" {:long 2500 :short 500} ;; net long 2000
...
...
...}
}
;; sample output for a power trade
{["PJM WH RealTime" "Peak 2x16"] { #inst "2014-11" {:short 50000}
#inst "2014-12" {:short 20000}
...
...
...
...}}
;; sample output for trades with multiple indexes
{["NG FP for GDD Malin" nil] {#inst "2014-11" {:long 30000}
#inst "2014-12" {:long 250000}
...
...
...
}
["PJM WH RealTime" "Peak 2x16"] {#inst "2014-11" 50000
#inst "2014-12" 30000
..
...
...}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment