@pipsend/sdk 0.2.0 → 0.3.1

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.d.mts CHANGED
@@ -18,7 +18,7 @@ interface WebSocketConfig {
18
18
  /**
19
19
  * Available WebSocket channels for subscription
20
20
  */
21
- type WebSocketChannel = 'positions:new' | 'positions:closed' | 'positions:updated' | 'accounts:balance';
21
+ type WebSocketChannel = 'positions:new' | 'positions:closed' | 'positions:updated' | 'accounts:balance' | 'account_metrics';
22
22
  /**
23
23
  * WebSocket operation types from server
24
24
  */
@@ -79,21 +79,27 @@ interface PositionEvent {
79
79
  };
80
80
  }
81
81
  /**
82
- * Balance update event
82
+ * Balance update event (account metrics)
83
83
  */
84
84
  interface BalanceEvent {
85
- account_id: string;
86
- balance: number;
87
- equity: number;
88
- margin: number;
89
- free_margin: number;
90
- margin_level: number;
91
- timestamp: number;
85
+ metrics: {
86
+ balance: number;
87
+ equity: number;
88
+ margin: number;
89
+ free_margin: number;
90
+ margin_level: number;
91
+ total_pnl: number;
92
+ leverage: number;
93
+ currency: string;
94
+ };
95
+ ts: number;
96
+ type: 'account_metrics';
97
+ login?: number;
92
98
  }
93
99
  /**
94
100
  * WebSocket event types (internal)
95
101
  */
96
- type WebSocketEventType = 'position:opened' | 'position:closed' | 'position:updated' | 'balance:updated' | 'connected' | 'disconnected' | 'error' | 'subscription_success' | 'unsubscription_success' | '*';
102
+ type WebSocketEventType = 'position:opened' | 'position:closed' | 'position:updated' | 'balance:updated' | 'account:metrics' | 'connected' | 'disconnected' | 'error' | 'subscription_success' | 'unsubscription_success' | '*';
97
103
  /**
98
104
  * @deprecated Use PositionEvent instead
99
105
  */
@@ -176,7 +182,7 @@ interface Account {
176
182
  last_name: string;
177
183
  middle_name?: string;
178
184
  company?: string;
179
- state: 'active' | 'inactive' | 'archived';
185
+ state: "active" | "inactive" | "archived";
180
186
  balance: number;
181
187
  credit: number;
182
188
  leverage: number;
@@ -239,7 +245,8 @@ interface AccountStatisticsParams {
239
245
  trading_group?: string;
240
246
  }
241
247
  interface ChangePasswordRequest {
242
- new_password: string;
248
+ master?: string;
249
+ investor?: string;
243
250
  }
244
251
  /**
245
252
  * Create account request
@@ -278,14 +285,14 @@ interface CreateAccountRequest {
278
285
  /** Leverage (uses group default if not specified) */
279
286
  leverage?: number;
280
287
  /** Account state: "active" or "inactive" (default: "active") */
281
- state?: 'active' | 'inactive';
288
+ state?: "active" | "inactive";
282
289
  }
283
290
  /**
284
291
  * Create account response
285
292
  */
286
293
  interface CreateAccountResponse {
287
- status: 'success';
288
- status_code: 'CREATED';
294
+ status: "success";
295
+ status_code: "CREATED";
289
296
  data: Account;
290
297
  }
291
298
  /**
@@ -317,14 +324,14 @@ interface UpdateAccountRequest {
317
324
  /** Leverage */
318
325
  leverage?: number;
319
326
  /** Account state: "active" or "inactive" */
320
- state?: 'active' | 'inactive';
327
+ state?: "active" | "inactive";
321
328
  }
322
329
  /**
323
330
  * Update account response
324
331
  */
325
332
  interface UpdateAccountResponse {
326
- status: 'success';
327
- status_code: 'SUCCESS';
333
+ status: "success";
334
+ status_code: "SUCCESS";
328
335
  data: Account;
329
336
  }
330
337
  /**
@@ -332,7 +339,7 @@ interface UpdateAccountResponse {
332
339
  */
