@gbozee/ultimate 0.0.2-194 → 0.0.2-196

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 CHANGED
@@ -55444,6 +55444,43 @@ class AppDatabase {
55444
55444
  const { id, params } = payload;
55445
55445
  return await this.pb.collection("compound_instances").update(id, params);
55446
55446
  }
55447
+ async getPositionsByAssetPair(payload) {
55448
+ const { asset, symbol, isCompound } = payload;
55449
+ const customFilter = isCompound ? ` && compound_instance.id != NULL ` : ``;
55450
+ const positionsWithAssetName = await this.fetchCentralPositions({
55451
+ asset: symbol !== asset ? asset : undefined,
55452
+ symbol: symbol === asset ? asset : undefined,
55453
+ customFilter
55454
+ });
55455
+ const map = new Map;
55456
+ for (const position of positionsWithAssetName) {
55457
+ const [_account, _exchange] = position.account.split(" ");
55458
+ const key = `${_account}-${_exchange}-${position.symbol}`;
55459
+ let existing = map.get(key) || [];
55460
+ existing.push({
55461
+ config: position.expand?.b_config,
55462
+ entry: position.entry,
55463
+ symbol: position.symbol,
55464
+ kind: position.kind,
55465
+ account_id: position.account_id,
55466
+ account: _account,
55467
+ exchange: _exchange,
55468
+ tp: position.kind === "long" ? position.target_pnl / position.quantity + position.entry : position.entry - position.target_pnl / position.quantity,
55469
+ strategy: position?.expand?.account_strategy,
55470
+ owner: position.account.split(" ")[0],
55471
+ raw: {
55472
+ ...position,
55473
+ owner: position.account.split(" ")[0],
55474
+ exchange: position.account.split(" ")[1]
55475
+ }
55476
+ });
55477
+ map.set(key, existing);
55478
+ }
55479
+ return {
55480
+ pairObject: Object.fromEntries(map),
55481
+ asset
55482
+ };
55483
+ }
55447
55484
  }
55448
55485
 
55449
55486
  // src/exchange-account.ts
@@ -59376,6 +59413,13 @@ async function placeStopOrder(client, payload) {
59376
59413
  type: "stop",
59377
59414
  kind: payload.kind
59378
59415
  });
59416
+ if (payload.hedge) {
59417
+ const r_kind = payload.kind === "long" ? "short" : "long";
59418
+ await cancelAllOrders(client, symbol, {
59419
+ type: "stop",
59420
+ kind: r_kind
59421
+ });
59422
+ }
59379
59423
  }
59380
59424
  const spread = 1.00005;
59381
59425
  const order = {
@@ -60010,7 +60054,9 @@ class BinanceExchange extends BaseExchange {
60010
60054
  balanceAfterTransfer: 0,
60011
60055
  marginRequirementAfterTransfer: 0,
60012
60056
  warnings,
60013
- errors: [`Failed to preview transfer: ${error instanceof Error ? error.message : error}`]
60057
+ errors: [
60058
+ `Failed to preview transfer: ${error instanceof Error ? error.message : error}`
60059
+ ]
60014
60060
  };
60015
60061
  }
60016
60062
  }
package/dist/index.d.ts CHANGED
@@ -828,6 +828,14 @@ export declare class AppDatabase {
828
828
  id: string;
829
829
  params: any;
830
830
  }): Promise<import("pocketbase").RecordModel>;
831
+ getPositionsByAssetPair(payload: {
832
+ asset: string;
833
+ symbol?: string;
834
+ isCompound?: boolean;
835
+ }): Promise<{
836
+ pairObject: any;
837
+ asset: string;
838
+ }>;
831
839
  }
