@@ -140,6 +140,22 @@ public async override Task<object> watchTicker(object symbol, object parameters
140
140
return await this . watchPublic ( messageHash , args , parameters ) ;
141
141
}
142
142
143
+ public async virtual Task < object > unWatchTicker ( object symbol , object parameters = null )
144
+ {
145
+ /**
146
+ * @method
147
+ * @name bitget#unWatchTicker
148
+ * @description unsubscribe from the ticker channel
149
+ * @see https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
150
+ * @see https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
151
+ * @param {string} symbol unified symbol of the market to unwatch the ticker for
152
+ * @returns {any} status of the unwatch request
153
+ */
154
+ parameters ??= new Dictionary < string , object > ( ) ;
155
+ await this . loadMarkets ( ) ;
156
+ return await this . unWatchChannel ( symbol , "ticker" , "ticker" , parameters ) ;
157
+ }
158
+
143
159
public async override Task < object > watchTickers ( object symbols = null , object parameters = null )
144
160
{
145
161
/**
@@ -370,6 +386,26 @@ public async override Task<object> watchOHLCV(object symbol, object timeframe =
370
386
return this . filterBySinceLimit ( ohlcv , since , limit , 0 , true ) ;
371
387
}
372
388
389
+ public async virtual Task < object > unWatchOHLCV ( object symbol , object timeframe = null , object parameters = null )
390
+ {
391
+ /**
392
+ * @method
393
+ * @name bitget#unWatchOHLCV
394
+ * @description unsubscribe from the ohlcv channel
395
+ * @see https://www.bitget.com/api-doc/spot/websocket/public/Candlesticks-Channel
396
+ * @see https://www.bitget.com/api-doc/contract/websocket/public/Candlesticks-Channel
397
+ * @param {string} symbol unified symbol of the market to unwatch the ohlcv for
398
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
399
+ */
400
+ timeframe ??= "1m" ;
401
+ parameters ??= new Dictionary < string , object > ( ) ;
402
+ await this . loadMarkets ( ) ;
403
+ object timeframes = this . safeDict ( this . options , "timeframes" ) ;
404
+ object interval = this . safeString ( timeframes , timeframe ) ;
405
+ object channel = add ( "candle" , interval ) ;
406
+ return await this . unWatchChannel ( symbol , channel , add ( "candles:" , timeframe ) , parameters ) ;
407
+ }
408
+
373
409
public virtual void handleOHLCV ( WebSocketClient client , object message )
374
410
{
375
411
//
@@ -482,15 +518,22 @@ public async virtual Task<object> unWatchOrderBook(object symbol, object paramet
482
518
*/
483
519
parameters ??= new Dictionary < string , object > ( ) ;
484
520
await this . loadMarkets ( ) ;
485
- object market = this . market ( symbol ) ;
486
- object messageHash = add ( "unsubscribe:orderbook:" , getValue ( market , "symbol" ) ) ;
487
521
object channel = "books" ;
488
522
object limit = this . safeInteger ( parameters , "limit" ) ;
489
523
if ( isTrue ( isTrue ( isTrue ( ( isEqual ( limit , 1 ) ) ) || isTrue ( ( isEqual ( limit , 5 ) ) ) ) || isTrue ( ( isEqual ( limit , 15 ) ) ) ) )
490
524
{
491
525
parameters = this . omit ( parameters , "limit" ) ;
492
526
channel = add ( channel , ( ( object ) limit ) . ToString ( ) ) ;
493
527
}
528
+ return await this . unWatchChannel ( symbol , channel , "orderbook" , parameters ) ;
529
+ }
530
+
531
+ public async virtual Task < object > unWatchChannel ( object symbol , object channel , object messageHashTopic , object parameters = null )
532
+ {
533
+ parameters ??= new Dictionary < string , object > ( ) ;
534
+ await this . loadMarkets ( ) ;
535
+ object market = this . market ( symbol ) ;
536
+ object messageHash = add ( add ( add ( "unsubscribe:" , messageHashTopic ) , ":" ) , getValue ( market , "symbol" ) ) ;
494
537
object instType = null ;
495
538
var instTypeparametersVariable = this . getInstType ( market , parameters ) ;
496
539
instType = ( ( IList < object > ) instTypeparametersVariable ) [ 0 ] ;
@@ -752,6 +795,22 @@ public async override Task<object> watchTradesForSymbols(object symbols, object
752
795
return this . filterBySinceLimit ( trades , since , limit , "timestamp" , true ) ;
753
796
}
754
797
798
+ public async virtual Task < object > unWatchTrades ( object symbol , object parameters = null )
799
+ {
800
+ /**
801
+ * @method
802
+ * @name bitget#unWatchTrades
803
+ * @description unsubscribe from the trades channel
804
+ * @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
805
+ * @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
806
+ * @param {string} symbol unified symbol of the market to unwatch the trades for
807
+ * @returns {any} status of the unwatch request
808
+ */
809
+ parameters ??= new Dictionary < string , object > ( ) ;
810
+ await this . loadMarkets ( ) ;
811
+ return await this . unWatchChannel ( symbol , "trade" , "trade" , parameters ) ;
812
+ }
813
+
755
814
public virtual void handleTrades ( WebSocketClient client , object message )
756
815
{
757
816
//
@@ -2069,6 +2128,133 @@ public virtual object handleSubscriptionStatus(WebSocketClient client, object me
2069
2128
return message ;
2070
2129
}
2071
2130
2131
+ public virtual void handleOrderBookUnSubscription ( WebSocketClient client , object message )
2132
+ {
2133
+ //
2134
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"books","instId":"BTCUSDT"}}
2135
+ //
2136
+ object arg = this . safeDict ( message , "arg" , new Dictionary < string , object > ( ) { } ) ;
2137
+ object instType = this . safeStringLower ( arg , "instType" ) ;
2138
+ object type = ( ( bool ) isTrue ( ( isEqual ( instType , "spot" ) ) ) ) ? "spot" : "contract" ;
2139
+ object instId = this . safeString ( arg , "instId" ) ;
2140
+ object market = this . safeMarket ( instId , null , null , type ) ;
2141
+ object symbol = getValue ( market , "symbol" ) ;
2142
+ object messageHash = add ( "unsubscribe:orderbook:" , getValue ( market , "symbol" ) ) ;
2143
+ object subMessageHash = add ( "orderbook:" , symbol ) ;
2144
+ if ( isTrue ( inOp ( this . orderbooks , symbol ) ) )
2145
+ {
2146
+
2147
+ }
2148
+ if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , subMessageHash ) ) )
2149
+ {
2150
+
2151
+ }
2152
+ if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , messageHash ) ) )
2153
+ {
2154
+
2155
+ }
2156
+ var error = new UnsubscribeError ( add ( add ( this . id , "orderbook " ) , symbol ) ) ;
2157
+ ( ( WebSocketClient ) client ) . reject ( error , subMessageHash ) ;
2158
+ callDynamically ( client as WebSocketClient , "resolve" , new object [ ] { true , messageHash } ) ;
2159
+ }
2160
+
2161
+ public virtual void handleTradesUnSubscription ( WebSocketClient client , object message )
2162
+ {
2163
+ //
2164
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"trade","instId":"BTCUSDT"}}
2165
+ //
2166
+ object arg = this . safeDict ( message , "arg" , new Dictionary < string , object > ( ) { } ) ;
2167
+ object instType = this . safeStringLower ( arg , "instType" ) ;
2168
+ object type = ( ( bool ) isTrue ( ( isEqual ( instType , "spot" ) ) ) ) ? "spot" : "contract" ;
2169
+ object instId = this . safeString ( arg , "instId" ) ;
2170
+ object market = this . safeMarket ( instId , null , null , type ) ;
2171
+ object symbol = getValue ( market , "symbol" ) ;
2172
+ object messageHash = add ( "unsubscribe:trade:" , getValue ( market , "symbol" ) ) ;
2173
+ object subMessageHash = add ( "trade:" , symbol ) ;
2174
+ if ( isTrue ( inOp ( this . trades , symbol ) ) )
2175
+ {
2176
+
2177
+ }
2178
+ if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , subMessageHash ) ) )
2179
+ {
2180
+
2181
+ }
2182
+ if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , messageHash ) ) )
2183
+ {
2184
+
2185
+ }
2186
+ var error = new UnsubscribeError ( add ( add ( this . id , "trades " ) , symbol ) ) ;
2187
+ ( ( WebSocketClient ) client ) . reject ( error , subMessageHash ) ;
2188
+ callDynamically ( client as WebSocketClient , "resolve" , new object [ ] { true , messageHash } ) ;
2189
+ }
2190
+
2191
+ public virtual void handleTickerUnSubscription ( WebSocketClient client , object message )
2192
+ {
2193
+ //
2194
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"trade","instId":"BTCUSDT"}}
2195
+ //
2196
+ object arg = this . safeDict ( message , "arg" , new Dictionary < string , object > ( ) { } ) ;
2197
+ object instType = this . safeStringLower ( arg , "instType" ) ;
2198
+ object type = ( ( bool ) isTrue ( ( isEqual ( instType , "spot" ) ) ) ) ? "spot" : "contract" ;
2199
+ object instId = this . safeString ( arg , "instId" ) ;
2200
+ object market = this . safeMarket ( instId , null , null , type ) ;
2201
+ object symbol = getValue ( market , "symbol" ) ;
2202
+ object messageHash = add ( "unsubscribe:ticker:" , getValue ( market , "symbol" ) ) ;
2203
+ object subMessageHash = add ( "ticker:" , symbol ) ;
2204
+ if ( isTrue ( inOp ( this . tickers , symbol ) ) )
2205
+ {
2206
+
2207
+ }
2208
+ if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , subMessageHash ) ) )
2209
+ {
2210
+
2211
+ }
2212
+ if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , messageHash ) ) )
2213
+ {
2214
+
2215
+ }
2216
+ var error = new UnsubscribeError ( add ( add ( this . id , "ticker " ) , symbol ) ) ;
2217
+ ( ( WebSocketClient ) client ) . reject ( error , subMessageHash ) ;
2218
+ callDynamically ( client as WebSocketClient , "resolve" , new object [ ] { true , messageHash } ) ;
2219
+ }
2220
+
2221
+ public virtual void handleOHLCVUnSubscription ( WebSocketClient client , object message )
2222
+ {
2223
+ //
2224
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"candle1m","instId":"BTCUSDT"}}
2225
+ //
2226
+ object arg = this . safeDict ( message , "arg" , new Dictionary < string , object > ( ) { } ) ;
2227
+ object instType = this . safeStringLower ( arg , "instType" ) ;
2228
+ object type = ( ( bool ) isTrue ( ( isEqual ( instType , "spot" ) ) ) ) ? "spot" : "contract" ;
2229
+ object instId = this . safeString ( arg , "instId" ) ;
2230
+ object channel = this . safeString ( arg , "channel" ) ;
2231
+ object interval = ( ( string ) channel ) . Replace ( ( string ) "candle" , ( string ) "" ) ;
2232
+ object timeframes = this . safeValue ( this . options , "timeframes" ) ;
2233
+ object timeframe = this . findTimeframe ( interval , timeframes ) ;
2234
+ object market = this . safeMarket ( instId , null , null , type ) ;
2235
+ object symbol = getValue ( market , "symbol" ) ;
2236
+ object messageHash = add ( add ( add ( "unsubscribe:candles:" , timeframe ) , ":" ) , getValue ( market , "symbol" ) ) ;
2237
+ object subMessageHash = add ( add ( add ( "candles:" , timeframe ) , ":" ) , symbol ) ;
2238
+ if ( isTrue ( inOp ( this . ohlcvs , symbol ) ) )
2239
+ {
2240
+ if ( isTrue ( inOp ( getValue ( this . ohlcvs , symbol ) , timeframe ) ) )
2241
+ {
2242
+
2243
+ }
2244
+ }
2245
+ if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , subMessageHash ) ) )
2246
+ {
2247
+
2248
+ }
2249
+ if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , messageHash ) ) )
2250
+ {
2251
+
2252
+ }
2253
+ var error = new UnsubscribeError ( add ( add ( add ( add ( this . id , " ohlcv " ) , timeframe ) , " " ) , symbol ) ) ;
2254
+ ( ( WebSocketClient ) client ) . reject ( error , subMessageHash ) ;
2255
+ callDynamically ( client as WebSocketClient , "resolve" , new object [ ] { true , messageHash } ) ;
2256
+ }
2257
+
2072
2258
public virtual object handleUnSubscriptionStatus ( WebSocketClient client , object message )
2073
2259
{
2074
2260
//
@@ -2102,26 +2288,16 @@ public virtual object handleUnSubscriptionStatus(WebSocketClient client, object
2102
2288
if ( isTrue ( isEqual ( channel , "books" ) ) )
2103
2289
{
2104
2290
// for now only unWatchOrderBook is supporteod
2105
- object instType = this . safeStringLower ( arg , "instType" ) ;
2106
- object type = ( ( bool ) isTrue ( ( isEqual ( instType , "spot" ) ) ) ) ? "spot" : "contract" ;
2107
- object instId = this . safeString ( arg , "instId" ) ;
2108
- object market = this . safeMarket ( instId , null , null , type ) ;
2109
- object symbol = getValue ( market , "symbol" ) ;
2110
- object messageHash = add ( "unsubscribe:orderbook:" , getValue ( market , "symbol" ) ) ;
2111
- object subMessageHash = add ( "orderbook:" , symbol ) ;
2112
- if ( isTrue ( inOp ( this . orderbooks , symbol ) ) )
2113
- {
2114
-
2115
- }
2116
- if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , subMessageHash ) ) )
2117
- {
2118
-
2119
- }
2120
- if ( isTrue ( inOp ( ( ( WebSocketClient ) client ) . subscriptions , messageHash ) ) )
2121
- {
2122
-
2123
- }
2124
- callDynamically ( client as WebSocketClient , "resolve" , new object [ ] { true , messageHash } ) ;
2291
+ this . handleOrderBookUnSubscription ( client as WebSocketClient , message ) ;
2292
+ } else if ( isTrue ( isEqual ( channel , "trade" ) ) )
2293
+ {
2294
+ this . handleTradesUnSubscription ( client as WebSocketClient , message ) ;
2295
+ } else if ( isTrue ( isEqual ( channel , "ticker" ) ) )
2296
+ {
2297
+ this . handleTickerUnSubscription ( client as WebSocketClient , message ) ;
2298
+ } else if ( isTrue ( ( ( string ) channel ) . StartsWith ( ( ( string ) "candle" ) ) ) )
2299
+ {
2300
+ this . handleOHLCVUnSubscription ( client as WebSocketClient , message ) ;
2125
2301
}
2126
2302
}
2127
2303
return message ;
0 commit comments