333
340
  interface AdjustBalanceRequest {
334
341
  /** Type of adjustment: "balance" or "credit" */
335
- type: 'balance' | 'credit';
342
+ type: "balance" | "credit";
336
343
  /** Amount to adjust (positive = add, negative = subtract) */
337
344
  amount: number;
338
345
  /** Descriptive comment (max 255 characters) */
@@ -342,8 +349,8 @@ interface AdjustBalanceRequest {
342
349
  * Adjust balance or credit response
343
350
  */
344
351
  interface AdjustBalanceResponse {
345
- status: 'success';
346
- status_code: 'SUCCESS';
352
+ status: "success";
353
+ status_code: "SUCCESS";
347
354
  data: Account;
348
355
  }
349
356
  /**
@@ -365,14 +372,14 @@ interface AccountStatus {
365
372
  * Account status response
366
373
  */
367
374
  interface AccountStatusResponse {
368
- status: 'success';
369
- status_code: 'SUCCESS';
375
+ status: "success";
376
+ status_code: "SUCCESS";
370
377
  data: AccountStatus;
371
378
  }
372
379
  /**
373
380
  * Account permission types
374
381
  */
375
- type AccountPermission = 'RIGHT_ENABLED' | 'RIGHT_LOGIN_ENABLED' | 'RIGHT_TRADE_ENABLED' | 'RIGHT_EA_ENABLED' | 'RIGHT_READONLY' | 'RIGHT_API_ACCESS_ENABLED' | 'RIGHT_BALANCE_READONLY' | 'RIGHT_DEPOSIT_ENABLED' | 'RIGHT_WITHDRAW_ENABLED' | 'RIGHT_PUSH_NOTIFICATIONS_ENABLED' | 'RIGHT_FORCE_PASSWORD_RESET';
382
+ type AccountPermission = "RIGHT_ENABLED" | "RIGHT_LOGIN_ENABLED" | "RIGHT_TRADE_ENABLED" | "RIGHT_EA_ENABLED" | "RIGHT_READONLY" | "RIGHT_API_ACCESS_ENABLED" | "RIGHT_BALANCE_READONLY" | "RIGHT_DEPOSIT_ENABLED" | "RIGHT_WITHDRAW_ENABLED" | "RIGHT_PUSH_NOTIFICATIONS_ENABLED" | "RIGHT_FORCE_PASSWORD_RESET";
376
383
  /**
377
384
  * Account rights/permissions
378
385
  */
@@ -1145,13 +1152,9 @@ declare class AccountsAPI {
1145
1152
  */
1146
1153
  getStatistics(params?: AccountStatisticsParams): Promise<AccountStatistics>;
1147
1154
  /**
1148
- * Change master password for an account
1149
- */
1150
- changeMasterPassword(login: number, request: ChangePasswordRequest): Promise<void>;
1151
- /**
1152
- * Change investor password for an account
1155
+ * Change account passwords (master and/or investor)
1153
1156
  */
1154
- changeInvestorPassword(login: number, request: ChangePasswordRequest): Promise<void>;
1157
+ changePassword(login: number, request: ChangePasswordRequest): Promise<void>;
1155
1158
  /**
1156
1159
  * Archive an account
1157
1160
  */
@@ -1465,6 +1468,10 @@ declare class PipsendClient {
1465
1468
  * Listens to balance updated events
1466
1469
  */
1467
1470
  onBalanceUpdated: (callback: WebSocketCallback<BalanceEvent>) => void;
1471
+ /**
1472
+ * Listens to account metrics events (replaces balance updates)
1473
+ */
1474
+ onAccountMetrics: (callback: WebSocketCallback<BalanceEvent>) => void;
1468
1475
  /**
1469
1476
  * @deprecated Use onPositionUpdated instead
1470
1477
  */
@@ -1493,6 +1500,10 @@ declare class PipsendClient {
1493
1500
  * Listens to error events
1494
1501
  */
1495
1502
  onError: (callback: WebSocketCallback) => void;
1503
+ /**
1504
+ * Registers a custom event listener
1505
+ */
1506
+ on: (event: string, callback: WebSocketCallback) => void;
1496
1507
  /**
1497
1508
  * Removes event listener
1498
1509
  */
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ interface WebSocketConfig {
18
18
  /**
19
19
  * Available WebSocket channels for subscription
20
20
  */
21
- type WebSocketChannel = 'positions:new' | 'positions:closed' | 'positions:updated' | 'accounts:balance';
21
+ type WebSocketChannel = 'positions:new' | 'positions:closed' | 'positions:updated' | 'accounts:balance' | 'account_metrics';
22
22
  /**
23
23
  * WebSocket operation types from server
24
24
  */
@@ -79,21 +79,27 @@ interface PositionEvent {
79
79
  };
80
80
  }
81
81
  /**
82
- * Balance update event
82
+ * Balance update event (account metrics)
83
83
  */
84
84
  interface BalanceEvent {
85
- account_id: string;
86
- balance: number;
87
- equity: number;
88
- margin: number;
89
- free_margin: number;
90
- margin_level: number;
91
- timestamp: number;
85
+ metrics: {
86
+ balance: number;
87
+ equity: number;
88
+ margin: number;
89
+ free_margin: number;
90
+ margin_level: number;
91
+ total_pnl: number;
92
+ leverage: number;
93
+ currency: string;
94
+ };
95
+ ts: number;
96
+ type: 'account_metrics';
97
+ login?: number;
92
98
  }
93
99
  /**
94
100
  * WebSocket event types (internal)
95
101
  */
96
- type WebSocketEventType = 'position:opened' | 'position:closed' | 'position:updated' | 'balance:updated' | 'connected' | 'disconnected' | 'error' | 'subscription_success' | 'unsubscription_success' | '*';
102
+ type WebSocketEventType = 'position:opened' | 'position:closed' | 'position:updated' | 'balance:updated' | 'account:metrics' | 'connected' | 'disconnected' | 'error' | 'subscription_success' | 'unsubscription_success' | '*';
97
103
  /**
98
104
  * @deprecated Use PositionEvent instead
99
105
  */
@@ -176,7 +182,7 @@ interface Account {
176
182
  last_name: string;
177
183
  middle_name?: string;
178
184
  company?: string;
179
- state: 'active' | 'inactive' | 'archived';
185
+ state: "active" | "inactive" | "archived";
180
186
  balance: number;
181
187
  credit: number;
182
188
  leverage: number;
@@ -239,7 +245,8 @@ interface AccountStatisticsParams {
239
245
  trading_group?: string;
240
246
  }
241
247
  interface ChangePasswordRequest {
242
- new_password: string;
248
+ master?: string;
249
+ investor?: string;
243
250
  }
244
251
  /**
245
252
  * Create account request
@@ -278,14 +285,14 @@ interface CreateAccountRequest {
278
285
  /** Leverage (uses group default if not specified) */
279
286
  leverage?: number;
280
287
  /** Account state: "active" or "inactive" (default: "active") */
281
- state?: 'active' | 'inactive';
288
+ state?: "active" | "inactive";
282
289
  }
283
290
  /**
284
291
  * Create account response
285
292
  */
286
293
  interface CreateAccountResponse {
287
- status: 'success';
288
- status_code: 'CREATED';
294
+ status: "success";
295
+ status_code: "CREATED";
289
296
  data: Account;
290
297
  }
291
298
  /**
@@ -317,14 +324,14 @@ interface UpdateAccountRequest {
317
324
  /** Leverage */
318
325
  leverage?: number;
319
326
  /** Account state: "active" or "inactive" */
320
- state?: 'active' | 'inactive';
327
+ state?: "active" | "inactive";
321
328
  }
322
329
  /**
323
330
  * Update account response
324
331
  */
325
332
  interface UpdateAccountResponse {
326
- status: 'success';
327
- status_code: 'SUCCESS';
333
+ status: "success";
334
+ status_code: "SUCCESS";
328
335
  data: Account;
329
336
  }
330
337
  /**
@@ -332,7 +339,7 @@ interface UpdateAccountResponse {
332
339
  */
333
340
  interface AdjustBalanceRequest {
334
341
  /** Type of adjustment: "balance" or "credit" */
335
- type: 'balance' | 'credit';
342
+ type: "balance" | "credit";
336
343
  /** Amount to adjust (positive = add, negative = subtract) */
337
344
  amount: number;
338
345
  /** Descriptive comment (max 255 characters) */
@@ -342,8 +349,8 @@ interface AdjustBalanceRequest {
342
349
  * Adjust balance or credit response
343
350
  */
344
351
  interface AdjustBalanceResponse {
345
- status: 'success';
346
- status_code: 'SUCCESS';
352
+ status: "success";
353
+ status_code: "SUCCESS";
347
354
  data: Account;
348
355
  }
349
356
  /**
@@ -365,14 +372,14 @@ interface AccountStatus {
365
372
  * Account status response
366
373
  */
367
374
  interface AccountStatusResponse {
368
- status: 'success';
369
- status_code: 'SUCCESS';
375
+ status: "success";
376
+ status_code: "SUCCESS";
370
377
  data: AccountStatus;
371
378
  }
372
379
  /**
373
380
  * Account permission types
374
381
  */
375
- type AccountPermission = 'RIGHT_ENABLED' | 'RIGHT_LOGIN_ENABLED' | 'RIGHT_TRADE_ENABLED' | 'RIGHT_EA_ENABLED' | 'RIGHT_READONLY' | 'RIGHT_API_ACCESS_ENABLED' | 'RIGHT_BALANCE_READONLY' | 'RIGHT_DEPOSIT_ENABLED' | 'RIGHT_WITHDRAW_ENABLED' | 'RIGHT_PUSH_NOTIFICATIONS_ENABLED' | 'RIGHT_FORCE_PASSWORD_RESET';
382
+ type AccountPermission = "RIGHT_ENABLED" | "RIGHT_LOGIN_ENABLED" | "RIGHT_TRADE_ENABLED" | "RIGHT_EA_ENABLED" | "RIGHT_READONLY" | "RIGHT_API_ACCESS_ENABLED" | "RIGHT_BALANCE_READONLY" | "RIGHT_DEPOSIT_ENABLED" | "RIGHT_WITHDRAW_ENABLED" | "RIGHT_PUSH_NOTIFICATIONS_ENABLED" | "RIGHT_FORCE_PASSWORD_RESET";
376
383
  /**
377
384
  * Account rights/permissions
378
385
  */
@@ -1145,13 +1152,9 @@ declare class AccountsAPI {
1145
1152
  */
1146
1153
  getStatistics(params?: AccountStatisticsParams): Promise<AccountStatistics>;
1147
1154
  /**
1148
- * Change master password for an account
1149
- */
1150
- changeMasterPassword(login: number, request: ChangePasswordRequest): Promise<void>;
1151
- /**
1152
- * Change investor password for an account
1155
+ * Change account passwords (master and/or investor)
1153
1156
  */
1154
- changeInvestorPassword(login: number, request: ChangePasswordRequest): Promise<void>;
1157
+ changePassword(login: number, request: ChangePasswordRequest): Promise<void>;
1155
1158
  /**
1156
1159
  * Archive an account
1157
1160
  */
@@ -1465,6 +1468,10 @@ declare class PipsendClient {
1465
1468
  * Listens to balance updated events
1466
1469
  */
1467
1470
  onBalanceUpdated: (callback: WebSocketCallback<BalanceEvent>) => void;
1471
+ /**
1472
+ * Listens to account metrics events (replaces balance updates)
1473
+ */
1474
+ onAccountMetrics: (callback: WebSocketCallback<BalanceEvent>) => void;
1468
1475
  /**
1469
1476
  * @deprecated Use onPositionUpdated instead
1470
1477
  */
@@ -1493,6 +1500,10 @@ declare class PipsendClient {
1493
1500
  * Listens to error events
1494
1501
  */
1495
1502
  onError: (callback: WebSocketCallback) => void;
1503
+ /**
1504
+ * Registers a custom event listener
1505
+ */
1506
+ on: (event: string, callback: WebSocketCallback) => void;
1496
1507
  /**
1497
1508
  * Removes event listener
1498
1509
  */
package/dist/index.js CHANGED
@@ -134,11 +134,6 @@ var AuthManager = class {
134
134
  }
135
135
  const data = await response.json();
136
136
  this.setTokenInfo(data);
137
- console.log("\u2705 Authentication successful");
138
- console.log(` User: ${data.user.first_name} ${data.user.last_name} (${data.user.email})`);
139
- console.log(` Login: ${data.user.login}`);
140
- console.log(` Balance: $${data.user.balance.toFixed(2)}`);
141
- console.log(` Logged with: ${data.logged_with}`);
142
137
  } catch (error) {
143
138
  if (error instanceof AuthenticationError) {
144
139
  throw error;
@@ -153,7 +148,6 @@ var AuthManager = class {
153
148
  */
154
149
  async refreshToken() {
155
150
  if (!this.tokenInfo?.refreshToken) {
156
- console.log("\u26A0\uFE0F No refresh token available, performing full authentication");
157
151
  this.tokenInfo = void 0;
158
152
  await this.authenticate();
159
153
  return;
@@ -167,7 +161,6 @@ var AuthManager = class {
167
161
  })
168
162
  });
169
163
  if (!response.ok) {
170
- console.log("\u26A0\uFE0F Refresh token failed, performing full authentication");
171
164
  this.tokenInfo = void 0;
172
165
  await this.authenticate();
173
166
  return;
@@ -182,9 +175,7 @@ var AuthManager = class {
182
175
  issuedAt: now,
183
176
  expiresAt
184
177
  };
185
- console.log("\u2705 Token refreshed successfully");
186
178
  } catch (error) {
187
- console.error("\u274C Error refreshing token:", error);
188
179
  this.tokenInfo = void 0;
189
180
  await this.authenticate();
190
181
  }
@@ -236,11 +227,9 @@ var WebSocketManager = class {
236
227
  */
237
228
  async connect() {
238
229
  if (this.isConnected) {
239
- console.log("\u26A0\uFE0F WebSocket already connected");
240
230
  return;
241
231
  }
242
232
  if (this.isReconnecting) {
243
- console.log("\u26A0\uFE0F WebSocket reconnection in progress");
244
233
  return;
245
234
  }
246
235
  const token = await this.authManager.ensureAuthenticated();
@@ -251,13 +240,11 @@ var WebSocketManager = class {
251
240
  const WS = this.getWebSocketConstructor();
252
241
  this.ws = new WS(wsUrl);
253
242
  this.ws.onopen = () => {
254
- console.log("\u2705 WebSocket connected");
255
243
  this.isConnected = true;
256
244
  this.isReconnecting = false;
257
245
  this.reconnectAttempts = 0;
258
246
  this.emit("connected", { timestamp: Date.now() });
259
247
  if (this.subscribedChannels.length > 0) {
260
- console.log("\u{1F504} Resubscribing to channels:", this.subscribedChannels);
261
248
  this.subscribe(this.subscribedChannels);
262
249
  }
263
250
  this.startHeartbeat();
@@ -279,7 +266,6 @@ var WebSocketManager = class {
279
266
  }
280
267
  };
281
268
  this.ws.onclose = (event) => {
282
- console.log("WebSocket disconnected", event.code, event.reason);
283
269
  this.isConnected = false;
284
270
  this.stopHeartbeat();
285
271
  this.emit("disconnected", {
@@ -309,14 +295,12 @@ var WebSocketManager = class {
309
295
  channels
310
296
  };
311
297
  this.sendAction(message);
312
- console.log("\u{1F4E1} Subscribed to channels:", channels);
313
298
  }
314
299
  /**
315
300
  * Unsubscribes from WebSocket channels
316
301
  */
317
302
  unsubscribe(channels) {
318
303
  if (!this.isConnected) {
319
- console.warn("WebSocket not connected, cannot unsubscribe");
320
304
  return;
321
305
  }
322
306
  this.subscribedChannels = this.subscribedChannels.filter(
@@ -327,7 +311,6 @@ var WebSocketManager = class {
327
311
  channels
328
312
  };
329
313
  this.sendAction(message);
330
- console.log("\u{1F4E1} Unsubscribed from channels:", channels);
331
314
  }
332
315
  /**
333
316
  * Registers an event listener
@@ -352,7 +335,6 @@ var WebSocketManager = class {
352
335
  * Disconnects from WebSocket
353
336
  */
354
337
  disconnect() {
355
- console.log("\u{1F44B} Disconnecting WebSocket...");
356
338
  this.stopHeartbeat();
357
339
  if (this.ws) {
358
340
  this.ws.close();
@@ -410,7 +392,6 @@ var WebSocketManager = class {
410
392
  */
411
393
  sendAction(message) {
412
394
  if (!this.ws || !this.isConnected) {
413
- console.warn("\u26A0\uFE0F WebSocket not ready, message not sent:", message.action);
414
395
  return;
415
396
  }
416
397
  try {
@@ -454,7 +435,7 @@ var WebSocketManager = class {
454
435
  this.handleError(message);
455
436
  break;
456
437
  default:
457
- console.warn(message.op);
438
+ break;
458
439
  }
459
440
  this.emit("*", message);
460
441
  }
@@ -462,22 +443,18 @@ var WebSocketManager = class {
462
443
  * Handles connected message from server
463
444
  */
464
445
  handleConnected(message) {
465
- console.log("\u2705 WebSocket connected:", message.data.message);
466
- console.log(" Available channels:", message.data.available_channels);
467
446
  this.emit("connected", message.data);
468
447
  }
469
448
  /**
470
449
  * Handles subscription success
471
450
  */
472
451
  handleSubscriptionSuccess(message) {
473
- console.log("\u2705 Subscription successful:", message.data.subscribed);
474
452
  this.emit("subscription_success", message.data);
475
453
  }
476
454
  /**
477
455
  * Handles unsubscription success
478
456
  */
479
457
  handleUnsubscriptionSuccess(message) {
480
- console.log("\u2705 Unsubscription successful:", message.data.unsubscribed);
481
458
  this.emit("unsubscription_success", message.data);
482
459
  }
483
460
  /**
@@ -497,11 +474,27 @@ var WebSocketManager = class {
497
474
  case "position.updated":
498
475
  this.emit("position:updated", eventData);
499
476
  break;
477
+ case "account_metrics":
478
+ const balanceEvent = eventData;
479
+ if (message.topic?.startsWith("balance:")) {
480
+ const loginMatch = message.topic.match(/balance:api:(\d+)/);
481
+ if (loginMatch) {
482
+ balanceEvent.login = parseInt(loginMatch[1], 10);
483
+ }
484
+ }
485
+ this.emit("account:metrics", balanceEvent);
486
+ this.emit("balance:updated", balanceEvent);
487
+ break;
500
488
  default:
501
489
  if (message.topic?.startsWith("balance:")) {
502
- this.emit("balance:updated", eventData);
503
- } else {
504
- console.warn("Unknown event type:", eventType);
490
+ const event = eventData;
491
+ const loginMatch = message.topic.match(/balance:api:(\d+)/);
492
+ if (loginMatch) {
493
+ event.login = parseInt(loginMatch[1], 10);
494
+ }
495
+ this.emit("balance:updated", event);
496
+ } else if (message.topic?.startsWith("account_metrics")) {
497
+ this.emit("account:metrics", eventData);
505
498
  }
506
499
  }
507
500
  }
@@ -537,18 +530,13 @@ var WebSocketManager = class {
537
530
  const autoReconnect = this.config.websocket?.autoReconnect ?? true;
538
531
  const maxAttempts = this.config.websocket?.maxReconnectAttempts ?? 5;
539
532
  if (!autoReconnect) {
540
- console.log("Auto-reconnect disabled");
541
533
  return;
542
534
  }
543
535
  if (this.reconnectAttempts >= maxAttempts) {
544
- console.log(`\u274C Max reconnection attempts (${maxAttempts}) reached. Giving up.`);
545
536
  this.emit("error", new WebSocketError("Max reconnection attempts reached"));
546
537
  return;
547
538
  }
548
539
  const delay = Math.min(1e3 * Math.pow(2, this.reconnectAttempts), 3e4);
549
- console.log(
550
- `\u{1F504} Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts + 1}/${maxAttempts})...`
551
- );
552
540
  this.isReconnecting = true;
553
541
  setTimeout(() => {
554
542
  this.reconnectAttempts++;
@@ -707,7 +695,10 @@ var AccountsAPI = class {
707
695
  * List all accounts with optional filters and pagination
708
696
  */
709
697
  async list(params) {
710
- return this.http.get("/api/v1/accounts", params);
698
+ return this.http.get(
699
+ "/api/v1/accounts",
700
+ params
701
+ );
711
702
  }
712
703
  /**
713
704
  * Get all account logins
@@ -719,25 +710,24 @@ var AccountsAPI = class {
719
710
  * Get account status/metrics (balance, equity, credit, margin)
720
711
  */
721
712
  async getStatus(login) {
722
- return this.http.get(`/api/v1/accounts/${login}/status`);
713
+ return this.http.get(
714
+ `/api/v1/accounts/${login}/status`
715
+ );
723
716
  }
724
717
  /**
725
718
  * Get account statistics with optional filters
726
719
  */
727
720
  async getStatistics(params) {
728
- return this.http.get("/api/v1/accounts/statistics", params);
729
- }
730
- /**
731
- * Change master password for an account
732
- */
733
- async changeMasterPassword(login, request) {
734
- return this.http.put(`/api/v1/accounts/${login}/password/master`, request);
721
+ return this.http.get(
722
+ "/api/v1/accounts/statistics",
723
+ params
724
+ );
735
725
  }
736
726
  /**
737
- * Change investor password for an account
727
+ * Change account passwords (master and/or investor)
738
728
  */
739
- async changeInvestorPassword(login, request) {
740
- return this.http.put(`/api/v1/accounts/${login}/password/investor`, request);
729
+ async changePassword(login, request) {
730
+ return this.http.put(`/api/v1/accounts/${login}/password`, request);
741
731
  }
742
732
  /**
743
733
  * Archive an account
@@ -756,14 +746,20 @@ var AccountsAPI = class {
756
746
  * All fields are optional, only send the ones you want to update
757
747
  */
758
748
  async update(login, request) {
759
- return this.http.put(`/api/v1/accounts/${login}`, request);
749
+ return this.http.put(
750
+ `/api/v1/accounts/${login}`,
751
+ request
752
+ );
760
753
  }
761
754
  /**
762
755
  * Adjust balance or credit for an account
763
756
  * The adjustment is relative: amount is added or subtracted from current value
764
757
  */
765
758
  async balance(login, request) {
766
- return this.http.put(`/api/v1/accounts/${login}/adjust`, request);
759
+ return this.http.put(
760
+ `/api/v1/accounts/${login}/adjust`,
761
+ request
762
+ );
767
763
  }
768
764
  /**
769
765
  * Get account permissions
@@ -1143,6 +1139,15 @@ var PipsendClient = class {
1143
1139
  }
1144
1140
  this.wsManager.on("balance:updated", callback);
1145
1141
  },
1142
+ /**
1143
+ * Listens to account metrics events (replaces balance updates)
1144
+ */
1145
+ onAccountMetrics: (callback) => {
1146
+ if (!this.wsManager) {
1147
+ throw new WebSocketError("WebSocket not enabled");
1148
+ }
1149
+ this.wsManager.on("account:metrics", callback);
1150
+ },
1146
1151
  // Legacy methods (deprecated but kept for compatibility)
1147
1152
  /**
1148
1153
  * @deprecated Use onPositionUpdated instead
@@ -1211,6 +1216,15 @@ var PipsendClient = class {
1211
1216
  }
1212
1217
  this.wsManager.on("error", callback);
1213
1218
  },
1219
+ /**
1220
+ * Registers a custom event listener
1221
+ */
1222
+ on: (event, callback) => {
1223
+ if (!this.wsManager) {
1224
+ throw new WebSocketError("WebSocket not enabled");
1225
+ }
1226
+ this.wsManager.on(event, callback);
1227
+ },
1214
1228
  /**
1215
1229
  * Removes event listener
1216
1230
  */