Comments (6)
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.
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.
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.
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.
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.
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)
- Adding a new symbol to a existing subscribtion HOT 3
- unsafe access to subscriptions collection on SocketConnection.ProcessReconnectAsync HOT 2
- request for new common features - withdraw HOT 1
- CallResult Error code is null on request timed out HOT 1
- Proposal: Ability for all Error derived classes to have Code and Data HOT 1
- Remove the ArrayConverter and Cache the New Expressions instead of using Activator.CreateInstance
- It is not possible to change ratelimiters after instantiating the REST client. HOT 2
- Exception "Value cannot be null" in RestApiClient.ParseRateLimitResponse HOT 1
- Hi i'm seeing an exception even though i haven't changed anything HOT 2
- How can i set BaseAddress, BaseAddressUsdtFutures for test url's HOT 2
- Mexc wrapper? HOT 3
- Custom KeepAliveInterval to SocketOptions
- CryptoExchange.Net work with Coinbase Pro's API in the Future???
- Improvement: Add "ExchangeName" to "IRestApiClient" HOT 1
- Common interface for SocketClients
- Miss (Parameter 'accountId')) on common PlaceOrderAsync for Huobi
- SetProxy(ClientWebSocket socket, ApiProxy proxy) Uri.TryCreate in part causes unnecessary errors HOT 1
- Question: Does this library or CryptoClients.Net have built-in support for local orderbook management? HOT 2
- Can't get options order books (Bybit)
- Suggestion - Mark Price on order book data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cryptoexchange.net.