Skip to content

api

api

Auto-generated API classes for WebSocket

Classes

PublicRPC

PublicRPC(session: WebSocketSession)

public RPC methods

Source code in derive_client/_clients/websockets/api.py
241
242
def __init__(self, session: WebSocketSession):
    self._session = session
Functions
build_register_session_key_tx async
build_register_session_key_tx(
    params: PublicBuildRegisterSessionKeyTxParamsSchema,
) -> PublicBuildRegisterSessionKeyTxResultSchema

Build a signable transaction params dictionary.

Source code in derive_client/_clients/websockets/api.py
244
245
246
247
248
249
250
251
252
253
254
255
256
async def build_register_session_key_tx(
    self,
    params: PublicBuildRegisterSessionKeyTxParamsSchema,
) -> PublicBuildRegisterSessionKeyTxResultSchema:
    """
    Build a signable transaction params dictionary.
    """

    method = "public/build_register_session_key_tx"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicBuildRegisterSessionKeyTxResultSchema)

    return result
register_session_key async
register_session_key(
    params: PublicRegisterSessionKeyParamsSchema,
) -> PublicRegisterSessionKeyResultSchema

Register or update expiry of an existing session key.

Currently, this only supports creating admin level session keys.

Keys with fewer permissions are registered via /register_scoped_session_key

Expiries updated on admin session keys may not happen immediately due to waiting for the onchain transaction to settle.

Source code in derive_client/_clients/websockets/api.py
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
async def register_session_key(
    self,
    params: PublicRegisterSessionKeyParamsSchema,
) -> PublicRegisterSessionKeyResultSchema:
    """
    Register or update expiry of an existing session key.

    Currently, this only supports creating admin level session keys.

    Keys with fewer permissions are registered via `/register_scoped_session_key`

    Expiries updated on admin session keys may not happen immediately due to waiting
    for the onchain transaction to settle.
    """

    method = "public/register_session_key"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicRegisterSessionKeyResultSchema)

    return result
deregister_session_key async
deregister_session_key(
    params: PublicDeregisterSessionKeyParamsSchema,
) -> PublicDeregisterSessionKeyResultSchema

Used for de-registering admin scoped keys. For other scopes, use /edit_session_key.

Source code in derive_client/_clients/websockets/api.py
279
280
281
282
283
284
285
286
287
288
289
290
291
292
async def deregister_session_key(
    self,
    params: PublicDeregisterSessionKeyParamsSchema,
) -> PublicDeregisterSessionKeyResultSchema:
    """
    Used for de-registering admin scoped keys. For other scopes, use
    `/edit_session_key`.
    """

    method = "public/deregister_session_key"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicDeregisterSessionKeyResultSchema)

    return result
login async
login(params: PublicLoginParamsSchema) -> list[int]

Authenticate a websocket connection. Unavailable via HTTP.

Source code in derive_client/_clients/websockets/api.py
294
295
296
297
298
299
300
301
302
303
304
305
306
async def login(
    self,
    params: PublicLoginParamsSchema,
) -> list[int]:
    """
    Authenticate a websocket connection. Unavailable via HTTP.
    """

    method = "public/login"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[int])

    return result
statistics async
statistics(
    params: PublicStatisticsParamsSchema,
) -> PublicStatisticsResultSchema

Get statistics for a specific instrument or instrument type

Source code in derive_client/_clients/websockets/api.py
308
309
310
311
312
313
314
315
316
317
318
319
320
async def statistics(
    self,
    params: PublicStatisticsParamsSchema,
) -> PublicStatisticsResultSchema:
    """
    Get statistics for a specific instrument or instrument type
    """

    method = "public/statistics"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicStatisticsResultSchema)

    return result
get_all_currencies async
get_all_currencies(
    params: PublicGetAllCurrenciesParamsSchema,
) -> list[CurrencyDetailedResponseSchema]

Get all active currencies with their spot price, spot price 24hrs ago.

For real-time updates, recommend using channels -> ticker or orderbook.

Source code in derive_client/_clients/websockets/api.py
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
async def get_all_currencies(
    self,
    params: PublicGetAllCurrenciesParamsSchema,
) -> list[CurrencyDetailedResponseSchema]:
    """
    Get all active currencies with their spot price, spot price 24hrs ago.

    For real-time updates, recommend using channels -> ticker or orderbook.
    """

    method = "public/get_all_currencies"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[CurrencyDetailedResponseSchema])

    return result
get_currency async
get_currency(
    params: PublicGetCurrencyParamsSchema,
) -> PublicGetCurrencyResultSchema

Get currency related risk params, spot price 24hrs ago and lending details for a specific currency.

Source code in derive_client/_clients/websockets/api.py
338
339
340
341
342
343
344
345
346
347
348
349
350
351
async def get_currency(
    self,
    params: PublicGetCurrencyParamsSchema,
) -> PublicGetCurrencyResultSchema:
    """
    Get currency related risk params, spot price 24hrs ago and lending details for a
    specific currency.
    """

    method = "public/get_currency"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetCurrencyResultSchema)

    return result
get_instrument async
get_instrument(
    params: PublicGetInstrumentParamsSchema,
) -> PublicGetInstrumentResultSchema

Get single instrument by asset name

Source code in derive_client/_clients/websockets/api.py
353
354
355
356
357
358
359
360
361
362
363
364
365
async def get_instrument(
    self,
    params: PublicGetInstrumentParamsSchema,
) -> PublicGetInstrumentResultSchema:
    """
    Get single instrument by asset name
    """

    method = "public/get_instrument"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetInstrumentResultSchema)

    return result
get_all_instruments async
get_all_instruments(
    params: PublicGetAllInstrumentsParamsSchema,
) -> PublicGetAllInstrumentsResultSchema

Get a paginated history of all instruments

Source code in derive_client/_clients/websockets/api.py
367
368
369
370
371
372
373
374
375
376
377
378
379
async def get_all_instruments(
    self,
    params: PublicGetAllInstrumentsParamsSchema,
) -> PublicGetAllInstrumentsResultSchema:
    """
    Get a paginated history of all instruments
    """

    method = "public/get_all_instruments"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetAllInstrumentsResultSchema)

    return result
get_instruments async
get_instruments(
    params: PublicGetInstrumentsParamsSchema,
) -> list[InstrumentPublicResponseSchema]

Get all active instruments for a given currency and type.

Source code in derive_client/_clients/websockets/api.py
381
382
383
384
385
386
387
388
389
390
391
392
393
async def get_instruments(
    self,
    params: PublicGetInstrumentsParamsSchema,
) -> list[InstrumentPublicResponseSchema]:
    """
    Get all active instruments for a given `currency` and `type`.
    """

    method = "public/get_instruments"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[InstrumentPublicResponseSchema])

    return result
get_ticker async
get_ticker(
    params: PublicGetTickerParamsSchema,
) -> PublicGetTickerResultSchema

Get ticker information (best bid / ask, instrument contraints, fees info, etc.) for a single instrument

DEPRECATION NOTICE: This RPC is deprecated in favor of get_tickers on Dec 1, 2025.

Source code in derive_client/_clients/websockets/api.py
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
async def get_ticker(
    self,
    params: PublicGetTickerParamsSchema,
) -> PublicGetTickerResultSchema:
    """
    Get ticker information (best bid / ask, instrument contraints, fees info, etc.)
    for a single instrument

    DEPRECATION NOTICE: This RPC is deprecated in favor of `get_tickers` on Dec 1,
    2025.
    """

    method = "public/get_ticker"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetTickerResultSchema)

    return result
get_tickers async
get_tickers(
    params: PublicGetTickersParamsSchema,
) -> PublicGetTickersResultSchema

Get tickers information (best bid / ask, stats, etc.) for a multiple instruments.

For options: currency is required and expiry_date is required.

For perps: currency is optional, expiry_date will throw an error.

For erc20s: currency is optional, expiry_date will throw an error.

For most up to date stream of tickers, use the ticker.<instrument_name>.<interval> channels.

Source code in derive_client/_clients/websockets/api.py
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
async def get_tickers(
    self,
    params: PublicGetTickersParamsSchema,
) -> PublicGetTickersResultSchema:
    """
    Get tickers information (best bid / ask, stats, etc.) for a multiple
    instruments.

    For options: currency is required and expiry_date is required.

    For perps: currency is optional, expiry_date will throw an error.

    For erc20s: currency is optional, expiry_date will throw an error.

    For most up to date stream of tickers, use the
    `ticker.<instrument_name>.<interval>` channels.
    """

    method = "public/get_tickers"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetTickersResultSchema)

    return result
get_latest_signed_feeds async
get_latest_signed_feeds(
    params: PublicGetLatestSignedFeedsParamsSchema,
) -> PublicGetLatestSignedFeedsResultSchema

Get latest signed data feeds

Source code in derive_client/_clients/websockets/api.py
437
438
439
440
441
442
443
444
445
446
447
448
449
async def get_latest_signed_feeds(
    self,
    params: PublicGetLatestSignedFeedsParamsSchema,
) -> PublicGetLatestSignedFeedsResultSchema:
    """
    Get latest signed data feeds
    """

    method = "public/get_latest_signed_feeds"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetLatestSignedFeedsResultSchema)

    return result
get_option_settlement_prices async
get_option_settlement_prices(
    params: PublicGetOptionSettlementPricesParamsSchema,
) -> PublicGetOptionSettlementPricesResultSchema

Get settlement prices by expiry for each currency

Source code in derive_client/_clients/websockets/api.py
451
452
453
454
455
456
457
458
459
460
461
462
463
async def get_option_settlement_prices(
    self,
    params: PublicGetOptionSettlementPricesParamsSchema,
) -> PublicGetOptionSettlementPricesResultSchema:
    """
    Get settlement prices by expiry for each currency
    """

    method = "public/get_option_settlement_prices"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetOptionSettlementPricesResultSchema)

    return result
