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 expirySwap: Perpetual contracts with no expiry date (also called perpetual futures)Futures: Delivery contracts with a specific expiry dateMargin: 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
impl DefaultType
Sourcepub const ALL: &'static [DefaultType]
pub const ALL: &'static [DefaultType]
All valid default type variants
Sourcepub fn as_str(&self) -> &'static str
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");Sourcepub fn is_derivative(&self) -> bool
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());Sourcepub fn is_contract(&self) -> bool
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
impl Clone for DefaultType
Source§fn clone(&self) -> DefaultType
fn clone(&self) -> DefaultType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DefaultType
impl Debug for DefaultType
Source§impl Default for DefaultType
impl Default for DefaultType
Source§fn default() -> DefaultType
fn default() -> DefaultType
Source§impl<'de> Deserialize<'de> for DefaultType
impl<'de> Deserialize<'de> for DefaultType
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DefaultType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DefaultType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for DefaultType
impl Display for DefaultType
Source§impl From<&str> for DefaultType
impl From<&str> for DefaultType
Source§fn from(s: &str) -> DefaultType
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
impl From<DefaultType> for MarketType
Source§fn from(dt: DefaultType) -> MarketType
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
impl From<String> for DefaultType
Source§fn from(s: String) -> DefaultType
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
impl FromStr for DefaultType
Source§fn from_str(s: &str) -> Result<DefaultType, <DefaultType as FromStr>::Err>
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
type Err = DefaultTypeError
Source§impl Hash for DefaultType
impl Hash for DefaultType
Source§impl PartialEq for DefaultType
impl PartialEq for DefaultType
Source§impl Serialize for DefaultType
impl Serialize for DefaultType
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<MarketType> for DefaultType
impl TryFrom<MarketType> for DefaultType
Source§fn try_from(
mt: MarketType,
) -> Result<DefaultType, <DefaultType as TryFrom<MarketType>>::Error>
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
type Error = DefaultTypeError
impl Copy for DefaultType
impl Eq for DefaultType
impl StructuralPartialEq for DefaultType
Auto Trait Implementations§
impl Freeze for DefaultType
impl RefUnwindSafe for DefaultType
impl Send for DefaultType
impl Sync for DefaultType
impl Unpin for DefaultType
impl UnwindSafe for DefaultType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.