pub enum DefaultSubType {
Linear,
Inverse,
}Expand description
Contract settlement type for derivatives
Determines whether contracts are settled in quote currency (linear/USDT-margined) or base currency (inverse/coin-margined).
§Variants
Linear: Settled in quote currency (USDT-margined)Inverse: Settled in base currency (coin-margined)
§Example
use ccxt_core::types::default_type::DefaultSubType;
use std::str::FromStr;
let linear = DefaultSubType::default();
assert_eq!(linear, DefaultSubType::Linear);
let inverse = DefaultSubType::from_str("inverse").unwrap();
assert_eq!(inverse.to_string(), "inverse");Variants§
Linear
Linear contract - settled in quote currency (USDT-margined)
Inverse
Inverse contract - settled in base currency (coin-margined)
Implementations§
Source§impl DefaultSubType
impl DefaultSubType
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::DefaultSubType;
assert_eq!(DefaultSubType::Linear.as_str(), "linear");
assert_eq!(DefaultSubType::Inverse.as_str(), "inverse");Sourcepub fn from_symbol(symbol: &ParsedSymbol) -> Option<DefaultSubType>
pub fn from_symbol(symbol: &ParsedSymbol) -> Option<DefaultSubType>
Infer sub-type from a parsed symbol
Returns Some(Linear) if settle equals quote currency,
Some(Inverse) if settle equals base currency,
or None if no settle currency is present (spot market).
§Example
use ccxt_core::types::default_type::DefaultSubType;
use ccxt_core::types::symbol::ParsedSymbol;
// Linear swap (USDT-margined)
let linear_symbol = ParsedSymbol::linear_swap("BTC".to_string(), "USDT".to_string());
assert_eq!(DefaultSubType::from_symbol(&linear_symbol), Some(DefaultSubType::Linear));
// Inverse swap (coin-margined)
let inverse_symbol = ParsedSymbol::inverse_swap("BTC".to_string(), "USD".to_string());
assert_eq!(DefaultSubType::from_symbol(&inverse_symbol), Some(DefaultSubType::Inverse));
// Spot (no sub-type)
let spot_symbol = ParsedSymbol::spot("BTC".to_string(), "USDT".to_string());
assert_eq!(DefaultSubType::from_symbol(&spot_symbol), None);Trait Implementations§
Source§impl Clone for DefaultSubType
impl Clone for DefaultSubType
Source§fn clone(&self) -> DefaultSubType
fn clone(&self) -> DefaultSubType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DefaultSubType
impl Debug for DefaultSubType
Source§impl Default for DefaultSubType
impl Default for DefaultSubType
Source§fn default() -> DefaultSubType
fn default() -> DefaultSubType
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for DefaultSubType
impl<'de> Deserialize<'de> for DefaultSubType
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DefaultSubType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DefaultSubType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for DefaultSubType
impl Display for DefaultSubType
Source§impl FromStr for DefaultSubType
impl FromStr for DefaultSubType
Source§fn from_str(s: &str) -> Result<DefaultSubType, <DefaultSubType as FromStr>::Err>
fn from_str(s: &str) -> Result<DefaultSubType, <DefaultSubType as FromStr>::Err>
Parse a DefaultSubType from a string (case-insensitive)
§Example
use ccxt_core::types::default_type::DefaultSubType;
use std::str::FromStr;
assert_eq!(DefaultSubType::from_str("linear").unwrap(), DefaultSubType::Linear);
assert_eq!(DefaultSubType::from_str("INVERSE").unwrap(), DefaultSubType::Inverse);
assert!(DefaultSubType::from_str("invalid").is_err());Source§type Err = DefaultTypeError
type Err = DefaultTypeError
The associated error which can be returned from parsing.
Source§impl Hash for DefaultSubType
impl Hash for DefaultSubType
Source§impl PartialEq for DefaultSubType
impl PartialEq for DefaultSubType
Source§impl Serialize for DefaultSubType
impl Serialize for DefaultSubType
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,
Serialize this value into the given Serde serializer. Read more
impl Copy for DefaultSubType
impl Eq for DefaultSubType
impl StructuralPartialEq for DefaultSubType
Auto Trait Implementations§
impl Freeze for DefaultSubType
impl RefUnwindSafe for DefaultSubType
impl Send for DefaultSubType
impl Sync for DefaultSubType
impl Unpin for DefaultSubType
impl UnwindSafe for DefaultSubType
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
Mutably borrows from an owned value. Read more
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.