get_spot_feed_history async
get_spot_feed_history(
    params: PublicGetSpotFeedHistoryParamsSchema,
) -> PublicGetSpotFeedHistoryResultSchema

Get spot feed history by currency

DB: read replica

Source code in derive_client/_clients/websockets/api.py
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
async def get_spot_feed_history(
    self,
    params: PublicGetSpotFeedHistoryParamsSchema,
) -> PublicGetSpotFeedHistoryResultSchema:
    """
    Get spot feed history by currency

    DB: read replica
    """

    method = "public/get_spot_feed_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetSpotFeedHistoryResultSchema)

    return result
get_spot_feed_history_candles async
get_spot_feed_history_candles(
    params: PublicGetSpotFeedHistoryCandlesParamsSchema,
) -> PublicGetSpotFeedHistoryCandlesResultSchema

Get spot feed history candles by currency

DB: read replica

Source code in derive_client/_clients/websockets/api.py
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
async def get_spot_feed_history_candles(
    self,
    params: PublicGetSpotFeedHistoryCandlesParamsSchema,
) -> PublicGetSpotFeedHistoryCandlesResultSchema:
    """
    Get spot feed history candles by currency

    DB: read replica
    """

    method = "public/get_spot_feed_history_candles"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetSpotFeedHistoryCandlesResultSchema)

    return result
get_funding_rate_history async
get_funding_rate_history(
    params: PublicGetFundingRateHistoryParamsSchema,
) -> PublicGetFundingRateHistoryResultSchema

Get funding rate history. Start timestamp is restricted to at most 30 days ago.

End timestamp greater than current time will be truncated to current time.

Zero start timestamp is allowed and will default to 30 days from the end timestamp.

DB: read replica

Source code in derive_client/_clients/websockets/api.py
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
async def get_funding_rate_history(
    self,
    params: PublicGetFundingRateHistoryParamsSchema,
) -> PublicGetFundingRateHistoryResultSchema:
    """
    Get funding rate history. Start timestamp is restricted to at most 30 days ago.

    End timestamp greater than current time will be truncated to current time.

    Zero start timestamp is allowed and will default to 30 days from the end
    timestamp.

    DB: read replica
    """

    method = "public/get_funding_rate_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetFundingRateHistoryResultSchema)

    return result
get_trade_history async
get_trade_history(
    params: PublicGetTradeHistoryParamsSchema,
) -> PublicGetTradeHistoryResultSchema

Get trade history for a subaccount, with filter parameters.

Source code in derive_client/_clients/websockets/api.py
518
519
520
521
522
523
524
525
526
527
528
529
530
async def get_trade_history(
    self,
    params: PublicGetTradeHistoryParamsSchema,
) -> PublicGetTradeHistoryResultSchema:
    """
    Get trade history for a subaccount, with filter parameters.
    """

    method = "public/get_trade_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetTradeHistoryResultSchema)

    return result
get_option_settlement_history async
get_option_settlement_history(
    params: PublicGetOptionSettlementHistoryParamsSchema,
) -> PublicGetOptionSettlementHistoryResultSchema

Get expired option settlement history for a subaccount

Source code in derive_client/_clients/websockets/api.py
532
533
534
535
536
537
538
539
540
541
542
543
544
async def get_option_settlement_history(
    self,
    params: PublicGetOptionSettlementHistoryParamsSchema,
) -> PublicGetOptionSettlementHistoryResultSchema:
    """
    Get expired option settlement history for a subaccount
    """

    method = "public/get_option_settlement_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetOptionSettlementHistoryResultSchema)

    return result
get_liquidation_history async
get_liquidation_history(
    params: PublicGetLiquidationHistoryParamsSchema,
) -> PublicGetLiquidationHistoryResultSchema

Returns a paginated liquidation history for all subaccounts. Note that the pagination is based on the number of

raw events that include bids, auction start, and auction end events. This means that the count returned in the

pagination info will be larger than the total number of auction events. This also means the number of returned

auctions per page will be smaller than the supplied page_size.

Source code in derive_client/_clients/websockets/api.py
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
async def get_liquidation_history(
    self,
    params: PublicGetLiquidationHistoryParamsSchema,
) -> PublicGetLiquidationHistoryResultSchema:
    """
    Returns a paginated liquidation history for all subaccounts. Note that the
    pagination is based on the number of

    raw events that include bids, auction start, and auction end events. This means
    that the count returned in the

    pagination info will be larger than the total number of auction events. This
    also means the number of returned

    auctions per page will be smaller than the supplied `page_size`.
    """

    method = "public/get_liquidation_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetLiquidationHistoryResultSchema)

    return result
get_interest_rate_history async
get_interest_rate_history(
    params: PublicGetInterestRateHistoryParamsSchema,
) -> PublicGetInterestRateHistoryResultSchema

Get latest USDC interest rate history

Source code in derive_client/_clients/websockets/api.py
569
570
571
572
573
574
575
576
577
578
579
580
581
async def get_interest_rate_history(
    self,
    params: PublicGetInterestRateHistoryParamsSchema,
) -> PublicGetInterestRateHistoryResultSchema:
    """
    Get latest USDC interest rate history
    """

    method = "public/get_interest_rate_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetInterestRateHistoryResultSchema)

    return result
get_transaction async
get_transaction(
    params: PublicGetTransactionParamsSchema,
) -> PublicGetTransactionResultSchema

Used for getting a transaction by its transaction id

Source code in derive_client/_clients/websockets/api.py
583
584
585
586
587
588
589
590
591
592
593
594
595
async def get_transaction(
    self,
    params: PublicGetTransactionParamsSchema,
) -> PublicGetTransactionResultSchema:
    """
    Used for getting a transaction by its transaction id
    """

    method = "public/get_transaction"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetTransactionResultSchema)

    return result
get_margin async
get_margin(
    params: PublicGetMarginParamsSchema,
) -> PublicGetMarginResultSchema

Calculates margin for a given portfolio and (optionally) a simulated state change.

Does not take into account open orders margin requirements.public/withdraw_debug

Source code in derive_client/_clients/websockets/api.py
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
async def get_margin(
    self,
    params: PublicGetMarginParamsSchema,
) -> PublicGetMarginResultSchema:
    """
    Calculates margin for a given portfolio and (optionally) a simulated state
    change.

    Does not take into account open orders margin requirements.public/withdraw_debug
    """

    method = "public/get_margin"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetMarginResultSchema)

    return result
margin_watch async
margin_watch(
    params: PublicMarginWatchParamsSchema,
) -> PublicMarginWatchResultSchema

Calculates MtM and maintenance margin for a given subaccount.

Source code in derive_client/_clients/websockets/api.py
614
615
616
617
618
619
620
621
622
623
624
625
626
async def margin_watch(
    self,
    params: PublicMarginWatchParamsSchema,
) -> PublicMarginWatchResultSchema:
    """
    Calculates MtM and maintenance margin for a given subaccount.
    """

    method = "public/margin_watch"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicMarginWatchResultSchema)

    return result
get_vault_share async
get_vault_share(
    params: PublicGetVaultShareParamsSchema,
) -> PublicGetVaultShareResultSchema

Gets the value of a vault's token against the base currency, underlying currency, and USD for a timestamp range.

The name of the vault from the Vault proxy contract is used to fetch the vault's value.

Source code in derive_client/_clients/websockets/api.py
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
async def get_vault_share(
    self,
    params: PublicGetVaultShareParamsSchema,
) -> PublicGetVaultShareResultSchema:
    """
    Gets the value of a vault's token against the base currency, underlying
    currency, and USD for a timestamp range.

    The name of the vault from the Vault proxy contract is used to fetch the vault's
    value.
    """

    method = "public/get_vault_share"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetVaultShareResultSchema)

    return result
get_vault_statistics async
get_vault_statistics(
    params: PublicGetVaultStatisticsParamsSchema,
) -> list[VaultStatisticsResponseSchema]

Gets all the latest vault shareRate, totalSupply and TVL values for all vaults.

For data on shares across chains, use public/get_vault_assets.

Source code in derive_client/_clients/websockets/api.py
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
async def get_vault_statistics(
    self,
    params: PublicGetVaultStatisticsParamsSchema,
) -> list[VaultStatisticsResponseSchema]:
    """
    Gets all the latest vault shareRate, totalSupply and TVL values for all vaults.

    For data on shares across chains, use public/get_vault_assets.
    """

    method = "public/get_vault_statistics"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[VaultStatisticsResponseSchema])

    return result
get_vault_balances async
get_vault_balances(
    params: PublicGetVaultBalancesParamsSchema,
) -> list[VaultBalanceResponseSchema]

Get all vault assets held by user. Can query by smart contract address or smart contract owner.

Includes VaultERC20Pool balances

Source code in derive_client/_clients/websockets/api.py
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
async def get_vault_balances(
    self,
    params: PublicGetVaultBalancesParamsSchema,
) -> list[VaultBalanceResponseSchema]:
    """
    Get all vault assets held by user. Can query by smart contract address or smart
    contract owner.

    Includes VaultERC20Pool balances
    """

    method = "public/get_vault_balances"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[VaultBalanceResponseSchema])

    return result
create_subaccount_debug async
create_subaccount_debug(
    params: PublicCreateSubaccountDebugParamsSchema,
) -> PublicCreateSubaccountDebugResultSchema

Used for debugging only, do not use in production. Will return the incremental encoded and hashed data.

See guides in Documentation for more.

Source code in derive_client/_clients/websockets/api.py
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
async def create_subaccount_debug(
    self,
    params: PublicCreateSubaccountDebugParamsSchema,
) -> PublicCreateSubaccountDebugResultSchema:
    """
    Used for debugging only, do not use in production. Will return the incremental
    encoded and hashed data.

    See guides in Documentation for more.
    """

    method = "public/create_subaccount_debug"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicCreateSubaccountDebugResultSchema)

    return result
