Skip to content
Open
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
6 changes: 6 additions & 0 deletions cs/ccxt/base/Exchange.Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ public List<Dictionary<string, object>> getFetchCache()
// return null; // stub to implement
// }

// returns the version of the ccxt library, e.g. "4.5.54"
public virtual object getCcxtVersion()
{
return ccxtVersion;
}

}
1 change: 1 addition & 0 deletions go/v4/exchange_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ type ICoreExchange interface {
Init(params map[string]any)
FetchDeposits(optionalArgs ...any) <-chan any
Milliseconds() int64
GetCcxtVersion() string
ParseNumber(v any, a ...any) any
OmitZero(v any) any
FetchOHLCV(symbol any, optionalArgs ...any) <-chan any
Expand Down
5 changes: 5 additions & 0 deletions go/v4/exchange_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ package ccxt

var Version string = "4.5.71"

// GetCcxtVersion returns the version of the ccxt library, e.g. "4.5.54"
func (this *Exchange) GetCcxtVersion() string {
return Version
}

var Exchanges []string = []string{"aftermath", "alpaca", "apex", "ascendex", "aster", "backpack", "bequant", "bigone", "binance", "binancecoinm", "binanceus", "binanceusdm", "bingx", "bit2c", "bitbank", "bitbns", "bitfinex", "bitflyer", "bitget", "bithumb", "bitmart", "bitmex", "bitopro", "bitrue", "bitso", "bitstamp", "bitteam", "bittrade", "bitvavo", "blockchaincom", "blofin", "btcbox", "btcmarkets", "btcturk", "bullish", "bybit", "bybiteu", "bydfi", "cex", "coinbase", "coinbaseexchange", "coinbaseinternational", "coincheck", "coinex", "coinmate", "coinmetro", "coinone", "coinsph", "coinspot", "cryptocom", "cryptomus", "deepcoin", "delta", "deribit", "derive", "digifinex", "dydx", "exmo", "extended", "fmfwio", "foxbit", "gate", "gemini", "grvt", "hashkey", "hibachi", "hitbtc", "hollaex", "htx", "hyperliquid", "independentreserve", "indodax", "kraken", "krakenfutures", "kucoin", "kucoinfutures", "latoken", "lbank", "lighter", "luno", "mercado", "mexc", "modetrade", "myokx", "ndax", "novadax", "okx", "okxus", "onetrading", "p2b", "pacifica", "paradex", "paymium", "phemex", "poloniex", "tokocrypto", "toobit", "upbit", "weex", "whitebit", "woo", "woofipro", "xt", "zaif", "zebpay"}
5 changes: 5 additions & 0 deletions java/lib/src/main/java/io/github/ccxt/BaseExchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,11 @@ public String uuid() {
return Strings.uuid();
}

// returns the version of the ccxt library, e.g. "4.5.71"
public String getCcxtVersion() {
return Version.VERSION;
}

// =======================
// Time
// =======================
Expand Down
5 changes: 5 additions & 0 deletions php/Exchange.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions python/ccxt/base/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,6 +1837,10 @@ def decode(string):
def to_array(value):
return list(value.values()) if type(value) is dict else value

def get_ccxt_version(self):
"""returns the version of the ccxt library, e.g. "4.5.54" """
return __version__

def precision_from_string(self, str):
# support string formats like '1e-4'
if 'e' in str or 'E' in str:
Expand Down
11 changes: 11 additions & 0 deletions ts/src/base/Exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,17 @@ export class BaseExchange {
return encodeURIComponent (...args);
}

/**
* @method
* @name Exchange#getCcxtVersion
* @description returns the version of the ccxt library, e.g. "4.5.54", or "unknown" when the version constant is not initialized (e.g. when an exchange module is imported directly, bypassing the ccxt entry point)
* @returns {string} the semver version of the ccxt library, or "unknown" when unavailable
*/
getCcxtVersion (): string {
const staticVersion = (Exchange as any).ccxtVersion;
return (staticVersion === undefined) ? 'unknown' : staticVersion;
}

throttle (cost: Num = undefined) {
return this.throttler.throttle (cost);
}
Expand Down
2 changes: 2 additions & 0 deletions ts/src/foxbit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2076,6 +2076,8 @@ export default class foxbit extends Exchange {
}
headers = {
'Content-Type': 'application/json',
'X-FB-CLIENT': 'ccxt',
'X-FB-CLIENT-VERSION': this.getCcxtVersion (),
};
if (urlPath === 'private') {
this.checkRequiredCredentials ();
Expand Down
22 changes: 21 additions & 1 deletion ts/src/test/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,8 @@ class testMainClass {
this.testModeTrade (),
this.testBackpack (),
this.testToobit (),
this.testWeex ()
this.testWeex (),
this.testFoxbit ()
];
await Promise.all (promises);
const successMessage = '[' + this.lang + '][TEST_SUCCESS] brokerId tests passed.';
Expand Down Expand Up @@ -2807,6 +2808,25 @@ class testMainClass {
clientOrderId = request['newClientOrderId'];
assert (clientOrderId.startsWith (id), 'weex - newClientOrderId: ' + clientOrderId + ' for swap order does not start with id: ' + id);
}

async testFoxbit () {
const exchange = this.initOfflineExchange ('foxbit');
let reqHeaders: Dict = {};
const id = 'ccxt';
try {
await exchange.createOrder ('BTC/BRL', 'limit', 'buy', 1, 20000);
} catch (e) {
// we expect an error here, we're only interested in the headers
reqHeaders = exchange.last_request_headers ? exchange.last_request_headers : {};
}
assert (reqHeaders['X-FB-CLIENT'] === id, 'foxbit - id: ' + id + ' not in headers.');
const version = exchange.getCcxtVersion ();
assert (reqHeaders['X-FB-CLIENT-VERSION'] === version, 'foxbit - version: ' + version + ' not in headers.');
if (!isSync ()) {
await close (exchange);
}
return true;
}
}

export default testMainClass;