

davidcrossey
Forum Replies Created
-
If you had the following scenario, you could sort the reward desending, sort the pickSeq ascending and use indices to solve for your problem:
q)n:10 q)people:([]pickSeq:0+til n;person:`$"person",/:string 1+til n;allowedToPick:n?01b) q)people pickSeq person allowedToPick ------------------------------ 0 person1 1 1 person2 1 2 person3 1 3 person4 1 4 person5 0 5 person6 0 6 person7 0 7 person8 1 8 person9 0 9 person10 0 q)rewards:([]prize:(1+til 10)*100) q)rewards prize ----- 100 200 300 400 500 600 700 800 900 1000 q)(update ind:i from xdesc[`prize;rewards]) lj `ind xkey update ind:i from select person from xasc[`pickSeq;people] where allowedToPick prize ind person ----------------- 1000 0 person1 900 1 person2 800 2 person3 700 3 person4 600 4 person8 500 5 400 6 300 7 200 8 100 9
You could also extract the person and their prize as follows:
q){if[1=count x;x:enlist x]; if[1=count y;y:enlist y]; y!x iasc y}[exec desc prize from rewards;] exec person from xasc[`pickSeq;people] where allowedToPick person1| 1000 person2| 900 person3| 800 person4| 700 person8| 600
-
-
davidcrossey
MemberMay 3, 2022 at 12:00 am in reply to: Whats the best toolset for developing in kdb+?VS Code in WSL with the KDB+/Q extension here
-
davidcrossey
MemberApril 14, 2022 at 12:00 am in reply to: Concurrent user request issues for sequential processing of processesCheck out the architecture diagram on Sync requests – KX Platform for an idea of how you could set this up.
Your Java client can use sync requests with a Gateway (GW) process.
The GW can then defer the response to the Java client and send the query (async) through a Query Router (QR), thus allowing the GW to handle more client requests.
Queries then flow on to a Query Process (QP) which completes the actual work, before sending the result back to the GW, and then finally the client.
Please also see information on Callbacks
-
You can do something like the following:
q)f:{[x] $[x~`a;5;x~`b;[y:6*6;$[y<6;6;y>9;10;y]];x]} q)f {[x] $[x~`a;5;x~`b;[y:6*6;$[y<6;6;y>9;10;y]];x]} q)f `a 5 q)f `b 10
I would use a function (as above) or a lambda (anonymous function), that way your temp variable will only remain for the scope of the function i.e. in the example above, y does not exist in my global namespace after execution. You can read more about conditional scope here
You can see if x is b in the above we have square brackets [ ] which defines a contained block of code to run if the statement is true. See more here
Please find more on the extended if-else / switch statement here
-
You’ll need to install a utility program like rlwrap and run that when you start q to add command history navigation within your q session.
-
davidcrossey
MemberApril 11, 2022 at 12:00 am in reply to: Query Routing/ Load Balancing / asynchronous callbacksI think the issue is that you are blocking on the client as your last command
x[]
Interprocess communication | Basics | kdb+ and q documentation – Kdb+ and q documentation (kx.com)
They may be no message being sent back from the client, especially true if is an issue on the server, or if you don’t have a callback on the calling handle.
Perhaps you meant to async flush?
neg[x][]
Might be worth while putting a nohup on the front of your ‘&’ commands, and I’d also suggest opening you handle as the projection, instead of opening per call to GW. You could add a check in your funct to check if the handle is valid and reopen as needed?
Just an note – you could save that function in any file, and source; doesn’t have to be .bashrc unless that’s your intention.
-
davidcrossey
MemberApril 11, 2022 at 12:00 am in reply to: Concurrent user request issues for sequential processing of processesTo handle multiple concurrent client sync requests you could consider using deferred response to suspend sync queries whilst they are being processed, allowing your gateway to process further client requests. The result will be returned to the client when processing has completed.
-
Specific port number shouldn’t be an issue.
Best to source all of the config params prior to running the launcher.q_ script as per this note i.e. running the config.bat script first.
-
ChartIQ requires a separate licence to run.
Generally you should utilise the custom financial chart, or alternatively canvas charts/chartGL which both have candlestick charts built in.
-
Do you have any data coming back through your data source “temp”?
-
davidcrossey
MemberApril 6, 2022 at 12:00 am in reply to: Is there a tuning guide document for production?Check out the following for each of your questions.
- Linux production notes Knowledge Base kdb+ and q documentation – Kdb+ and q documentation (kx.com)
- Logging Best Practices – KX
- If using KX Platform, Monitoring – KX Platform, or you could export metrics using Prometheus Exporter to visualise in another client application
Hope this helps.
-
A few things here;
- You won’t see any bars as your open/high/low/close prices are all the same value. In your test data you need a range of prices over the course of a day (for example), then you would take the first/max/min/last (OHLC) per date
- The documentation appears to be a little misleading with “Time” column. It should be a timestamp.
Here is a mock example I’ve just put together and a data source for reference
Data Source
n:10000; t:([]Date:n?.z.p;price:n?100f;Volume:n?100f); delete price from update Open:first price, Close:last price, High:max price, Low:min price, Volume:sum Volume by `date$Date from t
Hope this helps
-
davidcrossey
MemberApril 4, 2022 at 12:00 am in reply to: Query Routing/ Load Balancing / asynchronous callbacksHi Simon,
Thanks for sharing your query.
Just curious if you have you tried either of these approaches outside of Developer on raw q processes to run as async callbacks?
Regards,
David
-
Hi ekallivrousis,
Just an update here. There currently isn’t any plans to develop and support a Go interface from KX.
It may be worthwhile engaging with the wider community provided interfaces if you run into particular issues.
Kind regards,
David