@gbozee/ultimate 0.0.2-next.36 → 0.0.2-next.39
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.
- package/dist/index.cjs +66 -19
- package/dist/index.js +66 -19
- package/dist/mcp-server.cjs +66 -19
- package/dist/mcp-server.js +66 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -64977,8 +64977,25 @@ var ORDERS_PER_MINUTE = 2000;
|
|
|
64977
64977
|
var ORDERS_PER_SECOND = Math.floor(ORDERS_PER_MINUTE / 60);
|
|
64978
64978
|
var BATCH_SIZE = 5;
|
|
64979
64979
|
var CANCEL_BATCH_SIZE = 10;
|
|
64980
|
-
async function createLimitPurchaseOrdersParallel(client, symbol, priceFormat, quantityFormat,
|
|
64980
|
+
async function createLimitPurchaseOrdersParallel(client, symbol, priceFormat, quantityFormat, _orders, currentPrice, workingType = "last", realClose = false) {
|
|
64981
64981
|
const workingTypeValue = workingType === "mark" ? "MARK_PRICE" : "CONTRACT_PRICE";
|
|
64982
|
+
const orders = _orders.map((u) => {
|
|
64983
|
+
if (currentPrice && !u.stop) {
|
|
64984
|
+
if (u.kind === "long" && u.price > currentPrice && u.side === "buy") {
|
|
64985
|
+
return {
|
|
64986
|
+
...u,
|
|
64987
|
+
force_market: true
|
|
64988
|
+
};
|
|
64989
|
+
}
|
|
64990
|
+
if (u.kind === "short" && u.price < currentPrice && u.side === "sell") {
|
|
64991
|
+
return {
|
|
64992
|
+
...u,
|
|
64993
|
+
force_market: true
|
|
64994
|
+
};
|
|
64995
|
+
}
|
|
64996
|
+
}
|
|
64997
|
+
return u;
|
|
64998
|
+
});
|
|
64982
64999
|
const splitOrders = (inputOrders) => {
|
|
64983
65000
|
const result = [];
|
|
64984
65001
|
for (const o of inputOrders) {
|
|
@@ -65708,7 +65725,8 @@ class BinanceExchange extends BaseExchange {
|
|
|
65708
65725
|
return await cancelAllOrders(this.client, symbol, payload);
|
|
65709
65726
|
}
|
|
65710
65727
|
async _createLimitPurchaseOrders(payload) {
|
|
65711
|
-
|
|
65728
|
+
const current_price = await this.getCurrentPrice(payload.symbol);
|
|
65729
|
+
return await createLimitPurchaseOrdersParallel(this.client, payload.symbol, payload.price_places, payload.decimal_places, payload.orders, current_price);
|
|
65712
65730
|
}
|
|
65713
65731
|
async analyzeCharts(payload) {
|
|
65714
65732
|
return await analyzeCharts({
|
|
@@ -68731,21 +68749,29 @@ function determineNewPosition({
|
|
|
68731
68749
|
}) {
|
|
68732
68750
|
const kind = position2.kind;
|
|
68733
68751
|
const placed = trades.filter((t2) => {
|
|
68734
|
-
|
|
68735
|
-
|
|
68752
|
+
let _price = t2.entry || t2.price;
|
|
68753
|
+
let condition1 = kind === "long" ? _price >= price : _price <= price;
|
|
68754
|
+
return condition1;
|
|
68755
|
+
}).map((t2) => {
|
|
68756
|
+
let _price = t2.entry || t2.price;
|
|
68757
|
+
let condition2 = kind === "long" ? _price >= position2.entry : _price <= position2.entry;
|
|
68758
|
+
if (condition2) {
|
|
68759
|
+
return {
|
|
68760
|
+
...t2,
|
|
68761
|
+
price: position2.entry,
|
|
68762
|
+
entry: position2.entry
|
|
68763
|
+
};
|
|
68736
68764
|
}
|
|
68737
|
-
return t2
|
|
68765
|
+
return t2;
|
|
68738
68766
|
});
|
|
68739
68767
|
const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
|
|
68740
68768
|
if (position2.quantity > 0) {
|
|
68741
68769
|
const placed_less_than_entry = placed.filter((t2) => {
|
|
68742
|
-
|
|
68743
|
-
|
|
68744
|
-
}
|
|
68745
|
-
return t2.entry > position2.entry;
|
|
68770
|
+
let condition1 = kind === "long" ? t2.entry <= position2.entry : t2.entry >= position2.entry;
|
|
68771
|
+
return condition1;
|
|
68746
68772
|
});
|
|
68747
68773
|
const avg = determine_average_entry_and_size(placed_less_than_entry.map((o) => ({
|
|
68748
|
-
price: o.entry,
|
|
68774
|
+
price: o.entry || o.price,
|
|
68749
68775
|
quantity: o.quantity
|
|
68750
68776
|
})).concat([{ price: position2.entry, quantity: position2.quantity }]), global_config.decimal_places, global_config.price_places);
|
|
68751
68777
|
position2.entry = avg.price;
|
|
@@ -68771,16 +68797,14 @@ function positionAt({
|
|
|
68771
68797
|
taker: 0.05
|
|
68772
68798
|
};
|
|
68773
68799
|
const placed = trades.filter((t2) => {
|
|
68774
|
-
|
|
68775
|
-
|
|
68776
|
-
|
|
68777
|
-
return t2.entry <= price;
|
|
68800
|
+
let _price = t2.entry || t2.price;
|
|
68801
|
+
let condition1 = kind === "long" ? _price >= price : _price <= price;
|
|
68802
|
+
return condition1;
|
|
68778
68803
|
});
|
|
68779
68804
|
const not_placed = trades.filter((t2) => {
|
|
68780
|
-
|
|
68781
|
-
|
|
68782
|
-
|
|
68783
|
-
return t2.entry > price;
|
|
68805
|
+
let _price = t2.entry || t2.price;
|
|
68806
|
+
let condition1 = kind === "long" ? _price < price : _price > price;
|
|
68807
|
+
return condition1;
|
|
68784
68808
|
});
|
|
68785
68809
|
const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
|
|
68786
68810
|
const takerFee = price * placeQty * fee_rate.taker / 100;
|
|
@@ -69903,7 +69927,30 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
69903
69927
|
async _placeTpOrder(payload) {
|
|
69904
69928
|
return await placeTpOrder3(this.client, payload);
|
|
69905
69929
|
}
|
|
69906
|
-
async placeLimitOrders(
|
|
69930
|
+
async placeLimitOrders(payload) {
|
|
69931
|
+
const { price_places = "%.1f", decimal_places = "%.3f", symbol } = payload;
|
|
69932
|
+
if (payload.cancel) {
|
|
69933
|
+
await cancelAllOrders3(this.client, symbol, {
|
|
69934
|
+
type: "limit",
|
|
69935
|
+
kind: payload.kind
|
|
69936
|
+
});
|
|
69937
|
+
}
|
|
69938
|
+
if (payload.orders) {
|
|
69939
|
+
const orders = payload.orders.map((x) => ({
|
|
69940
|
+
side: payload.kind === "long" ? "buy" : "sell",
|
|
69941
|
+
price: x.entry,
|
|
69942
|
+
quantity: x.quantity,
|
|
69943
|
+
kind: payload.kind
|
|
69944
|
+
}));
|
|
69945
|
+
return await createLimitPurchaseOrders2(this.client, {
|
|
69946
|
+
symbol,
|
|
69947
|
+
kind: payload.kind,
|
|
69948
|
+
price_places,
|
|
69949
|
+
decimal_places,
|
|
69950
|
+
orders
|
|
69951
|
+
});
|
|
69952
|
+
}
|
|
69953
|
+
}
|
|
69907
69954
|
async _placeStopOrder(payload) {
|
|
69908
69955
|
return await placeStopOrder3(this.client, payload);
|
|
69909
69956
|
}
|
package/dist/index.js
CHANGED
|
@@ -64890,8 +64890,25 @@ var ORDERS_PER_MINUTE = 2000;
|
|
|
64890
64890
|
var ORDERS_PER_SECOND = Math.floor(ORDERS_PER_MINUTE / 60);
|
|
64891
64891
|
var BATCH_SIZE = 5;
|
|
64892
64892
|
var CANCEL_BATCH_SIZE = 10;
|
|
64893
|
-
async function createLimitPurchaseOrdersParallel(client, symbol, priceFormat, quantityFormat,
|
|
64893
|
+
async function createLimitPurchaseOrdersParallel(client, symbol, priceFormat, quantityFormat, _orders, currentPrice, workingType = "last", realClose = false) {
|
|
64894
64894
|
const workingTypeValue = workingType === "mark" ? "MARK_PRICE" : "CONTRACT_PRICE";
|
|
64895
|
+
const orders = _orders.map((u) => {
|
|
64896
|
+
if (currentPrice && !u.stop) {
|
|
64897
|
+
if (u.kind === "long" && u.price > currentPrice && u.side === "buy") {
|
|
64898
|
+
return {
|
|
64899
|
+
...u,
|
|
64900
|
+
force_market: true
|
|
64901
|
+
};
|
|
64902
|
+
}
|
|
64903
|
+
if (u.kind === "short" && u.price < currentPrice && u.side === "sell") {
|
|
64904
|
+
return {
|
|
64905
|
+
...u,
|
|
64906
|
+
force_market: true
|
|
64907
|
+
};
|
|
64908
|
+
}
|
|
64909
|
+
}
|
|
64910
|
+
return u;
|
|
64911
|
+
});
|
|
64895
64912
|
const splitOrders = (inputOrders) => {
|
|
64896
64913
|
const result = [];
|
|
64897
64914
|
for (const o of inputOrders) {
|
|
@@ -65621,7 +65638,8 @@ class BinanceExchange extends BaseExchange {
|
|
|
65621
65638
|
return await cancelAllOrders(this.client, symbol, payload);
|
|
65622
65639
|
}
|
|
65623
65640
|
async _createLimitPurchaseOrders(payload) {
|
|
65624
|
-
|
|
65641
|
+
const current_price = await this.getCurrentPrice(payload.symbol);
|
|
65642
|
+
return await createLimitPurchaseOrdersParallel(this.client, payload.symbol, payload.price_places, payload.decimal_places, payload.orders, current_price);
|
|
65625
65643
|
}
|
|
65626
65644
|
async analyzeCharts(payload) {
|
|
65627
65645
|
return await analyzeCharts({
|
|
@@ -68644,21 +68662,29 @@ function determineNewPosition({
|
|
|
68644
68662
|
}) {
|
|
68645
68663
|
const kind = position2.kind;
|
|
68646
68664
|
const placed = trades.filter((t2) => {
|
|
68647
|
-
|
|
68648
|
-
|
|
68665
|
+
let _price = t2.entry || t2.price;
|
|
68666
|
+
let condition1 = kind === "long" ? _price >= price : _price <= price;
|
|
68667
|
+
return condition1;
|
|
68668
|
+
}).map((t2) => {
|
|
68669
|
+
let _price = t2.entry || t2.price;
|
|
68670
|
+
let condition2 = kind === "long" ? _price >= position2.entry : _price <= position2.entry;
|
|
68671
|
+
if (condition2) {
|
|
68672
|
+
return {
|
|
68673
|
+
...t2,
|
|
68674
|
+
price: position2.entry,
|
|
68675
|
+
entry: position2.entry
|
|
68676
|
+
};
|
|
68649
68677
|
}
|
|
68650
|
-
return t2
|
|
68678
|
+
return t2;
|
|
68651
68679
|
});
|
|
68652
68680
|
const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
|
|
68653
68681
|
if (position2.quantity > 0) {
|
|
68654
68682
|
const placed_less_than_entry = placed.filter((t2) => {
|
|
68655
|
-
|
|
68656
|
-
|
|
68657
|
-
}
|
|
68658
|
-
return t2.entry > position2.entry;
|
|
68683
|
+
let condition1 = kind === "long" ? t2.entry <= position2.entry : t2.entry >= position2.entry;
|
|
68684
|
+
return condition1;
|
|
68659
68685
|
});
|
|
68660
68686
|
const avg = determine_average_entry_and_size(placed_less_than_entry.map((o) => ({
|
|
68661
|
-
price: o.entry,
|
|
68687
|
+
price: o.entry || o.price,
|
|
68662
68688
|
quantity: o.quantity
|
|
68663
68689
|
})).concat([{ price: position2.entry, quantity: position2.quantity }]), global_config.decimal_places, global_config.price_places);
|
|
68664
68690
|
position2.entry = avg.price;
|
|
@@ -68684,16 +68710,14 @@ function positionAt({
|
|
|
68684
68710
|
taker: 0.05
|
|
68685
68711
|
};
|
|
68686
68712
|
const placed = trades.filter((t2) => {
|
|
68687
|
-
|
|
68688
|
-
|
|
68689
|
-
|
|
68690
|
-
return t2.entry <= price;
|
|
68713
|
+
let _price = t2.entry || t2.price;
|
|
68714
|
+
let condition1 = kind === "long" ? _price >= price : _price <= price;
|
|
68715
|
+
return condition1;
|
|
68691
68716
|
});
|
|
68692
68717
|
const not_placed = trades.filter((t2) => {
|
|
68693
|
-
|
|
68694
|
-
|
|
68695
|
-
|
|
68696
|
-
return t2.entry > price;
|
|
68718
|
+
let _price = t2.entry || t2.price;
|
|
68719
|
+
let condition1 = kind === "long" ? _price < price : _price > price;
|
|
68720
|
+
return condition1;
|
|
68697
68721
|
});
|
|
68698
68722
|
const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
|
|
68699
68723
|
const takerFee = price * placeQty * fee_rate.taker / 100;
|
|
@@ -69816,7 +69840,30 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
69816
69840
|
async _placeTpOrder(payload) {
|
|
69817
69841
|
return await placeTpOrder3(this.client, payload);
|
|
69818
69842
|
}
|
|
69819
|
-
async placeLimitOrders(
|
|
69843
|
+
async placeLimitOrders(payload) {
|
|
69844
|
+
const { price_places = "%.1f", decimal_places = "%.3f", symbol } = payload;
|
|
69845
|
+
if (payload.cancel) {
|
|
69846
|
+
await cancelAllOrders3(this.client, symbol, {
|
|
69847
|
+
type: "limit",
|
|
69848
|
+
kind: payload.kind
|
|
69849
|
+
});
|
|
69850
|
+
}
|
|
69851
|
+
if (payload.orders) {
|
|
69852
|
+
const orders = payload.orders.map((x) => ({
|
|
69853
|
+
side: payload.kind === "long" ? "buy" : "sell",
|
|
69854
|
+
price: x.entry,
|
|
69855
|
+
quantity: x.quantity,
|
|
69856
|
+
kind: payload.kind
|
|
69857
|
+
}));
|
|
69858
|
+
return await createLimitPurchaseOrders2(this.client, {
|
|
69859
|
+
symbol,
|
|
69860
|
+
kind: payload.kind,
|
|
69861
|
+
price_places,
|
|
69862
|
+
decimal_places,
|
|
69863
|
+
orders
|
|
69864
|
+
});
|
|
69865
|
+
}
|
|
69866
|
+
}
|
|
69820
69867
|
async _placeStopOrder(payload) {
|
|
69821
69868
|
return await placeStopOrder3(this.client, payload);
|
|
69822
69869
|
}
|
package/dist/mcp-server.cjs
CHANGED
|
@@ -68700,8 +68700,25 @@ var ORDERS_PER_MINUTE = 2000;
|
|
|
68700
68700
|
var ORDERS_PER_SECOND = Math.floor(ORDERS_PER_MINUTE / 60);
|
|
68701
68701
|
var BATCH_SIZE = 5;
|
|
68702
68702
|
var CANCEL_BATCH_SIZE = 10;
|
|
68703
|
-
async function createLimitPurchaseOrdersParallel(client, symbol, priceFormat, quantityFormat,
|
|
68703
|
+
async function createLimitPurchaseOrdersParallel(client, symbol, priceFormat, quantityFormat, _orders, currentPrice, workingType = "last", realClose = false) {
|
|
68704
68704
|
const workingTypeValue = workingType === "mark" ? "MARK_PRICE" : "CONTRACT_PRICE";
|
|
68705
|
+
const orders = _orders.map((u) => {
|
|
68706
|
+
if (currentPrice && !u.stop) {
|
|
68707
|
+
if (u.kind === "long" && u.price > currentPrice && u.side === "buy") {
|
|
68708
|
+
return {
|
|
68709
|
+
...u,
|
|
68710
|
+
force_market: true
|
|
68711
|
+
};
|
|
68712
|
+
}
|
|
68713
|
+
if (u.kind === "short" && u.price < currentPrice && u.side === "sell") {
|
|
68714
|
+
return {
|
|
68715
|
+
...u,
|
|
68716
|
+
force_market: true
|
|
68717
|
+
};
|
|
68718
|
+
}
|
|
68719
|
+
}
|
|
68720
|
+
return u;
|
|
68721
|
+
});
|
|
68705
68722
|
const splitOrders = (inputOrders) => {
|
|
68706
68723
|
const result = [];
|
|
68707
68724
|
for (const o of inputOrders) {
|
|
@@ -69431,7 +69448,8 @@ class BinanceExchange extends BaseExchange {
|
|
|
69431
69448
|
return await cancelAllOrders(this.client, symbol, payload);
|
|
69432
69449
|
}
|
|
69433
69450
|
async _createLimitPurchaseOrders(payload) {
|
|
69434
|
-
|
|
69451
|
+
const current_price = await this.getCurrentPrice(payload.symbol);
|
|
69452
|
+
return await createLimitPurchaseOrdersParallel(this.client, payload.symbol, payload.price_places, payload.decimal_places, payload.orders, current_price);
|
|
69435
69453
|
}
|
|
69436
69454
|
async analyzeCharts(payload) {
|
|
69437
69455
|
return await analyzeCharts({
|
|
@@ -72454,21 +72472,29 @@ function determineNewPosition({
|
|
|
72454
72472
|
}) {
|
|
72455
72473
|
const kind = position2.kind;
|
|
72456
72474
|
const placed = trades.filter((t2) => {
|
|
72457
|
-
|
|
72458
|
-
|
|
72475
|
+
let _price = t2.entry || t2.price;
|
|
72476
|
+
let condition1 = kind === "long" ? _price >= price : _price <= price;
|
|
72477
|
+
return condition1;
|
|
72478
|
+
}).map((t2) => {
|
|
72479
|
+
let _price = t2.entry || t2.price;
|
|
72480
|
+
let condition2 = kind === "long" ? _price >= position2.entry : _price <= position2.entry;
|
|
72481
|
+
if (condition2) {
|
|
72482
|
+
return {
|
|
72483
|
+
...t2,
|
|
72484
|
+
price: position2.entry,
|
|
72485
|
+
entry: position2.entry
|
|
72486
|
+
};
|
|
72459
72487
|
}
|
|
72460
|
-
return t2
|
|
72488
|
+
return t2;
|
|
72461
72489
|
});
|
|
72462
72490
|
const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
|
|
72463
72491
|
if (position2.quantity > 0) {
|
|
72464
72492
|
const placed_less_than_entry = placed.filter((t2) => {
|
|
72465
|
-
|
|
72466
|
-
|
|
72467
|
-
}
|
|
72468
|
-
return t2.entry > position2.entry;
|
|
72493
|
+
let condition1 = kind === "long" ? t2.entry <= position2.entry : t2.entry >= position2.entry;
|
|
72494
|
+
return condition1;
|
|
72469
72495
|
});
|
|
72470
72496
|
const avg = determine_average_entry_and_size(placed_less_than_entry.map((o) => ({
|
|
72471
|
-
price: o.entry,
|
|
72497
|
+
price: o.entry || o.price,
|
|
72472
72498
|
quantity: o.quantity
|
|
72473
72499
|
})).concat([{ price: position2.entry, quantity: position2.quantity }]), global_config.decimal_places, global_config.price_places);
|
|
72474
72500
|
position2.entry = avg.price;
|
|
@@ -72494,16 +72520,14 @@ function positionAt({
|
|
|
72494
72520
|
taker: 0.05
|
|
72495
72521
|
};
|
|
72496
72522
|
const placed = trades.filter((t2) => {
|
|
72497
|
-
|
|
72498
|
-
|
|
72499
|
-
|
|
72500
|
-
return t2.entry <= price;
|
|
72523
|
+
let _price = t2.entry || t2.price;
|
|
72524
|
+
let condition1 = kind === "long" ? _price >= price : _price <= price;
|
|
72525
|
+
return condition1;
|
|
72501
72526
|
});
|
|
72502
72527
|
const not_placed = trades.filter((t2) => {
|
|
72503
|
-
|
|
72504
|
-
|
|
72505
|
-
|
|
72506
|
-
return t2.entry > price;
|
|
72528
|
+
let _price = t2.entry || t2.price;
|
|
72529
|
+
let condition1 = kind === "long" ? _price < price : _price > price;
|
|
72530
|
+
return condition1;
|
|
72507
72531
|
});
|
|
72508
72532
|
const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
|
|
72509
72533
|
const takerFee = price * placeQty * fee_rate.taker / 100;
|
|
@@ -73626,7 +73650,30 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
73626
73650
|
async _placeTpOrder(payload) {
|
|
73627
73651
|
return await placeTpOrder3(this.client, payload);
|
|
73628
73652
|
}
|
|
73629
|
-
async placeLimitOrders(
|
|
73653
|
+
async placeLimitOrders(payload) {
|
|
73654
|
+
const { price_places = "%.1f", decimal_places = "%.3f", symbol } = payload;
|
|
73655
|
+
if (payload.cancel) {
|
|
73656
|
+
await cancelAllOrders3(this.client, symbol, {
|
|
73657
|
+
type: "limit",
|
|
73658
|
+
kind: payload.kind
|
|
73659
|
+
});
|
|
73660
|
+
}
|
|
73661
|
+
if (payload.orders) {
|
|
73662
|
+
const orders = payload.orders.map((x) => ({
|
|
73663
|
+
side: payload.kind === "long" ? "buy" : "sell",
|
|
73664
|
+
price: x.entry,
|
|
73665
|
+
quantity: x.quantity,
|
|
73666
|
+
kind: payload.kind
|
|
73667
|
+
}));
|
|
73668
|
+
return await createLimitPurchaseOrders2(this.client, {
|
|
73669
|
+
symbol,
|
|
73670
|
+
kind: payload.kind,
|
|
73671
|
+
price_places,
|
|
73672
|
+
decimal_places,
|
|
73673
|
+
orders
|
|
73674
|
+
});
|
|
73675
|
+
}
|
|
73676
|
+
}
|
|
73630
73677
|
async _placeStopOrder(payload) {
|
|
73631
73678
|
return await placeStopOrder3(this.client, payload);
|
|
73632
73679
|
}
|
package/dist/mcp-server.js
CHANGED
|
@@ -68673,8 +68673,25 @@ var ORDERS_PER_MINUTE = 2000;
|
|
|
68673
68673
|
var ORDERS_PER_SECOND = Math.floor(ORDERS_PER_MINUTE / 60);
|
|
68674
68674
|
var BATCH_SIZE = 5;
|
|
68675
68675
|
var CANCEL_BATCH_SIZE = 10;
|
|
68676
|
-
async function createLimitPurchaseOrdersParallel(client, symbol, priceFormat, quantityFormat,
|
|
68676
|
+
async function createLimitPurchaseOrdersParallel(client, symbol, priceFormat, quantityFormat, _orders, currentPrice, workingType = "last", realClose = false) {
|
|
68677
68677
|
const workingTypeValue = workingType === "mark" ? "MARK_PRICE" : "CONTRACT_PRICE";
|
|
68678
|
+
const orders = _orders.map((u) => {
|
|
68679
|
+
if (currentPrice && !u.stop) {
|
|
68680
|
+
if (u.kind === "long" && u.price > currentPrice && u.side === "buy") {
|
|
68681
|
+
return {
|
|
68682
|
+
...u,
|
|
68683
|
+
force_market: true
|
|
68684
|
+
};
|
|
68685
|
+
}
|
|
68686
|
+
if (u.kind === "short" && u.price < currentPrice && u.side === "sell") {
|
|
68687
|
+
return {
|
|
68688
|
+
...u,
|
|
68689
|
+
force_market: true
|
|
68690
|
+
};
|
|
68691
|
+
}
|
|
68692
|
+
}
|
|
68693
|
+
return u;
|
|
68694
|
+
});
|
|
68678
68695
|
const splitOrders = (inputOrders) => {
|
|
68679
68696
|
const result = [];
|
|
68680
68697
|
for (const o of inputOrders) {
|
|
@@ -69404,7 +69421,8 @@ class BinanceExchange extends BaseExchange {
|
|
|
69404
69421
|
return await cancelAllOrders(this.client, symbol, payload);
|
|
69405
69422
|
}
|
|
69406
69423
|
async _createLimitPurchaseOrders(payload) {
|
|
69407
|
-
|
|
69424
|
+
const current_price = await this.getCurrentPrice(payload.symbol);
|
|
69425
|
+
return await createLimitPurchaseOrdersParallel(this.client, payload.symbol, payload.price_places, payload.decimal_places, payload.orders, current_price);
|
|
69408
69426
|
}
|
|
69409
69427
|
async analyzeCharts(payload) {
|
|
69410
69428
|
return await analyzeCharts({
|
|
@@ -72427,21 +72445,29 @@ function determineNewPosition({
|
|
|
72427
72445
|
}) {
|
|
72428
72446
|
const kind = position2.kind;
|
|
72429
72447
|
const placed = trades.filter((t2) => {
|
|
72430
|
-
|
|
72431
|
-
|
|
72448
|
+
let _price = t2.entry || t2.price;
|
|
72449
|
+
let condition1 = kind === "long" ? _price >= price : _price <= price;
|
|
72450
|
+
return condition1;
|
|
72451
|
+
}).map((t2) => {
|
|
72452
|
+
let _price = t2.entry || t2.price;
|
|
72453
|
+
let condition2 = kind === "long" ? _price >= position2.entry : _price <= position2.entry;
|
|
72454
|
+
if (condition2) {
|
|
72455
|
+
return {
|
|
72456
|
+
...t2,
|
|
72457
|
+
price: position2.entry,
|
|
72458
|
+
entry: position2.entry
|
|
72459
|
+
};
|
|
72432
72460
|
}
|
|
72433
|
-
return t2
|
|
72461
|
+
return t2;
|
|
72434
72462
|
});
|
|
72435
72463
|
const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
|
|
72436
72464
|
if (position2.quantity > 0) {
|
|
72437
72465
|
const placed_less_than_entry = placed.filter((t2) => {
|
|
72438
|
-
|
|
72439
|
-
|
|
72440
|
-
}
|
|
72441
|
-
return t2.entry > position2.entry;
|
|
72466
|
+
let condition1 = kind === "long" ? t2.entry <= position2.entry : t2.entry >= position2.entry;
|
|
72467
|
+
return condition1;
|
|
72442
72468
|
});
|
|
72443
72469
|
const avg = determine_average_entry_and_size(placed_less_than_entry.map((o) => ({
|
|
72444
|
-
price: o.entry,
|
|
72470
|
+
price: o.entry || o.price,
|
|
72445
72471
|
quantity: o.quantity
|
|
72446
72472
|
})).concat([{ price: position2.entry, quantity: position2.quantity }]), global_config.decimal_places, global_config.price_places);
|
|
72447
72473
|
position2.entry = avg.price;
|
|
@@ -72467,16 +72493,14 @@ function positionAt({
|
|
|
72467
72493
|
taker: 0.05
|
|
72468
72494
|
};
|
|
72469
72495
|
const placed = trades.filter((t2) => {
|
|
72470
|
-
|
|
72471
|
-
|
|
72472
|
-
|
|
72473
|
-
return t2.entry <= price;
|
|
72496
|
+
let _price = t2.entry || t2.price;
|
|
72497
|
+
let condition1 = kind === "long" ? _price >= price : _price <= price;
|
|
72498
|
+
return condition1;
|
|
72474
72499
|
});
|
|
72475
72500
|
const not_placed = trades.filter((t2) => {
|
|
72476
|
-
|
|
72477
|
-
|
|
72478
|
-
|
|
72479
|
-
return t2.entry > price;
|
|
72501
|
+
let _price = t2.entry || t2.price;
|
|
72502
|
+
let condition1 = kind === "long" ? _price < price : _price > price;
|
|
72503
|
+
return condition1;
|
|
72480
72504
|
});
|
|
72481
72505
|
const placeQty = placed.reduce((acc, trade) => acc + trade.quantity, 0);
|
|
72482
72506
|
const takerFee = price * placeQty * fee_rate.taker / 100;
|
|
@@ -73599,7 +73623,30 @@ class PaperBinanceExchange extends BaseExchange {
|
|
|
73599
73623
|
async _placeTpOrder(payload) {
|
|
73600
73624
|
return await placeTpOrder3(this.client, payload);
|
|
73601
73625
|
}
|
|
73602
|
-
async placeLimitOrders(
|
|
73626
|
+
async placeLimitOrders(payload) {
|
|
73627
|
+
const { price_places = "%.1f", decimal_places = "%.3f", symbol } = payload;
|
|
73628
|
+
if (payload.cancel) {
|
|
73629
|
+
await cancelAllOrders3(this.client, symbol, {
|
|
73630
|
+
type: "limit",
|
|
73631
|
+
kind: payload.kind
|
|
73632
|
+
});
|
|
73633
|
+
}
|
|
73634
|
+
if (payload.orders) {
|
|
73635
|
+
const orders = payload.orders.map((x) => ({
|
|
73636
|
+
side: payload.kind === "long" ? "buy" : "sell",
|
|
73637
|
+
price: x.entry,
|
|
73638
|
+
quantity: x.quantity,
|
|
73639
|
+
kind: payload.kind
|
|
73640
|
+
}));
|
|
73641
|
+
return await createLimitPurchaseOrders2(this.client, {
|
|
73642
|
+
symbol,
|
|
73643
|
+
kind: payload.kind,
|
|
73644
|
+
price_places,
|
|
73645
|
+
decimal_places,
|
|
73646
|
+
orders
|
|
73647
|
+
});
|
|
73648
|
+
}
|
|
73649
|
+
}
|
|
73603
73650
|
async _placeStopOrder(payload) {
|
|
73604
73651
|
return await placeStopOrder3(this.client, payload);
|
|
73605
73652
|
}
|