Skip to content

Commit 233c36a

Browse files
author
Travis CI
committed
chore: update auth method in upbit.ts file (ccxt#23492)
Co-authored-by: kyle <[email protected]> [ci skip]
1 parent b8ed432 commit 233c36a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1919
-229
lines changed

ccxt.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
require_once PATH_TO_CCXT . 'BadResponse.php';
102102
require_once PATH_TO_CCXT . 'NullResponse.php';
103103
require_once PATH_TO_CCXT . 'CancelPending.php';
104+
require_once PATH_TO_CCXT . 'UnsubscribeError.php';
104105

105106

106107
require_once PATH_TO_WS_CCXT . 'ClientTrait.php';

cs/ccxt/base/Exchange.Errors.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,9 @@ public CancelPending() : base() { }
237237
public CancelPending(string message) : base(message) { }
238238
public CancelPending(string message, OperationFailed inner) : base(message, inner) { }
239239
}
240+
public class UnsubscribeError : BaseError
241+
{
242+
public UnsubscribeError() : base() { }
243+
public UnsubscribeError(string message) : base(message) { }
244+
public UnsubscribeError(string message, BaseError inner) : base(message, inner) { }
245+
}

cs/ccxt/exchanges/hashkey.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public override object describe()
1515
{ "version", "v1" },
1616
{ "certified", true },
1717
{ "pro", true },
18-
{ "hostname", "/api-glb" },
1918
{ "has", new Dictionary<string, object>() {
2019
{ "CORS", null },
2120
{ "spot", true },

cs/ccxt/exchanges/kraken.cs

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,9 +1159,13 @@ public async override Task<object> fetchLedger(object code = null, object since
11591159
{
11601160
((IDictionary<string,object>)request)["start"] = this.parseToInt(divide(since, 1000));
11611161
}
1162-
var requestparametersVariable = this.handleUntilOption("end", request, parameters);
1163-
request = ((IList<object>)requestparametersVariable)[0];
1164-
parameters = ((IList<object>)requestparametersVariable)[1];
1162+
object until = this.safeStringN(parameters, new List<object>() {"until", "till", "end"});
1163+
if (isTrue(!isEqual(until, null)))
1164+
{
1165+
parameters = this.omit(parameters, new List<object>() {"until", "till"});
1166+
object untilDivided = Precise.stringDiv(until, "1000");
1167+
((IDictionary<string,object>)request)["end"] = this.parseToInt(Precise.stringAdd(untilDivided, "1"));
1168+
}
11651169
object response = await this.privatePostLedgers(this.extend(request, parameters));
11661170
// { error: [],
11671171
// "result": { ledger: { 'LPUAIB-TS774-UKHP7X': { refid: "A2B4HBV-L4MDIE-JU4N3N",
@@ -2284,6 +2288,7 @@ public async override Task<object> fetchMyTrades(object symbol = null, object si
22842288
* @param {int} [since] the earliest time in ms to fetch trades for
22852289
* @param {int} [limit] the maximum number of trades structures to retrieve
22862290
* @param {object} [params] extra parameters specific to the exchange API endpoint
2291+
* @param {int} [params.until] timestamp in ms of the latest trade entry
22872292
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
22882293
*/
22892294
parameters ??= new Dictionary<string, object>();
@@ -2293,6 +2298,13 @@ public async override Task<object> fetchMyTrades(object symbol = null, object si
22932298
{
22942299
((IDictionary<string,object>)request)["start"] = this.parseToInt(divide(since, 1000));
22952300
}
2301+
object until = this.safeStringN(parameters, new List<object>() {"until", "till", "end"});
2302+
if (isTrue(!isEqual(until, null)))
2303+
{
2304+
parameters = this.omit(parameters, new List<object>() {"until", "till"});
2305+
object untilDivided = Precise.stringDiv(until, "1000");
2306+
((IDictionary<string,object>)request)["end"] = this.parseToInt(Precise.stringAdd(untilDivided, "1"));
2307+
}
22962308
object response = await this.privatePostTradesHistory(this.extend(request, parameters));
22972309
//
22982310
// {
@@ -2742,6 +2754,7 @@ public async override Task<object> fetchDeposits(object code = null, object sinc
27422754
* @param {int} [since] the earliest time in ms to fetch deposits for
27432755
* @param {int} [limit] the maximum number of deposits structures to retrieve
27442756
* @param {object} [params] extra parameters specific to the exchange API endpoint
2757+
* @param {int} [params.until] timestamp in ms of the latest transaction entry
27452758
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
27462759
*/
27472760
// https://www.kraken.com/en-us/help/api#deposit-status
@@ -2755,7 +2768,15 @@ public async override Task<object> fetchDeposits(object code = null, object sinc
27552768
}
27562769
if (isTrue(!isEqual(since, null)))
27572770
{
2758-
((IDictionary<string,object>)request)["start"] = since;
2771+
object sinceString = this.numberToString(since);
2772+
((IDictionary<string,object>)request)["start"] = Precise.stringDiv(sinceString, "1000");
2773+
}
2774+
object until = this.safeStringN(parameters, new List<object>() {"until", "till", "end"});
2775+
if (isTrue(!isEqual(until, null)))
2776+
{
2777+
parameters = this.omit(parameters, new List<object>() {"until", "till"});
2778+
object untilDivided = Precise.stringDiv(until, "1000");
2779+
((IDictionary<string,object>)request)["end"] = Precise.stringAdd(untilDivided, "1");
27592780
}
27602781
object response = await this.privatePostDepositStatus(this.extend(request, parameters));
27612782
//
@@ -2811,8 +2832,8 @@ public async override Task<object> fetchWithdrawals(object code = null, object s
28112832
* @param {int} [since] the earliest time in ms to fetch withdrawals for
28122833
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
28132834
* @param {object} [params] extra parameters specific to the exchange API endpoint
2814-
* @param {object} [params.end] End timestamp, withdrawals created strictly after will be not be included in the response
2815-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times
2835+
* @param {int} [params.until] timestamp in ms of the latest transaction entry
2836+
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times
28162837
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
28172838
*/
28182839
parameters ??= new Dictionary<string, object>();
@@ -2834,7 +2855,15 @@ public async override Task<object> fetchWithdrawals(object code = null, object s
28342855
}
28352856
if (isTrue(!isEqual(since, null)))
28362857
{
2837-
((IDictionary<string,object>)request)["since"] = ((object)since).ToString();
2858+
object sinceString = this.numberToString(since);
2859+
((IDictionary<string,object>)request)["start"] = Precise.stringDiv(sinceString, "1000");
2860+
}
2861+
object until = this.safeStringN(parameters, new List<object>() {"until", "till", "end"});
2862+
if (isTrue(!isEqual(until, null)))
2863+
{
2864+
parameters = this.omit(parameters, new List<object>() {"until", "till"});
2865+
object untilDivided = Precise.stringDiv(until, "1000");
2866+
((IDictionary<string,object>)request)["end"] = Precise.stringAdd(untilDivided, "1");
28382867
}
28392868
object response = await this.privatePostWithdrawStatus(this.extend(request, parameters));
28402869
//

cs/ccxt/exchanges/pro/bitget.cs

Lines changed: 198 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ public async override Task<object> watchTicker(object symbol, object parameters
140140
return await this.watchPublic(messageHash, args, parameters);
141141
}
142142

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+
143159
public async override Task<object> watchTickers(object symbols = null, object parameters = null)
144160
{
145161
/**
@@ -370,6 +386,26 @@ public async override Task<object> watchOHLCV(object symbol, object timeframe =
370386
return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
371387
}
372388

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+
373409
public virtual void handleOHLCV(WebSocketClient client, object message)
374410
{
375411
//
@@ -482,15 +518,22 @@ public async virtual Task<object> unWatchOrderBook(object symbol, object paramet
482518
*/
483519
parameters ??= new Dictionary<string, object>();
484520
await this.loadMarkets();
485-
object market = this.market(symbol);
486-
object messageHash = add("unsubscribe:orderbook:", getValue(market, "symbol"));
487521
object channel = "books";
488522
object limit = this.safeInteger(parameters, "limit");
489523
if (isTrue(isTrue(isTrue((isEqual(limit, 1))) || isTrue((isEqual(limit, 5)))) || isTrue((isEqual(limit, 15)))))
490524
{
491525
parameters = this.omit(parameters, "limit");
492526
channel = add(channel, ((object)limit).ToString());
493527
}
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"));
494537
object instType = null;
495538
var instTypeparametersVariable = this.getInstType(market, parameters);
496539
instType = ((IList<object>)instTypeparametersVariable)[0];
@@ -752,6 +795,22 @@ public async override Task<object> watchTradesForSymbols(object symbols, object
752795
return this.filterBySinceLimit(trades, since, limit, "timestamp", true);
753796
}
754797

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+
755814
public virtual void handleTrades(WebSocketClient client, object message)
756815
{
757816
//
@@ -2069,6 +2128,133 @@ public virtual object handleSubscriptionStatus(WebSocketClient client, object me
20692128
return message;
20702129
}
20712130

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+
20722258
public virtual object handleUnSubscriptionStatus(WebSocketClient client, object message)
20732259
{
20742260
//
@@ -2102,26 +2288,16 @@ public virtual object handleUnSubscriptionStatus(WebSocketClient client, object
21022288
if (isTrue(isEqual(channel, "books")))
21032289
{
21042290
// 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);
21252301
}
21262302
}
21272303
return message;

cs/ccxt/exchanges/pro/poloniexfutures.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public override object describe()
2626
{ "watchTicker", true },
2727
{ "watchTickers", false },
2828
{ "watchTrades", true },
29+
{ "watchTradesForSymbols", false },
2930
{ "watchBalance", true },
3031
{ "watchOrders", true },
3132
{ "watchMyTrades", false },

0 commit comments

Comments
 (0)