rocuinneagain
Forum Replies Created
-
You could make windows like so:
q)start:0D q)duration:1D q)length1:0D00:20 q)length2:0D00:10 q)windows:{flip (0;y-1)+\:y*til `long$x div y}'[duration;(length1;length2)] q)(first;last)@\:windows 0 0D00:00:00.000000000 0D00:19:59.999999999 0D23:40:00.000000000 0D23:59:59.999999999 q)(first;last)@\:windows 1 0D00:00:00.000000000 0D00:09:59.999999999 0D23:50:00.000000000 0D23:59:59.999999999 q)t:([] time:100?1D;sym:100?`A`B`C) time sym ------------------------ 0D11:37:38.441374450 A 0D16:23:13.911677598 A 0D03:40:38.809463381 C 0D12:50:31.973013281 B 0D10:58:33.142468035 C 0D00:11:36.601854264 B
Query for small tables for each sym for each windows:
syms:exec distinct sym from t q){[x;y;z] select from x where sym=y,time within z}[t](.)/:syms cross enlist each windows 0 +`time`sym!(`timespan$();`symbol$()) +`time`sym!(,0D03:19:44.361107647;,`A) +`time`sym!(0D03:20:29.103351384 0D03:28:31.211699992;`A`A) ... +`time`sym!(,0D20:47:50.484825968;,`B) +`time`sym!(,0D21:14:37.927203476;,`B) +`time`sym!(0D21:39:42.773356139 0D21:37:00.400066673;`B`B) +`time`sym!(`timespan$();`symbol$()) +`time`sym!(,0D22:09:45.092769563;,`B)
-
The is a kdb+ Solace interface
- https://solace.com/kx/
- https://github.com/KxSystems/solace/tree/master
- https://code.kx.com/q/wp/solace/
One of the getPayloadAs* functions may be what you need
https://github.com/KxSystems/solace/blob/77dd10edefa014f39b6c5ed9a693bdcad7685509/q/solace.q#L30
q)msg "\PAR1\025\004\025\010...
q).solace.getPayloadAsBinary msg
-
, rather than ; separating the arguments of fbis. Otherwise runs fine:
q)fbis:{[c_;x0;p_]{[xn ;c;p] xn-((xn xexp p)-c)%(p*xn xexp p-1)}[;c_;p_]\[x0]}
q)fbis[2;1;3]
1
1.333333
1.263889
1.259933
1.259921
1.259921
-
Linux is best to make use of all features.
If you plan on using Platform/Developer I’d recommend Ubuntu 20.04 for best compatibility.
https://code.kx.com/developer/getting-started/#prerequisites
-
Dictionaries require lists to be passed to either side of !. You can use enlist to make lists from atoms:
q)d:.Q.def[enlist[`num1]!enlist 5].Q.opt .z.x
q)d
num1| 5If you are using kdb 4.1 you can use the new dictionary syntax which does not need enlist
q)d:.Q.def[([num1:5])].Q.opt .z.x
q)d
num1| 5 -
rocuinneagain
MemberApril 29, 2024 at 8:36 am in reply to: kx developer – from installation to the endYou need to install q to use developer. q cannot be installed by pip.
Instructions are here: https://code.kx.com/q/learn/install/
code.kx.com
Installing kdb+ | Learn | kdb+ and q documentation - Kdb+ and q documentation
How to install kdb+ on Linux, macOS, or Windows
-
rocuinneagain
MemberApril 23, 2024 at 11:50 am in reply to: Failed to Load KX Insights Core Library error when using pykx in qDid you download q from this link?
https://kx.com/kdb-personal-edition-download/
It does not include the cloud libraries.
Instead the insights edition is needed to have those libraries:
https://kx.com/kdb-insights-personal-edition-license-download/
-
rocuinneagain
MemberApril 22, 2024 at 7:29 pm in reply to: message after print to stderror not shownIf statements in q do not return data.
“The result of if is always the generic null.”
q)result:if[1b;1]
q)result
q).Q.s1 result //The generic null is returned
"::"
//You can include the date in the printed output:
q){if[x>1;-2"Warn ",string[x]," above threshold 1 ",string .z.D]} 2
Warn 2 above threshold 1 2024.04.22
code.kx.com
if control word | Reference | kdb+ and q documentation - Kdb+ and q documentation
if is a q control construct for conditional evaluation of one or more expressions.
-
We added some functionality in version 2.3.0
https://code.kx.com/pykx/2.4/release-notes/changelog.html#pykx-230
If you enable beta features as well as pykx threading all calls into q from any python thread will be run as if they were calling from the main thread which allows python multithreaded programs to use IPC connections in licensed mode.
You can enable this functionality like this:
import os
os.environ['PYKX_THREADING'] = '1'
os.environ['PYKX_BETA_FEATURES'] = '1'
import pykx as kxYou will also want to ensure that kx.shutdown_thread() is called when the script finishes. The safest way to do this is within a try – finally block like this.
if __name__ == '__main__':
try:
main()
finally:
kx.shutdown_thread()More information about this functionality and an example can be found within our documentation:
https://code.kx.com/pykx/2.4/examples/threaded_execution/threading.html
-
We added some functionality in version 2.3.0
https://code.kx.com/pykx/2.4/release-notes/changelog.html#pykx-230
If you enable beta features as well as pykx threading all calls into q from any python thread will be run as if they were calling from the main thread which allows python multithreaded programs to use IPC connections in licensed mode.
You can enable this functionality like this:
import os
os.environ['PYKX_THREADING'] = '1'
os.environ['PYKX_BETA_FEATURES'] = '1'
import pykx as kxYou will also want to ensure that kx.shutdown_thread() is called when the script finishes. The safest way to do this is within a try – finally block like this.
if __name__ == '__main__':
try:
main()
finally:
kx.shutdown_thread()More information about this functionality and an example can be found within our documentation:
https://code.kx.com/pykx/2.4/examples/threaded_execution/threading.html
-
Going forward PyKX under q is the recommended replacement for embedPy.
*It is not operational yet on Windows
-
The first error is saying you do not have node.js installed to be able to run that command
https://nodejs.org/en/download
The second error is saying that a different process is using the port 10001 blocking your new process from starting. You need to kill that other process or change your configuration to use a different port instead.
nodejs.org
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
-
rocuinneagain
MemberApril 29, 2024 at 8:20 pm in reply to: kx developer – from installation to the endYou have not exported PATH so q is available on it.
See: https://code.kx.com/q/learn/install/#step-5-edit-your-profile
setx PATH "%PATH%;C:\q\w64"
Or instead to make a permanent change to the existing PATH environment variable on windows you can follow this guide https://chlee.co/how-to-setup-environment-variables-for-windows-mac-and-linux/
code.kx.com
Installing kdb+ | Learn | kdb+ and q documentation - Kdb+ and q documentation
How to install kdb+ on Linux, macOS, or Windows
-
rocuinneagain
MemberApril 23, 2024 at 1:06 pm in reply to: Failed to Load KX Insights Core Library error when using pykx in qRun ‘ls’ on ‘/q’ in the container to see what files are there. The load error output suggests the cloud libraries are not there.
-
rocuinneagain
MemberApril 23, 2024 at 11:05 am in reply to: Failed to Load KX Insights Core Library error when using pykx in q.