832
840
  export type StrategyPosition = {
833
841
  entry: number;
package/dist/index.js CHANGED
@@ -55381,6 +55381,43 @@ class AppDatabase {
55381
55381
  const { id, params } = payload;
55382
55382
  return await this.pb.collection("compound_instances").update(id, params);
55383
55383
  }
55384
+ async getPositionsByAssetPair(payload) {
55385
+ const { asset, symbol, isCompound } = payload;
55386
+ const customFilter = isCompound ? ` && compound_instance.id != NULL ` : ``;
55387
+ const positionsWithAssetName = await this.fetchCentralPositions({
55388
+ asset: symbol !== asset ? asset : undefined,
55389
+ symbol: symbol === asset ? asset : undefined,
55390
+ customFilter
55391
+ });
55392
+ const map = new Map;
55393
+ for (const position of positionsWithAssetName) {
55394
+ const [_account, _exchange] = position.account.split(" ");
55395
+ const key = `${_account}-${_exchange}-${position.symbol}`;
55396
+ let existing = map.get(key) || [];
55397
+ existing.push({
55398
+ config: position.expand?.b_config,
55399
+ entry: position.entry,
55400
+ symbol: position.symbol,
55401
+ kind: position.kind,
55402
+ account_id: position.account_id,
55403
+ account: _account,
55404
+ exchange: _exchange,
55405
+ tp: position.kind === "long" ? position.target_pnl / position.quantity + position.entry : position.entry - position.target_pnl / position.quantity,
55406
+ strategy: position?.expand?.account_strategy,
55407
+ owner: position.account.split(" ")[0],
55408
+ raw: {
55409
+ ...position,
55410
+ owner: position.account.split(" ")[0],
55411
+ exchange: position.account.split(" ")[1]
55412
+ }
55413
+ });
55414
+ map.set(key, existing);
55415
+ }
55416
+ return {
55417
+ pairObject: Object.fromEntries(map),
55418
+ asset
55419
+ };
55420
+ }
55384
55421
  }
55385
55422
 
55386
55423
  // src/exchange-account.ts
@@ -59313,6 +59350,13 @@ async function placeStopOrder(client, payload) {
59313
59350
  type: "stop",
59314
59351
  kind: payload.kind
59315
59352
  });
59353
+ if (payload.hedge) {
59354
+ const r_kind = payload.kind === "long" ? "short" : "long";
59355
+ await cancelAllOrders(client, symbol, {
59356
+ type: "stop",
59357
+ kind: r_kind
59358
+ });
59359
+ }
59316
59360
  }
59317
59361
  const spread = 1.00005;
59318
59362
  const order = {
@@ -59947,7 +59991,9 @@ class BinanceExchange extends BaseExchange {
59947
59991
  balanceAfterTransfer: 0,
59948
59992
  marginRequirementAfterTransfer: 0,
59949
59993
  warnings,
59950
- errors: [`Failed to preview transfer: ${error instanceof Error ? error.message : error}`]
59994
+ errors: [
59995
+ `Failed to preview transfer: ${error instanceof Error ? error.message : error}`
59996
+ ]
59951
59997
  };
59952
59998
  }
59953
59999
  }
@@ -62137,6 +62137,43 @@ class AppDatabase {
62137
62137
  const { id, params } = payload;
62138
62138
  return await this.pb.collection("compound_instances").update(id, params);
62139
62139
  }
62140
+ async getPositionsByAssetPair(payload) {
62141
+ const { asset, symbol, isCompound } = payload;
62142
+ const customFilter = isCompound ? ` && compound_instance.id != NULL ` : ``;
62143
+ const positionsWithAssetName = await this.fetchCentralPositions({
62144
+ asset: symbol !== asset ? asset : undefined,
62145
+ symbol: symbol === asset ? asset : undefined,
62146
+ customFilter
62147
+ });
62148
+ const map2 = new Map;
62149
+ for (const position of positionsWithAssetName) {
62150
+ const [_account, _exchange] = position.account.split(" ");
62151
+ const key = `${_account}-${_exchange}-${position.symbol}`;
62152
+ let existing = map2.get(key) || [];
62153
+ existing.push({
62154
+ config: position.expand?.b_config,
62155
+ entry: position.entry,
62156
+ symbol: position.symbol,
62157
+ kind: position.kind,
62158
+ account_id: position.account_id,
62159
+ account: _account,
62160
+ exchange: _exchange,
62161
+ tp: position.kind === "long" ? position.target_pnl / position.quantity + position.entry : position.entry - position.target_pnl / position.quantity,
62162
+ strategy: position?.expand?.account_strategy,
62163
+ owner: position.account.split(" ")[0],
62164
+ raw: {
62165
+ ...position,
62166
+ owner: position.account.split(" ")[0],
62167
+ exchange: position.account.split(" ")[1]
62168
+ }
62169
+ });
62170
+ map2.set(key, existing);
62171
+ }
62172
+ return {
62173
+ pairObject: Object.fromEntries(map2),
62174
+ asset
62175
+ };
62176
+ }
62140
62177
  }