deposit_debug async
deposit_debug(
    params: PublicDepositDebugParamsSchema,
) -> PublicDepositDebugResultSchema

Used for debugging only, do not use in production. Will return the incremental encoded and hashed data.

See guides in Documentation for more.

Source code in derive_client/_clients/websockets/api.py
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
async def deposit_debug(
    self,
    params: PublicDepositDebugParamsSchema,
) -> PublicDepositDebugResultSchema:
    """
    Used for debugging only, do not use in production. Will return the incremental
    encoded and hashed data.

    See guides in Documentation for more.
    """

    method = "public/deposit_debug"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicDepositDebugResultSchema)

    return result
withdraw_debug async
withdraw_debug(
    params: PublicWithdrawDebugParamsSchema,
) -> PublicWithdrawDebugResultSchema

Used for debugging only, do not use in production. Will return the incremental encoded and hashed data.

See guides in Documentation for more.

Source code in derive_client/_clients/websockets/api.py
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
async def withdraw_debug(
    self,
    params: PublicWithdrawDebugParamsSchema,
) -> PublicWithdrawDebugResultSchema:
    """
    Used for debugging only, do not use in production. Will return the incremental
    encoded and hashed data.

    See guides in Documentation for more.
    """

    method = "public/withdraw_debug"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicWithdrawDebugResultSchema)

    return result
send_quote_debug async
send_quote_debug(
    params: PublicSendQuoteDebugParamsSchema,
) -> PublicSendQuoteDebugResultSchema

Sends a quote in response to an RFQ request.

The legs supplied in the parameters must exactly match those in the RFQ.

Source code in derive_client/_clients/websockets/api.py
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
async def send_quote_debug(
    self,
    params: PublicSendQuoteDebugParamsSchema,
) -> PublicSendQuoteDebugResultSchema:
    """
    Sends a quote in response to an RFQ request.

    The legs supplied in the parameters must exactly match those in the RFQ.
    """

    method = "public/send_quote_debug"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicSendQuoteDebugResultSchema)

    return result
execute_quote_debug async
execute_quote_debug(
    params: PublicExecuteQuoteDebugParamsSchema,
) -> PublicExecuteQuoteDebugResultSchema

Sends a quote in response to an RFQ request.

The legs supplied in the parameters must exactly match those in the RFQ.

Source code in derive_client/_clients/websockets/api.py
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
async def execute_quote_debug(
    self,
    params: PublicExecuteQuoteDebugParamsSchema,
) -> PublicExecuteQuoteDebugResultSchema:
    """
    Sends a quote in response to an RFQ request.

    The legs supplied in the parameters must exactly match those in the RFQ.
    """

    method = "public/execute_quote_debug"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicExecuteQuoteDebugResultSchema)

    return result
get_maker_programs async
get_maker_programs(
    params: PublicGetMakerProgramsParamsSchema,
) -> list[ProgramResponseSchema]

Get all maker programs, including past / historical ones.

Source code in derive_client/_clients/websockets/api.py
782
783
784
785
786
787
788
789
790
791
792
793
794
async def get_maker_programs(
    self,
    params: PublicGetMakerProgramsParamsSchema,
) -> list[ProgramResponseSchema]:
    """
    Get all maker programs, including past / historical ones.
    """

    method = "public/get_maker_programs"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[ProgramResponseSchema])

    return result
get_maker_program_scores async
get_maker_program_scores(
    params: PublicGetMakerProgramScoresParamsSchema,
) -> PublicGetMakerProgramScoresResultSchema

Get scores breakdown by maker program.

Source code in derive_client/_clients/websockets/api.py
796
797
798
799
800
801
802
803
804
805
806
807
808
async def get_maker_program_scores(
    self,
    params: PublicGetMakerProgramScoresParamsSchema,
) -> PublicGetMakerProgramScoresResultSchema:
    """
    Get scores breakdown by maker program.
    """

    method = "public/get_maker_program_scores"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetMakerProgramScoresResultSchema)

    return result
get_referral_performance async
get_referral_performance(
    params: PublicGetReferralPerformanceParamsSchema,
) -> PublicGetReferralPerformanceResultSchema

Get the broker program referral performance. Epochs are 28 days long.

Source code in derive_client/_clients/websockets/api.py
810
811
812
813
814
815
816
817
818
819
820
821
822
async def get_referral_performance(
    self,
    params: PublicGetReferralPerformanceParamsSchema,
) -> PublicGetReferralPerformanceResultSchema:
    """
    Get the broker program referral performance. Epochs are 28 days long.
    """

    method = "public/get_referral_performance"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PublicGetReferralPerformanceResultSchema)

    return result

PrivateRPC

PrivateRPC(session: WebSocketSession)

private RPC methods

Source code in derive_client/_clients/websockets/api.py
828
829
def __init__(self, session: WebSocketSession):
    self._session = session
Functions
get_account async
get_account(
    params: PrivateGetAccountParamsSchema,
) -> PrivateGetAccountResultSchema

Account details getter

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
async def get_account(
    self,
    params: PrivateGetAccountParamsSchema,
) -> PrivateGetAccountResultSchema:
    """
    Account details getter

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_account"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetAccountResultSchema)

    return result
create_subaccount async
create_subaccount(
    params: PrivateCreateSubaccountParamsSchema,
) -> PrivateCreateSubaccountResultSchema

Create a new subaccount under a given wallet, and deposit an asset into that subaccount.

See public/create_subaccount_debug for debugging invalid signature issues or go to guides in Documentation.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
async def create_subaccount(
    self,
    params: PrivateCreateSubaccountParamsSchema,
) -> PrivateCreateSubaccountResultSchema:
    """
    Create a new subaccount under a given wallet, and deposit an asset into that
    subaccount.

    See `public/create_subaccount_debug` for debugging invalid signature issues or
    go to guides in Documentation.

    Required minimum session key permission level is `admin`
    """

    method = "private/create_subaccount"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCreateSubaccountResultSchema)

    return result
get_subaccount async
get_subaccount(
    params: PrivateGetSubaccountParamsSchema,
) -> PrivateGetSubaccountResultSchema

Get open orders, active positions, and collaterals of a subaccount

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
async def get_subaccount(
    self,
    params: PrivateGetSubaccountParamsSchema,
) -> PrivateGetSubaccountResultSchema:
    """
    Get open orders, active positions, and collaterals of a subaccount

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_subaccount"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetSubaccountResultSchema)

    return result
get_subaccounts async
get_subaccounts(
    params: PrivateGetSubaccountsParamsSchema,
) -> PrivateGetSubaccountsResultSchema

Get all subaccounts of an account / wallet

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
async def get_subaccounts(
    self,
    params: PrivateGetSubaccountsParamsSchema,
) -> PrivateGetSubaccountsResultSchema:
    """
    Get all subaccounts of an account / wallet

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_subaccounts"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetSubaccountsResultSchema)

    return result
get_all_portfolios async
get_all_portfolios(
    params: PrivateGetAllPortfoliosParamsSchema,
) -> List[PrivateGetSubaccountResultSchema]

Get all portfolios of a wallet

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
async def get_all_portfolios(
    self,
    params: PrivateGetAllPortfoliosParamsSchema,
) -> List[PrivateGetSubaccountResultSchema]:
    """
    Get all portfolios of a wallet

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_all_portfolios"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[PrivateGetSubaccountResultSchema])

    return result
change_subaccount_label async
change_subaccount_label(
    params: PrivateChangeSubaccountLabelParamsSchema,
) -> PrivateChangeSubaccountLabelResultSchema

Change a user defined label for given subaccount

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
async def change_subaccount_label(
    self,
    params: PrivateChangeSubaccountLabelParamsSchema,
) -> PrivateChangeSubaccountLabelResultSchema:
    """
    Change a user defined label for given subaccount

    Required minimum session key permission level is `account`
    """

    method = "private/change_subaccount_label"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateChangeSubaccountLabelResultSchema)

    return result
get_notifications async
get_notifications(
    params: PrivateGetNotificationsParamsSchema,
) -> PrivateGetNotificationsResultSchema

