Skip to content

Commit beff507

Browse files
author
Travis CI
committed
feat(bingx) - features (ccxt#24315)
* feat(bingx) - features * feat(bingx) - .features finished * featuresMapping updates * bingx updates * commented extra [ci skip]
1 parent 0b918e9 commit beff507

23 files changed

Lines changed: 1145 additions & 128 deletions

File tree

‎cs/ccxt/base/Exchange.BaseMethods.cs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ public virtual void featuresGenerator()
14201420
this.features = new Dictionary<string, object>() {};
14211421
object unifiedMarketTypes = new List<object>() {"spot", "swap", "future", "option"};
14221422
object subTypes = new List<object>() {"linear", "inverse"};
1423-
// atm only support basic methods to avoid to be able to maintain, eg: 'createOrder', 'fetchOrder', 'fetchOrders', 'fetchMyTrades'
1423+
// atm only support basic methods, eg: 'createOrder', 'fetchOrder', 'fetchOrders', 'fetchMyTrades'
14241424
for (object i = 0; isLessThan(i, getArrayLength(unifiedMarketTypes)); postFixIncrement(ref i))
14251425
{
14261426
object marketType = getValue(unifiedMarketTypes, i);
@@ -1453,8 +1453,8 @@ public virtual object featuresMapper(object initialFeatures, object marketType,
14531453
if (isTrue(!isEqual(extendsStr, null)))
14541454
{
14551455
featuresObj = this.omit(featuresObj, "extends");
1456-
object extendObj = getValue(initialFeatures, extendsStr);
1457-
featuresObj = this.extend(extendObj, featuresObj); // Warning, do not use deepExtend here, because we override only one level
1456+
object extendObj = this.featuresMapper(initialFeatures, extendsStr);
1457+
featuresObj = this.deepExtend(extendObj, featuresObj);
14581458
}
14591459
//
14601460
// corrections
@@ -1467,10 +1467,10 @@ public virtual object featuresMapper(object initialFeatures, object marketType,
14671467
((IDictionary<string,object>)getValue(featuresObj, "createOrder"))["stopLoss"] = value;
14681468
((IDictionary<string,object>)getValue(featuresObj, "createOrder"))["takeProfit"] = value;
14691469
}
1470-
// omit 'hedged' from spot
1470+
// false 'hedged' for spot
14711471
if (isTrue(isEqual(marketType, "spot")))
14721472
{
1473-
((IDictionary<string,object>)getValue(featuresObj, "createOrder"))["hedged"] = null;
1473+
((IDictionary<string,object>)getValue(featuresObj, "createOrder"))["hedged"] = false;
14741474
}
14751475
}
14761476
return featuresObj;

‎cs/ccxt/exchanges/bingx.cs‎

Lines changed: 139 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,134 @@ public override object describe()
490490
{ "MATIC", "POLYGON" },
491491
} },
492492
} },
493+
{ "features", new Dictionary<string, object>() {
494+
{ "defaultForLinear", new Dictionary<string, object>() {
495+
{ "sandbox", true },
496+
{ "createOrder", new Dictionary<string, object>() {
497+
{ "triggerPrice", true },
498+
{ "triggerPriceType", new Dictionary<string, object>() {
499+
{ "last", true },
500+
{ "mark", true },
501+
{ "index", true },
502+
} },
503+
{ "triggerDirection", false },
504+
{ "stopLossPrice", true },
505+
{ "takeProfitPrice", true },
506+
{ "attachedStopLossTakeProfit", new Dictionary<string, object>() {
507+
{ "triggerPriceType", new Dictionary<string, object>() {
508+
{ "last", true },
509+
{ "mark", true },
510+
{ "index", true },
511+
} },
512+
{ "limitPrice", true },
513+
} },
514+
{ "marginMode", false },
515+
{ "timeInForce", new Dictionary<string, object>() {
516+
{ "GTC", true },
517+
{ "IOC", true },
518+
{ "FOK", true },
519+
{ "PO", true },
520+
{ "GTD", false },
521+
} },
522+
{ "hedged", true },
523+
{ "trailing", true },
524+
} },
525+
{ "createOrders", new Dictionary<string, object>() {
526+
{ "max", 5 },
527+
} },
528+
{ "fetchMyTrades", new Dictionary<string, object>() {
529+
{ "limit", 512 },
530+
{ "daysBack", 30 },
531+
{ "untilDays", 30 },
532+
} },
533+
{ "fetchOrder", new Dictionary<string, object>() {
534+
{ "marginMode", false },
535+
{ "trigger", false },
536+
{ "trailing", false },
537+
} },
538+
{ "fetchOpenOrders", new Dictionary<string, object>() {
539+
{ "limit", null },
540+
{ "marginMode", false },
541+
{ "trigger", false },
542+
{ "trailing", false },
543+
} },
544+
{ "fetchOrders", new Dictionary<string, object>() {
545+
{ "limit", 1000 },
546+
{ "daysBack", 20000 },
547+
{ "untilDays", 7 },
548+
{ "marginMode", false },
549+
{ "trigger", false },
550+
{ "trailing", false },
551+
} },
552+
{ "fetchClosedOrders", new Dictionary<string, object>() {
553+
{ "limit", 1000 },
554+
{ "daysBackClosed", null },
555+
{ "daysBackCanceled", null },
556+
{ "untilDays", 7 },
557+
{ "marginMode", false },
558+
{ "trigger", false },
559+
{ "trailing", false },
560+
} },
561+
{ "fetchOHLCV", new Dictionary<string, object>() {
562+
{ "limit", 1440 },
563+
} },
564+
} },
565+
{ "defaultForInverse", new Dictionary<string, object>() {
566+
{ "extends", "defaultForLinear" },
567+
{ "fetchMyTrades", new Dictionary<string, object>() {
568+
{ "limit", 1000 },
569+
{ "daysBack", null },
570+
{ "untilDays", null },
571+
} },
572+
{ "fetchOHLCV", new Dictionary<string, object>() {
573+
{ "limit", 1440 },
574+
} },
575+
{ "fetchOrders", null },
576+
{ "fetchClosedOrders", new Dictionary<string, object>() {
577+
{ "limit", 1000 },
578+
{ "daysBackClosed", null },
579+
{ "daysBackCanceled", null },
580+
{ "untilDays", 7 },
581+
{ "marginMode", false },
582+
{ "trigger", false },
583+
{ "trailing", false },
584+
} },
585+
} },
586+
{ "spot", new Dictionary<string, object>() {
587+
{ "extends", "defaultForLinear" },
588+
{ "createOrder", new Dictionary<string, object>() {
589+
{ "triggerPriceType", null },
590+
{ "attachedStopLossTakeProfit", null },
591+
{ "trailing", false },
592+
} },
593+
{ "fetchMyTrades", new Dictionary<string, object>() {
594+
{ "limit", 1000 },
595+
{ "daysBack", 1 },
596+
{ "untilDays", 1 },
597+
} },
598+
{ "fetchOrders", null },
599+
{ "fetchClosedOrders", new Dictionary<string, object>() {
600+
{ "limit", 100 },
601+
{ "untilDays", null },
602+
} },
603+
} },
604+
{ "swap", new Dictionary<string, object>() {
605+
{ "linear", new Dictionary<string, object>() {
606+
{ "extends", "defaultForLinear" },
607+
} },
608+
{ "inverse", new Dictionary<string, object>() {
609+
{ "extends", "defaultForInverse" },
610+
} },
611+
} },
612+
{ "future", new Dictionary<string, object>() {
613+
{ "linear", new Dictionary<string, object>() {
614+
{ "extends", "defaultForLinear" },
615+
} },
616+
{ "inverse", new Dictionary<string, object>() {
617+
{ "extends", "defaultForInverse" },
618+
} },
619+
} },
620+
} },
493621
});
494622
}
495623

