DefaultType

Enum DefaultType 

Source
pub enum DefaultType {
    Spot,
    Swap,
    Futures,
    Margin,
    Option,
}
Expand description

Default market type for exchange operations

This enum determines which API endpoints and market filters to use when calling generic exchange methods.

§Variants

  • Spot: Regular cryptocurrency trading without leverage or expiry
  • Swap: Perpetual contracts with no expiry date (also called perpetual futures)
  • Futures: Delivery contracts with a specific expiry date
  • Margin: Spot trading with borrowed funds (leverage)
  • Option: Options contracts (calls and puts)

§Example

use ccxt_core::types::default_type::DefaultType;

let default = DefaultType::default();
assert_eq!(default, DefaultType::Spot);

assert!(DefaultType::Swap.is_derivative());
assert!(DefaultType::Futures.is_contract());
assert!(!DefaultType::Spot.is_derivative());

Variants§

§

Spot

Spot market - regular cryptocurrency trading

§

Swap

Swap market - perpetual contracts with no expiry

§

Futures

Futures market - delivery contracts with expiry date

§

Margin

Margin market - spot trading with borrowed funds

§

Option

Option market - options contracts (calls and puts)

Implementations§

Source§

impl DefaultType

Source

pub const ALL: &'static [DefaultType]

All valid default type variants

Source

pub fn as_str(&self) -> &'static str

Returns the string representation (lowercase)

§Example
use ccxt_core::types::default_type::DefaultType;

assert_eq!(DefaultType::Spot.as_str(), "spot");
assert_eq!(DefaultType::Swap.as_str(), "swap");
Source

pub fn is_derivative(&self) -> bool

Check if this type represents a derivative market

Derivatives include swap, futures, margin, and option markets.

§Example
use ccxt_core::types::default_type::DefaultType;

assert!(!DefaultType::Spot.is_derivative());
assert!(DefaultType::Swap.is_derivative());
assert!(DefaultType::Futures.is_derivative());
assert!(DefaultType::Margin.is_derivative());
assert!(DefaultType::Option.is_derivative());
Source

pub fn is_contract(&self) -> bool

Check if this type represents a contract market (swap, futures, option)

Contract markets are those that trade derivative contracts rather than the underlying asset directly.

§Example
use ccxt_core::types::default_type::DefaultType;

assert!(!DefaultType::Spot.is_contract());
assert!(DefaultType::Swap.is_contract());
assert!(DefaultType::Futures.is_contract());
assert!(!DefaultType::Margin.is_contract());
assert!(DefaultType::Option.is_contract());

Trait Implementations§

Source§

impl Clone for DefaultType

Source§

fn clone(&self) -> DefaultType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DefaultType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for DefaultType

Source§

fn default() -> DefaultType

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DefaultType

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<DefaultType, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for DefaultType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<&str> for DefaultType

Source§

fn from(s: &str) -> DefaultType

Convert a string slice to DefaultType.

Panics if the string is not a valid DefaultType. For fallible conversion, use FromStr::from_str() instead.

§Example
use ccxt_core::types::default_type::DefaultType;

let dt: DefaultType = "spot".into();
assert_eq!(dt, DefaultType::Spot);

let dt: DefaultType = "swap".into();
assert_eq!(dt, DefaultType::Swap);
§Panics

Panics if the string is not a valid DefaultType value.

Source§

impl From<DefaultType> for MarketType

Source§

fn from(dt: DefaultType) -> MarketType

Convert DefaultType to MarketType

Note: Margin maps to Spot since margin trading uses spot markets with leverage.

Source§

impl From<String> for DefaultType

Source§

fn from(s: String) -> DefaultType

Convert a String to DefaultType.

Falls back to Spot if the string is not a valid DefaultType. For fallible conversion, use FromStr::from_str() instead.

§Example
use ccxt_core::types::default_type::DefaultType;

let dt: DefaultType = "swap".to_string().into();
assert_eq!(dt, DefaultType::Swap);
Source§

impl FromStr for DefaultType

Source§

fn from_str(s: &str) -> Result<DefaultType, <DefaultType as FromStr>::Err>

Parse a DefaultType from a string (case-insensitive)

§Example
use ccxt_core::types::default_type::DefaultType;
use std::str::FromStr;

assert_eq!(DefaultType::from_str("spot").unwrap(), DefaultType::Spot);
assert_eq!(DefaultType::from_str("SWAP").unwrap(), DefaultType::Swap);
assert_eq!(DefaultType::from_str("Futures").unwrap(), DefaultType::Futures);

assert!(DefaultType::from_str("invalid").is_err());
Source§

type Err = DefaultTypeError

The associated error which can be returned from parsing.
Source§

impl Hash for DefaultType

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DefaultType

Source§

fn eq(&self, other: &DefaultType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for DefaultType

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<MarketType> for DefaultType

Source§

fn try_from( mt: MarketType, ) -> Result<DefaultType, <DefaultType as TryFrom<MarketType>>::Error>

Convert MarketType to DefaultType

Note: MarketType::Spot could be either DefaultType::Spot or DefaultType::Margin, so this conversion defaults to Spot.

Source§

type Error = DefaultTypeError

The type returned in the event of a conversion error.
Source§

impl Copy for DefaultType

Source§

impl Eq for DefaultType

Source§

impl StructuralPartialEq for DefaultType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,