ccxt 4.2.35 → 4.2.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1543,11 +1543,12 @@ class woo extends woo$1 {
1543
1543
  * @method
1544
1544
  * @name woo#fetchOHLCV
1545
1545
  * @see https://docs.woo.org/#kline-public
1546
+ * @see https://docs.woo.org/#kline-historical-data-public
1546
1547
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1547
1548
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1548
1549
  * @param {string} timeframe the length of time each candle represents
1549
1550
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
1550
- * @param {int} [limit] the maximum amount of candles to fetch
1551
+ * @param {int} [limit] max=1000, max=100 when since is defined and is less than (now - (999 * (timeframe in ms)))
1551
1552
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1552
1553
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1553
1554
  */
@@ -1557,42 +1558,70 @@ class woo extends woo$1 {
1557
1558
  'symbol': market['id'],
1558
1559
  'type': this.safeString(this.timeframes, timeframe, timeframe),
1559
1560
  };
1560
- if (limit !== undefined) {
1561
+ let useHistEndpoint = since !== undefined;
1562
+ if ((limit !== undefined) && (since !== undefined)) {
1563
+ const oneThousandCandles = this.parseTimeframe(timeframe) * 1000 * 999; // 999 because there will be delay between this and the request, causing the latest candle to be excluded sometimes
1564
+ const startWithLimit = this.milliseconds() - oneThousandCandles;
1565
+ useHistEndpoint = since < startWithLimit;
1566
+ }
1567
+ if (useHistEndpoint) {
1568
+ request['start_time'] = since;
1569
+ }
1570
+ else if (limit !== undefined) { // the hist endpoint does not accept limit
1561
1571
  request['limit'] = Math.min(limit, 1000);
1562
1572
  }
1563
- const response = await this.v1PublicGetKline(this.extend(request, params));
1564
- // {
1565
- // "success": true,
1566
- // "rows": [
1567
- // {
1568
- // "open": "0.94238",
1569
- // "close": "0.94271",
1570
- // "low": "0.94238",
1571
- // "high": "0.94296",
1572
- // "volume": "73.55",
1573
- // "amount": "69.32040520",
1574
- // "symbol": "SPOT_WOO_USDT",
1575
- // "type": "1m",
1576
- // "start_timestamp": "1641584700000",
1577
- // "end_timestamp": "1641584760000"
1578
- // },
1579
- // {
1580
- // "open": "0.94186",
1581
- // "close": "0.94186",
1582
- // "low": "0.94186",
1583
- // "high": "0.94186",
1584
- // "volume": "64.00",
1585
- // "amount": "60.27904000",
1586
- // "symbol": "SPOT_WOO_USDT",
1587
- // "type": "1m",
1588
- // "start_timestamp": "1641584640000",
1589
- // "end_timestamp": "1641584700000"
1590
- // },
1591
- // ...
1592
- // ]
1593
- // }
1594
- const data = this.safeValue(response, 'rows', []);
1595
- return this.parseOHLCVs(data, market, timeframe, since, limit);
1573
+ let response = undefined;
1574
+ if (!useHistEndpoint) {
1575
+ response = await this.v1PublicGetKline(this.extend(request, params));
1576
+ //
1577
+ // {
1578
+ // "success": true,
1579
+ // "rows": [
1580
+ // {
1581
+ // "open": "0.94238",
1582
+ // "close": "0.94271",
1583
+ // "low": "0.94238",
1584
+ // "high": "0.94296",
1585
+ // "volume": "73.55",
1586
+ // "amount": "69.32040520",
1587
+ // "symbol": "SPOT_WOO_USDT",
1588
+ // "type": "1m",
1589
+ // "start_timestamp": "1641584700000",
1590
+ // "end_timestamp": "1641584760000"
1591
+ // },
1592
+ // ...
1593
+ // ]
1594
+ // }
1595
+ //
1596
+ }
1597
+ else {
1598
+ response = await this.v1PubGetHistKline(this.extend(request, params));
1599
+ response = this.safeDict(response, 'data');
1600
+ //
1601
+ // {
1602
+ // "success": true,
1603
+ // "data": {
1604
+ // "rows": [
1605
+ // {
1606
+ // "symbol": "SPOT_BTC_USDT",
1607
+ // "open": 44181.40000000,
1608
+ // "close": 44174.29000000,
1609
+ // "high": 44193.44000000,
1610
+ // "low": 44148.34000000,
1611
+ // "volume": 110.11930100,
1612
+ // "amount": 4863796.24318878,
1613
+ // "type": "1m",
1614
+ // "start_timestamp": 1704153600000,
1615
+ // "end_timestamp": 1704153660000
1616
+ // },
1617
+ // ...
1618
+ // ]
1619
+ // }
1620
+ // }
1621
+ //
1622
+ }
1623
+ const rows = this.safeValue(response, 'rows', []);
1624
+ return this.parseOHLCVs(rows, market, timeframe, since, limit);
1596
1625
  }
1597
1626
  parseOHLCV(ohlcv, market = undefined) {
1598
1627
  // example response in fetchOHLCV
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.2.34";
7
+ declare const version = "4.2.36";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.2.35';
41
+ const version = '4.2.37';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -556,6 +556,7 @@ export default class Exchange {
556
556
  indexedOrderBook(snapshot?: {}, depth?: number): IndexedOrderBook;
557
557
  countedOrderBook(snapshot?: {}, depth?: number): CountedOrderBook;
558
558
  handleMessage(client: any, message: any): void;
559
+ ping(client: any): any;
559
560
  client(url: any): WsClient;
560
561
  watchMultiple(url: any, messageHashes: any, message?: any, subscribeHashes?: any, subscription?: any): import("./ws/Future.js").FutureInterface;
561
562
  watch(url: any, messageHash: any, message?: any, subscribeHash?: any, subscription?: any): any;
@@ -1063,9 +1063,9 @@ export default class Exchange {
1063
1063
  }
1064
1064
  handleMessage(client, message) { } // stub to override
1065
1065
  // ping (client) {} // stub to override
1066
- // ping (client) {
1067
- // return undefined;
1068
- // }
1066
+ ping(client) {
1067
+ return undefined;
1068
+ }
1069
1069
  client(url) {
1070
1070
  this.clients = this.clients || {};
1071
1071
  if (!this.clients[url]) {
@@ -103,6 +103,7 @@ export interface Order {
103
103
  filled: number;
104
104
  remaining: number;
105
105
  stopPrice?: number;
106
+ triggerPrice?: number;
106
107
  takeProfitPrice?: number;
107
108
  stopLossPrice?: number;
108
109
  cost: number;
@@ -234,6 +235,7 @@ export interface Position {
234
235
  notional?: number;
235
236
  leverage?: number;
236
237
  unrealizedPnl?: number;
238
+ realizedPnl?: number;
237
239
  collateral?: number;
238
240
  entryPrice?: number;
239
241
  markPrice?: number;
@@ -143,9 +143,12 @@ export default class Client {
143
143
  this.onError(new RequestTimeout('Connection to ' + this.url + ' timed out due to a ping-pong keepalive missing on time'));
144
144
  }
145
145
  else {
146
+ let message;
146
147
  if (this.ping) {
147
- this.send(this.ping(this))
148
- .catch((error) => {
148
+ message = this.ping(this);
149
+ }
150
+ if (message) {
151
+ this.send(message).catch((error) => {
149
152
  this.onError(error);
150
153
  });
151
154
  }