62141
62178
 
62142
62179
  // src/exchanges/binance/index.ts
@@ -65949,6 +65986,13 @@ async function placeStopOrder(client, payload) {
65949
65986
  type: "stop",
65950
65987
  kind: payload.kind
65951
65988
  });
65989
+ if (payload.hedge) {
65990
+ const r_kind = payload.kind === "long" ? "short" : "long";
65991
+ await cancelAllOrders(client, symbol, {
65992
+ type: "stop",
65993
+ kind: r_kind
65994
+ });
65995
+ }
65952
65996
  }
65953
65997
  const spread = 1.00005;
65954
65998
  const order = {
@@ -66583,7 +66627,9 @@ class BinanceExchange extends BaseExchange {
66583
66627
  balanceAfterTransfer: 0,
66584
66628
  marginRequirementAfterTransfer: 0,
66585
66629
  warnings,
66586
- errors: [`Failed to preview transfer: ${error instanceof Error ? error.message : error}`]
66630
+ errors: [
66631
+ `Failed to preview transfer: ${error instanceof Error ? error.message : error}`
66632
+ ]
66587
66633
  };
66588
66634
  }
66589
66635
  }
@@ -62110,6 +62110,43 @@ class AppDatabase {
62110
62110
  const { id, params } = payload;
62111
62111
  return await this.pb.collection("compound_instances").update(id, params);
62112
62112
  }
62113
+ async getPositionsByAssetPair(payload) {
62114
+ const { asset, symbol, isCompound } = payload;
62115
+ const customFilter = isCompound ? ` && compound_instance.id != NULL ` : ``;
62116
+ const positionsWithAssetName = await this.fetchCentralPositions({
62117
+ asset: symbol !== asset ? asset : undefined,
62118
+ symbol: symbol === asset ? asset : undefined,
62119
+ customFilter
62120
+ });
62121
+ const map2 = new Map;
62122
+ for (const position of positionsWithAssetName) {
62123
+ const [_account, _exchange] = position.account.split(" ");
62124
+ const key = `${_account}-${_exchange}-${position.symbol}`;
62125
+ let existing = map2.get(key) || [];
62126
+ existing.push({
62127
+ config: position.expand?.b_config,
62128
+ entry: position.entry,
62129
+ symbol: position.symbol,
62130
+ kind: position.kind,
62131
+ account_id: position.account_id,
62132
+ account: _account,
62133
+ exchange: _exchange,
62134
+ tp: position.kind === "long" ? position.target_pnl / position.quantity + position.entry : position.entry - position.target_pnl / position.quantity,
62135
+ strategy: position?.expand?.account_strategy,
62136
+ owner: position.account.split(" ")[0],
62137
+ raw: {
62138
+ ...position,
62139
+ owner: position.account.split(" ")[0],
62140
+ exchange: position.account.split(" ")[1]
62141
+ }
62142
+ });
62143
+ map2.set(key, existing);
62144
+ }
62145
+ return {
62146
+ pairObject: Object.fromEntries(map2),
62147
+ asset
62148
+ };
62149
+ }
62113
62150
  }
62114
62151
 
62115
62152
  // src/exchanges/binance/index.ts
@@ -65922,6 +65959,13 @@ async function placeStopOrder(client, payload) {
65922
65959
  type: "stop",
65923
65960
  kind: payload.kind
65924
65961
  });
65962
+ if (payload.hedge) {
65963
+ const r_kind = payload.kind === "long" ? "short" : "long";
65964
+ await cancelAllOrders(client, symbol, {
65965
+ type: "stop",
65966
+ kind: r_kind
65967
+ });
65968
+ }
65925
65969
  }
65926
65970
  const spread = 1.00005;
65927
65971
  const order = {
@@ -66556,7 +66600,9 @@ class BinanceExchange extends BaseExchange {
66556
66600
  balanceAfterTransfer: 0,
66557
66601
  marginRequirementAfterTransfer: 0,
66558
66602
  warnings,
66559
- errors: [`Failed to preview transfer: ${error instanceof Error ? error.message : error}`]
66603
+ errors: [
66604
+ `Failed to preview transfer: ${error instanceof Error ? error.message : error}`
66605
+ ]
66560
66606
  };
66561
66607
  }
66562
66608
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-194",
4
+ "version": "0.0.2-196",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",