Giter Site home page Giter Site logo

Comments (6)

JKorf avatar JKorf commented on September 16, 2024 1

The websocket connection works based on events. So when you're calling SubscribeToTickerUpdates you connect to a stream and when data is received on that stream you get an update. To handle the update you'll have to pass an update handler to the subscribe method. This is what the data => {} bit is.
Between the {} you'll have to handle the data. What to do with it is obviously up to you, but having a console application this will simply write the price of the latest tick to the console:

client.SubscribeToTickerUpdates("XBT/EUR", data => { 
      Console.WriteLine(data.Market + " last trade price: " + data.Data.LastTrade.Price);
});

from cryptoexchange.net.

JKorf avatar JKorf commented on September 16, 2024

The initial error cannot convert from 'int' to 'Kraken.Net.Interfaces.IKrakenSocketClient' is because the kraken order book doesn't need the same parameters as the binance order book you copied from the examples. I'll add to the examples that different order books might need slightly different parameters.

The basic kraken order book only needs a limit specified like this:
new KrakenSymbolOrderBook("XBT/USD", 100);
The socket client you can pass in the options is used to combine multiple order book on the same socket connection.

The second error you ran into is refering to the limit parameter, a limit of 1 is not supported. I know a limit of 100 is supported, but I'm not sure what all other possible values might be. Also note that the market you pass ('XXBTZEUR') is not a valid websocket market. The KrakenSymbolOrderBook uses a websocket connection, and the websocket needs different market names than the Rest API uses.. (thanks kraken)
To get the correct websocket name of a market you can use the GetMarkets call on the KrakenClient and use the WebsocketName of the market you're interested in. For Bitcoin / Euro that would be XBT/EUR:
new KrakenSymbolOrderBook("XBT/EUR", 100);

from cryptoexchange.net.

cr0wburn avatar cr0wburn commented on September 16, 2024

By changing the KrakenSymbolOrderBook to:
KrakenSymbolOrderBook orderBook = new KrakenSymbolOrderBook("XBT/EUR", 100);

It works like a charm, thank you for your help.

from cryptoexchange.net.

cr0wburn avatar cr0wburn commented on September 16, 2024

I have never worked with WebSockets before, and you are super helpfull. :)

var subResult = client.SubscribeToTickerUpdates("XBT/EUR", data => { });
subResult contains Succes = true;

But where does the Kraken.Net.Objects.KrakenStreamTick go ?
I don't know how to get it, and after i get it, how do i get an updated value at the next tick ?
Sorry for posting a non issue, but maybe this can be added to the manual.

Thanks(and sorry)

from cryptoexchange.net.

cr0wburn avatar cr0wburn commented on September 16, 2024

Thank you, this is exactly what i needed to know!
I did it like this (as an example)

var subResult = client.SubscribeToTickerUpdates("XBT/EUR", data => Ticker(data));
 
      static void Ticker(Kraken.Net.Objects.Socket.KrakenSocketEvent<Kraken.Net.Objects.KrakenStreamTick> tick)
        {
            var a = tick.Data;
            var bid = a.BestBids;
            var ask = a.BestAsks;
        }

from cryptoexchange.net.

JKorf avatar JKorf commented on September 16, 2024

Yup that's fine.
(You could shorthand it by writing client.SubscribeToTickerUpdates("XBT/EUR", Ticker);, which is the same)

from cryptoexchange.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.