Laura
Forum Replies Created
-
Hi Richard,
Thanks for the question, glad to see you found out the answer.
And thanks for leaving the question up for others that might have the same query!
Happy coding,
Laura
-
Laura
AdministratorDecember 17, 2021 at 12:00 am in reply to: How to setup KX Developer IDE workspace with specific Q and C/C++ integrationHi Ori,
Thanks again for your questions, we love to see people updating us that they have worked some steps out for themselves!
For using KX Developer in general, I wonder have you seen the Developer Walkthrough documentation?
There is also a section on Visualizing Data which I think you’ll find really useful!
For further learning, there is a short ~20minute course on KX Academy called Introduction to Developer which could also be a great tool for you going forward.
Hope this helps!
Laura
-
I just found out. So the odbc.k file goes into the q directory and odbc.dll goes into the W64 folder!
-
Hi leguan,
Thank you for the questions!
1. HARD_SESSION_TIMEOUT_MS is the maximum time a session can last
2. SOFT_SESSION_TIMEOUT_MS is the maximum time between requests
More information on those configurations can be found here: https://code.kx.com/platform/kx_connect/#session-management
You may be able to extend the maximum time of the session by changing the HARD_SESSION_TIMEOUT_MS config.
Something to note: Documentation is shipped with all installs and can be found in the help menu within the platform.
Hope this helps!
Thanks,
Laura
-
Laura
AdministratorDecember 13, 2021 at 12:00 am in reply to: a question about parameter file DS_MASTER_PROCESSHi leguan,
DS_MASTERED_PROCESS defines lists of leader and backup processes.
The description of parameters can be viewed within the Control UI: https://code.kx.com/platform/configurations/#parameters-viewer
The help menu might be helpful again here as it always contains the documentation for your specific install version, including parameter details.Hope this helps!
Laura
-
Laura
AdministratorDecember 13, 2021 at 12:00 am in reply to: how to print debug or view message whenever a message arrive on q kdb+Hi Ori,
Thanks for your questions!
Can I get a bit more information from you so I can understand your system set up?
Is this a real-time or historical system?
Are you using any other KX products or are you trying to data from q processes?
It sounds like you could benefit from adding some logging to the processes that are ingesting the data: https://code.kx.com/q/kb/logging/
Looking forward to finding out more about this use case.
Thanks,
Laura
-
Hi Eugene,
Great question, yes there is – KX Academy
To focus on the q language itself, I would recommend the Introductory Workshop followed by the Fundamentals Course.
Happy coding!
Laura
-
Thanks for your questions!
1. If f1 in your example is a column, you can simply assign this in your select statement e.g.
f1var: select f1 from table1
then f1var will be available to you to use as a local variable
2. I’ll need a little more information to answer this question fully for you. By cointegration do you mean combining two columns into one? If so, this will depend the datatypes of the columns.
You can see an example of combining two columns into a single column here: https://code.kx.com/q/basics/qsql/#computed-columns
3. The drop command in SQL is similar to the delete keyword in q. You can delete a table from memory by running something like
tables[] `aggregate_quote`aggregate_quote1`trades delete aggregate_quote1 from `. tables[] `aggregate_quote`trades
Take care when using this. The delete keyword will only work for removing variables from a namespace and will not delete from a partitioned database, for example. More info here https://code.kx.com/q/ref/delete/
4. I’m not familiar with ta-lib myself, but from a quick google I can see that it is a python library for technical analysis of financial data. We don’t have libraries as such for this kind of analysis – financial analysis is really q’s bread and butter, with or without use of one of our KX products. But we also have the option to integrate with python in a few different ways: https://code.kx.com/pykdb/comparisons.html
Hope this helps!
Laura
-
Hi Alex,
Thanks for your question!
There is no direct way to read XML into q, however one of our KX experts has previously shared a utility he wrote called qxml using embedPy to extract XML data into a kdb+ process.
Another route you could take might be to use .j.k if you are able to convert the XML to JSON (which q can natively parse).
Hope this helps!
Thanks,
Laura
-
Not quite what you asked, but better if you can to store prices as longs.
trade:([]time:`time$();sym:`symbol$();price:`long$();size:`int$()); `trade insert(09:30:00.000;`a;1075;100); `trade insert(09:31:00.000;`a;1175;100); `trade insert(09:32:00.000;`a;1320;100); `trade insert(09:30:00.000;`b;10075;100); `trade insert(09:31:00.000;`b;10695;100); `trade insert(09:32:00.000;`b;12395;100);
Your query then becomes
q)select time,sym,price:%[;100] 10 xbar 5+trade`price from trade time sym price ---------------------- 09:30:00.000 a 10.8 09:31:00.000 a 11.8 09:32:00.000 a 13.2 09:30:00.000 b 100.8 09:31:00.000 b 107 09:32:00.000 b 124
If you want a general rounding function adapted for dollars stored as cents (or any price as 100ש
q)roundi:{%[;100]s xbar y+.5*s:10 xexp 2-x} q)select time,sym,price:roundi[1]price from trade time sym price ---------------------- 09:30:00.000 a 10.8 09:31:00.000 a 11.8 09:32:00.000 a 13.2 09:30:00.000 b 100.8 09:31:00.000 b 107 09:32:00.000 b 124
If you want formatted strings then the new internal function @sujoy13 mentions does the rounding for you.
q)select time,sym,price:-27!(1i;price%100) from trade time sym price ------------------------ 09:30:00.000 a "10.8" 09:31:00.000 a "11.8" 09:32:00.000 a "13.2" 09:30:00.000 b "100.8" 09:31:00.000 b "107.0" 09:32:00.000 b "124.0"
-
Hi Freddie,
Looks like your nested lj isn’t doing what you expect as only columns from instRef are being joined on, not ones from optRef. The question asks for both.
Hint the table schema of edgeProfileFull should look like
c | t f a ---------| ----- option_id| s numTrds | j avgEdge | f minQty | j maxQty | j inst_id | j opt_type | s strike | j expiry | d inst_syb | s inst_name| C
and the table should be keyed.
Hope this helps!
-
For this query you are better using the ‘update’ query rather than ‘select’.
This will show you the updated trade table but it will not save it in place as the new trade table. If you want to save the new column to the trade table permanently then use `trades in the update statement, i.e. update change:price-prev price by sym from `trade
Here’s a link if you want to read more about the update statement.
https://code.kx.com/q4m3/9_Queries_q-sql/#95-the-update-template
-
Hi @rocuinneagain , thanks for the detailed reply and some informative clarification!
But I still have some confusion…the crux is this sentence you wrote
2. The messages arrive to PubSub and .z.pg evaluates them. This mean upd/insert (pubsub.q line 8 will save the incoming data to quote/trade. PubSub now has some data cached.
I understand that .z.pg is a function under the .z namespace, my questions are:
- Can I say that it is like a callback function which will be called by q when some events (i.e. synchronous request in this case) happen?
- In the caller side (https://github.com/kxcontrib/websocket/blob/ad2f0b268afaee1fc5f4dda2fc2467440c7e2f0c/AppendixB/fh.q#L18-L19), since we called the handler this way: h(`upd;`quote;(n#.z.N;s;getbid'[s];getask'[s]));, does it mean that .z.pg will evaluate the parameters, i.e., `upd, `quote and (n#.z.N;s;getbid'[s];getask'[s]) and .z.pg will interpret these parameters as: “execute the function upd and pass two parameters (i.e., `quote and (n#.z.N;s;getbid'[s];getask'[s])) to it”?
- Regarding this statement: “This code is a basic demo so it may have some holes in it’s logic (like never clearing data in PubSub so eventually memory will run out)”, do you mean that if feedhandler constantly inserts new rows by calling h(`upd;`quote;(n#.z.N;s;getbid'[s];getask'[s]));, tables `quote and `trade will grow larger and larger and the memory will be filled by these two tables?
- Regarding this function (https://github.com/kxcontrib/websocket/blob/ad2f0b268afaee1fc5f4dda2fc2467440c7e2f0c/AppendixB/pubsub.q#L33-L36), due to brevity of kdb/q, I am still decoding what exactly it is doing. But after reading you last reply, my vague understanding is that subscribers registered their handlers in the table `subs. So the pub function is essentially enumerating the `subs table and call all subscribers’ handlers one by one. This series of function calls is what we say to “publish data” to subscribers. Is this understanding basically correct?Thanks!
-
Thanks @rocuinneagain for taking a look at my lengthy question! Let’s say we examine the flow this way:
- information is generated by feedhandler fh.q (https://github.com/kxcontrib/websocket/blob/master/AppendixB/fh.q)
- information is passed to tickerplant subpub.q (https://github.com/kxcontrib/websocket/blob/master/AppendixB/pubsub.q) (please correct me if this is not a tickerplant)
- information is received by a JavaScript-based subscriber (https://github.com/kxcontrib/websocket/blob/master/AppendixB/websockets.js) In this particular example, I understand that information is randomly generated by fh.q; and fh.q interact with pubsub.q via these two function calls (https://github.com/kxcontrib/websocket/blob/ad2f0b268afaee1fc5f4dda2fc2467440c7e2f0c/AppendixB/fh.q#L18-L19) .
My confusion starts here: in lines 18 and 19 of fh.q, `upd is an alias to insert; `quote and `trade are table names, and the rest are parameters randomly generated–so which line in pubsub.q will be invoked when these two function calls are made (please correct me if the term “function call” is inaccurate)?
Thanks!
-
Laura
AdministratorNovember 11, 2021 at 12:00 am in reply to: Struggling to understand two statementsHi mauricelim, thanks for the quick help! Can I say that the big picture is to define two empty tables called trade and subs here?