KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Academy capstone 3.2

  • capstone 3.2

    Posted by 5031 on November 8, 2023 at 12:00 am

    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.

     

     

    ?

    ?

    5031 replied 9 months, 3 weeks ago 2 Members · 1 Reply
  • 1 Reply
  • Laura

    Administrator
    November 8, 2023 at 12:00 am

    Hi  ,

    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

Log in to reply.