-
Notifications
You must be signed in to change notification settings - Fork 9
/
CryptowatchAPI.cs
699 lines (666 loc) · 25.7 KB
/
CryptowatchAPI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
// Copyright(c) 2017 Stock84-dev
// https://github.com/Stock84-dev/Cryptowatch-API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.IO;
using Newtonsoft.Json; // install Newtonsoft.Json nuGet package
using Newtonsoft.Json.Linq;
namespace Cryptowatch
{
/// <summary>
/// Documentation can be found here https://cryptowat.ch/docs/api
/// </summary>
public class CryptowatchAPI
{
/// <summary>
/// Allowance is updated with every call.
/// </summary>
public static Allowance allowance = null;
///<summary>
///You can always request this to query your allowance without any extra result - this request costs very little.
/// </summary>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static SiteInformation GetSiteInformation()
{
try
{
return Deserialize<SiteInformation>(GetJObject("https://api.cryptowat.ch"));
}
catch
{
throw;
}
}
/// <summary>
///Returns all assets(in no particular order)
/// </summary>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static List<Assets> GetAssets()
{
try
{
return DeserializeToList<Assets>(GetJObject("https://api.cryptowat.ch/assets"));
}
catch
{
throw;
}
}
/// <summary>
///Returns a single asset. Lists all markets which have this asset as a base or quote.
/// </summary>
/// <param name="route"> Asset specific url, e.g. https://api.cryptowat.ch/assets/btc </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static Asset GetAsset(string route)
{
try
{
return Deserialize<Asset>(GetJObject(route));
}
catch
{
throw;
}
}
/// <summary>
/// Returns all pairs (in no particular order).
/// </summary>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static List<Pairs> GetPairs()
{
try
{
return DeserializeToList<Pairs>(GetJObject("https://api.cryptowat.ch/pairs"));
}
catch
{
throw;
}
}
/// <summary>
/// Returns a single pair. Lists all markets for this pair.
/// </summary>
/// <param name="route"> Pair specific url, e.g. https://api.cryptowat.ch/pairs/ethbtc </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static Pair GetPair(string route)
{
try
{
return Deserialize<Pair>(GetJObject(route));
}
catch
{
throw;
}
}
/// <summary>
/// Returns a list of all supported exchanges.
/// </summary>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static List<Exchanges> GetExchanges()
{
try
{
return DeserializeToList<Exchanges>(GetJObject("https://api.cryptowat.ch/exchanges"));
}
catch
{
throw;
}
}
/// <summary>
/// Returns a single exchange, with associated routes.
/// </summary>
/// <param name="route"> Exchange specific url, e.g. https://api.cryptowat.ch/exchanges/kraken </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static Exchange GetExchange(string route)
{
try
{
return Deserialize<Exchange>(GetJObject(route));
}
catch
{
throw;
}
}
/// <summary>
/// Returns a list of all supported markets.
/// </summary>
/// <param name="route">You can also get the supported markets for only a specific exchange. e.g. https://api.cryptowat.ch/markets/kraken </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static List<Markets> GetMarkets(string route = "https://api.cryptowat.ch/markets")
{
try
{
return DeserializeToList<Markets>(GetJObject(route));
}
catch
{
throw;
}
}
/// <summary>
/// Returns a single market, with associated routes.
/// </summary>
/// <param name="route"> Market specific url, e.g. https://api.cryptowat.ch/markets/gdax/btcusd </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static Market GetMarket(string route)
{
try
{
return Deserialize<Market>(GetJObject(route));
}
catch
{
throw;
}
}
/// <summary>
/// Returns the current price for all supported markets. Some values may be out of date by a few seconds.
/// <para>
/// key = exchangeName:pairName
/// </para>
/// </summary>
/// <returns> dictionsry</returns>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static Dictionary<string, double> GetPrices()
{
try
{
return Deserialize<Dictionary<string, double>>(GetJObject("https://api.cryptowat.ch/markets/prices"));
}
catch
{
throw;
}
}
/// <summary>
/// Returns a market’s last price.
/// </summary>
/// <param name="route"> Price specific url, e.g. https://api.cryptowat.ch/markets/gdax/btcusd/price </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static double GetPrice(string route)
{
try
{
return Deserialize<Price>(GetJObject(route)).price;
}
catch
{
throw;
}
}
/// <summary>
/// Returns the market summary for all supported markets. Some values may be out of date by a few seconds.
/// <para>
/// key = exchangeName:pairName
/// </para>
/// </summary>
/// <returns> dictionsry</returns>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static Dictionary<string, Summary> GetSummaries()
{
try
{
return Deserialize<Dictionary<string, Summary>>(GetJObject("https://api.cryptowat.ch/markets/summaries"));
}
catch
{
throw;
}
}
/// <summary>
/// Returns a market’s last price as well as other stats based on a 24-hour sliding window: High price, Low price, % change, Absolute change, Volume
/// </summary>
/// <param name="route"> Summary specific url, e.g. https://api.cryptowat.ch/markets/gdax/btcusd/summary </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static Summary GetSummary(string route)
{
try
{
return Deserialize<Summary>(GetJObject(route));
}
catch
{
throw;
}
}
/// <summary>
/// Returns a market’s most recent trades, incrementing chronologically. Note some exchanges don’t provide IDs for public trades.
/// </summary>
/// <param name="route"> Trade specific url, e.g. https://api.cryptowat.ch/markets/gdax/btcusd/trades </param>
/// <param name="limit"> Limit amount of trades returned. If 0 returns all.</param>
/// <param name="since"> Only return trades at or after this time. </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static List<Trade> GetTrades(string route, int limit = 50, long since = -1)
{
if (limit != 50 && since != -1)
{
route += "?limit=" + limit.ToString() + "&since=" + since.ToString();
}
else if(since != -1)
{
route += "?since=" + since.ToString();
}
else if(limit != 50)
{
route += "?limit=" + limit.ToString();
}
try
{
List<double[]> tradeList = DeserializeToList<double[]>(GetJObject(route));
List<Trade> trades = new List<Trade>();
foreach (var t in tradeList)
{
trades.Add(new Trade((int)t[0], (long)t[1], t[2], t[3]));
}
return trades;
}
catch
{
throw;
}
}
/// <summary>
/// Returns a market’s order book.
/// </summary>
/// <param name="route"> OrderNook specific url, e.g. https://api.cryptowat.ch/markets/gdax/btcusd/orderbook </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static OrderBook GetOrderBook(string route)
{
try
{
_OrderBook _orderBook = Deserialize<_OrderBook>(GetJObject(route));
OrderBook orderBook = new OrderBook();
foreach (var bid in _orderBook.bids)
{
orderBook.bids.Add(new Order(bid[0], bid[1]));
}
foreach (var ask in _orderBook.asks)
{
orderBook.asks.Add(new Order(ask[0], ask[1]));
}
return orderBook;
}
catch
{
throw;
}
}
/// <summary>
/// Returns a market’s OHLC candlestick data.
/// </summary>
/// <param name="route"> Candlestick specific url, e.g. https://api.cryptowat.ch/markets/gdax/btcusd/ohlc </param>
/// <param name="timeFrame"> Candlestick timeframe.</param>
/// <param name="after"> Only return candles opening after this time. If set to -1 max limit is 6000, otherwise it's 500.</param>
/// <param name="before"> Only return candles opening before this time. </param>
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
public static List<Candlestick> GetCandlesticks(string route, TimeFrame timeFrame, long after = -2, long before = 0)
{
route += "?periods=" + ((int)timeFrame).ToString();
if (after != -2)
{
route += "&after=" + after.ToString();
}
if (before != 0)
{
route += "&before=" + before.ToString();
}
try
{
_Candlestick _candlestick = Deserialize<_Candlestick>(GetJObject(route));
List<Candlestick> candles = new List<Candlestick>();
foreach (var c in _candlestick.allCandlesticks)
{
candles.Add(new Candlestick((long)c[0], c[1], c[2], c[3], c[4], c[5]));
}
return candles;
}
catch
{
throw;
}
}
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
private static Stream GetResponseStream(string url)
{
try
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Accept = "*/*";
httpWebRequest.Method = "GET";
//httpWebRequest.Headers.Add("Authorization", "Basic reallylongstring");
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
return httpResponse.GetResponseStream();
}
catch
{
throw;
}
}
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
private static JObject GetJObject(string url)
{
try
{
StreamReader sr = new StreamReader(GetResponseStream(url));
string response = sr.ReadToEnd();
JObject jObject = JObject.Parse(response);
sr.Close();
return jObject;
}
catch
{
throw;
}
}
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
private static List<T> DeserializeToList<T>(JObject jObject)
{
try
{
// if we get any other error from cryptowatch
foreach (var responseType in jObject)
{
if (responseType.Key == "error")
throw new Exception("Cryptowatch error: " + responseType.Value.ToObject<string>());
}
// get JSON result objects into a list
List<JToken> jTokens = jObject["result"].Children().ToList();
allowance = jObject["allowance"].ToObject<Allowance>();
// serialize JSON results into .NET objects
List<T> objects = new List<T>();
foreach (JToken jToken in jTokens)
{
// JToken.ToObject is a helper method that uses JsonSerializer internally
objects.Add(jToken.ToObject<T>());
}
return objects;
}
catch
{
throw;
}
}
/// <exception cref="OutOfMemoryException"></exception>
/// <exception cref="IOException"></exception>
/// <exception cref="JsonReaderException"></exception>
/// <exception cref="NotSupportedException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="System.Security.SecurityException"></exception>
/// <exception cref="UriFormatException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="InvalidOperationException"></exception>
/// <exception cref="ProtocolViolationException"></exception>
/// <exception cref="WebException"></exception>
/// <exception cref="ObjectDisposedException"></exception>
private static T Deserialize<T>(JObject jObject)
{
try
{
// if we get any other error from cryptowatch
foreach (var responseType in jObject)
{
if (responseType.Key == "error")
throw new Exception("Cryptowatch error: " + responseType.Value.ToObject<string>());
}
allowance = jObject["allowance"].ToObject<Allowance>();
return jObject["result"].ToObject<T>();
}
catch
{
throw;
}
}
private class _OrderBook
{
public double[][] asks { get; set; }
public double[][] bids { get; set; }
}
private class _Candlestick
{
public double[][] allCandlesticks { get; set; }
[JsonProperty("60")]
private double[][] min { set { allCandlesticks = value; } }
[JsonProperty("180")]
private double[][] _180 { set { allCandlesticks = value; } }
[JsonProperty("300")]
private double[][] _300 { set { allCandlesticks = value; } }
[JsonProperty("900")]
private double[][] _900 { set { allCandlesticks = value; } }
[JsonProperty("1800")]
private double[][] _1800 { set { allCandlesticks = value; } }
[JsonProperty("3600")]
private double[][] _3600 { set { allCandlesticks = value; } }
[JsonProperty("7200")]
private double[][] _7200 { set { allCandlesticks = value; } }
[JsonProperty("14400")]
private double[][] _14400 { set { allCandlesticks = value; } }
[JsonProperty("21600")]
private double[][] _21600 { set { allCandlesticks = value; } }
[JsonProperty("43200")]
private double[][] _43200 { set { allCandlesticks = value; } }
[JsonProperty("86400")]
private double[][] _86400 { set { allCandlesticks = value; } }
[JsonProperty("259200")]
private double[][] _259200 { set { allCandlesticks = value; } }
[JsonProperty("604800")]
private double[][] _604800 { set { allCandlesticks = value; } }
}
private class Price
{
public double price { get; set; }
}
}
}