Get the notifications related to a subaccount.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
async def get_notifications(
    self,
    params: PrivateGetNotificationsParamsSchema,
) -> PrivateGetNotificationsResultSchema:
    """
    Get the notifications related to a subaccount.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_notifications"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetNotificationsResultSchema)

    return result
update_notifications async
update_notifications(
    params: PrivateUpdateNotificationsParamsSchema,
) -> PrivateUpdateNotificationsResultSchema

RPC to mark specified notifications as seen for a given subaccount.

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
async def update_notifications(
    self,
    params: PrivateUpdateNotificationsParamsSchema,
) -> PrivateUpdateNotificationsResultSchema:
    """
    RPC to mark specified notifications as seen for a given subaccount.

    Required minimum session key permission level is `account`
    """

    method = "private/update_notifications"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateUpdateNotificationsResultSchema)

    return result
deposit async
deposit(
    params: PrivateDepositParamsSchema,
) -> PrivateDepositResultSchema

Deposit an asset to a subaccount.

See `public/deposit_debug' for debugging invalid signature issues or go to guides in Documentation.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
async def deposit(
    self,
    params: PrivateDepositParamsSchema,
) -> PrivateDepositResultSchema:
    """
    Deposit an asset to a subaccount.

    See `public/deposit_debug' for debugging invalid signature issues or go to
    guides in Documentation.

    Required minimum session key permission level is `admin`
    """

    method = "private/deposit"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateDepositResultSchema)

    return result
withdraw async
withdraw(
    params: PrivateWithdrawParamsSchema,
) -> PrivateWithdrawResultSchema

Withdraw an asset to wallet.

See public/withdraw_debug for debugging invalid signature issues or go to guides in Documentation.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
async def withdraw(
    self,
    params: PrivateWithdrawParamsSchema,
) -> PrivateWithdrawResultSchema:
    """
    Withdraw an asset to wallet.

    See `public/withdraw_debug` for debugging invalid signature issues or go to
    guides in Documentation.

    Required minimum session key permission level is `admin`
    """

    method = "private/withdraw"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateWithdrawResultSchema)

    return result
transfer_erc20 async
transfer_erc20(
    params: PrivateTransferErc20ParamsSchema,
) -> PrivateTransferErc20ResultSchema

Transfer ERC20 assets from one subaccount to another (e.g. USDC or ETH).

For transfering positions (e.g. options or perps), use private/transfer_position instead.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
async def transfer_erc20(
    self,
    params: PrivateTransferErc20ParamsSchema,
) -> PrivateTransferErc20ResultSchema:
    """
    Transfer ERC20 assets from one subaccount to another (e.g. USDC or ETH).

    For transfering positions (e.g. options or perps), use
    `private/transfer_position` instead.

    Required minimum session key permission level is `admin`
    """

    method = "private/transfer_erc20"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateTransferErc20ResultSchema)

    return result
transfer_position async
transfer_position(
    params: PrivateTransferPositionParamsSchema,
) -> PrivateTransferPositionResultSchema

Transfers a positions from one subaccount to another, owned by the same wallet.

The transfer is executed as a pair of orders crossing each other.

The maker order is created first, followed by a taker order crossing it.

The order amounts, limit prices and instrument name must be the same for both orders.

Fee is not charged and a zero max_fee must be signed.

The maker order is forcibly considered to be reduce_only, meaning it can only reduce the position size.

History: For position transfer history, use the private/get_trade_history RPC (not private/get_erc20_transfer_history).

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
async def transfer_position(
    self,
    params: PrivateTransferPositionParamsSchema,
) -> PrivateTransferPositionResultSchema:
    """
    Transfers a positions from one subaccount to another, owned by the same wallet.

    The transfer is executed as a pair of orders crossing each other.

    The maker order is created first, followed by a taker order crossing it.

    The order amounts, limit prices and instrument name must be the same for both
    orders.

    Fee is not charged and a zero `max_fee` must be signed.

    The maker order is forcibly considered to be `reduce_only`, meaning it can only
    reduce the position size.

    History: For position transfer history, use the `private/get_trade_history` RPC
    (not `private/get_erc20_transfer_history`).

    Required minimum session key permission level is `admin`
    """

    method = "private/transfer_position"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateTransferPositionResultSchema)

    return result
transfer_positions async
transfer_positions(
    params: PrivateTransferPositionsParamsSchema,
) -> PrivateTransferPositionsResultSchema

Transfers multiple positions from one subaccount to another, owned by the same wallet.

The transfer is executed as a an RFQ. A mock RFQ is first created from the taker parameters, followed by a maker quote and a taker execute.

The leg amounts, prices and instrument name must be the same in both param payloads.

Fee is not charged and a zero max_fee must be signed.

Every leg in the transfer must be a position reduction for either maker or taker (or both).

History: for position transfer history, use the private/get_trade_history RPC (not private/get_erc20_transfer_history).

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
async def transfer_positions(
    self,
    params: PrivateTransferPositionsParamsSchema,
) -> PrivateTransferPositionsResultSchema:
    """
    Transfers multiple positions from one subaccount to another, owned by the same
    wallet.

    The transfer is executed as a an RFQ. A mock RFQ is first created from the taker
    parameters, followed by a maker quote and a taker execute.

    The leg amounts, prices and instrument name must be the same in both param
    payloads.

    Fee is not charged and a zero `max_fee` must be signed.

    Every leg in the transfer must be a position reduction for either maker or taker
    (or both).

    History: for position transfer history, use the `private/get_trade_history` RPC
    (not `private/get_erc20_transfer_history`).

    Required minimum session key permission level is `admin`
    """

    method = "private/transfer_positions"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateTransferPositionsResultSchema)

    return result
order async
order(
    params: PrivateOrderParamsSchema,
) -> PrivateOrderResultSchema

Create a new order.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
async def order(
    self,
    params: PrivateOrderParamsSchema,
) -> PrivateOrderResultSchema:
    """
    Create a new order.

    Required minimum session key permission level is `admin`
    """

    method = "private/order"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateOrderResultSchema)

    return result
replace async
replace(
    params: PrivateReplaceParamsSchema,
) -> PrivateReplaceResultSchema

Cancel an existing order with nonce or order_id and create new order with different order_id in a single RPC call.

If the cancel fails, the new order will not be created.

If the cancel succeeds but the new order fails, the old order will still be cancelled.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
async def replace(
    self,
    params: PrivateReplaceParamsSchema,
) -> PrivateReplaceResultSchema:
    """
    Cancel an existing order with nonce or order_id and create new order with
    different order_id in a single RPC call.

    If the cancel fails, the new order will not be created.

    If the cancel succeeds but the new order fails, the old order will still be
    cancelled.

    Required minimum session key permission level is `admin`
    """

    method = "private/replace"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateReplaceResultSchema)

    return result
order_debug async
order_debug(
    params: PrivateOrderDebugParamsSchema,
) -> PrivateOrderDebugResultSchema

Debug a new order

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
async def order_debug(
    self,
    params: PrivateOrderDebugParamsSchema,
) -> PrivateOrderDebugResultSchema:
    """
    Debug a new order

    Required minimum session key permission level is `read_only`
    """

    method = "private/order_debug"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateOrderDebugResultSchema)

    return result
get_order async
get_order(
    params: PrivateGetOrderParamsSchema,
) -> PrivateGetOrderResultSchema

Get state of an order by order id. If the order is an MMP order, it will not show up if cancelled/expired.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
async def get_order(
    self,
    params: PrivateGetOrderParamsSchema,
) -> PrivateGetOrderResultSchema:
    """
    Get state of an order by order id.  If the order is an MMP order, it will not
    show up if cancelled/expired.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_order"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetOrderResultSchema)

    return result
get_orders async
get_orders(
    params: PrivateGetOrdersParamsSchema,
) -> PrivateGetOrdersResultSchema

Get orders for a subaccount, with optional filtering.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
async def get_orders(
    self,
    params: PrivateGetOrdersParamsSchema,
) -> PrivateGetOrdersResultSchema:
    """
    Get orders for a subaccount, with optional filtering.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_orders"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetOrdersResultSchema)

    return result
get_open_orders async
get_open_orders(
    params: PrivateGetOpenOrdersParamsSchema,
) -> PrivateGetOpenOrdersResultSchema

Get all open orders of a subacccount

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
async def get_open_orders(
    self,
    params: PrivateGetOpenOrdersParamsSchema,
) -> PrivateGetOpenOrdersResultSchema:
    """
    Get all open orders of a subacccount

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_open_orders"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetOpenOrdersResultSchema)

    return result
cancel async
cancel(
    params: PrivateCancelParamsSchema,
) -> PrivateCancelResultSchema

Cancel a single order.

Other private/cancel_* routes are available through both REST and WebSocket.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
async def cancel(
    self,
    params: PrivateCancelParamsSchema,
) -> PrivateCancelResultSchema:
    """
    Cancel a single order.

    Other `private/cancel_*` routes are available through both REST and WebSocket.

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCancelResultSchema)

    return result
cancel_all async
cancel_all(params: PrivateCancelAllParamsSchema) -> Result

Cancel all orders for this instrument.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
async def cancel_all(
    self,
    params: PrivateCancelAllParamsSchema,
) -> Result:
    """
    Cancel all orders for this instrument.

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel_all"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, Result)

    return result
cancel_by_label async
cancel_by_label(
    params: PrivateCancelByLabelParamsSchema,
) -> PrivateCancelByLabelResultSchema

Cancel all open orders for a given subaccount and a given label. If instrument_name is provided, only orders for that instrument will be cancelled.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
async def cancel_by_label(
    self,
    params: PrivateCancelByLabelParamsSchema,
) -> PrivateCancelByLabelResultSchema:
    """
    Cancel all open orders for a given subaccount and a given label.  If
    instrument_name is provided, only orders for that instrument will be cancelled.

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel_by_label"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCancelByLabelResultSchema)

    return result
cancel_by_nonce async
cancel_by_nonce(
    params: PrivateCancelByNonceParamsSchema,
) -> PrivateCancelByNonceResultSchema

Cancel a single order by nonce. Uses up that nonce if the order does not exist, so any future orders with that nonce will fail

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
async def cancel_by_nonce(
    self,
    params: PrivateCancelByNonceParamsSchema,
) -> PrivateCancelByNonceResultSchema:
    """
    Cancel a single order by nonce. Uses up that nonce if the order does not exist,
    so any future orders with that nonce will fail

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel_by_nonce"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCancelByNonceResultSchema)

    return result
cancel_by_instrument async
cancel_by_instrument(
    params: PrivateCancelByInstrumentParamsSchema,
) -> PrivateCancelByInstrumentResultSchema

Cancel all orders for this instrument.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
async def cancel_by_instrument(
    self,
    params: PrivateCancelByInstrumentParamsSchema,
) -> PrivateCancelByInstrumentResultSchema:
    """
    Cancel all orders for this instrument.

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel_by_instrument"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCancelByInstrumentResultSchema)

    return result
cancel_trigger_order async
cancel_trigger_order(
    params: PrivateCancelTriggerOrderParamsSchema,
) -> PrivateCancelTriggerOrderResultSchema

Cancels a trigger order.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
async def cancel_trigger_order(
    self,
    params: PrivateCancelTriggerOrderParamsSchema,
) -> PrivateCancelTriggerOrderResultSchema:
    """
    Cancels a trigger order.

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel_trigger_order"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCancelTriggerOrderResultSchema)

    return result
cancel_all_trigger_orders async
cancel_all_trigger_orders(
    params: PrivateCancelAllTriggerOrdersParamsSchema,
) -> Result

Cancel all trigger orders for this subaccount.

Also used by cancel_all in WS.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
async def cancel_all_trigger_orders(
    self,
    params: PrivateCancelAllTriggerOrdersParamsSchema,
) -> Result:
    """
    Cancel all trigger orders for this subaccount.

    Also used by cancel_all in WS.

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel_all_trigger_orders"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, Result)

    return result
get_order_history async
get_order_history(
    params: PrivateGetOrderHistoryParamsSchema,
) -> PrivateGetOrderHistoryResultSchema

Get order history for a subaccount

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
async def get_order_history(
    self,
    params: PrivateGetOrderHistoryParamsSchema,
) -> PrivateGetOrderHistoryResultSchema:
    """
    Get order history for a subaccount

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_order_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetOrderHistoryResultSchema)

    return result
get_trade_history async
get_trade_history(
    params: PrivateGetTradeHistoryParamsSchema,
) -> PrivateGetTradeHistoryResultSchema

Get trade history for a subaccount, with filter parameters.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
async def get_trade_history(
    self,
    params: PrivateGetTradeHistoryParamsSchema,
) -> PrivateGetTradeHistoryResultSchema:
    """
    Get trade history for a subaccount, with filter parameters.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_trade_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetTradeHistoryResultSchema)

    return result
get_deposit_history async
get_deposit_history(
    params: PrivateGetDepositHistoryParamsSchema,
) -> PrivateGetDepositHistoryResultSchema

Get subaccount deposit history.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
async def get_deposit_history(
    self,
    params: PrivateGetDepositHistoryParamsSchema,
) -> PrivateGetDepositHistoryResultSchema:
    """
    Get subaccount deposit history.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_deposit_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetDepositHistoryResultSchema)

    return result
get_withdrawal_history async
get_withdrawal_history(
    params: PrivateGetWithdrawalHistoryParamsSchema,
) -> PrivateGetWithdrawalHistoryResultSchema

Get subaccount withdrawal history.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
async def get_withdrawal_history(
    self,
    params: PrivateGetWithdrawalHistoryParamsSchema,
) -> PrivateGetWithdrawalHistoryResultSchema:
    """
    Get subaccount withdrawal history.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_withdrawal_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetWithdrawalHistoryResultSchema)

    return result
send_rfq async
send_rfq(
    params: PrivateSendRfqParamsSchema,
) -> PrivateSendRfqResultSchema

Requests two-sided quotes from participating market makers.

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
async def send_rfq(
    self,
    params: PrivateSendRfqParamsSchema,
) -> PrivateSendRfqResultSchema:
    """
    Requests two-sided quotes from participating market makers.

    Required minimum session key permission level is `account`
    """

    method = "private/send_rfq"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateSendRfqResultSchema)

    return result
cancel_rfq async
cancel_rfq(params: PrivateCancelRfqParamsSchema) -> Result

Cancels a single RFQ by id.

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
async def cancel_rfq(
    self,
    params: PrivateCancelRfqParamsSchema,
) -> Result:
    """
    Cancels a single RFQ by id.

    Required minimum session key permission level is `account`
    """

    method = "private/cancel_rfq"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, Result)

    return result
cancel_batch_rfqs async
cancel_batch_rfqs(
    params: PrivateCancelBatchRfqsParamsSchema,
) -> PrivateCancelBatchRfqsResultSchema

Cancels RFQs given optional filters.

If no filters are provided, all RFQs for the subaccount are cancelled.

All filters are combined using AND logic, so mutually exclusive filters will result in no RFQs being cancelled.

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
async def cancel_batch_rfqs(
    self,
    params: PrivateCancelBatchRfqsParamsSchema,
) -> PrivateCancelBatchRfqsResultSchema:
    """
    Cancels RFQs given optional filters.

    If no filters are provided, all RFQs for the subaccount are cancelled.

    All filters are combined using `AND` logic, so mutually exclusive filters will
    result in no RFQs being cancelled.

    Required minimum session key permission level is `account`
    """

    method = "private/cancel_batch_rfqs"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCancelBatchRfqsResultSchema)

    return result
get_rfqs async
get_rfqs(
    params: PrivateGetRfqsParamsSchema,
) -> PrivateGetRfqsResultSchema

Retrieves a list of RFQs matching filter criteria. Takers can use this to get their open RFQs, RFQ history, etc.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
async def get_rfqs(
    self,
    params: PrivateGetRfqsParamsSchema,
) -> PrivateGetRfqsResultSchema:
    """
    Retrieves a list of RFQs matching filter criteria. Takers can use this to get
    their open RFQs, RFQ history, etc.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_rfqs"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetRfqsResultSchema)

    return result
poll_rfqs async
poll_rfqs(
    params: PrivatePollRfqsParamsSchema,
) -> PrivatePollRfqsResultSchema

Retrieves a list of RFQs matching filter criteria. Market makers can use this to poll RFQs directed to them.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
async def poll_rfqs(
    self,
    params: PrivatePollRfqsParamsSchema,
) -> PrivatePollRfqsResultSchema:
    """
    Retrieves a list of RFQs matching filter criteria. Market makers can use this to
    poll RFQs directed to them.

    Required minimum session key permission level is `read_only`
    """

    method = "private/poll_rfqs"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivatePollRfqsResultSchema)

    return result
send_quote async
send_quote(
    params: PrivateSendQuoteParamsSchema,
) -> PrivateSendQuoteResultSchema

Sends a quote in response to an RFQ request.

The legs supplied in the parameters must exactly match those in the RFQ.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
async def send_quote(
    self,
    params: PrivateSendQuoteParamsSchema,
) -> PrivateSendQuoteResultSchema:
    """
    Sends a quote in response to an RFQ request.

    The legs supplied in the parameters must exactly match those in the RFQ.

    Required minimum session key permission level is `admin`
    """

    method = "private/send_quote"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateSendQuoteResultSchema)

    return result
replace_quote async
replace_quote(
    params: PrivateReplaceQuoteParamsSchema,
) -> PrivateReplaceQuoteResultSchema

Cancel an existing quote with nonce or quote_id and create new quote with different quote_id in a single RPC call.

If the cancel fails, the new quote will not be created.

If the cancel succeeds but the new quote fails, the old quote will still be cancelled.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
async def replace_quote(
    self,
    params: PrivateReplaceQuoteParamsSchema,
) -> PrivateReplaceQuoteResultSchema:
    """
    Cancel an existing quote with nonce or quote_id and create new quote with
    different quote_id in a single RPC call.

    If the cancel fails, the new quote will not be created.

    If the cancel succeeds but the new quote fails, the old quote will still be
    cancelled.

    Required minimum session key permission level is `admin`
    """

    method = "private/replace_quote"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateReplaceQuoteResultSchema)

    return result
cancel_quote async
cancel_quote(
    params: PrivateCancelQuoteParamsSchema,
) -> PrivateCancelQuoteResultSchema

Cancels an open quote.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
async def cancel_quote(
    self,
    params: PrivateCancelQuoteParamsSchema,
) -> PrivateCancelQuoteResultSchema:
    """
    Cancels an open quote.

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel_quote"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCancelQuoteResultSchema)

    return result
cancel_batch_quotes async
cancel_batch_quotes(
    params: PrivateCancelBatchQuotesParamsSchema,
) -> PrivateCancelBatchQuotesResultSchema

Cancels quotes given optional filters. If no filters are provided, all quotes by the subaccount are cancelled.

All filters are combined using AND logic, so mutually exclusive filters will result in no quotes being cancelled.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
async def cancel_batch_quotes(
    self,
    params: PrivateCancelBatchQuotesParamsSchema,
) -> PrivateCancelBatchQuotesResultSchema:
    """
    Cancels quotes given optional filters. If no filters are provided, all quotes by
    the subaccount are cancelled.

    All filters are combined using `AND` logic, so mutually exclusive filters will
    result in no quotes being cancelled.

    Required minimum session key permission level is `admin`
    """

    method = "private/cancel_batch_quotes"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateCancelBatchQuotesResultSchema)

    return result
get_quotes async
get_quotes(
    params: PrivateGetQuotesParamsSchema,
) -> PrivateGetQuotesResultSchema

Retrieves a list of quotes matching filter criteria.

Market makers can use this to get their open quotes, quote history, etc.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
async def get_quotes(
    self,
    params: PrivateGetQuotesParamsSchema,
) -> PrivateGetQuotesResultSchema:
    """
    Retrieves a list of quotes matching filter criteria.

    Market makers can use this to get their open quotes, quote history, etc.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_quotes"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetQuotesResultSchema)

    return result
poll_quotes async
poll_quotes(
    params: PrivatePollQuotesParamsSchema,
) -> PrivatePollQuotesResultSchema

Retrieves a list of quotes matching filter criteria.

Takers can use this to poll open quotes that they can fill against their open RFQs.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
async def poll_quotes(
    self,
    params: PrivatePollQuotesParamsSchema,
) -> PrivatePollQuotesResultSchema:
    """
    Retrieves a list of quotes matching filter criteria.

    Takers can use this to poll open quotes that they can fill against their open
    RFQs.

    Required minimum session key permission level is `read_only`
    """

    method = "private/poll_quotes"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivatePollQuotesResultSchema)

    return result
execute_quote async
execute_quote(
    params: PrivateExecuteQuoteParamsSchema,
) -> PrivateExecuteQuoteResultSchema

Executes a quote.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
async def execute_quote(
    self,
    params: PrivateExecuteQuoteParamsSchema,
) -> PrivateExecuteQuoteResultSchema:
    """
    Executes a quote.

    Required minimum session key permission level is `admin`
    """

    method = "private/execute_quote"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateExecuteQuoteResultSchema)

    return result
rfq_get_best_quote async
rfq_get_best_quote(
    params: PrivateRfqGetBestQuoteParamsSchema,
) -> PrivateRfqGetBestQuoteResultSchema

Performs a "dry run" on an RFQ, returning the estimated fee and whether the trade is expected to pass.

Should any exception be raised in the process of evaluating the trade, a standard RPC error will be returned

with the error details.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
async def rfq_get_best_quote(
    self,
    params: PrivateRfqGetBestQuoteParamsSchema,
) -> PrivateRfqGetBestQuoteResultSchema:
    """
    Performs a "dry run" on an RFQ, returning the estimated fee and whether the
    trade is expected to pass.

    Should any exception be raised in the process of evaluating the trade, a
    standard RPC error will be returned

    with the error details.

    Required minimum session key permission level is `read_only`
    """

    method = "private/rfq_get_best_quote"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateRfqGetBestQuoteResultSchema)

    return result
get_margin async
get_margin(
    params: PrivateGetMarginParamsSchema,
) -> PrivateGetMarginResultSchema

Calculates margin for a given subaccount and (optionally) a simulated state change. Does not take into account

open orders margin requirements.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
async def get_margin(
    self,
    params: PrivateGetMarginParamsSchema,
) -> PrivateGetMarginResultSchema:
    """
    Calculates margin for a given subaccount and (optionally) a simulated state
    change. Does not take into account

    open orders margin requirements.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_margin"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetMarginResultSchema)

    return result
get_collaterals async
get_collaterals(
    params: PrivateGetCollateralsParamsSchema,
) -> PrivateGetCollateralsResultSchema

Get collaterals of a subaccount

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
async def get_collaterals(
    self,
    params: PrivateGetCollateralsParamsSchema,
) -> PrivateGetCollateralsResultSchema:
    """
    Get collaterals of a subaccount

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_collaterals"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetCollateralsResultSchema)

    return result
get_positions async
get_positions(
    params: PrivateGetPositionsParamsSchema,
) -> PrivateGetPositionsResultSchema

Get active positions of a subaccount

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
async def get_positions(
    self,
    params: PrivateGetPositionsParamsSchema,
) -> PrivateGetPositionsResultSchema:
    """
    Get active positions of a subaccount

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_positions"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetPositionsResultSchema)

    return result
get_option_settlement_history async
get_option_settlement_history(
    params: PrivateGetOptionSettlementHistoryParamsSchema,
) -> PrivateGetOptionSettlementHistoryResultSchema

Get expired option settlement history for a subaccount

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
async def get_option_settlement_history(
    self,
    params: PrivateGetOptionSettlementHistoryParamsSchema,
) -> PrivateGetOptionSettlementHistoryResultSchema:
    """
    Get expired option settlement history for a subaccount

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_option_settlement_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetOptionSettlementHistoryResultSchema)

    return result
get_subaccount_value_history async
get_subaccount_value_history(
    params: PrivateGetSubaccountValueHistoryParamsSchema,
) -> PrivateGetSubaccountValueHistoryResultSchema

Get the value history of a subaccount

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
async def get_subaccount_value_history(
    self,
    params: PrivateGetSubaccountValueHistoryParamsSchema,
) -> PrivateGetSubaccountValueHistoryResultSchema:
    """
    Get the value history of a subaccount

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_subaccount_value_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetSubaccountValueHistoryResultSchema)

    return result
expired_and_cancelled_history async
expired_and_cancelled_history(
    params: PrivateExpiredAndCancelledHistoryParamsSchema,
) -> PrivateExpiredAndCancelledHistoryResultSchema

Generate a list of URLs to retrieve archived orders

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
async def expired_and_cancelled_history(
    self,
    params: PrivateExpiredAndCancelledHistoryParamsSchema,
) -> PrivateExpiredAndCancelledHistoryResultSchema:
    """
    Generate a list of URLs to retrieve archived orders

    Required minimum session key permission level is `read_only`
    """

    method = "private/expired_and_cancelled_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateExpiredAndCancelledHistoryResultSchema)

    return result
get_funding_history async
get_funding_history(
    params: PrivateGetFundingHistoryParamsSchema,
) -> PrivateGetFundingHistoryResultSchema

Get subaccount funding history.

DB: read replica

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
async def get_funding_history(
    self,
    params: PrivateGetFundingHistoryParamsSchema,
) -> PrivateGetFundingHistoryResultSchema:
    """
    Get subaccount funding history.

    DB: read replica

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_funding_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetFundingHistoryResultSchema)

    return result
get_interest_history async
get_interest_history(
    params: PrivateGetInterestHistoryParamsSchema,
) -> PrivateGetInterestHistoryResultSchema

Get subaccount interest payment history.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
async def get_interest_history(
    self,
    params: PrivateGetInterestHistoryParamsSchema,
) -> PrivateGetInterestHistoryResultSchema:
    """
    Get subaccount interest payment history.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_interest_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetInterestHistoryResultSchema)

    return result
get_erc20_transfer_history async
get_erc20_transfer_history(
    params: PrivateGetErc20TransferHistoryParamsSchema,
) -> PrivateGetErc20TransferHistoryResultSchema

Get subaccount erc20 transfer history.

Position transfers (e.g. options or perps) are treated as trades. Use private/get_trade_history for position transfer history.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
async def get_erc20_transfer_history(
    self,
    params: PrivateGetErc20TransferHistoryParamsSchema,
) -> PrivateGetErc20TransferHistoryResultSchema:
    """
    Get subaccount erc20 transfer history.

    Position transfers (e.g. options or perps) are treated as trades. Use
    `private/get_trade_history` for position transfer history.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_erc20_transfer_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetErc20TransferHistoryResultSchema)

    return result
get_liquidation_history async
get_liquidation_history(
    params: PrivateGetLiquidationHistoryParamsSchema,
) -> List[AuctionHistoryResultSchema]

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
async def get_liquidation_history(
    self,
    params: PrivateGetLiquidationHistoryParamsSchema,
) -> List[AuctionHistoryResultSchema]:
    """
    Required minimum session key permission level is `read_only`
    """

    method = "private/get_liquidation_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[AuctionHistoryResultSchema])

    return result
liquidate async
liquidate(
    params: PrivateLiquidateParamsSchema,
) -> PrivateLiquidateResultSchema

Liquidates a given subaccount using funds from another subaccount. This endpoint has a few limitations:

  1. If succesful, the RPC will freeze the caller's subaccount until the bid is settled or is reverted on chain.

  2. The caller's subaccount must not have any open orders.

  3. The caller's subaccount must have enough withdrawable cash to cover the bid and the buffer margin requirements.

Required minimum session key permission level is admin

Source code in derive_client/_clients/websockets/api.py
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
async def liquidate(
    self,
    params: PrivateLiquidateParamsSchema,
) -> PrivateLiquidateResultSchema:
    """
    Liquidates a given subaccount using funds from another subaccount. This endpoint
    has a few limitations:

    1. If succesful, the RPC will freeze the caller's subaccount until the bid is
    settled or is reverted on chain.

    2. The caller's subaccount must not have any open orders.

    3. The caller's subaccount must have enough withdrawable cash to cover the bid
    and the buffer margin requirements.

    Required minimum session key permission level is `admin`
    """

    method = "private/liquidate"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateLiquidateResultSchema)

    return result
get_liquidator_history async
get_liquidator_history(
    params: PrivateGetLiquidatorHistoryParamsSchema,
) -> PrivateGetLiquidatorHistoryResultSchema

Returns a paginated history of auctions that the subaccount has participated in as a liquidator.

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
async def get_liquidator_history(
    self,
    params: PrivateGetLiquidatorHistoryParamsSchema,
) -> PrivateGetLiquidatorHistoryResultSchema:
    """
    Returns a paginated history of auctions that the subaccount has participated in
    as a liquidator.

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_liquidator_history"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateGetLiquidatorHistoryResultSchema)

    return result
session_keys async
session_keys(
    params: PrivateSessionKeysParamsSchema,
) -> PrivateSessionKeysResultSchema

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
async def session_keys(
    self,
    params: PrivateSessionKeysParamsSchema,
) -> PrivateSessionKeysResultSchema:
    """
    Required minimum session key permission level is `read_only`
    """

    method = "private/session_keys"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateSessionKeysResultSchema)

    return result
edit_session_key async
edit_session_key(
    params: PrivateEditSessionKeyParamsSchema,
) -> PrivateEditSessionKeyResultSchema

Edits session key parameters such as label and IP whitelist.

For non-admin keys you can also toggle whether to disable a particular key.

Disabling non-admin keys must be done through /deregister_session_key

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
async def edit_session_key(
    self,
    params: PrivateEditSessionKeyParamsSchema,
) -> PrivateEditSessionKeyResultSchema:
    """
    Edits session key parameters such as label and IP whitelist.

    For non-admin keys you can also toggle whether to disable a particular key.

    Disabling non-admin keys must be done through /deregister_session_key

    Required minimum session key permission level is `account`
    """

    method = "private/edit_session_key"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateEditSessionKeyResultSchema)

    return result
register_scoped_session_key async
register_scoped_session_key(
    params: PrivateRegisterScopedSessionKeyParamsSchema,
) -> PrivateRegisterScopedSessionKeyResultSchema

Registers a new session key bounded to a scope without a transaction attached.

If you want to register an admin key, you must provide a signed raw transaction.

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
async def register_scoped_session_key(
    self,
    params: PrivateRegisterScopedSessionKeyParamsSchema,
) -> PrivateRegisterScopedSessionKeyResultSchema:
    """
    Registers a new session key bounded to a scope without a transaction attached.

    If you want to register an admin key, you must provide a signed raw transaction.

    Required minimum session key permission level is `account`
    """

    method = "private/register_scoped_session_key"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateRegisterScopedSessionKeyResultSchema)

    return result
get_mmp_config async
get_mmp_config(
    params: PrivateGetMmpConfigParamsSchema,
) -> List[MMPConfigResultSchema]

Get the current mmp config for a subaccount (optionally filtered by currency)

Required minimum session key permission level is read_only

Source code in derive_client/_clients/websockets/api.py
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
async def get_mmp_config(
    self,
    params: PrivateGetMmpConfigParamsSchema,
) -> List[MMPConfigResultSchema]:
    """
    Get the current mmp config for a subaccount (optionally filtered by currency)

    Required minimum session key permission level is `read_only`
    """

    method = "private/get_mmp_config"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, list[MMPConfigResultSchema])

    return result
set_mmp_config async
set_mmp_config(
    params: PrivateSetMmpConfigParamsSchema,
) -> PrivateSetMmpConfigResultSchema

Set the mmp config for the subaccount and currency

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
async def set_mmp_config(
    self,
    params: PrivateSetMmpConfigParamsSchema,
) -> PrivateSetMmpConfigResultSchema:
    """
    Set the mmp config for the subaccount and currency

    Required minimum session key permission level is `account`
    """

    method = "private/set_mmp_config"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, PrivateSetMmpConfigResultSchema)

    return result
reset_mmp async
reset_mmp(params: PrivateResetMmpParamsSchema) -> Result

Resets (unfreezes) the mmp state for a subaccount (optionally filtered by currency)

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
async def reset_mmp(
    self,
    params: PrivateResetMmpParamsSchema,
) -> Result:
    """
    Resets (unfreezes) the mmp state for a subaccount (optionally filtered by
    currency)

    Required minimum session key permission level is `account`
    """

    method = "private/reset_mmp"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, Result)

    return result
set_cancel_on_disconnect async
set_cancel_on_disconnect(
    params: PrivateSetCancelOnDisconnectParamsSchema,
) -> Result

Enables cancel on disconnect for the account

Required minimum session key permission level is account

Source code in derive_client/_clients/websockets/api.py
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
async def set_cancel_on_disconnect(
    self,
    params: PrivateSetCancelOnDisconnectParamsSchema,
) -> Result:
    """
    Enables cancel on disconnect for the account

    Required minimum session key permission level is `account`
    """

    method = "private/set_cancel_on_disconnect"
    envelope = await self._session._send_request(method, params=params)
    result = decode_result(envelope, Result)

    return result

PublicChannels

PublicChannels(session: WebSocketSession)

public channel subscriptions

Source code in derive_client/_clients/websockets/api.py
1939
1940
def __init__(self, session: WebSocketSession):
    self._session = session
Functions
auctions_watch async
auctions_watch(
    callback: Handler[List[AuctionResultSchema]],
) -> SubscriptionResult

Subscribe to state of ongoing auctions.

Parameters:

Name Type Description Default
callback Handler[List[AuctionResultSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
async def auctions_watch(
    self,
    callback: Handler[List[AuctionResultSchema]],
) -> SubscriptionResult:
    """
    Subscribe to state of ongoing auctions.

    Args:
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "auctions.watch".format()
    envelope = await self._session.subscribe(channel, callback, List[AuctionResultSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
margin_watch async
margin_watch(
    callback: Handler[List[MarginWatchResultSchema]],
) -> SubscriptionResult

Subscribe to state of margin and MtM of all users.

Parameters:

Name Type Description Default
callback Handler[List[MarginWatchResultSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
async def margin_watch(
    self,
    callback: Handler[List[MarginWatchResultSchema]],
) -> SubscriptionResult:
    """
    Subscribe to state of margin and MtM of all users.

    Args:
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "margin.watch".format()
    envelope = await self._session.subscribe(channel, callback, List[MarginWatchResultSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
orderbook_group_depth_by_instrument_name async
orderbook_group_depth_by_instrument_name(
    instrument_name: str,
    group: Group,
    depth: Depth,
    callback: Handler[
        OrderbookInstrumentNameGroupDepthPublisherDataSchema
    ],
) -> SubscriptionResult

Periodically publishes bids and asks for an instrument.

The 100ms orderbook emits at 1s intervals if the orderbook is not changing, otherwise emits at 100ms intervals.

Parameters:

Name Type Description Default
instrument_name str

Instrument Name

required
group Group

Group

required
depth Depth

Depth

required
callback Handler[OrderbookInstrumentNameGroupDepthPublisherDataSchema]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
async def orderbook_group_depth_by_instrument_name(
    self,
    instrument_name: str,
    group: Group,
    depth: Depth,
    callback: Handler[OrderbookInstrumentNameGroupDepthPublisherDataSchema],
) -> SubscriptionResult:
    """
    Periodically publishes bids and asks for an instrument.

    The 100ms orderbook emits at 1s intervals if the orderbook is not changing,
    otherwise emits at 100ms intervals.

    Args:
        instrument_name: Instrument Name
        group: Group
        depth: Depth
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "orderbook.{instrument_name}.{group}.{depth}".format(
        instrument_name=instrument_name.value if isinstance(instrument_name, Enum) else instrument_name,
        group=group.value if isinstance(group, Enum) else group,
        depth=depth.value if isinstance(depth, Enum) else depth,
    )
    envelope = await self._session.subscribe(
        channel, callback, OrderbookInstrumentNameGroupDepthPublisherDataSchema
    )
    result = decode_result(envelope, SubscriptionResult)

    return result
spot_feed_by_currency async
spot_feed_by_currency(
    currency: str,
    callback: Handler[SpotFeedCurrencyPublisherDataSchema],
) -> SubscriptionResult

Periodically publishes spot index price by currency.

Parameters:

Name Type Description Default
currency str

Currency

required
callback Handler[SpotFeedCurrencyPublisherDataSchema]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
async def spot_feed_by_currency(
    self,
    currency: str,
    callback: Handler[SpotFeedCurrencyPublisherDataSchema],
) -> SubscriptionResult:
    """
    Periodically publishes spot index price by currency.

    Args:
        currency: Currency
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "spot_feed.{currency}".format(
        currency=currency.value if isinstance(currency, Enum) else currency,
    )
    envelope = await self._session.subscribe(channel, callback, SpotFeedCurrencyPublisherDataSchema)
    result = decode_result(envelope, SubscriptionResult)

    return result
ticker_slim_interval_by_instrument_name async
ticker_slim_interval_by_instrument_name(
    instrument_name: str,
    interval: Interval,
    callback: Handler[
        TickerSlimInstrumentNameIntervalPublisherDataSchema
    ],
) -> SubscriptionResult

Periodically publishes ticker info (best bid / ask, instrument contraints, fees, etc.) for a single instrument.

The 100ms ticker emits at 1s intervals if best bid / ask are not changing, otherwise emits at 100ms interval.

The 1s ticker always emits at 1s intervals.

Parameters:

Name Type Description Default
instrument_name str

Instrument Name

required
interval Interval

Interval

required
callback Handler[TickerSlimInstrumentNameIntervalPublisherDataSchema]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
async def ticker_slim_interval_by_instrument_name(
    self,
    instrument_name: str,
    interval: Interval,
    callback: Handler[TickerSlimInstrumentNameIntervalPublisherDataSchema],
) -> SubscriptionResult:
    """
    Periodically publishes ticker info (best bid / ask, instrument contraints, fees,
    etc.) for a single instrument.

    The 100ms ticker emits at 1s intervals if best bid / ask are not changing,
    otherwise emits at 100ms interval.

    The 1s ticker always emits at 1s intervals.

    Args:
        instrument_name: Instrument Name
        interval: Interval
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "ticker_slim.{instrument_name}.{interval}".format(
        instrument_name=instrument_name.value if isinstance(instrument_name, Enum) else instrument_name,
        interval=interval.value if isinstance(interval, Enum) else interval,
    )
    envelope = await self._session.subscribe(channel, callback, TickerSlimInstrumentNameIntervalPublisherDataSchema)
    result = decode_result(envelope, SubscriptionResult)

    return result
trades_by_instrument_name async
trades_by_instrument_name(
    instrument_name: str,
    callback: Handler[List[TradePublicResponseSchema]],
) -> SubscriptionResult

Subscribe to trades (order executions) for a given instrument name.

Parameters:

Name Type Description Default
instrument_name str

Instrument Name

required
callback Handler[List[TradePublicResponseSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
async def trades_by_instrument_name(
    self,
    instrument_name: str,
    callback: Handler[List[TradePublicResponseSchema]],
) -> SubscriptionResult:
    """
    Subscribe to trades (order executions) for a given instrument name.

    Args:
        instrument_name: Instrument Name
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "trades.{instrument_name}".format(
        instrument_name=instrument_name.value if isinstance(instrument_name, Enum) else instrument_name,
    )
    envelope = await self._session.subscribe(channel, callback, List[TradePublicResponseSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
trades_by_instrument_type async
trades_by_instrument_type(
    instrument_type: AssetType,
    currency: str,
    callback: Handler[List[TradePublicResponseSchema]],
) -> SubscriptionResult

Subscribe to trades (order executions) for a given instrument type and currency.

Parameters:

Name Type Description Default
instrument_type AssetType

Instrument Type

required
currency str

Currency

required
callback Handler[List[TradePublicResponseSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
async def trades_by_instrument_type(
    self,
    instrument_type: AssetType,
    currency: str,
    callback: Handler[List[TradePublicResponseSchema]],
) -> SubscriptionResult:
    """
    Subscribe to trades (order executions) for a given instrument type and currency.

    Args:
        instrument_type: Instrument Type
        currency: Currency
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "trades.{instrument_type}.{currency}".format(
        instrument_type=instrument_type.value if isinstance(instrument_type, Enum) else instrument_type,
        currency=currency.value if isinstance(currency, Enum) else currency,
    )
    envelope = await self._session.subscribe(channel, callback, List[TradePublicResponseSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
trades_tx_status_by_instrument_type async
trades_tx_status_by_instrument_type(
    instrument_type: AssetType,
    currency: str,
    tx_status: TxStatus4,
    callback: Handler[
        List[TradeSettledPublicResponseSchema]
    ],
) -> SubscriptionResult

Subscribe to the status on on-chain trade settlement events for a given instrument type and currency.

Parameters:

Name Type Description Default
instrument_type AssetType

Instrument Type

required
currency str

Currency

required
tx_status TxStatus4

Tx Status

required
callback Handler[List[TradeSettledPublicResponseSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
async def trades_tx_status_by_instrument_type(
    self,
    instrument_type: AssetType,
    currency: str,
    tx_status: TxStatus4,
    callback: Handler[List[TradeSettledPublicResponseSchema]],
) -> SubscriptionResult:
    """
    Subscribe to the status on on-chain trade settlement events for a given
    instrument type and currency.

    Args:
        instrument_type: Instrument Type
        currency: Currency
        tx_status: Tx Status
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "trades.{instrument_type}.{currency}.{tx_status}".format(
        instrument_type=instrument_type.value if isinstance(instrument_type, Enum) else instrument_type,
        currency=currency.value if isinstance(currency, Enum) else currency,
        tx_status=tx_status.value if isinstance(tx_status, Enum) else tx_status,
    )
    envelope = await self._session.subscribe(channel, callback, List[TradeSettledPublicResponseSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result

PrivateChannels

PrivateChannels(session: WebSocketSession)

private channel subscriptions

Source code in derive_client/_clients/websockets/api.py
2160
2161
def __init__(self, session: WebSocketSession):
    self._session = session
Functions
balances_by_subaccount_id async
balances_by_subaccount_id(
    subaccount_id: str,
    callback: Handler[List[BalanceUpdateSchema]],
) -> SubscriptionResult

Subscribe to changes in user's positions for a given subaccount ID.

For perpetuals, additional balance updates are emitted under the name Q-{ccy}-PERP where Q stands for "quote".

This balance is a proxy for an on-chain state of lastMarkPrice.

Because of a synchronization lag with the on-chain state, the orderbook instead keeps track of a running total cost of perpetual trades,

For example:

Q-ETH-PERP balance of $6,600 and an ETH-PERP balance of 3 means the lastMarkPrice state is estimated to be $2,200.

Parameters:

Name Type Description Default
subaccount_id str

Subaccount Id

required
callback Handler[List[BalanceUpdateSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
async def balances_by_subaccount_id(
    self,
    subaccount_id: str,
    callback: Handler[List[BalanceUpdateSchema]],
) -> SubscriptionResult:
    """
    Subscribe to changes in user's positions for a given subaccount ID.

    For perpetuals, additional balance updates are emitted under the name
    Q-{ccy}-PERP where Q stands for "quote".

    This balance is a proxy for an on-chain state of lastMarkPrice.

    Because of a synchronization lag with the on-chain state, the orderbook instead
    keeps track of a running total cost of perpetual trades,

    For example:

    Q-ETH-PERP balance of $6,600 and an ETH-PERP balance of 3 means the
    lastMarkPrice state is estimated to be $2,200.

    Args:
        subaccount_id: Subaccount Id
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "{subaccount_id}.balances".format(
        subaccount_id=subaccount_id.value if isinstance(subaccount_id, Enum) else subaccount_id,
    )
    envelope = await self._session.subscribe(channel, callback, List[BalanceUpdateSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
best_quotes_by_subaccount_id async
best_quotes_by_subaccount_id(
    subaccount_id: str,
    callback: Handler[List[BestQuoteChannelResultSchema]],
) -> SubscriptionResult

Subscribe to best quote state for a given subaccount ID.

This will notify the user about the best quote available for the RFQ they have sent.

Parameters:

Name Type Description Default
subaccount_id str

Subaccount Id

required
callback Handler[List[BestQuoteChannelResultSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
async def best_quotes_by_subaccount_id(
    self,
    subaccount_id: str,
    callback: Handler[List[BestQuoteChannelResultSchema]],
) -> SubscriptionResult:
    """
    Subscribe to best quote state for a given subaccount ID.

    This will notify the user about the best quote available for the RFQ they have
    sent.

    Args:
        subaccount_id: Subaccount Id
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "{subaccount_id}.best.quotes".format(
        subaccount_id=subaccount_id.value if isinstance(subaccount_id, Enum) else subaccount_id,
    )
    envelope = await self._session.subscribe(channel, callback, List[BestQuoteChannelResultSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
orders_by_subaccount_id async
orders_by_subaccount_id(
    subaccount_id: str,
    callback: Handler[List[OrderResponseSchema]],
) -> SubscriptionResult

Subscribe to changes in user's orders for a given subaccount ID.

Parameters:

Name Type Description Default
subaccount_id str

Subaccount Id

required
callback Handler[List[OrderResponseSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
async def orders_by_subaccount_id(
    self,
    subaccount_id: str,
    callback: Handler[List[OrderResponseSchema]],
) -> SubscriptionResult:
    """
    Subscribe to changes in user's orders for a given subaccount ID.

    Args:
        subaccount_id: Subaccount Id
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "{subaccount_id}.orders".format(
        subaccount_id=subaccount_id.value if isinstance(subaccount_id, Enum) else subaccount_id,
    )
    envelope = await self._session.subscribe(channel, callback, List[OrderResponseSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
quotes_by_subaccount_id async
quotes_by_subaccount_id(
    subaccount_id: str,
    callback: Handler[List[QuoteResultSchema]],
) -> SubscriptionResult

Subscribe to quote state for a given subaccount ID.

This will notify the usser about the state change of the quotes they have sent.

Parameters:

Name Type Description Default
subaccount_id str

Subaccount Id

required
callback Handler[List[QuoteResultSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
async def quotes_by_subaccount_id(
    self,
    subaccount_id: str,
    callback: Handler[List[QuoteResultSchema]],
) -> SubscriptionResult:
    """
    Subscribe to quote state for a given subaccount ID.

    This will notify the usser about the state change of the quotes they have sent.

    Args:
        subaccount_id: Subaccount Id
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "{subaccount_id}.quotes".format(
        subaccount_id=subaccount_id.value if isinstance(subaccount_id, Enum) else subaccount_id,
    )
    envelope = await self._session.subscribe(channel, callback, List[QuoteResultSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
trades_by_subaccount_id async
trades_by_subaccount_id(
    subaccount_id: str,
    callback: Handler[List[TradeResponseSchema]],
) -> SubscriptionResult

Subscribe to user's trades (order executions) for a given subaccount ID.

Parameters:

Name Type Description Default
subaccount_id str

Subaccount Id

required
callback Handler[List[TradeResponseSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
async def trades_by_subaccount_id(
    self,
    subaccount_id: str,
    callback: Handler[List[TradeResponseSchema]],
) -> SubscriptionResult:
    """
    Subscribe to user's trades (order executions) for a given subaccount ID.

    Args:
        subaccount_id: Subaccount Id
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "{subaccount_id}.trades".format(
        subaccount_id=subaccount_id.value if isinstance(subaccount_id, Enum) else subaccount_id,
    )
    envelope = await self._session.subscribe(channel, callback, List[TradeResponseSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
trades_tx_status_by_subaccount_id async
trades_tx_status_by_subaccount_id(
    subaccount_id: int,
    tx_status: TxStatus4,
    callback: Handler[List[TradeResponseSchema]],
) -> SubscriptionResult

Subscribe to user's trade settlement for a given subaccount ID.

Parameters:

Name Type Description Default
subaccount_id int

Subaccount Id

required
tx_status TxStatus4

Tx Status

required
callback Handler[List[TradeResponseSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
async def trades_tx_status_by_subaccount_id(
    self,
    subaccount_id: int,
    tx_status: TxStatus4,
    callback: Handler[List[TradeResponseSchema]],
) -> SubscriptionResult:
    """
    Subscribe to user's trade settlement for a given subaccount ID.

    Args:
        subaccount_id: Subaccount Id
        tx_status: Tx Status
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "{subaccount_id}.trades.{tx_status}".format(
        subaccount_id=subaccount_id.value if isinstance(subaccount_id, Enum) else subaccount_id,
        tx_status=tx_status.value if isinstance(tx_status, Enum) else tx_status,
    )
    envelope = await self._session.subscribe(channel, callback, List[TradeResponseSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result
rfqs_by_wallet async
rfqs_by_wallet(
    wallet: str,
    callback: Handler[List[RFQResultPublicSchema]],
) -> SubscriptionResult

Subscribe to RFQs directed to a given wallet.

Parameters:

Name Type Description Default
wallet str

Wallet

required
callback Handler[List[RFQResultPublicSchema]]

Callback function to handle notifications

required

Returns:

Type Description
SubscriptionResult

Subscription result with status and current subscriptions

Source code in derive_client/_clients/websockets/api.py
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
async def rfqs_by_wallet(
    self,
    wallet: str,
    callback: Handler[List[RFQResultPublicSchema]],
) -> SubscriptionResult:
    """
    Subscribe to RFQs directed to a given wallet.

    Args:
        wallet: Wallet
        callback: Callback function to handle notifications

    Returns:
        Subscription result with status and current subscriptions
    """

    channel = "{wallet}.rfqs".format(
        wallet=wallet.value if isinstance(wallet, Enum) else wallet,
    )
    envelope = await self._session.subscribe(channel, callback, List[RFQResultPublicSchema])
    result = decode_result(envelope, SubscriptionResult)

    return result

PublicAPI

PublicAPI(session: WebSocketSession)

Combined public API - RPC and channels

Source code in derive_client/_clients/websockets/api.py
2361
2362
2363
2364
def __init__(self, session: WebSocketSession):
    self.rpc = PublicRPC(session)

    self.channels = PublicChannels(session)

PrivateAPI

PrivateAPI(session: WebSocketSession)

Combined private API - RPC and channels

Source code in derive_client/_clients/websockets/api.py
2370
2371
2372
2373
def __init__(self, session: WebSocketSession):
    self.rpc = PrivateRPC(session)

    self.channels = PrivateChannels(session)

Functions