@gbozee/ultimate 0.0.2-124 → 0.0.2-127
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 +55 -16
- package/dist/index.d.ts +6 -0
- package/dist/index.js +55 -16
- package/dist/mcp-server.cjs +55 -16
- package/dist/mcp-server.js +55 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -55074,10 +55074,13 @@ class BaseExchange {
|
|
|
55074
55074
|
quantity,
|
|
55075
55075
|
increase = false,
|
|
55076
55076
|
price_places,
|
|
55077
|
-
decimal_places
|
|
55077
|
+
decimal_places,
|
|
55078
|
+
place = true
|
|
55078
55079
|
} = payload;
|
|
55079
55080
|
const spread = 1.00005;
|
|
55081
|
+
const purchase_spread = 1.000055;
|
|
55080
55082
|
const stop = kind === "long" ? _stop * spread ** -1 : _stop * spread;
|
|
55083
|
+
const purchase_stop = kind === "long" ? _stop * purchase_spread ** -1 : _stop * purchase_spread;
|
|
55081
55084
|
const order = [
|
|
55082
55085
|
{
|
|
55083
55086
|
kind,
|
|
@@ -55091,18 +55094,21 @@ class BaseExchange {
|
|
|
55091
55094
|
if (increase) {
|
|
55092
55095
|
order.push({
|
|
55093
55096
|
kind,
|
|
55094
|
-
price:
|
|
55097
|
+
price: purchase_stop,
|
|
55095
55098
|
side: kind === "long" ? "buy" : "sell",
|
|
55096
55099
|
quantity,
|
|
55097
55100
|
is_market: false
|
|
55098
55101
|
});
|
|
55099
55102
|
}
|
|
55100
|
-
|
|
55101
|
-
|
|
55102
|
-
|
|
55103
|
-
|
|
55104
|
-
|
|
55105
|
-
|
|
55103
|
+
if (place) {
|
|
55104
|
+
return this.rawCreateLimitPurchaseOrders({
|
|
55105
|
+
orders: order,
|
|
55106
|
+
symbol,
|
|
55107
|
+
price_places,
|
|
55108
|
+
decimal_places
|
|
55109
|
+
});
|
|
55110
|
+
}
|
|
55111
|
+
return order;
|
|
55106
55112
|
}
|
|
55107
55113
|
async placeBadStopEntry(payload) {
|
|
55108
55114
|
const { symbol, orders, price_places, decimal_places } = payload;
|
|
@@ -58675,6 +58681,40 @@ class ExchangeAccount {
|
|
|
58675
58681
|
});
|
|
58676
58682
|
}
|
|
58677
58683
|
}
|
|
58684
|
+
async increasePositionAtStop(payload) {
|
|
58685
|
+
const { symbol, kind, place = false } = payload;
|
|
58686
|
+
const position2 = await this.syncAccount({
|
|
58687
|
+
symbol,
|
|
58688
|
+
kind,
|
|
58689
|
+
as_view: true
|
|
58690
|
+
});
|
|
58691
|
+
console.log(position2);
|
|
58692
|
+
if (position2 && position2.stop_loss) {
|
|
58693
|
+
const { price, quantity } = position2.stop_loss;
|
|
58694
|
+
const symbol_config = await this.recomputeSymbolConfig({
|
|
58695
|
+
symbol
|
|
58696
|
+
});
|
|
58697
|
+
const price_places = symbol_config.price_places;
|
|
58698
|
+
const decimal_places = symbol_config.decimal_places;
|
|
58699
|
+
if (place) {
|
|
58700
|
+
await this.cancelOrders({
|
|
58701
|
+
symbol,
|
|
58702
|
+
kind,
|
|
58703
|
+
limit: true
|
|
58704
|
+
});
|
|
58705
|
+
}
|
|
58706
|
+
return await this.exchange.customStopLoss({
|
|
58707
|
+
symbol,
|
|
58708
|
+
kind,
|
|
58709
|
+
stop: price,
|
|
58710
|
+
quantity,
|
|
58711
|
+
price_places,
|
|
58712
|
+
decimal_places,
|
|
58713
|
+
increase: true,
|
|
58714
|
+
place
|
|
58715
|
+
});
|
|
58716
|
+
}
|
|
58717
|
+
}
|
|
58678
58718
|
async triggerTradeFromConfig(payload) {
|
|
58679
58719
|
const {
|
|
58680
58720
|
symbol,
|
|
@@ -58686,7 +58726,8 @@ class ExchangeAccount {
|
|
|
58686
58726
|
} = payload;
|
|
58687
58727
|
const position2 = await this.syncAccount({
|
|
58688
58728
|
symbol,
|
|
58689
|
-
kind
|
|
58729
|
+
kind,
|
|
58730
|
+
as_view: true
|
|
58690
58731
|
});
|
|
58691
58732
|
const config2 = await this.getPositionConfig({
|
|
58692
58733
|
symbol,
|
|
@@ -59929,9 +59970,7 @@ class ExchangeAccount {
|
|
|
59929
59970
|
const reverse_kind = focus_position.kind === "long" ? "short" : "long";
|
|
59930
59971
|
const reverse_position = positions.find((k) => k.kind === reverse_kind);
|
|
59931
59972
|
const strategy2 = focus_position?.expand?.account_strategy;
|
|
59932
|
-
|
|
59933
|
-
return;
|
|
59934
|
-
}
|
|
59973
|
+
const target_pnl = Math.abs(focus_position.take_profit - focus_position.entry) * focus_position.quantity;
|
|
59935
59974
|
return computeProfitDetail({
|
|
59936
59975
|
focus_position: {
|
|
59937
59976
|
kind: focus_position.kind,
|
|
@@ -59940,11 +59979,11 @@ class ExchangeAccount {
|
|
|
59940
59979
|
avg_price: focus_position.avg_price,
|
|
59941
59980
|
avg_qty: focus_position.avg_qty
|
|
59942
59981
|
},
|
|
59943
|
-
pnl:
|
|
59982
|
+
pnl: target_pnl,
|
|
59944
59983
|
strategy: {
|
|
59945
|
-
reward_factor: strategy2
|
|
59946
|
-
risk: strategy2
|
|
59947
|
-
max_reward_factor: strategy2
|
|
59984
|
+
reward_factor: strategy2?.reward_factor || 1,
|
|
59985
|
+
risk: strategy2?.risk || 1,
|
|
59986
|
+
max_reward_factor: strategy2?.max_reward_factor || 0
|
|
59948
59987
|
},
|
|
59949
59988
|
reduce_position: {
|
|
59950
59989
|
kind: reduce_position.kind,
|
package/dist/index.d.ts
CHANGED
|
@@ -496,6 +496,7 @@ declare abstract class BaseExchange {
|
|
|
496
496
|
stop: number;
|
|
497
497
|
quantity: number;
|
|
498
498
|
increase?: boolean;
|
|
499
|
+
place?: boolean;
|
|
499
500
|
}): Promise<any>;
|
|
500
501
|
abstract getOpenOrders(payload: {
|
|
501
502
|
symbol: string;
|
|
@@ -1959,6 +1960,11 @@ declare class ExchangeAccount$1 {
|
|
|
1959
1960
|
symbol: string;
|
|
1960
1961
|
kind: "long" | "short";
|
|
1961
1962
|
}): Promise<string>;
|
|
1963
|
+
increasePositionAtStop(payload: {
|
|
1964
|
+
symbol: string;
|
|
1965
|
+
kind: "long" | "short";
|
|
1966
|
+
place?: boolean;
|
|
1967
|
+
}): Promise<any>;
|
|
1962
1968
|
triggerTradeFromConfig(payload: {
|
|
1963
1969
|
symbol: string;
|
|
1964
1970
|
kind: "long" | "short";
|
package/dist/index.js
CHANGED
|
@@ -55024,10 +55024,13 @@ class BaseExchange {
|
|
|
55024
55024
|
quantity,
|
|
55025
55025
|
increase = false,
|
|
55026
55026
|
price_places,
|
|
55027
|
-
decimal_places
|
|
55027
|
+
decimal_places,
|
|
55028
|
+
place = true
|
|
55028
55029
|
} = payload;
|
|
55029
55030
|
const spread = 1.00005;
|
|
55031
|
+
const purchase_spread = 1.000055;
|
|
55030
55032
|
const stop = kind === "long" ? _stop * spread ** -1 : _stop * spread;
|
|
55033
|
+
const purchase_stop = kind === "long" ? _stop * purchase_spread ** -1 : _stop * purchase_spread;
|
|
55031
55034
|
const order = [
|
|
55032
55035
|
{
|
|
55033
55036
|
kind,
|
|
@@ -55041,18 +55044,21 @@ class BaseExchange {
|
|
|
55041
55044
|
if (increase) {
|
|
55042
55045
|
order.push({
|
|
55043
55046
|
kind,
|
|
55044
|
-
price:
|
|
55047
|
+
price: purchase_stop,
|
|
55045
55048
|
side: kind === "long" ? "buy" : "sell",
|
|
55046
55049
|
quantity,
|
|
55047
55050
|
is_market: false
|
|
55048
55051
|
});
|
|
55049
55052
|
}
|
|
55050
|
-
|
|
55051
|
-
|
|
55052
|
-
|
|
55053
|
-
|
|
55054
|
-
|
|
55055
|
-
|
|
55053
|
+
if (place) {
|
|
55054
|
+
return this.rawCreateLimitPurchaseOrders({
|
|
55055
|
+
orders: order,
|
|
55056
|
+
symbol,
|
|
55057
|
+
price_places,
|
|
55058
|
+
decimal_places
|
|
55059
|
+
});
|
|
55060
|
+
}
|
|
55061
|
+
return order;
|
|
55056
55062
|
}
|
|
55057
55063
|
async placeBadStopEntry(payload) {
|
|
55058
55064
|
const { symbol, orders, price_places, decimal_places } = payload;
|
|
@@ -58625,6 +58631,40 @@ class ExchangeAccount {
|
|
|
58625
58631
|
});
|
|
58626
58632
|
}
|
|
58627
58633
|
}
|
|
58634
|
+
async increasePositionAtStop(payload) {
|
|
58635
|
+
const { symbol, kind, place = false } = payload;
|
|
58636
|
+
const position2 = await this.syncAccount({
|
|
58637
|
+
symbol,
|
|
58638
|
+
kind,
|
|
58639
|
+
as_view: true
|
|
58640
|
+
});
|
|
58641
|
+
console.log(position2);
|
|
58642
|
+
if (position2 && position2.stop_loss) {
|
|
58643
|
+
const { price, quantity } = position2.stop_loss;
|
|
58644
|
+
const symbol_config = await this.recomputeSymbolConfig({
|
|
58645
|
+
symbol
|
|
58646
|
+
});
|
|
58647
|
+
const price_places = symbol_config.price_places;
|
|
58648
|
+
const decimal_places = symbol_config.decimal_places;
|
|
58649
|
+
if (place) {
|
|
58650
|
+
await this.cancelOrders({
|
|
58651
|
+
symbol,
|
|
58652
|
+
kind,
|
|
58653
|
+
limit: true
|
|
58654
|
+
});
|
|
58655
|
+
}
|
|
58656
|
+
return await this.exchange.customStopLoss({
|
|
58657
|
+
symbol,
|
|
58658
|
+
kind,
|
|
58659
|
+
stop: price,
|
|
58660
|
+
quantity,
|
|
58661
|
+
price_places,
|
|
58662
|
+
decimal_places,
|
|
58663
|
+
increase: true,
|
|
58664
|
+
place
|
|
58665
|
+
});
|
|
58666
|
+
}
|
|
58667
|
+
}
|
|
58628
58668
|
async triggerTradeFromConfig(payload) {
|
|
58629
58669
|
const {
|
|
58630
58670
|
symbol,
|
|
@@ -58636,7 +58676,8 @@ class ExchangeAccount {
|
|
|
58636
58676
|
} = payload;
|
|
58637
58677
|
const position2 = await this.syncAccount({
|
|
58638
58678
|
symbol,
|
|
58639
|
-
kind
|
|
58679
|
+
kind,
|
|
58680
|
+
as_view: true
|
|
58640
58681
|
});
|
|
58641
58682
|
const config2 = await this.getPositionConfig({
|
|
58642
58683
|
symbol,
|
|
@@ -59879,9 +59920,7 @@ class ExchangeAccount {
|
|
|
59879
59920
|
const reverse_kind = focus_position.kind === "long" ? "short" : "long";
|
|
59880
59921
|
const reverse_position = positions.find((k) => k.kind === reverse_kind);
|
|
59881
59922
|
const strategy2 = focus_position?.expand?.account_strategy;
|
|
59882
|
-
|
|
59883
|
-
return;
|
|
59884
|
-
}
|
|
59923
|
+
const target_pnl = Math.abs(focus_position.take_profit - focus_position.entry) * focus_position.quantity;
|
|
59885
59924
|
return computeProfitDetail({
|
|
59886
59925
|
focus_position: {
|
|
59887
59926
|
kind: focus_position.kind,
|
|
@@ -59890,11 +59929,11 @@ class ExchangeAccount {
|
|
|
59890
59929
|
avg_price: focus_position.avg_price,
|
|
59891
59930
|
avg_qty: focus_position.avg_qty
|
|
59892
59931
|
},
|
|
59893
|
-
pnl:
|
|
59932
|
+
pnl: target_pnl,
|
|
59894
59933
|
strategy: {
|
|
59895
|
-
reward_factor: strategy2
|
|
59896
|
-
risk: strategy2
|
|
59897
|
-
max_reward_factor: strategy2
|
|
59934
|
+
reward_factor: strategy2?.reward_factor || 1,
|
|
59935
|
+
risk: strategy2?.risk || 1,
|
|
59936
|
+
max_reward_factor: strategy2?.max_reward_factor || 0
|
|
59898
59937
|
},
|
|
59899
59938
|
reduce_position: {
|
|
59900
59939
|
kind: reduce_position.kind,
|
package/dist/mcp-server.cjs
CHANGED
|
@@ -61752,10 +61752,13 @@ class BaseExchange {
|
|
|
61752
61752
|
quantity,
|
|
61753
61753
|
increase = false,
|
|
61754
61754
|
price_places,
|
|
61755
|
-
decimal_places
|
|
61755
|
+
decimal_places,
|
|
61756
|
+
place = true
|
|
61756
61757
|
} = payload;
|
|
61757
61758
|
const spread = 1.00005;
|
|
61759
|
+
const purchase_spread = 1.000055;
|
|
61758
61760
|
const stop = kind === "long" ? _stop * spread ** -1 : _stop * spread;
|
|
61761
|
+
const purchase_stop = kind === "long" ? _stop * purchase_spread ** -1 : _stop * purchase_spread;
|
|
61759
61762
|
const order = [
|
|
61760
61763
|
{
|
|
61761
61764
|
kind,
|
|
@@ -61769,18 +61772,21 @@ class BaseExchange {
|
|
|
61769
61772
|
if (increase) {
|
|
61770
61773
|
order.push({
|
|
61771
61774
|
kind,
|
|
61772
|
-
price:
|
|
61775
|
+
price: purchase_stop,
|
|
61773
61776
|
side: kind === "long" ? "buy" : "sell",
|
|
61774
61777
|
quantity,
|
|
61775
61778
|
is_market: false
|
|
61776
61779
|
});
|
|
61777
61780
|
}
|
|
61778
|
-
|
|
61779
|
-
|
|
61780
|
-
|
|
61781
|
-
|
|
61782
|
-
|
|
61783
|
-
|
|
61781
|
+
if (place) {
|
|
61782
|
+
return this.rawCreateLimitPurchaseOrders({
|
|
61783
|
+
orders: order,
|
|
61784
|
+
symbol,
|
|
61785
|
+
price_places,
|
|
61786
|
+
decimal_places
|
|
61787
|
+
});
|
|
61788
|
+
}
|
|
61789
|
+
return order;
|
|
61784
61790
|
}
|
|
61785
61791
|
async placeBadStopEntry(payload) {
|
|
61786
61792
|
const { symbol, orders, price_places, decimal_places } = payload;
|
|
@@ -65353,6 +65359,40 @@ class ExchangeAccount {
|
|
|
65353
65359
|
});
|
|
65354
65360
|
}
|
|
65355
65361
|
}
|
|
65362
|
+
async increasePositionAtStop(payload) {
|
|
65363
|
+
const { symbol, kind, place = false } = payload;
|
|
65364
|
+
const position2 = await this.syncAccount({
|
|
65365
|
+
symbol,
|
|
65366
|
+
kind,
|
|
65367
|
+
as_view: true
|
|
65368
|
+
});
|
|
65369
|
+
console.log(position2);
|
|
65370
|
+
if (position2 && position2.stop_loss) {
|
|
65371
|
+
const { price, quantity } = position2.stop_loss;
|
|
65372
|
+
const symbol_config = await this.recomputeSymbolConfig({
|
|
65373
|
+
symbol
|
|
65374
|
+
});
|
|
65375
|
+
const price_places = symbol_config.price_places;
|
|
65376
|
+
const decimal_places = symbol_config.decimal_places;
|
|
65377
|
+
if (place) {
|
|
65378
|
+
await this.cancelOrders({
|
|
65379
|
+
symbol,
|
|
65380
|
+
kind,
|
|
65381
|
+
limit: true
|
|
65382
|
+
});
|
|
65383
|
+
}
|
|
65384
|
+
return await this.exchange.customStopLoss({
|
|
65385
|
+
symbol,
|
|
65386
|
+
kind,
|
|
65387
|
+
stop: price,
|
|
65388
|
+
quantity,
|
|
65389
|
+
price_places,
|
|
65390
|
+
decimal_places,
|
|
65391
|
+
increase: true,
|
|
65392
|
+
place
|
|
65393
|
+
});
|
|
65394
|
+
}
|
|
65395
|
+
}
|
|
65356
65396
|
async triggerTradeFromConfig(payload) {
|
|
65357
65397
|
const {
|
|
65358
65398
|
symbol,
|
|
@@ -65364,7 +65404,8 @@ class ExchangeAccount {
|
|
|
65364
65404
|
} = payload;
|
|
65365
65405
|
const position2 = await this.syncAccount({
|
|
65366
65406
|
symbol,
|
|
65367
|
-
kind
|
|
65407
|
+
kind,
|
|
65408
|
+
as_view: true
|
|
65368
65409
|
});
|
|
65369
65410
|
const config2 = await this.getPositionConfig({
|
|
65370
65411
|
symbol,
|
|
@@ -66607,9 +66648,7 @@ class ExchangeAccount {
|
|
|
66607
66648
|
const reverse_kind = focus_position.kind === "long" ? "short" : "long";
|
|
66608
66649
|
const reverse_position = positions.find((k) => k.kind === reverse_kind);
|
|
66609
66650
|
const strategy2 = focus_position?.expand?.account_strategy;
|
|
66610
|
-
|
|
66611
|
-
return;
|
|
66612
|
-
}
|
|
66651
|
+
const target_pnl = Math.abs(focus_position.take_profit - focus_position.entry) * focus_position.quantity;
|
|
66613
66652
|
return computeProfitDetail({
|
|
66614
66653
|
focus_position: {
|
|
66615
66654
|
kind: focus_position.kind,
|
|
@@ -66618,11 +66657,11 @@ class ExchangeAccount {
|
|
|
66618
66657
|
avg_price: focus_position.avg_price,
|
|
66619
66658
|
avg_qty: focus_position.avg_qty
|
|
66620
66659
|
},
|
|
66621
|
-
pnl:
|
|
66660
|
+
pnl: target_pnl,
|
|
66622
66661
|
strategy: {
|
|
66623
|
-
reward_factor: strategy2
|
|
66624
|
-
risk: strategy2
|
|
66625
|
-
max_reward_factor: strategy2
|
|
66662
|
+
reward_factor: strategy2?.reward_factor || 1,
|
|
66663
|
+
risk: strategy2?.risk || 1,
|
|
66664
|
+
max_reward_factor: strategy2?.max_reward_factor || 0
|
|
66626
66665
|
},
|
|
66627
66666
|
reduce_position: {
|
|
66628
66667
|
kind: reduce_position.kind,
|
package/dist/mcp-server.js
CHANGED
|
@@ -61729,10 +61729,13 @@ class BaseExchange {
|
|
|
61729
61729
|
quantity,
|
|
61730
61730
|
increase = false,
|
|
61731
61731
|
price_places,
|
|
61732
|
-
decimal_places
|
|
61732
|
+
decimal_places,
|
|
61733
|
+
place = true
|
|
61733
61734
|
} = payload;
|
|
61734
61735
|
const spread = 1.00005;
|
|
61736
|
+
const purchase_spread = 1.000055;
|
|
61735
61737
|
const stop = kind === "long" ? _stop * spread ** -1 : _stop * spread;
|
|
61738
|
+
const purchase_stop = kind === "long" ? _stop * purchase_spread ** -1 : _stop * purchase_spread;
|
|
61736
61739
|
const order = [
|
|
61737
61740
|
{
|
|
61738
61741
|
kind,
|
|
@@ -61746,18 +61749,21 @@ class BaseExchange {
|
|
|
61746
61749
|
if (increase) {
|
|
61747
61750
|
order.push({
|
|
61748
61751
|
kind,
|
|
61749
|
-
price:
|
|
61752
|
+
price: purchase_stop,
|
|
61750
61753
|
side: kind === "long" ? "buy" : "sell",
|
|
61751
61754
|
quantity,
|
|
61752
61755
|
is_market: false
|
|
61753
61756
|
});
|
|
61754
61757
|
}
|
|
61755
|
-
|
|
61756
|
-
|
|
61757
|
-
|
|
61758
|
-
|
|
61759
|
-
|
|
61760
|
-
|
|
61758
|
+
if (place) {
|
|
61759
|
+
return this.rawCreateLimitPurchaseOrders({
|
|
61760
|
+
orders: order,
|
|
61761
|
+
symbol,
|
|
61762
|
+
price_places,
|
|
61763
|
+
decimal_places
|
|
61764
|
+
});
|
|
61765
|
+
}
|
|
61766
|
+
return order;
|
|
61761
61767
|
}
|
|
61762
61768
|
async placeBadStopEntry(payload) {
|
|
61763
61769
|
const { symbol, orders, price_places, decimal_places } = payload;
|
|
@@ -65330,6 +65336,40 @@ class ExchangeAccount {
|
|
|
65330
65336
|
});
|
|
65331
65337
|
}
|
|
65332
65338
|
}
|
|
65339
|
+
async increasePositionAtStop(payload) {
|
|
65340
|
+
const { symbol, kind, place = false } = payload;
|
|
65341
|
+
const position2 = await this.syncAccount({
|
|
65342
|
+
symbol,
|
|
65343
|
+
kind,
|
|
65344
|
+
as_view: true
|
|
65345
|
+
});
|
|
65346
|
+
console.log(position2);
|
|
65347
|
+
if (position2 && position2.stop_loss) {
|
|
65348
|
+
const { price, quantity } = position2.stop_loss;
|
|
65349
|
+
const symbol_config = await this.recomputeSymbolConfig({
|
|
65350
|
+
symbol
|
|
65351
|
+
});
|
|
65352
|
+
const price_places = symbol_config.price_places;
|
|
65353
|
+
const decimal_places = symbol_config.decimal_places;
|
|
65354
|
+
if (place) {
|
|
65355
|
+
await this.cancelOrders({
|
|
65356
|
+
symbol,
|
|
65357
|
+
kind,
|
|
65358
|
+
limit: true
|
|
65359
|
+
});
|
|
65360
|
+
}
|
|
65361
|
+
return await this.exchange.customStopLoss({
|
|
65362
|
+
symbol,
|
|
65363
|
+
kind,
|
|
65364
|
+
stop: price,
|
|
65365
|
+
quantity,
|
|
65366
|
+
price_places,
|
|
65367
|
+
decimal_places,
|
|
65368
|
+
increase: true,
|
|
65369
|
+
place
|
|
65370
|
+
});
|
|
65371
|
+
}
|
|
65372
|
+
}
|
|
65333
65373
|
async triggerTradeFromConfig(payload) {
|
|
65334
65374
|
const {
|
|
65335
65375
|
symbol,
|
|
@@ -65341,7 +65381,8 @@ class ExchangeAccount {
|
|
|
65341
65381
|
} = payload;
|
|
65342
65382
|
const position2 = await this.syncAccount({
|
|
65343
65383
|
symbol,
|
|
65344
|
-
kind
|
|
65384
|
+
kind,
|
|
65385
|
+
as_view: true
|
|
65345
65386
|
});
|
|
65346
65387
|
const config2 = await this.getPositionConfig({
|
|
65347
65388
|
symbol,
|
|
@@ -66584,9 +66625,7 @@ class ExchangeAccount {
|
|
|
66584
66625
|
const reverse_kind = focus_position.kind === "long" ? "short" : "long";
|
|
66585
66626
|
const reverse_position = positions.find((k) => k.kind === reverse_kind);
|
|
66586
66627
|
const strategy2 = focus_position?.expand?.account_strategy;
|
|
66587
|
-
|
|
66588
|
-
return;
|
|
66589
|
-
}
|
|
66628
|
+
const target_pnl = Math.abs(focus_position.take_profit - focus_position.entry) * focus_position.quantity;
|
|
66590
66629
|
return computeProfitDetail({
|
|
66591
66630
|
focus_position: {
|
|
66592
66631
|
kind: focus_position.kind,
|
|
@@ -66595,11 +66634,11 @@ class ExchangeAccount {
|
|
|
66595
66634
|
avg_price: focus_position.avg_price,
|
|
66596
66635
|
avg_qty: focus_position.avg_qty
|
|
66597
66636
|
},
|
|
66598
|
-
pnl:
|
|
66637
|
+
pnl: target_pnl,
|
|
66599
66638
|
strategy: {
|
|
66600
|
-
reward_factor: strategy2
|
|
66601
|
-
risk: strategy2
|
|
66602
|
-
max_reward_factor: strategy2
|
|
66639
|
+
reward_factor: strategy2?.reward_factor || 1,
|
|
66640
|
+
risk: strategy2?.risk || 1,
|
|
66641
|
+
max_reward_factor: strategy2?.max_reward_factor || 0
|
|
66603
66642
|
},
|
|
66604
66643
|
reduce_position: {
|
|
66605
66644
|
kind: reduce_position.kind,
|