@@ -24,8 +24,9 @@ namespace ExchangeSharp
24
24
public sealed partial class ExchangeHuobiAPI : ExchangeAPI
25
25
{
26
26
public override string BaseUrl { get ; set ; } = "https://api.huobipro.com" ;
27
- public string BaseUrlV1 { get ; set ; } = "https://api.huobipro.com/v1" ;
28
- public override string BaseUrlWebSocket { get ; set ; } = "wss://api.huobipro.com/ws" ;
27
+ public string BaseUrlV1 { get ; set ; } = "https://api.huobipro.com/v1" ;
28
+ public string BaseUrlV2 { get ; set ; } = "https://api.huobipro.com/v2" ;
29
+ public override string BaseUrlWebSocket { get ; set ; } = "wss://api.huobipro.com/ws" ;
29
30
public string PrivateUrlV1 { get ; set ; } = "https://api.huobipro.com/v1" ;
30
31
31
32
public bool IsMargin { get ; set ; }
@@ -123,43 +124,64 @@ protected override async Task<IEnumerable<string>> OnGetMarketSymbolsAsync()
123
124
124
125
protected internal override async Task < IEnumerable < ExchangeMarket > > OnGetMarketSymbolsMetadataAsync ( )
125
126
{
126
- /*
127
- {
128
- "status"
129
- :
130
- "ok", "data"
131
- :
132
- [{
133
- "base-currency": "btc",
134
- "quote-currency": "usdt",
135
- "price-precision": 2,
136
- "amount-precision": 4,
137
- "symbol-partition": "main"
138
- }, {
139
- "base-currency": "bch",
140
- "quote-currency": "usdt",
141
- "price-precision": 2,
142
- "amount-precision": 4,
143
- "symbol-partition": "main"
144
- },
145
-
146
- */
147
- List < ExchangeMarket > markets = new List < ExchangeMarket > ( ) ;
148
- JToken allMarketSymbols = await MakeJsonRequestAsync < JToken > ( "/common/symbols" , BaseUrlV1 , null ) ;
127
+ /*{
128
+ "status":"ok",
129
+ "data":[
130
+ {
131
+ "tags": "",
132
+ "state": "online",
133
+ "wr": "1.5",
134
+ "sc": "ethusdt",
135
+ "p": [
136
+ {
137
+ "id": 9,
138
+ "name": "Grayscale",
139
+ "weight": 91
140
+ }
141
+ ],
142
+ "bcdn": "ETH",
143
+ "qcdn": "USDT",
144
+ "elr": null,
145
+ "tpp": 2,
146
+ "tap": 4,
147
+ "fp": 8,
148
+ "smlr": null,
149
+ "flr": null,
150
+ "whe": false,
151
+ "cd": false,
152
+ "te": true,
153
+ "sp": "main",
154
+ "d": null,
155
+ "bc": "eth",
156
+ "qc": "usdt",
157
+ "toa": 1514779200000,
158
+ "ttp": 8,
159
+ "w": 999400000,
160
+ "lr": 5,
161
+ "dn": "ETH/USDT"
162
+ }
163
+ ],
164
+ "ts":"1641870869718",
165
+ "full":1
166
+ }*/
167
+ List < ExchangeMarket > markets = new List < ExchangeMarket > ( ) ;
168
+ JToken allMarketSymbols = await MakeJsonRequestAsync < JToken > ( "/settings/common/symbols" , BaseUrlV2 , null ) ;
149
169
foreach ( var marketSymbol in allMarketSymbols )
150
170
{
151
- var baseCurrency = marketSymbol [ "base-currency" ] . ToStringLowerInvariant ( ) ;
152
- var quoteCurrency = marketSymbol [ "quote-currency" ] . ToStringLowerInvariant ( ) ;
153
- var pricePrecision = marketSymbol [ "price-precision" ] . ConvertInvariant < double > ( ) ;
171
+ var baseCurrency = marketSymbol [ "bc" ] . ToStringLowerInvariant ( ) ;
172
+ var quoteCurrency = marketSymbol [ "qc" ] . ToStringLowerInvariant ( ) ;
173
+ var symbolCode = marketSymbol [ "sc" ] . ToStringLowerInvariant ( ) ;
174
+ var pricePrecision = marketSymbol [ "tpp" ] . ConvertInvariant < double > ( ) ;
154
175
var priceStepSize = Math . Pow ( 10 , - pricePrecision ) . ConvertInvariant < decimal > ( ) ;
155
- var amountPrecision = marketSymbol [ "amount-precision " ] . ConvertInvariant < double > ( ) ;
176
+ var amountPrecision = marketSymbol [ "tap " ] . ConvertInvariant < double > ( ) ;
156
177
var quantityStepSize = Math . Pow ( 10 , - amountPrecision ) . ConvertInvariant < decimal > ( ) ;
178
+ var state = marketSymbol [ "state" ] . ToStringLowerInvariant ( ) ;
157
179
var market = new ExchangeMarket
158
180
{
159
181
BaseCurrency = baseCurrency ,
160
182
QuoteCurrency = quoteCurrency ,
161
- MarketSymbol = baseCurrency + quoteCurrency ,
162
- IsActive = true ,
183
+ MarketSymbol = symbolCode ,
184
+ IsActive = state == "online" ,
163
185
PriceStepSize = priceStepSize ,
164
186
QuantityStepSize = quantityStepSize ,
165
187
MinPrice = priceStepSize ,
@@ -278,7 +300,7 @@ protected override async Task<IWebSocket> OnGetTradesWebSocketAsync(Func<KeyValu
278
300
{
279
301
if ( marketSymbols == null || marketSymbols . Length == 0 )
280
302
{
281
- marketSymbols = ( await GetMarketSymbolsAsync ( ) ) . ToArray ( ) ;
303
+ marketSymbols = ( await GetMarketSymbolsMetadataAsync ( ) ) . Where ( s => s . IsActive . Value ) . Select ( s => s . MarketSymbol ) . ToArray ( ) ;
282
304
}
283
305
foreach ( string marketSymbol in marketSymbols )
284
306
{
0 commit comments