Jump to content

Recommended Posts

I know this forum doesn't support Lightstreamer but I am trying to create the smallest working C# .NET console app that will give me a streaming price. Finding the right set of parameters is proving difficult. Looking at the Lightstreamer documentation doesn't really help as this problem might be specific to the CityIndex parameters. I've managed to use the cityindex API for various other stuff without issues, so I have a valid session ID, etc.. Can you see an obvious problem with this code?

Any help is greatly appreciated.

Chris.

void Main()
{
    LightstreamerClient lsClient = new LightstreamerClient("https://push.cityindex.com", "STREAMINGALL");
    lsClient.connectionDetails.User = <UserName>;
    lsClient.connectionDetails.Password = <SessionId>;
    lsClient.connect();
    var testSubscription = new Subscription("MERGE");
    testSubscription.Fields = new string[2] { "MarketId", "Bid"};
    testSubscription.Items = new string[1] { "PRICE.154297" };
    testSubscription.DataAdapter = "PRICES";
    //testSubscription.RequestedMaxFrequency = "3.0";
    testSubscription.addListener(new QuoteListener());
    lsClient.subscribe(testSubscription);
    Console.WriteLine("Press a key to quit...");
    Console.Read();
}

class QuoteListener : SubscriptionListener
{
    void SubscriptionListener.onClearSnapshot(string itemName, int itemPos)
    {
        Console.WriteLine("Clear Snapshot for " + itemName + ".");
    }

    void SubscriptionListener.onCommandSecondLevelItemLostUpdates(int lostUpdates, string key)
    {
        Console.WriteLine("Lost Updates for " + key + " (" + lostUpdates + ").");
    }

    void SubscriptionListener.onCommandSecondLevelSubscriptionError(int code, string message, string key)
    {
        Console.WriteLine("Subscription Error for " + key + ": " + message);
    }

    void SubscriptionListener.onEndOfSnapshot(string itemName, int itemPos)
    {
        Console.WriteLine("End of Snapshot for " + itemName + ".");
    }

    void SubscriptionListener.onItemLostUpdates(string itemName, int itemPos, int lostUpdates)
    {
        Console.WriteLine("Lost Updates for " + itemName + " (" + lostUpdates + ").");
    }

    void SubscriptionListener.onItemUpdate(ItemUpdate itemUpdate)
    {
        Console.WriteLine("New update for " + itemUpdate.ItemName);

        IDictionary<string, string> listc = itemUpdate.ChangedFields;
        foreach (string value in listc.Values)
        {
            Console.WriteLine(" >>>>>>>>>>>>> " + value);
        }
    }

    void SubscriptionListener.onListenEnd(Subscription subscription)
    {
        // throw new System.NotImplementedException();
    }

    void SubscriptionListener.onListenStart(Subscription subscription)
    {
        // throw new System.NotImplementedException();
    }

    void SubscriptionListener.onRealMaxFrequency(string frequency)
    {
        Console.WriteLine("Real frequency: " + frequency + ".");
    }

    void SubscriptionListener.onSubscription()
    {
        Console.WriteLine("Start subscription.");
    }

    void SubscriptionListener.onSubscriptionError(int code, string message)
    {
        Console.WriteLine("Subscription error: " + message);
    }

    void SubscriptionListener.onUnsubscription()
    {
        Console.WriteLine("Stop subscription.");
    }

}

Share this post


Link to post

Hi Chris,

You didn't say what problem you were encoutering is? What error messqges do you receive, what happens when you run your code etc.

Kind Regards, PM

Share this post


Link to post

Apologies PM, the result of running this code is that it simply waits for me to press a key with nothing appearing in the console, so no callbacks to QuoteListener.

Kind Regards
Chris.

 

Share this post


Link to post

Hi Chris,

I forgot to ask, are you a US or a British client? The MarketID you are subscribing to is (154297) the GBP/USD CFD market, which would not be available to US clients. If you are a US client this would explain why you are not receiving anything back at all.

The GBP/USD spot FX market that US clients do have access to should have the Market ID of 401484392. You can follow the instructions in http://docs.labs.gaincapital.com/#How Do I/Find Market ID.htm%3FTocPath%3DHow%20Do%20I...%3F|_____1 to query for other market IDs as required. 

Kind Regards, PM

Share this post


Link to post

Hi Chris,

The only thing I can think of in terms of CityIndex parameters that might apply is including the "TickDate" in your price call:

testSubscription.Fields = new string[2] { "MarketId", "TickDate", "Bid"};

 

As documented in the PriceDTO http://docs.labs.gaincapital.com/#Data Types/PriceDTO.htm. Everything else is using standard Lightstreamer connection and subscription methods. You could try the LS forum at https://forums.lightstreamer.com/ to see if you can get help on using LS.

Kind Regards, PM

 

Share this post


Link to post

Hi chriss,

It looks like you're using the interface implementations (Subscription, SubscriptionListener, etc) from the Lightstreamer .NET Standard Client Library v.5.0.*, which appears to be solely compatible with Lightstreamer 7.1.0+. Since GCAPI is using Lightstreamer 7.0.3 (at least it was the last I checked), you'll want to use the .NET Client Library v. 4.0.0.

I only know this because my app is also written in C#, and I spent a while banging my head on the proverbial wall trying to get my live streaming sorted out properly. :lol:

It's available in NuGet - you just have to specify Version 4.0.0 when installing.

And the documentation is here: https://lightstreamer.com/api/ls-dotnetstandard-client/4.0.0/frames.html?frmname=topic&frmfile=index.html

Garrett

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×