Subscribing to trade table in C#

Hi everybody!

I’m trying to subscribe to our `quote table in KDB using C# (c.cs) to update some charts. I was following the example found at:

http://code.kx.com/wiki/Cookbook/InterfacingWithCSharp#Simple\_Subscriber

So far no luck, I can’t get it to work.

Does anybody has a working sample in C# using c.cs to create a simple subscriber? All I want is to get ask & bid prices from that table to update some charts.

Appreciate any help.

Best, Diego

Can you post some code and whether you see any errors? Can you see a handle in .u.w in the tickerplant when you connect/subscribe?

  1. Are you definitely subscribing to a tickerplant (rather than an RDB for example which in standard setup wouldn’t have pub/sub functionality)?
  2. Do the symbols you are subscribing to exist in the tickerplant?  The “starting kdb+” example that is referenced has symbols like MSFTIBM rather than MSFT.OIBM.N as in the example.  If you just want to subscribe to all change the subscription line to

c.k(“sub[quote;]”)

Sorry for the late reply.

This is the code I’m running:

            c conn = null;

            try

            {

                conn = new c(server, port);

                conn.k(“sub[trade;]”);

                while (true)

                {

                    object result = conn.k();

                    c.Flip d = c.td(result);

                    Console.WriteLine(d != null);

                }

            }

            catch (Exception ex)

            {

                Console.WriteLine(ex.Message);

                Console.WriteLine(ex.StackTrace);

            }

            finally

            {

                if (conn != null) conn.Close();

            } 

But I can’t get pass this line of code: conn.k(“sub[trade;]”);

I get an exception saying “sub” that points to a few k() functions in kx.cs

I’m not exactly sure how to check if I’m subscribing to a tickerplant or what our setup is like. Is there a way for me to check that? Or is that something I have to check with our System Administrator?

Thanks a lot for your help.

Best,

Diego

I think you should probably check with your sys admin what is running on the host and port you are connecting to - generally people don?t appreciate test connections hitting their tickerplant processes unannounced!

If it?s a standard tickerplant then you will need to execute .u.sub rather than sub (a tickerplant doesn?t have a method called sub defined)