Forum Replies Created

Page 18 of 21
  • rocuinneagain

    Member
    April 17, 2022 at 12:00 am in reply to: Putting CSV data into a chart & other questions

    This is likely close to how qsql  would be used based on your example

     

    //Read CSV and store in memory table 
    myCSV:("PFFFFF";enlist csv) 0: `$":/q/spy.csv" 
    //Only retain lines where Line and close do not equal 0 
    myCSV:select from myCSV where Line<>0, close<>0 
    //Add deltas other extra columns 
    myCSV:update dc:deltas Line, dclose:deltas close, dc2:1+til count i, dclose2:1+til count i from myCSV 
    //Display the table myCSV

     

    If you run those lines in Developer then you can use myCSVin your Dashboard widget to display it as the data is stored in an in memory table.

    set stores data in kdb+ binary files (not human readable).

    If you wish to save as CSV either of these should work for you:

    `:myCSV.csv 0: csv 0: myCSV save `myCSV.csv

     

  • You can so this using over

    q)tab:([] A:1 2 3;B:4 5 6;C:7 8 9) 
    // Sample table 
    q)tab 
    A B C 
    ----- 
    1 4 7 
    2 5 8 
    3 6 9 
    q)func:{![x;();0b;enlist[y]!enlist (+;y;1)]} 
    //Function I want to run 
    q)func[tab;`A] // Same as: update A:A+1 from tab 
    A B C 
    ----- 
    2 4 7 
    3 5 8 
    4 6 9 
    q)func over enlist[tab],`A`B`C // Using over accumulator 
    A B C 
    ------ 
    2 5 8 
    3 6 9 
    4 7 10

     

     

     

  • rocuinneagain

    Member
    April 11, 2022 at 12:00 am in reply to: how to read this two symbols

    It is a projection on take

    q)1#1b ,1b 
    q)2#1b 11b 
    q)#[;1b] 1 ,1b 
    q)#[;1b] 2 11b

     

     

  • rocuinneagain

    Member
    April 4, 2022 at 12:00 am in reply to: KX Maintain a proper GoLang package?

    Another Github user recently created a new Go interface: jshinonome/geek: golang interface for kdb+/q (github.com)

  • rocuinneagain

    Member
    April 1, 2022 at 12:00 am in reply to: 1 "hello" return hello1

    This behaviour happens with file handles also:

    Applying the handle to data appends it to the file as bytes.
    Applying the neg of the handle to char data appends it as text. The result of a successful operation is the positive or negative handle.

    File system | Basics | kdb+ and q documentation – Kdb+ and q documentation (kx.com)

    As to why I am not sure. The choice could have been made to return a generic null (::) instead possibly.

     

    For stdout and stderr it can feel strange at first but it is not printing ‘hello1’ in one go. Instead ‘hello’ is printed as you requested then as you are in an interactive session the q) prompt wants to display the returned object so it then prints ‘1’.

    q)1"hello"; //The ; stops the q) prompt from printing the returned object '1' hello
    q)
    q)-1"hello"; //-1 is often more useful as it includes a n newline char hello

     

  • rocuinneagain

    Member
    April 1, 2022 at 12:00 am in reply to: Financial chart
    1. How are you trying to plot the data? table, bar, line etc. ?
    2. Are you seeing an error? Why do you say it cannot be plotted?

     

    Common components to chart:

  • rocuinneagain

    Member
    March 21, 2022 at 12:00 am in reply to: What is the purpose of publishing value each t to t in .u.pub?

    This is batching mode when the timer t is set. https://code.kx.com/q/basics/syscmds/#t-timer

    In this mode the TP will cache data and only publish it when the timer triggers .z.ts https://code.kx.com/q/ref/dotz/#zts-timer

    In this case t is a list of tables and it calls pub on each of them (' form)  https://code.kx.com/q/ref/maps/#each

    value is called so that the cached data from the TP is populated in pub to send to subscribers (RDB etc.)

    Some more information on batch mode: https://code.kx.com/q/wp/tick-profiling/

     

    q)upd'[t;value each t] 
    //A demo 'upd' which prints the parameters sent to it 
    q)a:([] c1:1 2 3) 
    q)b:([] c2:4 5 6) 
    q)t:tables[] //Create list of tables 
    q)t `s#`a`b 
    q)upd'[t;value each t] (`a;+(,`c1)!,1 2 3) (`b;+(,`c2)!,4 5 6)

     

     

  • rocuinneagain

    Member
    March 11, 2022 at 12:00 am in reply to: Save creating 3 files

    Can you include a small reproducible piece of code?

    I do not see the files being created.

    //Including kdb+ version information 
    //If behaviour has changed include previous version information also 
    q).z.k 2021.07.12 
    q).z.K 4f 
    //An example table
    q)ot:([]a:1 2 3;b:`a`b`n;c:("jj";"kk";"pp")) 
    q)save `ot `:ot 
    //No # or ## files created by `save` keyword 
    q){x where x like "ot*"}key `:. ,`ot

     

    The # and ## files you see are used by the anymap datatype on disk.

    You can still read your file with

    get `:ot

     

  • rocuinneagain

    Member
    March 10, 2022 at 12:00 am in reply to: Cannot run kdb 64bit behind a proxy

    The email you received with your kc.lic included some details on this topic:

     

    Generally, kdb+ as an on-demand client behaves exactly like, and should be treated the same as, any plain http client (e.g. curl, apt-get or firefox) accessing a CDN-fronted web service.
    It connects to a remote port 80 as part of a normal http request; thus you generally only need to allow outbound http _connections_ but both _traffic_ to and from remote port 80.
    As the communication protocol is plain http you can employ any standard mechanism, including proxies (transparent and opaque by setting the HTTP_PROXY environment variable) as long as kdb+ is able to issue an http request and receive a response from the remote Kx service.
    If you need to allowlist the remote servers should treat kdb+ on-demand as a CDN-fronted service and employ DNS-based filtering. The current list of hostnames required for kdb+ on-demand operation is {h,g}.kdbod.{com,net,org}.

  • rocuinneagain

    Member
    March 8, 2022 at 12:00 am in reply to: Purpose of s.k file in q

    There is some background on DSL files here:

    https://code.kx.com/q/wp/query-interface/#background

    What documentation are you following for JDBC connectivity?

  • rocuinneagain

    Member
    February 18, 2022 at 12:00 am in reply to: Anyone using the Tensorflow functional API from inside q(embedpy)?

    You could load the function in to q rather than redefine it line by line.

     

    Example file.p

    def get_model(input_shape, time2vec_dim = 3): inp = Input(input_shape) x = inp time_embedding = keras.layers.TimeDistributed(Time2Vec(time2vec_dim – 1))(x)

    Load it and pull in the function:

    q)l file.p 
    q)get_model:.p.get`get_model 
    q)get_model[(65;16)]

    Another example of this: https://github.com/rianoc/qparquet

     

    Looking to replicate an example from https://keras.io/api/layers/recurrent_layers/time_distributed/

    q)lyr:.p.import`keras.layers 
    q)x:lyr[`:Input;`shape pykw (10, 128, 128, 3)] 
    q)conv_2d_layer:lyr[`:Conv2D;64;(3;3)] 
    q)time_embedding:lyr[`:TimeDistributed;conv_2d_layer] q
    )outputs:time_embedding[x] 
    q)print outputs[`:shape] (None, 10, 126, 126, 64)

     

  • rocuinneagain

    Member
    February 15, 2022 at 12:00 am in reply to: embedPy inside q (kdb+) process fails to import a module

    The error is that a variable “cxt” is not being found.

    https://code.kx.com/q/basics/errors/#runtime-errors

     

    General debugging tips included on: https://code.kx.com/q/basics/debug/

     

    As this is a third party project you will get better support by raising an issue with the developer directly:

    The developer does not document the supported embedPy versions which would be important to know.

     

    One difference I see is you are calling

    pc:.cbpro.PublicClient[]

    But the developer passes a string – this could be your issue

    https://github.com/michaelsimonelli/qoinbase-q/blob/359653d9e45b6319d897f5ae50af048225605ae2/cbpro.q#L27

    cli: .cli.priv.addFuncs .cbpro.PublicClient[url];

     

     

  • rocuinneagain

    Member
    February 15, 2022 at 12:00 am in reply to: KX SQL Introductory Project – .s.e error

    To load the SQL interpreter you can run:

     

    l s.k

     

    Otherwise when you run your first ‘s)’ query this would be done automatically.

  • rocuinneagain

    Member
    February 7, 2022 at 12:00 am in reply to: KX Dashboards Help "Text Editor"

    Hi Michael,

    Hopefully this helps.

    Sample Datasource:

    ([] description:enlist “ROMANI 4.875 01/24”;Volume:enlist 1.6385)

    ‘Template Text’ in ‘Text’ widget:

    {{#each this}} {{description}} <br> Volume:{{toPrecision Volume 2}}m {{/each}}

     

     

     

  • rocuinneagain

    Member
    February 2, 2022 at 12:00 am in reply to: Default dictionary value

    This blog on JSON parsing may also have some useful tips for you as it covers some areas of nested data with irregular keys

    https://kx.com/blog/kdb-q-insights-parsing-json-files/

     

    An example for your ask is to use a prototype dictionary of default values

    
    
    // Prototype of default values if lookup fails 
    q)p:`a`b`c`d!("X";99;99;99) 
    q)p a| "X" b| 99 c| 99 d| 99 
    // Actual dictionary 
    q)d:`a`b`c!("";2;3) 
    q)d a| "" b| 2 c| 3 
    // Failed lookup uses null of type of first key 
    // a is first key, it is type char, null char is "" 
    q)d`d "" 
    // Prototype can be used by appending your dict to it 
    q)(p,d)`d 99 
    q)(p,d)`b 2 // Handles vectors of keys nicely 
    q)(p,d)`d`b`a 99 2 ""

     

     

Page 18 of 21