cancel
Showing results for 
Search instead for 
Did you mean: 

capstone 3.2

005031
New Contributor

The way I'm looking at it my code looks correct and its outputting what I expect for all the values I've checked except the one I've highlighted, correct me if I'm wrong but this trade is selling so should output 1 if the price is higher than the id which it is. but its outputting a 0.

Screenshot 2023-11-08 105500.png

Screenshot 2023-11-08 105527.png

1 ACCEPTED SOLUTION

Laura
Community Manager Community Manager
Community Manager

Hi @005031 ,

You are correct that trade should be marked as a good trade.

Using "~" in your function is actually always coming back false, therefore each trade is being assigned the last argument of your vector conditional.  This actually still works for most of the trades, but for the trade you have highlighted, the ask is also lower than the price, hence it's assigning the wrong exQuality.

If you use "=" instead of "~" your classifyTrades function should work correctly.

For more insight into why you should use equals over the match operator here, I've added some links below.

Comparison | Basics | kdb+ and q documentation - Kdb+ and q documentation (kx.com)

4. Operators - Q for Mortals (kx.com)

Hope this helps!

Laura

View solution in original post

1 REPLY 1

Laura
Community Manager Community Manager
Community Manager

Hi @005031 ,

You are correct that trade should be marked as a good trade.

Using "~" in your function is actually always coming back false, therefore each trade is being assigned the last argument of your vector conditional.  This actually still works for most of the trades, but for the trade you have highlighted, the ask is also lower than the price, hence it's assigning the wrong exQuality.

If you use "=" instead of "~" your classifyTrades function should work correctly.

For more insight into why you should use equals over the match operator here, I've added some links below.

Comparison | Basics | kdb+ and q documentation - Kdb+ and q documentation (kx.com)

4. Operators - Q for Mortals (kx.com)

Hope this helps!

Laura