Skip to content

Add new property to ExchangeTicker that contains response JSON. This … #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
457 changes: 224 additions & 233 deletions src/ExchangeSharp/API/Exchanges/Aquanow/ExchangeAquanowAPI.cs

Large diffs are not rendered by default.

776 changes: 394 additions & 382 deletions src/ExchangeSharp/API/Exchanges/BitBank/ExchangeBitBankAPI.cs

Large diffs are not rendered by default.

352 changes: 233 additions & 119 deletions src/ExchangeSharp/API/Exchanges/Bitfinex/ExchangeBitfinexAPI.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace ExchangeSharp
{
public partial class ExchangeBittrexAPI
{

#if HAS_SIGNALR

/// <summary>
Expand Down Expand Up @@ -78,7 +77,7 @@ public async Task<IWebSocket> SubscribeToExchangeDeltasAsync(Func<string, Task>
}
}

private BittrexWebSocketManager webSocket;
private BittrexWebSocketManager webSocket;

public static string ReverseMarketNameForWS(string WebSocketFeedMarketName)
{
Expand All @@ -96,10 +95,11 @@ protected override async Task<IWebSocket> OnGetTickersWebSocketAsync(Action<IRea
async Task innerCallback(string json)
{
#region sample json

/*
{
Nonce : int,
Deltas :
Deltas :
[
{
MarketName : string,
Expand All @@ -119,15 +119,14 @@ async Task innerCallback(string json)
]
}
*/
#endregion

#endregion sample json

var freshTickers = new Dictionary<string, ExchangeTicker>(StringComparer.OrdinalIgnoreCase);
JToken token = JToken.Parse(json);
token = token["D"];
foreach (JToken ticker in token)
{


string marketName = ReverseMarketNameForWS(ticker["M"].ToStringInvariant());
if (filter.Count != 0 && !filter.Contains(marketName))
{
Expand All @@ -143,6 +142,7 @@ async Task innerCallback(string json)
var t = new ExchangeTicker
{
MarketSymbol = marketName,
ApiResponse = ticker,
Ask = ask,
Bid = bid,
Last = last,
Expand Down Expand Up @@ -176,27 +176,28 @@ params string[] marketSymbols
Task innerCallback(string json)
{
#region sample json

/*
{
MarketName : string,
Nonce : int,
Buys:
Buys:
[
{
Type : int,
Rate : decimal,
Quantity : decimal
}
],
Sells:
Sells:
[
{
Type : int,
Rate : decimal,
Quantity : decimal
}
],
Fills:
Fills:
[
{
FillId : int,
Expand All @@ -208,7 +209,8 @@ Task innerCallback(string json)
]
}
*/
#endregion

#endregion sample json

var ordersUpdates = JsonConvert.DeserializeObject<BittrexStreamUpdateExchangeState>(json);
var book = new ExchangeOrderBook();
Expand All @@ -229,8 +231,8 @@ Task innerCallback(string json)
return Task.CompletedTask;
}

return await new BittrexWebSocketManager().SubscribeToExchangeDeltasAsync(innerCallback, marketSymbols);
}
return await new BittrexWebSocketManager().SubscribeToExchangeDeltasAsync(innerCallback, marketSymbols);
}

protected override async Task<IWebSocket> OnGetTradesWebSocketAsync(Func<KeyValuePair<string, ExchangeTrade>, Task> callback, params string[] marketSymbols)
{
Expand Down Expand Up @@ -261,19 +263,17 @@ async Task innerCallback(string json)

#endif

protected override void OnDispose()
{

protected override void OnDispose()
{
#if HAS_SIGNALR

if (webSocket != null)
{
webSocket.Dispose();
webSocket = null;
}
if (webSocket != null)
{
webSocket.Dispose();
webSocket = null;
}

#endif

}
}
}
}
}
Loading