-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDerivativesClient.ts
More file actions
1064 lines (976 loc) · 29.3 KB
/
Copy pathDerivativesClient.ts
File metadata and controls
1064 lines (976 loc) · 29.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { nanoid } from 'nanoid';
import { BaseRestClient } from './lib/BaseRestClient.js';
import { REST_CLIENT_TYPE_ENUM, RestClientType } from './lib/requestUtils.js';
import {
FuturesAddAssignmentPreferenceParams,
FuturesBatchOrderParams,
FuturesCancelOrderParams,
FuturesEditOrderParams,
FuturesGetAccountLogParams,
FuturesGetAnalyticsParams,
FuturesGetCandlesParams,
FuturesGetOrderEventsParams,
FuturesGetPositionEventsParams,
FuturesGetTriggerEventsParams,
FuturesHistoryBaseParams,
FuturesInitiateSubaccountTransferParams,
FuturesInitiateWalletTransferParams,
FuturesMarketHistoryBaseParams,
FuturesSendOrderParams,
FuturesSubmitToSpotParams,
FuturesUpdateSelfTradeStrategyParams,
} from './types/request/derivatives.types.js';
import {
FuturesAccountLog,
FuturesAccounts,
FuturesAnalyticsResponse,
FuturesApiKeyV3Check,
FuturesAssignmentProgram,
FuturesAssignmentProgramHistory,
FuturesBatchOrderStatus,
FuturesCancelAllOrdersStatus,
FuturesCancelOrderStatus,
FuturesCandles,
FuturesDeadMansSwitchStatus,
FuturesEditOrderStatus,
FuturesFeeSchedule,
FuturesFill,
FuturesHistoricalFundingRate,
FuturesHistoryExecutionEvent,
FuturesHistoryOrderEvent,
FuturesHistoryResponse,
FuturesHistoryTriggerEvent,
FuturesInstrument,
FuturesInstrumentStatus,
FuturesLeveragePreference,
FuturesMarketHistoryResponse,
FuturesMarketShare,
FuturesNotification,
FuturesOpenOffer,
FuturesOpenOrder,
FuturesOpenPosition,
FuturesOrderBook,
FuturesOrderStatusInfo,
FuturesPnlPreference,
FuturesPortfolioMarginParameters,
FuturesPortfolioSimulation,
FuturesPositionUpdateEvent,
FuturesPublicExecutionEvent,
FuturesPublicMarkPriceEvent,
FuturesPublicOrderEvent,
FuturesResolution,
FuturesRfq,
FuturesSelfTradeStrategy,
FuturesSendOrderStatus,
FuturesSubaccountsInfo,
FuturesTicker,
FuturesTickType,
FuturesTradeHistoryItem,
FuturesUnwindQueuePosition,
} from './types/response/derivatives.types.js';
import { DerivativesAPISuccessResponse } from './types/response/shared.types.js';
/**
* The DerivativesClient provides integration to the Kraken Derivatives API.
*
* Docs:
* - https://docs.kraken.com/api/docs/guides/futures-introduction
* - https://docs.kraken.com/api/docs/guides/futures-rest
* - https://docs.kraken.com/api/docs/futures-api/trading/get-history
*/
export class DerivativesClient extends BaseRestClient {
getClientType(): RestClientType {
return REST_CLIENT_TYPE_ENUM.derivatives;
}
/**
*
* Misc Utility Methods
*
*/
generateNewOrderID(): string {
return nanoid(32);
}
/**
*
* Futures REST API - Trading - Market Data
*
*/
/**
* Get trade history
*
* This endpoint returns the most recent 100 trades prior to the specified lastTime value up to past 7 days or recent trading engine restart (whichever is sooner).
* If no lastTime specified, it will return 100 most recent trades.
*/
getTradeHistory(params: {
symbol: string;
lastTime?: string;
}): Promise<
DerivativesAPISuccessResponse<{ history: FuturesTradeHistoryItem[] }>
> {
return this.get('derivatives/api/v3/history', params);
}
/**
* Get orderbook
*
* This endpoint returns the entire non-cumulative order book of currently listed Futures contracts.
*/
getOrderbook(params: {
symbol: string;
}): Promise<DerivativesAPISuccessResponse<{ orderBook: FuturesOrderBook }>> {
return this.get('derivatives/api/v3/orderbook', params);
}
/**
* Get tickers
*
* This endpoint returns current market data for all currently listed Futures contracts and indices.
*/
getTickers(): Promise<
DerivativesAPISuccessResponse<{ tickers: FuturesTicker[] }>
> {
return this.get('derivatives/api/v3/tickers');
}
/**
* Get ticker by symbol
*
* Get market data for contract or index by symbol.
*/
getTicker(params: {
symbol: string;
}): Promise<DerivativesAPISuccessResponse<{ ticker: FuturesTicker }>> {
return this.get(`derivatives/api/v3/tickers/${params.symbol}`);
}
/**
*
* Futures REST API - Trading - Instrument Details
*
*/
/**
* Get instruments
*
* Returns specifications for all currently listed markets and indices.
*/
getInstruments(): Promise<
DerivativesAPISuccessResponse<{ instruments: FuturesInstrument[] }>
> {
return this.get('derivatives/api/v3/instruments');
}
/**
* Get instrument status list
*
* Returns price dislocation and volatility details for all markets.
*/
getInstrumentStatusList(): Promise<
DerivativesAPISuccessResponse<{
instrumentStatus: FuturesInstrumentStatus[];
}>
> {
return this.get('derivatives/api/v3/instruments/status');
}
/**
* Get instrument status
*
* Returns price dislocation and volatility details for given market.
*/
getInstrumentStatus(params: {
symbol: string;
}): Promise<DerivativesAPISuccessResponse<FuturesInstrumentStatus>> {
return this.get(`derivatives/api/v3/instruments/${params.symbol}/status`);
}
/**
*
* Futures REST API - Trading - Order Management
*
*/
/**
* Batch order management
*
* This endpoint allows sending limit or stop order(s) and/or cancelling open order(s) and/or editing open order(s) for a currently listed Futures contract in batch.
* When editing an order, if the trailingStopMaxDeviation and trailingStopDeviationUnit parameters are sent unchanged, the system will recalculate a new stop price upon successful order modification.
*/
batchOrderManagement(
params: FuturesBatchOrderParams,
): Promise<
DerivativesAPISuccessResponse<{ batchStatus: FuturesBatchOrderStatus[] }>
> {
const { ProcessBefore, json } = params;
return this.postPrivate('derivatives/api/v3/batchorder', {
body: {
ProcessBefore: ProcessBefore,
json,
},
});
}
/**
* Cancel all orders
*
* This endpoint allows cancelling orders which are associated with a future's contract or a margin account. If no arguments are specified all open orders will be cancelled.
*/
cancelAllOrders(params?: { symbol?: string }): Promise<
DerivativesAPISuccessResponse<{
cancelStatus: FuturesCancelAllOrdersStatus;
}>
> {
return this.postPrivate('derivatives/api/v3/cancelallorders', {
body: params,
});
}
/**
* Dead man's switch
*
* This endpoint provides a Dead Man's Switch mechanism to protect the user from network malfunctions. The user can send a request with a timeout in seconds which will trigger a countdown timer that will cancel all user orders when timeout expires. The user has to keep sending request to push back the timeout expiration or they can deactivate the mechanism by specifying a timeout of zero (0).
* The recommended mechanism usage is making a call every 15 to 20 seconds and provide a timeout of 60 seconds. This allows the user to keep the orders in place on a brief network failure, while keeping them safe in case of a network breakdown.
*/
cancelAllOrdersAfter(params: {
timeout: number;
}): Promise<
DerivativesAPISuccessResponse<{ status: FuturesDeadMansSwitchStatus }>
> {
return this.postPrivate('derivatives/api/v3/cancelallordersafter', {
body: params,
});
}
/**
* Cancel order
*
* This endpoint allows cancelling an open order for a Futures contract.
*/
cancelOrder(
params: FuturesCancelOrderParams,
): Promise<
DerivativesAPISuccessResponse<{ cancelStatus: FuturesCancelOrderStatus }>
> {
return this.postPrivate('derivatives/api/v3/cancelorder', {
body: params,
});
}
/**
* Edit order
*
* This endpoint allows editing an existing order for a currently listed Futures contract.
* When editing an order, if the trailingStopMaxDeviation and trailingStopDeviationUnit parameters are sent unchanged, the system will recalculate a new stop price upon successful order modification.
*/
editOrder(
params: FuturesEditOrderParams,
): Promise<
DerivativesAPISuccessResponse<{ editStatus: FuturesEditOrderStatus }>
> {
return this.postPrivate('derivatives/api/v3/editorder', {
body: params,
});
}
/**
* Get open orders
*
* This endpoint returns information on all open orders for all Futures contracts.
*/
getOpenOrders(): Promise<
DerivativesAPISuccessResponse<{ openOrders: FuturesOpenOrder[] }>
> {
return this.getPrivate('derivatives/api/v3/openorders');
}
/**
* Send order
*
* This endpoint allows sending a limit, stop, take profit or immediate-or-cancel order for a currently listed Futures contract.
*/
submitOrder(
params: FuturesSendOrderParams,
): Promise<
DerivativesAPISuccessResponse<{ sendStatus: FuturesSendOrderStatus }>
> {
return this.postPrivate('derivatives/api/v3/sendorder', {
body: params,
});
}
/**
* Get Specific Orders' Status
*
* Returns information on specified orders which are open or were filled/cancelled in the last 5 seconds.
*/
getOrderStatus(params?: {
orderIds?: string[];
cliOrdIds?: string[];
}): Promise<
DerivativesAPISuccessResponse<{ orders: FuturesOrderStatusInfo[] }>
> {
return this.postPrivate('derivatives/api/v3/orders/status', {
body: params,
});
}
/**
*
* Futures REST API - Trading - Multi-Collateral
*
*/
/**
* Get PNL currency preferences
*
* The PNL currency preference is used to determine which currency to pay out when realizing PNL gains.
*/
getPnlPreferences(): Promise<
DerivativesAPISuccessResponse<{ preferences: FuturesPnlPreference[] }>
> {
return this.getPrivate('derivatives/api/v3/pnlpreferences');
}
/**
* Set PNL currency preference
*
* The PNL currency preference is used to determine which currency to pay out when realizing PNL gains.
* Calling this API can result in the following error codes: 87 (Contract does not exist), 88 (Contract not a multi-collateral futures contract), 89 (Currency does not exist), 90 (Currency is not enabled for multi-collateral futures), 41 (Would cause liquidation).
*/
setPnlPreference(params: {
symbol: string;
pnlPreference: string;
}): Promise<DerivativesAPISuccessResponse<Record<string, never>>> {
return this.putPrivate('derivatives/api/v3/pnlpreferences', {
query: params,
});
}
/**
* Get leverage settings
*
* Returns list of configured leverage preferences.
*/
getLeverageSettings(): Promise<
DerivativesAPISuccessResponse<{
leveragePreferences: FuturesLeveragePreference[];
}>
> {
return this.getPrivate('derivatives/api/v3/leveragepreferences');
}
/**
* Set leverage settings
*
* Sets a contract's margin mode, either "isolated" or "cross" margin.
* When specifying a max leverage, the contract's margin mode will be isolated.
*/
setLeverageSettings(params: {
symbol: string;
maxLeverage?: number;
}): Promise<DerivativesAPISuccessResponse<Record<string, never>>> {
return this.putPrivate('derivatives/api/v3/leveragepreferences', {
query: params,
});
}
/**
*
* Futures REST API - Trading - Account Information
*
*/
/**
* Get wallets
*
* This endpoint returns key information relating to all your accounts which may either be cash accounts or margin accounts.
* This includes digital asset balances, instrument balances, margin requirements, margin trigger estimates and
* auxiliary information such as available funds, PnL of open positions and portfolio value.
*/
getAccounts(): Promise<
DerivativesAPISuccessResponse<{ accounts: FuturesAccounts }>
> {
return this.getPrivate('derivatives/api/v3/accounts');
}
/**
* Get open positions
*
* This endpoint returns the size and average entry price of all open positions in Futures contracts.
* This includes Futures contracts that have matured but have not yet been settled.
*/
getOpenPositions(): Promise<
DerivativesAPISuccessResponse<{ openPositions: FuturesOpenPosition[] }>
> {
return this.getPrivate('derivatives/api/v3/openpositions');
}
/**
* Get position percentile of unwind queue
*
* This endpoint returns the percentile of the open position in case of unwinding.
*/
getPositionPercentile(): Promise<
DerivativesAPISuccessResponse<{ queue: FuturesUnwindQueuePosition[] }>
> {
return this.getPrivate('derivatives/api/v3/unwindqueue');
}
/**
* Get portfolio margin parameters
*
* Retrieve current portfolio margin calculation parameters.
* Also includes user specific limits related to options trading.
* Note: This is currently available exclusively in the Kraken Futures DEMO environment.
*/
getPortfolioMarginParameters(): Promise<
DerivativesAPISuccessResponse<FuturesPortfolioMarginParameters>
> {
return this.getPrivate('derivatives/api/v3/portfolio-margining/parameters');
}
/**
* Calculate portfolio margin, pnl and greeks
*
* For a given portfolio of balances and positions (futures and options), calculate the margin requirements, pnl and option greeks.
* Note: This is currently available exclusively in the Kraken Futures DEMO environment.
*/
simulateMarginRequirements(params: {
json: any; // Complex structure for portfolio simulation
}): Promise<DerivativesAPISuccessResponse<FuturesPortfolioSimulation>> {
return this.postPrivate('derivatives/api/v3/portfolio-margining/simulate', {
query: params,
});
}
/**
*
* Futures REST API - Trading - Assignment Program
*
*/
/**
* List assignment programs
*
* This endpoint returns information on currently active assignment programs.
*/
getAssignmentPrograms(): Promise<
DerivativesAPISuccessResponse<{ participants: FuturesAssignmentProgram[] }>
> {
return this.getPrivate('derivatives/api/v3/assignmentprogram/current');
}
/**
* Add assignment preference
*
* This endpoint adds an assignment program preference.
*/
addAssignmentPreference(
params: FuturesAddAssignmentPreferenceParams,
): Promise<DerivativesAPISuccessResponse<FuturesAssignmentProgram>> {
return this.postPrivate('derivatives/api/v3/assignmentprogram/add', {
body: params,
});
}
/**
* Delete assignment preference
*
* This endpoint deletes an assignment program preference.
*/
deleteAssignmentPreference(params: {
id: number;
}): Promise<DerivativesAPISuccessResponse<FuturesAssignmentProgram>> {
return this.postPrivate('derivatives/api/v3/assignmentprogram/delete', {
body: params,
});
}
/**
* List assignment preferences history
*
* This endpoint returns information on assignment program preferences change history.
*/
getAssignmentPreferencesHistory(): Promise<
DerivativesAPISuccessResponse<{
participants: FuturesAssignmentProgramHistory[];
}>
> {
return this.getPrivate('derivatives/api/v3/assignmentprogram/history');
}
/**
*
* Futures REST API - Trading - Fee Schedules
*
*/
/**
* Get fee schedules
*
* This endpoint lists all fee schedules.
*
* @deprecated Effective 2026-06-22. Use SpotClient.getTradingVolume() with a Spot API key instead.
*/
getFeeSchedules(): Promise<
DerivativesAPISuccessResponse<{ feeSchedules: FuturesFeeSchedule[] }>
> {
return this.get('derivatives/api/v3/feeschedules');
}
/**
* Get fee schedule volumes
*
* Returns your fee schedule volumes for each fee schedule.
*
* @deprecated Effective 2026-06-22. Use SpotClient.getTradingVolume() with a Spot API key instead.
*/
getFeeScheduleVolumes(): Promise<
DerivativesAPISuccessResponse<{
volumesByFeeSchedule: Record<string, number>;
}>
> {
return this.getPrivate('derivatives/api/v3/feeschedules/volumes');
}
/**
*
* Futures REST API - Trading - General
*
*/
/**
* Get notifications
*
* This endpoint provides the platform's notifications.
*/
getNotifications(): Promise<
DerivativesAPISuccessResponse<{ notifications: FuturesNotification[] }>
> {
return this.getPrivate('derivatives/api/v3/notifications');
}
/**
*
* Futures REST API - Trading - Historical Data
*
*/
/**
* Get your fills
*
* This endpoint returns information on your filled orders for all futures contracts.
*/
getFills(params?: {
lastFillTime?: string;
}): Promise<DerivativesAPISuccessResponse<{ fills: FuturesFill[] }>> {
return this.getPrivate('derivatives/api/v3/fills', params);
}
/**
*
* Futures REST API - Trading - Historical Funding Rates
*
*/
/**
* Historical funding rates
*
* Returns list of historical funding rates for given market.
*/
getHistoricalFundingRates(params: {
symbol: string;
}): Promise<
DerivativesAPISuccessResponse<{ rates: FuturesHistoricalFundingRate[] }>
> {
return this.get('derivatives/api/v3/historical-funding-rates', params);
}
/**
*
* Futures REST API - Trading - Trading Settings
*
*/
/**
* Get self trade strategy
*
* Returns account-wide self-trade matching strategy.
*/
getSelfTradeStrategy(): Promise<
DerivativesAPISuccessResponse<{
strategy: FuturesSelfTradeStrategy;
}>
> {
return this.getPrivate('derivatives/api/v3/self-trade-strategy');
}
/**
* Update self trade strategy
*
* Updates account-wide self-trade matching behavior to given strategy.
*/
updateSelfTradeStrategy(
params: FuturesUpdateSelfTradeStrategyParams,
): Promise<
DerivativesAPISuccessResponse<{
strategy: FuturesSelfTradeStrategy;
}>
> {
return this.putPrivate('derivatives/api/v3/self-trade-strategy', {
query: params,
});
}
/**
*
* Futures REST API - Trading - Subaccounts
*
*/
/**
* Check subaccount trading status
*
* Returns trading capability info for given subaccount.
*/
getSubaccountTradingStatus(params: {
subaccountUid: string;
}): Promise<DerivativesAPISuccessResponse<{ tradingEnabled: boolean }>> {
return this.getPrivate(
`derivatives/api/v3/subaccount/${params.subaccountUid}/trading-enabled`,
);
}
/**
* Update subaccount trading status
*
* Updates trading capabilities for given subaccount.
*/
updateSubaccountTradingStatus(params: {
subaccountUid: string;
tradingEnabled: boolean;
}): Promise<DerivativesAPISuccessResponse<{ tradingEnabled: boolean }>> {
const { subaccountUid, ...otherParams } = params;
return this.putPrivate(
`derivatives/api/v3/subaccount/${subaccountUid}/trading-enabled`,
{ query: otherParams },
);
}
/**
* Get subaccounts
*
* Return information about subaccounts, including balances and UIDs.
*/
getSubaccounts(): Promise<
DerivativesAPISuccessResponse<FuturesSubaccountsInfo>
> {
return this.getPrivate('derivatives/api/v3/subaccounts');
}
/**
*
* Futures REST API - Trading - Transfers
*
*/
/**
* Initiate wallet transfer
*
* This endpoint allows you to transfer funds between two margin accounts with the same collateral currency, or between a margin account and your cash account.
*/
submitWalletTransfer(
params: FuturesInitiateWalletTransferParams,
): Promise<DerivativesAPISuccessResponse<Record<string, never>>> {
return this.postPrivate('derivatives/api/v3/transfer', {
body: params,
});
}
/**
* Initiate sub account transfer
*
* This endpoint allows you to transfer funds between the current account and a sub account, between two margin accounts with the same collateral currency, or between a margin account and your cash account.
*/
submitSubaccountTransfer(
params: FuturesInitiateSubaccountTransferParams,
): Promise<DerivativesAPISuccessResponse<Record<string, never>>> {
return this.postPrivate('derivatives/api/v3/transfer/subaccount', {
body: params,
});
}
/**
* Initiate withdrawal to Spot wallet
*
* This endpoint allows you to request to withdraw digital assets to your Kraken Spot wallet.
* Wallet names can be found in the 'accounts' structure in the Get Wallets /accounts response.
*/
submitTransferToSpot(
params: FuturesSubmitToSpotParams,
): Promise<DerivativesAPISuccessResponse<{ uid: string }>> {
return this.postPrivate('derivatives/api/v3/withdrawal', {
body: params,
});
}
/**
*
* Futures REST API - Trading - RFQs
*
*/
/**
* List all open RFQs
*
* Retrieve all currently open RFQs.
* Note: This is currently available exclusively in the Kraken Futures DEMO environment.
*/
getOpenRFQs(): Promise<
DerivativesAPISuccessResponse<{ rfqs: FuturesRfq[] }>
> {
return this.get('derivatives/api/v3/rfqs');
}
/**
* Retrieve a single open RFQ
*
* Retrieve a specific open RFQ by its unique identifier.
* Note: This is currently available exclusively in the Kraken Futures DEMO environment.
*/
getOpenRFQ(params: {
rfqUid: string;
}): Promise<DerivativesAPISuccessResponse<{ rfq: FuturesRfq }>> {
return this.get(`derivatives/api/v3/rfqs/${params.rfqUid}`);
}
/**
* List open offers on open RFQs
*
* Retrieve all open offers for the account on currently open RFQs.
* Note: This is currently available exclusively in the Kraken Futures DEMO environment.
*/
getRFQOpenOffers(): Promise<
DerivativesAPISuccessResponse<{ openOffers: FuturesOpenOffer[] }>
> {
return this.getPrivate('derivatives/api/v3/rfqs/open-offers');
}
/**
* Place new offer on an open RFQ
*
* Place a new offer for the given amount in USD on the specified open RFQ, bid and ask are optional but at least one must be provided.
* Note: This is currently available exclusively in the Kraken Futures DEMO environment.
*/
submitRFQNewOffer(params: {
rfqUid: string;
bid?: number;
ask?: number;
}): Promise<DerivativesAPISuccessResponse<{ offerUid: string }>> {
const { rfqUid, ...bodyParams } = params;
return this.postPrivate(`derivatives/api/v3/rfqs/${rfqUid}/place-offer`, {
body: bodyParams,
});
}
/**
* Replace open offer on open RFQ
*
* Replace the current open offer on the specified open RFQ, bid and ask are optional but at least one must be provided.
* Note: This is currently available exclusively in the Kraken Futures DEMO environment.
*/
updateRFQOpenOffer(params: {
rfqUid: string;
bid?: number;
ask?: number;
}): Promise<DerivativesAPISuccessResponse<Record<string, never>>> {
const { rfqUid, ...bodyParams } = params;
return this.putPrivate(`derivatives/api/v3/rfqs/${rfqUid}/replace-offer`, {
body: bodyParams,
});
}
/**
* Cancel open offer on open RFQ
*
* Cancel the current open offer on the specified open RFQ.
* Note: This is currently available exclusively in the Kraken Futures DEMO environment.
*/
cancelRFQOffer(params: {
rfqUid: string;
}): Promise<DerivativesAPISuccessResponse<Record<string, never>>> {
return this.deletePrivate(
`derivatives/api/v3/rfqs/${params.rfqUid}/cancel-offer`,
);
}
/**
*
* Futures REST API - History - Account History
*
*/
/**
* Get execution events
*
* Lists executions/trades for authenticated account.
*/
getExecutionEvents(
params?: FuturesHistoryBaseParams,
): Promise<
DerivativesAPISuccessResponse<
FuturesHistoryResponse<FuturesHistoryExecutionEvent>
>
> {
return this.getPrivate('api/history/v3/executions', params);
}
/**
* Get order events
*
* Lists order events for authenticated account.
*/
getOrderEvents(
params?: FuturesGetOrderEventsParams,
): Promise<
DerivativesAPISuccessResponse<
FuturesHistoryResponse<FuturesHistoryOrderEvent>
>
> {
return this.getPrivate('api/history/v3/orders', params);
}
/**
* Get trigger events
*
* Lists trigger events for authenticated account.
*/
getTriggerEvents(
params?: FuturesGetTriggerEventsParams,
): Promise<
DerivativesAPISuccessResponse<
FuturesHistoryResponse<FuturesHistoryTriggerEvent>
>
> {
return this.getPrivate('api/history/v3/triggers', params);
}
/**
* Get position update events
*
* Lists position events for authenticated account.
*/
getPositionEvents(
params?: FuturesGetPositionEventsParams,
): Promise<
DerivativesAPISuccessResponse<
FuturesHistoryResponse<FuturesPositionUpdateEvent>
>
> {
return this.getPrivate('api/history/v3/positions', params);
}
/**
* Get account log
*
* Lists account log entries, paged by timestamp or by ID.
* To request entries by time range, use the since and before parameters. To request entries by ID range, use the from and to parameters. Any combination of since, before, from and to can be used to restrict the requested range of entries.
*/
getAccountLog(
params?: FuturesGetAccountLogParams,
): Promise<DerivativesAPISuccessResponse<FuturesAccountLog>> {
return this.getPrivate('api/history/v3/account-log', params);
}
/**
* Account log (CSV)
*
* Lists recent account log entries in CSV format.
*/
getAccountLogCsv(params?: { conversion_details?: boolean }): Promise<string> {
return this.getPrivate('api/history/v3/accountlogcsv', params);
}
/**
*
* Futures REST API - History - Market History
*
*/
/**
* Get public execution events
*
* Lists trades for a market.
*/
getPublicExecutionEvents(
params: FuturesMarketHistoryBaseParams,
): Promise<FuturesMarketHistoryResponse<FuturesPublicExecutionEvent>> {
const { tradeable, ...otherParams } = params;
return this.get(`api/history/v3/market/${tradeable}/executions`, {
params: otherParams,
});
}
/**
* Get public order events
*
* Lists order events for a market.
*/
getPublicOrderEvents(
params: FuturesMarketHistoryBaseParams,
): Promise<FuturesMarketHistoryResponse<FuturesPublicOrderEvent>> {
const { tradeable, ...otherParams } = params;
return this.get(`api/history/v3/market/${tradeable}/orders`, {
params: otherParams,
});
}
/**
* Get public mark price events
*
* Lists price events for a market.
*/
getPublicMarkPriceEvents(
params: FuturesMarketHistoryBaseParams,
): Promise<FuturesMarketHistoryResponse<FuturesPublicMarkPriceEvent>> {
const { tradeable, ...otherParams } = params;
return this.get(`api/history/v3/market/${tradeable}/price`, {
params: otherParams,
});
}
/**
*
* Futures REST API - Charts - Candles
*
*/
/**
* Tick Types
*
* Returns all available tick types to use with the getMarketsForTickType() endpoint.
*/
getTickTypes(): Promise<FuturesTickType[]> {
return this.get('api/charts/v1/');
}
/**
* Markets
*
* Markets available for specified tick type.
* List of available tick types can be fetched from the getTickTypes() endpoint.
*/
getMarketsForTickType(params: {
tickType: FuturesTickType;
}): Promise<string[]> {
return this.get(`api/charts/v1/${params.tickType}`);
}
/**
* Resolutions
*
* Candle resolutions available for specified tick type and market.
* List of available tick types can be fetched from the getTickTypes() endpoint.
* List of available markets can be fetched from the getMarketsForTickType() endpoint.
*/
getResolutions(params: {
tickType: FuturesTickType;
symbol: string;
}): Promise<FuturesResolution[]> {
return this.get(`api/charts/v1/${params.tickType}/${params.symbol}`);
}
/**
* Market Candles
*
* Candles for specified tick type, market, and resolution.
* List of available tick types can be fetched from the getTickTypes() endpoint.
* List of available markets can be fetched from the getMarketsForTickType() endpoint.
* List of available resolutions can be fetched from the getResolutions() endpoint.
*/
getCandles(params: FuturesGetCandlesParams): Promise<FuturesCandles> {
const { tickType, symbol, resolution, ...otherParams } = params;
return this.get(`api/charts/v1/${tickType}/${symbol}/${resolution}`, {
params: otherParams,
});