Skip to content

Instantly share code, notes, and snippets.

@jheusser
Last active August 29, 2015 14:18
Show Gist options
  • Save jheusser/9f4833cba0a98f8913a6 to your computer and use it in GitHub Desktop.
Save jheusser/9f4833cba0a98f8913a6 to your computer and use it in GitHub Desktop.
/ create table
ticker:flip `buy`high`last`low`sell`timestamp`vol!()
/ decode json data responses, insert into ticker table
.z.ws:{x: (.j.k x)`data; `ticker upsert (first x)}
/ assumes local stunnel pointing to real.okcoin.com:10440 for ssl
r:(`$":ws://127.0.0.1:8100")"GET /websocket/okcoinapi HTTP/1.1\r\nHost: real.okcoin.com:10440\r\n\r\n"
/ subscribe to ticker
data:.j.j `event`channel!`addChannel`ok_btcusd_ticker
/ needs parsing of response r for right fd
neg[3]data
@jheusser
Copy link
Author

jheusser commented Apr 1, 2015

q)\l ws.q
q)ticker
buy      high     last     low     sell     timestamp       vol
-----------------------------------------------------------------------
"245.75" "248.36" "245.84" "239.2" "245.9"  "1427918294196" "16,915.69"
"245.75" "248.36" "245.84" "239.2" "245.79" "1427918294330" "16,915.69"
"245.75" "248.36" "245.79" "239.2" "245.89" "1427918296347" "16,919.93"
"245.75" "248.36" "245.79" "239.2" "245.89" "1427918296574" "16,919.83"
"245.75" "248.36" "245.79" "239.2" "245.88" "1427918297475" "16,919.83"
"245.75" "248.36" "245.79" "239.2" "245.87" "1427918299521" "16,910.37"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment