ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

q KDB

by komsit37 ST3

Sublime Text Plugin for q/kdb

Details

Installs

  • Total 2K
  • Win 867
  • Mac 418
  • Linux 266
Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8
Windows 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

q REPL for Sublime Text 3

Connect to remote q sessions and execute q statements in Sublime Text

Image of screenshot

  • Cmd + alt + q to select/add/modify your q connections
  • Cmd + Enter to send current line or highlighted block of text to selected q session and show results in the output panel
  • Cmd + Shift + Enter send the command as above, but show results in Phantom
  • Cmd + e same as above, but show result in popup
  • Cmd + j same as above, but get result as json (requires .j.j from kdb 3.x/4.x)
  • Run custom routines with Cmd + alt + r
  • 3 result modes: output panel, inline popup, and phantom (inline block)
  • Syntax highlighting (from atf1206 https://github.com/atf1206/q-kdb-syntax, based on kimtang's https://github.com/kimtang/sublime-q)
  • Status bar with rows, column, time, mem usage
  • Syntax autocomplete
  • Plot table data in html/js (similar to Studio for Kdb+ - with a few customizations)

[change Cmd to Ctrl for windows]

Shortcuts

  • F1 open help at cursor
  • F2 print variable at cursor
  • Shift + F2 browse table variable at cursor
  • F3 show type at cursor
  • F4 plot latest data in browser
  • shift + F4 show latest data in browser using datatable js
  • F5 show environments
  • shift + F5 show memory usage
  • F6 show table and column names

[hold shift to show output in inline popup instead of output panel]

Installation

via package control https://packagecontrol.io/packages/q%20KDB

Features

Charts

Shortcut F4 will plot an html/js chart from the latest REPL result (the usage is similar to Studio for Kdb+ - with a few chart customizations). See js/canvasjs/example.q

Error: language “q” is not supported
/default is line chart
lineData: ([] ts: 2019.01.01D00:00 + 1D * til 10; price: 10000 + 10?100)
/multiple series - 1 column per series
multilineData: ([] ts: 2019.01.01D00:00 + 1D * til 10; price: 10?100; price2: 10?200)
/change to column chart if first column type is symbol
colData: ([] sym: `a`b`c`d`e`f`g`h`i`j`k`l; volume: 12#100 200 300)
/you can also have multiple series for column chart
multicolData: ([] sym: `a`b`c`d`e`f`g`h`i`j`k`l; volume: 12#100 200 300; volume2: 12#400 330 210)
/use candlestick automatically if column name contains open, high, low, close. with optional volume column
ohlcvData: ([] date: 2019.01.01 + til 5; high: 105 99 150 120 180; low: 99 84 110 110 150; close: 102 99 105 120 180; open: 100 90 110 120 140; volume: 10000 15000 9000 12000 11000)
/multiple series - if second column type is symbol
multiSymData: ([] date: 6#(2019.01.01 + til 3); sym: raze 3#'`a`b; price: 100 + 6?100)
/auto generate 2nd axis if range is more than 50 times different 
needAxis2Data: ([] time: "z"$2019.01.01 + til 3; a: 3?100; b: 3?1000; c: 3?100; d: 3?100000)
/can also plot list or dict directly
10?100
(`a`b`c)!(100; 120; 130)

/override option by adding chart hints
/s - change type to scatter by prefixing s: to column name
`ts`s:a`s:b xcol pointData: ([] ts: 100 * til 3; a: 3?100; b: 3?1000)
/y2 - specify 2nd axis by prefixing y2: to column name
`time`a`y2:b xcol ([] time: 2019.01.01 + til 3; a: 3?100; b: 3?1000)
/bu - bubble chart will use next column as bubble size
`time`bu:a xcol ([] time: 2019.01.01 + til 3; a: 3?100; b: 3?1000)

Output

There are 3 output modes to show results from q queries: * Cmd + Enter output panel - I mostly use this * Cmd + Shift + Enter inline phantom - Use this when you need some reference data * Cmd + e overlay popup - I don't use this so much

Extra: shortcut Shift + F2 lets you browse the table variable at cursor (utilizing .h.jx)

Custom Routines

Define your own custom routines. Shortcut Cmd + alt + r will bring up custom routine options. For example:

"routines": [
        {
          "name": "show",
          "description": "show variable at cursor",
          "command": {"qstatement": ".Q.s {0}", "output": "q_out_panel"}
        }
    ]

Where {0} is the variable name at cursor. You can also define shortcuts by referring to the routine by name:

{ "keys": ["f2"],       "command": "q_routine", "args": {"name": "show"}, "context":[{ "key": "selector", "operator": "equal", "operand": "source.q" }]},

See more example in settings/sublime-q.sublime-settings

Please feel free to open issues for any feedback, bugs, or feature requests.

Contribute

Clone this git repository into your Sublime Text 3/Packages directory. NOTE: You may need to change dir to q KDB

  • Windows: C:\Users\[username]\AppData\Roaming\Sublime Text 3\Packages
  • OS X: ~/Library/Application Support/Sublime Text 3/Packages
git clone https://github.com/komsit37/sublime-q.git 'q KDB'

From sublime text, run package control: satisfy dependencies (you may need to open package folder in sublime text first). This will install numpy as a dependency package to your packages folder

Supported OS

  • osx_x64
  • windows_x64
  • linux_x64

Unsupported OS

Support could be extended by adding the proper numpy 1.8 build with python 3.3 (see https://github.com/komsit37/sublime-q/issues/12). Please send a PR if you can build any of these: * osx_x32 * windows_x32 * linux_x32

This plugin is for Sublime Text 3. For Sublime Text 2, please use https://github.com/komsit37/sublime-q-2

To build numpy

The included numpy version should work for osx and windows 64bit, but if you need to build numpy:

  1. download python 3.3
  2. download http://sourceforge.net/projects/numpy/files/NumPy/1.8.1/
  3. run python3.3 setup.py install
  4. numpy will be installed to your default python lib
  5. then follow steps here https://github.com/komsit37/sublime-q/issues/12