@pipsend/sdk 0.1.0

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.
@@ -0,0 +1,1194 @@
1
+ /**
2
+ * WebSocket configuration options
3
+ */
4
+ interface WebSocketConfig {
5
+ /** Enable WebSocket connection (default: false) */
6
+ enabled?: boolean;
7
+ /** WebSocket endpoint path (default: '/ws') */
8
+ path?: string;
9
+ /** Auto-connect on client creation (default: false) */
10
+ autoConnect?: boolean;
11
+ /** Auto-reconnect on disconnect (default: true) */
12
+ autoReconnect?: boolean;
13
+ /** Maximum reconnection attempts (default: 5) */
14
+ maxReconnectAttempts?: number;
15
+ /** Heartbeat interval in milliseconds (default: 30000) */
16
+ heartbeatInterval?: number;
17
+ }
18
+ /**
19
+ * WebSocket message structure
20
+ */
21
+ interface WebSocketMessage {
22
+ type: string;
23
+ payload?: any;
24
+ timestamp?: number;
25
+ }
26
+ /**
27
+ * Real-time price update
28
+ */
29
+ interface PriceUpdate {
30
+ symbol: string;
31
+ bid: number;
32
+ ask: number;
33
+ spread: number;
34
+ timestamp: number;
35
+ }
36
+ /**
37
+ * Real-time order update
38
+ */
39
+ interface OrderUpdate {
40
+ orderId: string;
41
+ symbol: string;
42
+ status: 'pending' | 'filled' | 'partial' | 'cancelled' | 'rejected';
43
+ type: 'buy' | 'sell';
44
+ volume: number;
45
+ filledVolume: number;
46
+ price?: number;
47
+ openTime: number;
48
+ closeTime?: number;
49
+ timestamp: number;
50
+ }
51
+ /**
52
+ * Real-time position update
53
+ */
54
+ interface PositionUpdate {
55
+ positionId: string;
56
+ symbol: string;
57
+ type: 'buy' | 'sell';
58
+ volume: number;
59
+ openPrice: number;
60
+ currentPrice: number;
61
+ profit: number;
62
+ profitPercentage: number;
63
+ timestamp: number;
64
+ }
65
+ /**
66
+ * Account balance update
67
+ */
68
+ interface BalanceUpdate {
69
+ balance: number;
70
+ equity: number;
71
+ margin: number;
72
+ freeMargin: number;
73
+ marginLevel: number;
74
+ timestamp: number;
75
+ }
76
+ /**
77
+ * WebSocket event types
78
+ */
79
+ type WebSocketEventType = 'price' | 'order' | 'position' | 'balance' | 'connected' | 'disconnected' | 'error' | 'authenticated' | '*';
80
+ /**
81
+ * WebSocket event callback
82
+ */
83
+ type WebSocketCallback<T = any> = (data: T) => void;
84
+
85
+ /**
86
+ * Common types used across the API
87
+ */
88
+ interface PaginationParams {
89
+ page?: number;
90
+ per_page?: number;
91
+ }
92
+ interface PaginatedResponse<T> {
93
+ data: T[];
94
+ meta: {
95
+ current_page: number;
96
+ per_page: number;
97
+ total: number;
98
+ total_pages: number;
99
+ };
100
+ }
101
+
102
+ /**
103
+ * Account types
104
+ */
105
+ interface Account {
106
+ login: number;
107
+ email: string;
108
+ first_name: string;
109
+ last_name: string;
110
+ middle_name?: string;
111
+ company?: string;
112
+ state: 'active' | 'inactive' | 'archived';
113
+ balance: number;
114
+ credit: number;
115
+ leverage: number;
116
+ phone?: string;
117
+ city?: string;
118
+ address?: string;
119
+ zip_code?: string;
120
+ country: string;
121
+ trading_group: string;
122
+ created_at: string;
123
+ updated_at: string;
124
+ }
125
+ interface AccountsListParams extends PaginationParams {
126
+ /** Single login or comma-separated logins */
127
+ login?: string | number;
128
+ /** Single state or comma-separated states (active, inactive, archived) */
129
+ state?: string;
130
+ /** Single country or comma-separated countries */
131
+ country?: string;
132
+ /** Trading group name */
133
+ trading_group?: string;
134
+ /** Email or partial email search */
135
+ email?: string;
136
+ /** Search in login, first_name, last_name, email */
137
+ search?: string;
138
+ /** Minimum balance */
139
+ min_balance?: number;
140
+ /** Maximum balance */
141
+ max_balance?: number;
142
+ /** Minimum credit */
143
+ min_credit?: number;
144
+ /** Maximum credit */
145
+ max_credit?: number;
146
+ }
147
+ interface AccountStatistics {
148
+ total_accounts: number;
149
+ active_accounts: number;
150
+ inactive_accounts: number;
151
+ archived_accounts?: number;
152
+ total_balance: number;
153
+ total_credit: number;
154
+ average_balance: number;
155
+ by_country?: Array<{
156
+ country: string;
157
+ count: number;
158
+ total_balance: number;
159
+ }>;
160
+ by_trading_group?: Array<{
161
+ trading_group: string;
162
+ count: number;
163
+ total_balance: number;
164
+ }>;
165
+ }
166
+ interface AccountStatisticsParams {
167
+ /** Filter by country */
168
+ country?: string;
169
+ /** Filter by state */
170
+ state?: string;
171
+ /** Filter by trading group */
172
+ trading_group?: string;
173
+ }
174
+ interface ChangePasswordRequest {
175
+ new_password: string;
176
+ }
177
+
178
+ /**
179
+ * Trading Group types
180
+ */
181
+ interface TradingGroup {
182
+ name: string;
183
+ company: string;
184
+ type: string;
185
+ is_demo: boolean;
186
+ currency: string;
187
+ leverage: number;
188
+ margin_call: number;
189
+ stop_out: number;
190
+ created_at: string;
191
+ updated_at: string;
192
+ }
193
+ interface TradingGroupsListParams {
194
+ type?: string;
195
+ is_demo?: boolean;
196
+ search?: string;
197
+ }
198
+ interface TradingGroupStatistics {
199
+ total_groups: number;
200
+ demo_groups: number;
201
+ real_groups: number;
202
+ by_type: Record<string, number>;
203
+ }
204
+
205
+ /**
206
+ * Market data types
207
+ */
208
+ interface Candle {
209
+ symbol: string;
210
+ timeframe: string;
211
+ timestamp: string;
212
+ open: number;
213
+ high: number;
214
+ low: number;
215
+ close: number;
216
+ volume: number;
217
+ }
218
+ interface CandlesParams extends PaginationParams {
219
+ /** Symbol names (comma-separated) - REQUIRED */
220
+ symbol: string;
221
+ /** Timeframes: 1m, 5m, 15m, 1h, 4h, 1d (comma-separated) - REQUIRED */
222
+ timeframe: string;
223
+ /** Start date (ISO 8601) */
224
+ from?: string;
225
+ /** End date (ISO 8601, max: now - 1h) */
226
+ to?: string;
227
+ /** Minimum volume */
228
+ min_volume?: number;
229
+ /** Maximum volume */
230
+ max_volume?: number;
231
+ /** Minimum price (close) */
232
+ min_price?: number;
233
+ /** Maximum price (close) */
234
+ max_price?: number;
235
+ /** Sort field: timestamp, volume, close (default: timestamp) */
236
+ sort?: string;
237
+ /** Sort order: asc, desc (default: desc) */
238
+ order?: 'asc' | 'desc';
239
+ /** Limit results (max: 10000, ignores pagination) */
240
+ limit?: number;
241
+ }
242
+ interface Symbol {
243
+ name: string;
244
+ display_name: string;
245
+ description: string;
246
+ group_path: string;
247
+ type: string;
248
+ is_active: boolean;
249
+ has_data: boolean;
250
+ timeframes: string[];
251
+ first_candle?: string;
252
+ last_candle?: string;
253
+ }
254
+ interface SymbolsParams extends PaginationParams {
255
+ /** Symbol names (comma-separated) */
256
+ name?: string;
257
+ /** Group codes (comma-separated) */
258
+ group?: string;
259
+ /** Symbol types (comma-separated) */
260
+ type?: string;
261
+ /** General search (name, code, description) */
262
+ search?: string;
263
+ /** Filter by active state (default: true) */
264
+ is_active?: boolean;
265
+ /** Filter symbols with available data */
266
+ has_data?: boolean;
267
+ /** Sort field: name, group_path, type, created_at (default: name) */
268
+ sort?: string;
269
+ /** Sort order: asc, desc (default: asc) */
270
+ order?: 'asc' | 'desc';
271
+ }
272
+ interface Group {
273
+ code: string;
274
+ name: string;
275
+ path: string;
276
+ level: number;
277
+ is_active: boolean;
278
+ order: number;
279
+ symbol_count: number;
280
+ }
281
+ interface GroupsParams {
282
+ /** Group codes (comma-separated) */
283
+ code?: string;
284
+ /** Full paths (exact or partial, comma-separated) */
285
+ path?: string;
286
+ /** General search (code, name) */
287
+ search?: string;
288
+ /** Filter by active state */
289
+ is_active?: boolean;
290
+ /** Filter by hierarchy level (0 = root) */
291
+ level?: number;
292
+ /** Only root groups (level 0) */
293
+ root_only?: boolean;
294
+ /** Sort field: path, code, order, symbol_count (default: path) */
295
+ sort?: string;
296
+ /** Sort order: asc, desc (default: asc) */
297
+ order?: 'asc' | 'desc';
298
+ }
299
+
300
+ /**
301
+ * Position types
302
+ */
303
+ interface Position {
304
+ id: number;
305
+ login: number;
306
+ symbol: string;
307
+ type: 'buy' | 'sell';
308
+ volume: number;
309
+ entry_price: number;
310
+ current_price: number;
311
+ profit: number;
312
+ commission: number;
313
+ swap: number;
314
+ net_profit: number;
315
+ stop_loss?: number;
316
+ take_profit?: number;
317
+ opened_at: string;
318
+ updated_at: string;
319
+ state: 'open' | 'closed';
320
+ }
321
+ interface PositionsListParams extends PaginationParams {
322
+ /** Position IDs (comma-separated) */
323
+ id?: string;
324
+ /** Account logins (comma-separated) */
325
+ login?: string;
326
+ /** Symbols (comma-separated, e.g., "EURUSD,GBPUSD") */
327
+ symbol?: string;
328
+ /** Position types: "buy", "sell" (comma-separated) */
329
+ type?: string;
330
+ /** Position states: "open", "closed" (comma-separated) */
331
+ state?: string;
332
+ /** Opened from date (RFC3339) */
333
+ opened_from?: string;
334
+ /** Opened to date (RFC3339) */
335
+ opened_to?: string;
336
+ /** Updated from date (RFC3339) */
337
+ updated_from?: string;
338
+ /** Updated to date (RFC3339) */
339
+ updated_to?: string;
340
+ /** Minimum profit */
341
+ profit_min?: number;
342
+ /** Maximum profit */
343
+ profit_max?: number;
344
+ /** Minimum volume */
345
+ volume_min?: number;
346
+ /** Maximum volume */
347
+ volume_max?: number;
348
+ /** Include deleted positions (default: false) */
349
+ include_deleted?: boolean;
350
+ /** Sort by field (default: "id") */
351
+ sort_by?: string;
352
+ /** Sort order: "asc", "desc" (default: "desc") */
353
+ sort_order?: 'asc' | 'desc';
354
+ }
355
+ interface PositionStatsParams {
356
+ /** Account logins (comma-separated) */
357
+ login?: string;
358
+ /** Symbols (comma-separated) */
359
+ symbol?: string;
360
+ /** Position types: "buy", "sell" (comma-separated) */
361
+ type?: string;
362
+ /** Position states: "open", "closed" (comma-separated) */
363
+ state?: string;
364
+ /** Opened from date (RFC3339) */
365
+ opened_from?: string;
366
+ /** Opened to date (RFC3339) */
367
+ opened_to?: string;
368
+ /** Group by: "login", "symbol", "type", "state" */
369
+ group_by?: string;
370
+ }
371
+ interface PositionStatistics {
372
+ total_positions: number;
373
+ total_volume: number;
374
+ total_profit: number;
375
+ total_commission: number;
376
+ total_swap: number;
377
+ avg_profit: number;
378
+ max_profit: number;
379
+ min_profit: number;
380
+ }
381
+ interface PositionStatisticsGrouped {
382
+ group_key: string;
383
+ total_positions: number;
384
+ total_volume: number;
385
+ total_profit: number;
386
+ avg_profit: number;
387
+ }
388
+ interface PositionTotalsParams {
389
+ /** Account logins (comma-separated) */
390
+ login?: string;
391
+ /** Symbols (comma-separated) */
392
+ symbol?: string;
393
+ /** Position types: "buy", "sell" (comma-separated) */
394
+ type?: string;
395
+ /** Position states: "open", "closed" (comma-separated) */
396
+ state?: string;
397
+ /** Group by (required): "login", "symbol", "type", "state" */
398
+ group_by: string;
399
+ }
400
+ interface PositionTotals {
401
+ group_key: string;
402
+ count: number;
403
+ total_volume: number;
404
+ total_profit: number;
405
+ total_commission: number;
406
+ total_swap: number;
407
+ avg_profit: number;
408
+ avg_volume: number;
409
+ }
410
+ interface UpdatePositionRequest {
411
+ login: number;
412
+ stop_loss?: number;
413
+ take_profit?: number;
414
+ }
415
+ interface UpdatePositionResponse {
416
+ id: number;
417
+ login: number;
418
+ symbol: string;
419
+ stop_loss?: number;
420
+ take_profit?: number;
421
+ updated_at: string;
422
+ message: string;
423
+ }
424
+ interface DeletePositionParams {
425
+ login: number;
426
+ }
427
+ interface CheckPositionsRequest {
428
+ ids?: number[];
429
+ filters?: {
430
+ logins?: number[];
431
+ symbols?: string[];
432
+ states?: string[];
433
+ };
434
+ }
435
+ interface CheckPositionsResponse {
436
+ total_checked: number;
437
+ total_updated: number;
438
+ positions: Array<{
439
+ id: number;
440
+ updated: boolean;
441
+ message: string;
442
+ changes?: {
443
+ profit?: {
444
+ old: number;
445
+ new: number;
446
+ };
447
+ swap?: {
448
+ old: number;
449
+ new: number;
450
+ };
451
+ };
452
+ }>;
453
+ }
454
+
455
+ /**
456
+ * Order types
457
+ */
458
+ interface Order {
459
+ id: number;
460
+ login: number;
461
+ symbol: string;
462
+ type: 'buy' | 'sell';
463
+ order_type: 'market' | 'limit' | 'stop' | 'stop_limit';
464
+ status: 'new' | 'partial' | 'filled' | 'cancelled' | 'rejected' | 'expired';
465
+ volume: number;
466
+ filled_volume: number;
467
+ price: number;
468
+ stop_price?: number;
469
+ stop_loss?: number;
470
+ take_profit?: number;
471
+ created_at: string;
472
+ updated_at: string;
473
+ comment?: string;
474
+ }
475
+ interface OrdersListParams extends PaginationParams {
476
+ /** Order IDs (comma-separated) */
477
+ id?: string;
478
+ /** Account logins (comma-separated) */
479
+ login?: string;
480
+ /** Symbols (comma-separated, e.g., "EURUSD,GBPUSD") */
481
+ symbol?: string;
482
+ /** Order types: "buy", "sell" (comma-separated) */
483
+ type?: string;
484
+ /** Order types: "market", "limit", "stop", "stop_limit" */
485
+ order_type?: string;
486
+ /** Order statuses (comma-separated) */
487
+ status?: string;
488
+ /** Created from date (RFC3339) */
489
+ created_from?: string;
490
+ /** Created to date (RFC3339) */
491
+ created_to?: string;
492
+ /** Updated from date (RFC3339) */
493
+ updated_from?: string;
494
+ /** Updated to date (RFC3339) */
495
+ updated_to?: string;
496
+ /** Minimum price */
497
+ price_min?: number;
498
+ /** Maximum price */
499
+ price_max?: number;
500
+ /** Minimum volume */
501
+ volume_min?: number;
502
+ /** Maximum volume */
503
+ volume_max?: number;
504
+ /** Include deleted orders (default: false) */
505
+ include_deleted?: boolean;
506
+ /** Sort by field (default: "id") */
507
+ sort_by?: string;
508
+ /** Sort order: "asc", "desc" (default: "desc") */
509
+ sort_order?: 'asc' | 'desc';
510
+ }
511
+ interface OrderStatsParams {
512
+ /** Account logins (comma-separated) */
513
+ login?: string;
514
+ /** Symbols (comma-separated) */
515
+ symbol?: string;
516
+ /** Order types: "buy", "sell" (comma-separated) */
517
+ type?: string;
518
+ /** Order types: "market", "limit", "stop" */
519
+ order_type?: string;
520
+ /** Order statuses (comma-separated) */
521
+ status?: string;
522
+ /** Created from date (RFC3339) */
523
+ created_from?: string;
524
+ /** Created to date (RFC3339) */
525
+ created_to?: string;
526
+ /** Group by: "login", "symbol", "type", "order_type", "status" */
527
+ group_by?: string;
528
+ }
529
+ interface OrderStatistics {
530
+ total_orders: number;
531
+ total_volume: number;
532
+ total_filled_volume: number;
533
+ avg_volume: number;
534
+ avg_price: number;
535
+ max_volume: number;
536
+ min_volume: number;
537
+ }
538
+ interface OrderStatisticsGrouped {
539
+ group_key: string;
540
+ total_orders: number;
541
+ total_volume: number;
542
+ avg_volume: number;
543
+ }
544
+ interface OrderTotalsParams {
545
+ /** Account logins (comma-separated) */
546
+ login?: string;
547
+ /** Symbols (comma-separated) */
548
+ symbol?: string;
549
+ /** Order types: "buy", "sell" (comma-separated) */
550
+ type?: string;
551
+ /** Order types: "market", "limit", "stop" */
552
+ order_type?: string;
553
+ /** Order statuses (comma-separated) */
554
+ status?: string;
555
+ /** Group by (required): "login", "symbol", "type", "order_type", "status" */
556
+ group_by: string;
557
+ }
558
+ interface OrderTotals {
559
+ group_key: string;
560
+ count: number;
561
+ total_volume: number;
562
+ total_filled_volume: number;
563
+ avg_volume: number;
564
+ avg_price: number;
565
+ }
566
+ interface UpdateOrderRequest {
567
+ login: number;
568
+ stop_loss?: number;
569
+ take_profit?: number;
570
+ }
571
+ interface UpdateOrderResponse {
572
+ id: number;
573
+ login: number;
574
+ symbol: string;
575
+ stop_loss?: number;
576
+ take_profit?: number;
577
+ updated_at: string;
578
+ message: string;
579
+ }
580
+ interface DeleteOrderParams {
581
+ login: number;
582
+ }
583
+ interface CheckOrdersRequest {
584
+ ids?: number[];
585
+ filters?: {
586
+ logins?: number[];
587
+ symbols?: string[];
588
+ statuses?: string[];
589
+ };
590
+ }
591
+ interface CheckOrdersResponse {
592
+ total_checked: number;
593
+ total_updated: number;
594
+ orders: Array<{
595
+ id: number;
596
+ updated: boolean;
597
+ message: string;
598
+ changes?: {
599
+ status?: {
600
+ old: string;
601
+ new: string;
602
+ };
603
+ };
604
+ }>;
605
+ }
606
+
607
+ /**
608
+ * Trade operation types
609
+ */
610
+ interface OpenTradeRequest {
611
+ login: number;
612
+ symbol: string;
613
+ action: 'buy' | 'sell';
614
+ type: 'market' | 'limit' | 'stop' | 'stop_limit';
615
+ volume: number;
616
+ price?: number;
617
+ stop_price?: number;
618
+ stop_loss?: number;
619
+ take_profit?: number;
620
+ force_price?: boolean;
621
+ force_timestamp?: string;
622
+ comment?: string;
623
+ magic?: number;
624
+ }
625
+ interface OpenTradeResponse {
626
+ order_id: number;
627
+ position_id: number;
628
+ status: string;
629
+ filled_volume: number;
630
+ fill_price: number;
631
+ message: string;
632
+ symbol: string;
633
+ action: string;
634
+ volume: number;
635
+ stop_loss?: number;
636
+ take_profit?: number;
637
+ created_at: string;
638
+ was_forced: boolean;
639
+ }
640
+ interface CloseTradeRequest {
641
+ login: number;
642
+ position_id: number;
643
+ volume?: number;
644
+ price?: number;
645
+ force_price?: boolean;
646
+ force_timestamp?: string;
647
+ comment?: string;
648
+ }
649
+ interface CloseTradeResponse {
650
+ position_id: number;
651
+ closed_volume: number;
652
+ remaining_volume: number;
653
+ close_price: number;
654
+ realized_pnl: number;
655
+ commission: number;
656
+ swap: number;
657
+ net_pnl: number;
658
+ message: string;
659
+ symbol: string;
660
+ was_fully_closed: boolean;
661
+ closed_at: string;
662
+ was_forced: boolean;
663
+ }
664
+ interface ModifyTradeRequest {
665
+ login: number;
666
+ position_id: number;
667
+ stop_loss?: number;
668
+ take_profit?: number;
669
+ comment?: string;
670
+ }
671
+ interface ModifyTradeResponse {
672
+ position_id: number;
673
+ stop_loss?: number;
674
+ take_profit?: number;
675
+ message: string;
676
+ symbol: string;
677
+ updated_at: string;
678
+ }
679
+ interface CheckMarginRequest {
680
+ login: number;
681
+ symbol: string;
682
+ action: 'buy' | 'sell';
683
+ volume: number;
684
+ price?: number;
685
+ }
686
+ interface CheckMarginResponse {
687
+ margin_required: number;
688
+ margin_available: number;
689
+ margin_free: number;
690
+ can_execute: boolean;
691
+ leverage: number;
692
+ symbol: string;
693
+ volume: number;
694
+ price: number;
695
+ account_currency: string;
696
+ reason?: string;
697
+ }
698
+ interface CalculateProfitRequest {
699
+ login: number;
700
+ symbol: string;
701
+ action: 'buy' | 'sell';
702
+ volume: number;
703
+ open_price: number;
704
+ close_price: number;
705
+ }
706
+ interface CalculateProfitResponse {
707
+ profit: number;
708
+ profit_currency: string;
709
+ profit_pips: number;
710
+ profit_percent: number;
711
+ symbol: string;
712
+ action: string;
713
+ volume: number;
714
+ open_price: number;
715
+ close_price: number;
716
+ contract_size: number;
717
+ point_value: number;
718
+ }
719
+
720
+ /**
721
+ * Health check types
722
+ */
723
+ interface HealthCheckResponse {
724
+ status: 'ok' | 'error';
725
+ timestamp: string;
726
+ version?: string;
727
+ }
728
+
729
+ /**
730
+ * Required configuration to initialize the Pipsend client
731
+ */
732
+ interface PipsendConfig {
733
+ /** Pipsend server URL (required) */
734
+ server: string;
735
+ /** User credentials for SDK authentication (optional, for future use) */
736
+ login?: string;
737
+ /** User password for SDK authentication (optional, for future use) */
738
+ password?: string;
739
+ /** Timezone for operations (optional, default: UTC) */
740
+ timezone?: string;
741
+ /** Enable auto-refresh of tokens (default: true) */
742
+ autoRefresh?: boolean;
743
+ /** Safety margin for refresh in minutes (default: 5) */
744
+ refreshMarginMinutes?: number;
745
+ /** WebSocket configuration (optional) */
746
+ websocket?: WebSocketConfig;
747
+ }
748
+ /**
749
+ * Authentication token information
750
+ */
751
+ interface TokenInfo {
752
+ token: string;
753
+ expiresAt: Date;
754
+ issuedAt: Date;
755
+ }
756
+ /**
757
+ * Trading order data
758
+ */
759
+ interface OrderData {
760
+ symbol: string;
761
+ volume: number;
762
+ type?: 'buy' | 'sell';
763
+ price?: number;
764
+ stopLoss?: number;
765
+ takeProfit?: number;
766
+ }
767
+ /**
768
+ * Server authentication response
769
+ * TODO: Adjust according to real API response
770
+ */
771
+ interface AuthResponse {
772
+ token: string;
773
+ expiresIn: number;
774
+ }
775
+ /**
776
+ * Custom SDK errors
777
+ */
778
+ declare class PipsendError extends Error {
779
+ code?: string | undefined;
780
+ statusCode?: number | undefined;
781
+ constructor(message: string, code?: string | undefined, statusCode?: number | undefined);
782
+ }
783
+ declare class AuthenticationError extends PipsendError {
784
+ constructor(message: string);
785
+ }
786
+ declare class ConfigurationError extends PipsendError {
787
+ constructor(message: string);
788
+ }
789
+ declare class WebSocketError extends PipsendError {
790
+ constructor(message: string);
791
+ }
792
+
793
+ /**
794
+ * HTTP client for making requests to the Pipsend API
795
+ */
796
+ declare class HttpClient {
797
+ private baseUrl;
798
+ constructor(baseUrl: string);
799
+ /**
800
+ * Makes an HTTP request
801
+ */
802
+ request<T>(endpoint: string, options?: RequestInit): Promise<T>;
803
+ /**
804
+ * GET request
805
+ */
806
+ get<T>(endpoint: string, params?: Record<string, any>): Promise<T>;
807
+ /**
808
+ * POST request
809
+ */
810
+ post<T>(endpoint: string, body?: any): Promise<T>;
811
+ /**
812
+ * PUT request
813
+ */
814
+ put<T>(endpoint: string, body?: any): Promise<T>;
815
+ /**
816
+ * DELETE request
817
+ */
818
+ delete<T>(endpoint: string): Promise<T>;
819
+ /**
820
+ * Builds query string from params object
821
+ */
822
+ private buildQueryString;
823
+ }
824
+
825
+ /**
826
+ * Accounts API
827
+ */
828
+ declare class AccountsAPI {
829
+ private http;
830
+ constructor(http: HttpClient);
831
+ /**
832
+ * List all accounts with optional filters and pagination
833
+ */
834
+ list(params?: AccountsListParams): Promise<PaginatedResponse<Account> | Account[]>;
835
+ /**
836
+ * Get all account logins
837
+ */
838
+ getLogins(): Promise<number[]>;
839
+ /**
840
+ * Get account statistics with optional filters
841
+ */
842
+ getStatistics(params?: AccountStatisticsParams): Promise<AccountStatistics>;
843
+ /**
844
+ * Change master password for an account
845
+ */
846
+ changeMasterPassword(login: number, request: ChangePasswordRequest): Promise<void>;
847
+ /**
848
+ * Change investor password for an account
849
+ */
850
+ changeInvestorPassword(login: number, request: ChangePasswordRequest): Promise<void>;
851
+ /**
852
+ * Archive an account
853
+ */
854
+ archive(login: number): Promise<void>;
855
+ /**
856
+ * Unarchive an account
857
+ */
858
+ unarchive(login: number): Promise<void>;
859
+ }
860
+
861
+ /**
862
+ * Trading Groups API
863
+ */
864
+ declare class TradingGroupsAPI {
865
+ private http;
866
+ constructor(http: HttpClient);
867
+ /**
868
+ * List all trading groups with optional filters
869
+ */
870
+ list(params?: TradingGroupsListParams): Promise<TradingGroup[]>;
871
+ /**
872
+ * Get trading group by name
873
+ */
874
+ getByName(name: string): Promise<TradingGroup>;
875
+ /**
876
+ * Get all trading group names
877
+ */
878
+ getNames(): Promise<string[]>;
879
+ /**
880
+ * Get trading group statistics
881
+ */
882
+ getStatistics(type?: string): Promise<TradingGroupStatistics>;
883
+ }
884
+
885
+ /**
886
+ * Market Data API
887
+ *
888
+ * Note: All data has a minimum age of 1 hour (no real-time data)
889
+ */
890
+ declare class MarketDataAPI {
891
+ private http;
892
+ constructor(http: HttpClient);
893
+ /**
894
+ * Get historical OHLCV candles
895
+ *
896
+ * @param params - Candles parameters (symbol and timeframe are required)
897
+ * @returns Paginated candles or array of candles
898
+ *
899
+ * @example
900
+ * ```ts
901
+ * // Get last 100 candles
902
+ * const candles = await client.marketData.getCandles({
903
+ * symbol: 'BTCUSD',
904
+ * timeframe: '1m',
905
+ * limit: 100,
906
+ * order: 'desc'
907
+ * });
908
+ *
909
+ * // Get candles with time range
910
+ * const candles = await client.marketData.getCandles({
911
+ * symbol: 'BTCUSD,ETHUSD',
912
+ * timeframe: '1h',
913
+ * from: '2025-11-01T00:00:00Z',
914
+ * to: '2025-11-02T00:00:00Z'
915
+ * });
916
+ * ```
917
+ */
918
+ getCandles(params: CandlesParams): Promise<PaginatedResponse<Candle> | Candle[]>;
919
+ /**
920
+ * Get available symbols with metadata
921
+ *
922
+ * @param params - Optional filters for symbols
923
+ * @returns Paginated symbols or array of symbols
924
+ *
925
+ * @example
926
+ * ```ts
927
+ * // Get all symbols
928
+ * const symbols = await client.marketData.getSymbols();
929
+ *
930
+ * // Filter by group
931
+ * const cryptoSymbols = await client.marketData.getSymbols({
932
+ * group: 'CRYPTO_MAJOR',
933
+ * has_data: true
934
+ * });
935
+ * ```
936
+ */
937
+ getSymbols(params?: SymbolsParams): Promise<PaginatedResponse<Symbol> | Symbol[]>;
938
+ /**
939
+ * Get symbol groups hierarchy
940
+ *
941
+ * Note: This endpoint never uses pagination
942
+ *
943
+ * @param params - Optional filters for groups
944
+ * @returns Array of groups
945
+ *
946
+ * @example
947
+ * ```ts
948
+ * // Get all groups
949
+ * const groups = await client.marketData.getGroups();
950
+ *
951
+ * // Get only root groups
952
+ * const rootGroups = await client.marketData.getGroups({
953
+ * root_only: true
954
+ * });
955
+ * ```
956
+ */
957
+ getGroups(params?: GroupsParams): Promise<Group[]>;
958
+ }
959
+
960
+ /**
961
+ * Positions API
962
+ */
963
+ declare class PositionsAPI {
964
+ private http;
965
+ constructor(http: HttpClient);
966
+ /**
967
+ * List positions with optional filters and pagination
968
+ */
969
+ list(params?: PositionsListParams): Promise<PaginatedResponse<Position> | Position[]>;
970
+ /**
971
+ * Get position statistics with optional filters and grouping
972
+ */
973
+ getStats(params?: PositionStatsParams): Promise<PositionStatistics | PositionStatisticsGrouped[]>;
974
+ /**
975
+ * Get position totals with dynamic grouping
976
+ */
977
+ getTotals(params: PositionTotalsParams): Promise<PositionTotals[]>;
978
+ /**
979
+ * Update position (modify SL/TP)
980
+ */
981
+ update(id: number, request: UpdatePositionRequest): Promise<UpdatePositionResponse>;
982
+ /**
983
+ * Delete (close) position
984
+ */
985
+ delete(id: number, params: DeletePositionParams): Promise<void>;
986
+ /**
987
+ * Check and recalculate positions
988
+ */
989
+ check(request: CheckPositionsRequest): Promise<CheckPositionsResponse>;
990
+ }
991
+
992
+ /**
993
+ * Orders API
994
+ */
995
+ declare class OrdersAPI {
996
+ private http;
997
+ constructor(http: HttpClient);
998
+ /**
999
+ * List orders with optional filters and pagination
1000
+ */
1001
+ list(params?: OrdersListParams): Promise<PaginatedResponse<Order> | Order[]>;
1002
+ /**
1003
+ * Get order statistics with optional filters and grouping
1004
+ */
1005
+ getStats(params?: OrderStatsParams): Promise<OrderStatistics | OrderStatisticsGrouped[]>;
1006
+ /**
1007
+ * Get order totals with dynamic grouping
1008
+ */
1009
+ getTotals(params: OrderTotalsParams): Promise<OrderTotals[]>;
1010
+ /**
1011
+ * Update order (modify SL/TP)
1012
+ */
1013
+ update(id: number, request: UpdateOrderRequest): Promise<UpdateOrderResponse>;
1014
+ /**
1015
+ * Delete (cancel) order
1016
+ */
1017
+ delete(id: number, params: DeleteOrderParams): Promise<void>;
1018
+ /**
1019
+ * Check and validate pending orders
1020
+ */
1021
+ check(request: CheckOrdersRequest): Promise<CheckOrdersResponse>;
1022
+ }
1023
+
1024
+ /**
1025
+ * Trades API
1026
+ */
1027
+ declare class TradesAPI {
1028
+ private http;
1029
+ constructor(http: HttpClient);
1030
+ /**
1031
+ * Open a new trade (market or pending order)
1032
+ */
1033
+ open(request: OpenTradeRequest): Promise<OpenTradeResponse>;
1034
+ /**
1035
+ * Close a trade (full or partial)
1036
+ */
1037
+ close(request: CloseTradeRequest): Promise<CloseTradeResponse>;
1038
+ /**
1039
+ * Modify trade Stop Loss and/or Take Profit
1040
+ */
1041
+ modify(request: ModifyTradeRequest): Promise<ModifyTradeResponse>;
1042
+ /**
1043
+ * Check if there's sufficient margin for a trade
1044
+ */
1045
+ checkMargin(request: CheckMarginRequest): Promise<CheckMarginResponse>;
1046
+ /**
1047
+ * Calculate potential profit for a trade
1048
+ */
1049
+ calculateProfit(request: CalculateProfitRequest): Promise<CalculateProfitResponse>;
1050
+ }
1051
+
1052
+ /**
1053
+ * Main Pipsend SDK client
1054
+ */
1055
+ declare class PipsendClient {
1056
+ private authManager;
1057
+ private wsManager?;
1058
+ private config;
1059
+ private http;
1060
+ readonly accounts: AccountsAPI;
1061
+ readonly tradingGroups: TradingGroupsAPI;
1062
+ readonly marketData: MarketDataAPI;
1063
+ readonly positions: PositionsAPI;
1064
+ readonly orders: OrdersAPI;
1065
+ readonly trades: TradesAPI;
1066
+ constructor(config: PipsendConfig);
1067
+ /**
1068
+ * Validates the initial configuration
1069
+ */
1070
+ private validateConfig;
1071
+ /**
1072
+ * Authentication API
1073
+ * TODO: Implement when authentication is available
1074
+ */
1075
+ auth: {
1076
+ /**
1077
+ * Forces a token refresh
1078
+ */
1079
+ refresh: () => Promise<void>;
1080
+ /**
1081
+ * Checks if the client is authenticated
1082
+ */
1083
+ isAuthenticated: () => boolean;
1084
+ /**
1085
+ * Gets the current token (if it exists)
1086
+ */
1087
+ getToken: () => string | undefined;
1088
+ /**
1089
+ * Logs out by clearing the token
1090
+ */
1091
+ logout: () => void;
1092
+ };
1093
+ /**
1094
+ * WebSocket streaming API
1095
+ * Provides real-time updates for prices, orders, positions, etc.
1096
+ */
1097
+ stream: {
1098
+ /**
1099
+ * Connects to WebSocket server
1100
+ */
1101
+ connect: () => Promise<void>;
1102
+ /**
1103
+ * Disconnects from WebSocket server
1104
+ */
1105
+ disconnect: () => void;
1106
+ /**
1107
+ * Checks if WebSocket is connected
1108
+ */
1109
+ isConnected: () => boolean;
1110
+ /**
1111
+ * Subscribes to symbols or channels
1112
+ * @example
1113
+ * client.stream.subscribe(['EURUSD', 'GBPUSD']);
1114
+ */
1115
+ subscribe: (channels: string[]) => void;
1116
+ /**
1117
+ * Unsubscribes from symbols or channels
1118
+ */
1119
+ unsubscribe: (channels: string[]) => void;
1120
+ /**
1121
+ * Gets list of subscribed channels
1122
+ */
1123
+ getSubscriptions: () => string[];
1124
+ /**
1125
+ * Listens to real-time price updates
1126
+ */
1127
+ onPriceUpdate: (callback: WebSocketCallback<PriceUpdate>) => void;
1128
+ /**
1129
+ * Listens to real-time order updates
1130
+ */
1131
+ onOrderUpdate: (callback: WebSocketCallback<OrderUpdate>) => void;
1132
+ /**
1133
+ * Listens to real-time position updates
1134
+ */
1135
+ onPositionUpdate: (callback: WebSocketCallback<PositionUpdate>) => void;
1136
+ /**
1137
+ * Listens to real-time balance updates
1138
+ */
1139
+ onBalanceUpdate: (callback: WebSocketCallback<BalanceUpdate>) => void;
1140
+ /**
1141
+ * Listens to connection events
1142
+ */
1143
+ onConnected: (callback: WebSocketCallback) => void;
1144
+ /**
1145
+ * Listens to disconnection events
1146
+ */
1147
+ onDisconnected: (callback: WebSocketCallback) => void;
1148
+ /**
1149
+ * Listens to error events
1150
+ */
1151
+ onError: (callback: WebSocketCallback) => void;
1152
+ /**
1153
+ * Removes event listener
1154
+ */
1155
+ off: (event: string, callback?: WebSocketCallback) => void;
1156
+ };
1157
+ /**
1158
+ * Health check
1159
+ */
1160
+ ping(): Promise<HealthCheckResponse>;
1161
+ /**
1162
+ * Client information
1163
+ */
1164
+ getConfig(): Readonly<PipsendConfig>;
1165
+ }
1166
+
1167
+ /**
1168
+ * Creates a new instance of the Pipsend client
1169
+ *
1170
+ * @example
1171
+ * ```typescript
1172
+ * import { createClient } from '@pipsend/sdk';
1173
+ *
1174
+ * const client = createClient({
1175
+ * server: 'https://api.pipsend.com',
1176
+ * login: 'your-username',
1177
+ * password: 'your-password',
1178
+ * timezone: 'America/New_York' // optional
1179
+ * });
1180
+ *
1181
+ * // The SDK handles authentication automatically
1182
+ * await client.orders.send({
1183
+ * symbol: 'EURUSD',
1184
+ * volume: 0.1
1185
+ * });
1186
+ * ```
1187
+ */
1188
+ declare function createClient(config: PipsendConfig): PipsendClient;
1189
+ declare const sdk: {
1190
+ createClient: typeof createClient;
1191
+ PipsendClient: typeof PipsendClient;
1192
+ };
1193
+
1194
+ export { type Account, type AccountStatistics, type AccountStatisticsParams, type AccountsListParams, type AuthResponse, AuthenticationError, type BalanceUpdate, type CalculateProfitRequest, type CalculateProfitResponse, type Candle, type CandlesParams, type ChangePasswordRequest, type CheckMarginRequest, type CheckMarginResponse, type CloseTradeRequest, type CloseTradeResponse, ConfigurationError, type Group, type GroupsParams, type HealthCheckResponse, type ModifyTradeRequest, type ModifyTradeResponse, type OpenTradeRequest, type OpenTradeResponse, type Order, type OrderData, type OrderStatistics, type OrderUpdate, type OrdersListParams, type PaginatedResponse, type PaginationParams, PipsendClient, type PipsendConfig, PipsendError, type Position, type PositionStatistics, type PositionUpdate, type PositionsListParams, type PriceUpdate, type Symbol, type SymbolsParams, type TokenInfo, type TradingGroup, type TradingGroupStatistics, type TradingGroupsListParams, type UpdateOrderRequest, type UpdatePositionRequest, type WebSocketCallback, type WebSocketConfig, WebSocketError, type WebSocketEventType, type WebSocketMessage, createClient, sdk as default };