rocuinneagain
Forum Replies Created
-
rocuinneagain
MemberApril 19, 2024 at 12:10 pm in reply to: PyKX could not establish an IPC connection in the Flask appWe 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
-
rocuinneagain
MemberApril 16, 2024 at 9:21 am in reply to: Natural Query Interface API fails to aggregate rdb + hdb resultsWhat is Holistic API? You may be using an internal tool which we can not answer questions on.
Standard kdb will not behave as you have outlined:
q)`:testHDB/2024.04.16/tableName/ set ([] publishTime:asc 100?.z.t;otherCol:100?100.0)
`:testHDB/2024.04.16/tableName/
q)`:testHDB/2024.04.15/tableName/ set ([] publishTime:asc 100?.z.t;otherCol:100?100.0)
`:testHDB/2024.04.15/tableName/
q)\l testHDB
q)select last publishTime from tableName where date within(.z.D-5;.z.D)
publishTime
------------
09:12:36.839 -
rocuinneagain
MemberApril 11, 2024 at 9:31 am in reply to: Could Someone Give Me Guidance on Integrating KDB+/q with Machine Learning?There are a lot of resources here: https://code.kx.com/q/ml/
Note: These show use of embedPy which is still usable but is not being actively updated. These can be however be migrated to use the current Python interface PyKX which includes notes on upgrading from embedPy.
Related to the question to you linked to you may be interested in this Websocket example interfacing with coinapi.io:
code.kx.com
Machine learning | kdb+ and q documentation - Kdb+ and q documentation
Machine-learning capabilities are at the heart of future technology development at KX. Libraries are added here as they are released. Libraries are released under the Apache 2 license, and are free for all use cases, including 64-bit and commercial use.
-
Yes you can renew it again.
-
What is the definition of handle_close?
Trying to close a handle which is already closed will throw that error.
Since you call exit 0 above the handle will be closed by the process exiting.
q)hclose 5 //Success first time
q)hclose 5 //Fails as 5 no longer exists, was closed above
'close. OS reports: Bad file descriptor
[0] hclose 5
-
Here are some links and resources. What changes you may make depend heavily on your data and use-case:
- Whitepaper: https://code.kx.com/q/wp/rt-tick/
- Tick configuration: https://code.kx.com/q/kb/kdb-tick/
- Tick architecture: https://www.defconq.tech/docs/architecture/plain
- Tick source code: https://github.com/KxSystems/kdb-tick/blob/master/tick.q
- Similar recent question: https://stackoverflow.com/questions/78278007/problems-and-solutions-for-an-increased-amount-of-tick-data-in-kdb-q
- Custom tick partitioning: https://kx.com/blog/partitioning-data-in-kdb/
- TorQ tickerplant modes: https://dataintellecttech.github.io/TorQ/Processes/#tickerplant
-
q)type"t" // t is a character atom - 'like' expects a character vector -10h q)type"IBM" // IBM is a character vector 10h q)type enlist "t" // You can enlist an atom to be a single item vector 10h q)type (),"t" // (), is useful as a conditional enlist. It enlists the atom 10h q)type (),"IBM" // It does not enlist the vector 10h
-
rocuinneagain
MemberApril 3, 2024 at 9:27 am in reply to: What is the difference between the sym files- The sym file in root of the partitioned database is an enumeration file.
- Each date does not have it’s own enumeration file.
- The sym files inside the date/table folders are columns of name sym.
These names are not enforced but it is a common practice that ticker symbols are stored in a column named ‘sym’ of type symbol and are enumerated against a file called ‘sym’.
-
Hi
- What problem/error do you see?
- Can you share the text or a screenshot?
- What operating system are you installing on?
-
Related thread: embedPy installation: os error with kdb and python – Stack Overflow
I would try:
python -m pip install libpython
If still failing see output from https://pypi.org/project/find-libpython/
pip install find_libpython
>>> from find_libpython import find_libpython
>>> find_libpython() -
rocuinneagain
MemberMarch 19, 2024 at 11:29 am in reply to: How to convert sym columns to guid or to original dataCan you include some more code to explain what the issue is?
To create a symbol vector you are using:
`symbol$()
but you should use:
`$()
.i.e
q)order_histories:([]time:`timespan$();sym:`$();user_uuid:`$();order_id:`long$();instrument:`$())
q)order_histories
time sym user_uuid order_id instrument
--------------------------------------Insert some data and set a port:
q)order_histories insert (2?.z.N;2?`6;2?`6;2?100000;2?`6)
0 1
q)order_histories
time sym user_uuid order_id instrument
---------------------------------------------------------0D09:21:01.649029855 kfmohp kfhogj 81418 milgli
0D05:24:41.981647398 lkklco jecpae 75009 igfbag
q)\p 5000Query from PyKX
>>> import pykx as kx
>>> conn('order_histories')
pykx.Table(pykx.q('
time sym user_uuid order_id instrument
---------------------------------------------------------
0D09:21:01.649029855 kfmohp kfhogj 81418 milgli
0D05:24:41.981647398 lkklco jecpae 75009 igfbag
'))
>>> conn('order_histories').pd()
time sym user_uuid order_id instrument
0 0 days 09:21:01.649029855 kfmohp kfhogj 81418 milgli
1 0 days 05:24:41.981647398 lkklco jecpae 75009 igfbag -
A few different variations:
-1 {i:where ""~/:x;raze "<html><body><p>",@[x;i;:;count[i]#enlist "</p><p>"],"</p></body></html>"} read0 `:smile.txt -1"<html><body><p>",,[;"</p></body></html>"] ssr[;"n";""] "</p><p>" sv "nn" vs`char$read1`:smile.txt -1"<html><body><p>",ssr["</p><p>"sv"nn"vs`char$read1`:smile.txt;"n";""],"</p></body></html>" -1{.h.htc[y;x]}over(ssr["</p><p>"sv"nn"vs`char$read1`:smile.txt;"n";""];`p;`body;`html) -1({.h.htc[y;x]})(ssr["</p><p>"sv"nn"vs`char$read1`:smile.txt;"n";""];`p;`body;`html)
-
rocuinneagain
MemberFebruary 23, 2024 at 12:00 am in reply to: Interaction between peach and other optimisationskdb+ 4.1 has been released with some interesting improvements for
peach
which changes some of my answers as nesting is now supportedhttps://code.kx.com/q//releases/ChangesIn4.1/#peachparallel-processing-enhancements
-
Can you try https://pypi.org/project/find-libpython/
pip install find_libpython
>>> from find_libpython import find_libpython
>>> find_libpython()What is the output?
-
rocuinneagain
MemberMarch 20, 2024 at 4:37 pm in reply to: How to convert sym columns to guid or to original dataCan you share a small sample of your PyKX code which shows the issue?