@@ -3751,7 +3879,8 @@ public async override Task<object> fetchOrder(object id, object symbol = null, o
37513879
* @method
37523880
* @name bingx#fetchOrders
37533881
* @description fetches information on multiple orders made by the user
3754-
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#User's%20All%20Orders
3882+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#All%20Orders
3883+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history (returns less fields than above)
37553884
* @param {string} symbol unified market symbol of the market orders were made in
37563885
* @param {int} [since] the earliest time in ms to fetch orders for
37573886
* @param {int} [limit] the maximum number of order structures to retrieve
@@ -3787,13 +3916,9 @@ public async override Task<object> fetchOrders(object symbol = null, object sinc
37873916
{
37883917
((IDictionary<string,object>)request)["startTime"] = since;
37893918
}
3790-
object until = this.safeInteger(parameters, "until"); // unified in milliseconds
3791-
object endTime = this.safeInteger(parameters, "endTime", until); // exchange-specific in milliseconds
3792-
parameters = this.omit(parameters, new List<object>() {"endTime", "until"});
3793-
if (isTrue(!isEqual(endTime, null)))
3794-
{
3795-
((IDictionary<string,object>)request)["endTime"] = endTime;
3796-
}
3919+
var requestparametersVariable = this.handleUntilOption("endTime", request, parameters);
3920+
request = ((IList<object>)requestparametersVariable)[0];
3921+
parameters = ((IList<object>)requestparametersVariable)[1];
37973922
object response = await this.swapV1PrivateGetTradeFullOrder(this.extend(request, parameters));
37983923
//
37993924
// {
@@ -4106,6 +4231,10 @@ public async override Task<object> fetchCanceledAndClosedOrders(object symbol =
41064231
response = await this.contractV1PrivateGetAllOrders(this.extend(request, parameters));
41074232
} else if (isTrue(isEqual(type, "spot")))
41084233
{
4234+
if (isTrue(!isEqual(limit, null)))
4235+
{
4236+
((IDictionary<string,object>)request)["limit"] = limit;
4237+
}
41094238
response = await this.spotV1PrivateGetTradeHistoryOrders(this.extend(request, parameters));
41104239
} else
41114240
{
@@ -4834,6 +4963,7 @@ public async override Task<object> setLeverage(object leverage, object symbol =
48344963
* @description fetch all trades made by the user
48354964
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20transaction%20details
48364965
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20orders
4966+
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20details
48374967
* @see https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order%20Trade%20Detail
48384968
* @param {string} [symbol] unified market symbol
48394969
* @param {int} [since] the earliest time in ms to fetch trades for
@@ -4879,7 +5009,7 @@ public async override Task<object> fetchMyTrades(object symbol = null, object si
48795009
((IDictionary<string,object>)request)[(string)startTimeReq] = since;
48805010
} else if (isTrue(getValue(market, "swap")))
48815011
{
4882-
((IDictionary<string,object>)request)["startTs"] = subtract(now, 7776000000); // 90 days
5012+
((IDictionary<string,object>)request)["startTs"] = subtract(now, multiply(multiply(multiply(multiply(30, 24), 60), 60), 1000)); // 30 days for swap
48835013
}
48845014
object until = this.safeInteger(parameters, "until");
48855015
parameters = this.omit(parameters, "until");

‎cs/ccxt/wrappers/bingx.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@ public async Task<Order> FetchOrder(string id, string symbol = null, Dictionary<
806806
/// fetches information on multiple orders made by the user
807807
/// </summary>
808808
/// <remarks>
809-
/// See <see href="https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#User's%20All%20Orders"/> <br/>
809+
/// See <see href="https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#All%20Orders"/> <br/>
810+
/// See <see href="https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20Order%20history"/> <br/>
810811
/// <list type="table">
811812
/// <item>
812813
/// <term>since</term>
@@ -1318,6 +1319,7 @@ public async Task<Dictionary<string, object>> SetLeverage(Int64 leverage, string
13181319
/// <remarks>
13191320
/// See <see href="https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20transaction%20details"/> <br/>
13201321
/// See <see href="https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20orders"/> <br/>
1322+
/// See <see href="https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Query%20historical%20transaction%20details"/> <br/>
13211323
/// See <see href="https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Query%20Order%20Trade%20Detail"/> <br/>
13221324
/// <list type="table">
13231325
/// <item>

‎cs/tests/Generated/Exchange/test.features.cs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ public static void testFeaturesInner(Exchange exchange, object skippedProperties
7272
{ "GTD", false },
7373
} },
7474
{ "hedged", false },
75-
{ "selfTradePrevention", false },
7675
{ "trailing", false },
77-
{ "twap", false },
78-
{ "iceberg", false },
79-
{ "oco", false },
8076
} },
8177
{ "createOrders", new Dictionary<string, object>() {
8278
{ "max", 5 },

0 commit comments

Comments
 (0)