#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::Params;
use crate::Config;
use crate::prediction::myriad::MyriadCore;
use crate::types::*;
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct Myriad {
core: Box<MyriadCore>,
}
impl Myriad {
pub fn new(config: Option<Value>) -> Self {
Self { core: Box::new(MyriadCore::new(config)) }
}
pub fn with_config(config: Config) -> Self {
Self { core: Box::new(MyriadCore::new(config.into_option())) }
}
pub fn from_core(core: MyriadCore) -> Self {
Self { core: Box::new(core) }
}
#[inline]
fn core_mut(&mut self) -> &mut MyriadCore {
&mut self.core
}
pub async fn load_markets(&mut self, reload: bool) -> Value {
self.core_mut().load_markets(&[Value::Bool(reload), Value::Null]).await
}
pub async fn try_load_markets(&mut self, reload: bool) -> crate::Result<Vec<Market>> {
crate::runtime::call_typed(
self.core_mut().load_markets(&[Value::Bool(reload), Value::Null]),
).await?;
Ok(self.markets())
}
pub fn market(&self, symbol: &str) -> crate::Result<Market> {
let sym = Value::Str(symbol.to_string());
crate::runtime::catch_typed(|| Market::from_value(ExchangeBase::market(&*self.core, sym)))
}
pub fn markets(&self) -> Vec<Market> {
match &self.core.markets {
Value::Dict(d) => d.values().cloned().map(Market::from_value).collect(),
_ => Vec::new(),
}
}
pub fn currencies(&self) -> Vec<Currency> {
match &self.core.currencies {
Value::Dict(d) => d.values().cloned().map(Currency::from_value).collect(),
_ => Vec::new(),
}
}
pub fn set_verbose(&mut self, on: bool) -> &mut Self {
self.core.verbose = Value::Bool(on);
self
}
pub fn is_verbose(&self) -> bool {
matches!(self.core.verbose, Value::Bool(true))
}
pub fn set_enable_rate_limit(&mut self, on: bool) -> &mut Self {
self.core.enableRateLimit = Value::Bool(on);
self
}
pub fn set_rate_limit_ms(&mut self, ms: i64) -> &mut Self {
self.core.rateLimit = Value::Int(ms);
self
}
pub fn set_timeout_ms(&mut self, ms: i64) -> &mut Self {
self.core.timeout = Value::Int(ms);
self
}
pub fn set_api_key(&mut self, v: &str) -> &mut Self {
self.core.apiKey = Value::Str(v.to_string());
self
}
pub fn set_secret(&mut self, v: &str) -> &mut Self {
self.core.secret = Value::Str(v.to_string());
self
}
pub fn set_password(&mut self, v: &str) -> &mut Self {
self.core.password = Value::Str(v.to_string());
self
}
pub fn set_uid(&mut self, v: &str) -> &mut Self {
self.core.uid = Value::Str(v.to_string());
self
}
pub fn set_wallet_address(&mut self, v: &str) -> &mut Self {
self.core.walletAddress = Value::Str(v.to_string());
self
}
pub fn set_private_key(&mut self, v: &str) -> &mut Self {
self.core.privateKey = Value::Str(v.to_string());
self
}
pub fn set_token(&mut self, v: &str) -> &mut Self {
self.core.token = Value::Str(v.to_string());
self
}
pub fn set_http_proxy(&mut self, url: &str) -> &mut Self {
self.core.httpProxy = Value::Str(url.to_string());
self
}
pub fn set_https_proxy(&mut self, url: &str) -> &mut Self {
self.core.httpsProxy = Value::Str(url.to_string());
self
}
pub fn set_socks_proxy(&mut self, url: &str) -> &mut Self {
self.core.socksProxy = Value::Str(url.to_string());
self
}
pub fn set_ws_proxy(&mut self, url: &str) -> &mut Self {
self.core.wsProxy = Value::Str(url.to_string());
self
}
pub fn set_options(&mut self, options: Params) -> &mut Self {
let merged = Config::new().options(Params::from(self.core.options.clone()))
.options(options)
.into_value();
self.core.options = crate::runtime::get_value(
&merged,
&Value::Str("options".to_string()),
);
self
}
pub fn set_sandbox_mode(&mut self, on: bool) -> crate::Result<()> {
let has_test = !matches!(
crate::runtime::get_value(&self.core.urls, &Value::Str("test".to_string())),
Value::Null
);
if on && !has_test {
return Err(crate::exchange_errors::not_supported(format!(
"{} does not have a sandbox URL",
self.id()
)));
}
let core = &mut *self.core;
crate::runtime::catch_typed(move || {
<_ as crate::exchange_generated::ExchangeBase>::set_sandbox_mode(
core,
Value::Bool(on),
)
})
}
pub fn is_sandbox_mode_enabled(&self) -> bool {
matches!(self.core.isSandboxModeEnabled, Value::Bool(true))
}
pub fn id(&self) -> String {
match &self.core.id {
Value::Str(s) => s.clone(),
_ => String::new(),
}
}
pub fn symbols(&self) -> Vec<String> {
let mut out: Vec<String> = self.markets().into_iter().map(|m| m.symbol).collect();
out.sort();
out
}
}
impl std::ops::Deref for Myriad {
type Target = MyriadCore;
fn deref(&self) -> &Self::Target { &*self.core }
}
impl Myriad {
pub async fn fetch_markets(&mut self, params: impl Into<Params>) -> crate::Result<Vec<Market>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_markets(&[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Market::from_value))
}
pub async fn fetch_accounts(&mut self, params: impl Into<Params>) -> crate::Result<Vec<Account>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_accounts(&[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Account::from_value))
}
pub async fn fetch_deposit_addresses(&mut self, codes: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Vec<DepositAddress>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_deposit_addresses(&[match codes { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(vec_from_value(&v, DepositAddress::from_value))
}
pub async fn fetch_margin_mode(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<MarginMode> {
let v = crate::runtime::call_typed(self.core_mut().fetch_margin_mode(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(MarginMode::from_value(v))
}
pub async fn fetch_margin_modes(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<MarginModes> {
let v = crate::runtime::call_typed(self.core_mut().fetch_margin_modes(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, MarginMode::from_value))
}
pub async fn fetch_time(&mut self, params: impl Into<Params>) -> crate::Result<Option<i64>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_time(&[params.into().into_value()])).await?;
Ok(match v { Value::Int(n) => Some(n), _ => None })
}
pub async fn fetch_cross_borrow_rates(&mut self, params: impl Into<Params>) -> crate::Result<CrossBorrowRates> {
let v = crate::runtime::call_typed(self.core_mut().fetch_cross_borrow_rates(&[params.into().into_value()])).await?;
Ok(dict_from_value(&v, BorrowRate::from_value))
}
pub async fn fetch_isolated_borrow_rates(&mut self, params: impl Into<Params>) -> crate::Result<IsolatedBorrowRates> {
let v = crate::runtime::call_typed(self.core_mut().fetch_isolated_borrow_rates(&[params.into().into_value()])).await?;
Ok(dict_from_value(&v, IsolatedBorrowRate::from_value))
}
pub async fn fetch_leverage_tiers(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<LeverageTiers> {
let v = crate::runtime::call_typed(self.core_mut().fetch_leverage_tiers(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, |row| vec_from_value(&row, LeverageTier::from_value)))
}
pub async fn fetch_funding_rates(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<FundingRates> {
let v = crate::runtime::call_typed(self.core_mut().fetch_funding_rates(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, FundingRate::from_value))
}
pub async fn fetch_funding_intervals(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<FundingRates> {
let v = crate::runtime::call_typed(self.core_mut().fetch_funding_intervals(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, FundingRate::from_value))
}
pub async fn transfer(&mut self, code: &str, amount: f64, from_account: &str, to_account: &str, params: impl Into<Params>) -> crate::Result<Transfer> {
let v = crate::runtime::call_typed(self.core_mut().transfer(Value::Str(code.to_string()), Value::Float(amount), Value::Str(from_account.to_string()), Value::Str(to_account.to_string()), &[params.into().into_value()])).await?;
Ok(Transfer::from_value(v))
}
pub async fn withdraw(&mut self, code: &str, amount: f64, address: &str, tag: Option<&str>, params: impl Into<Params>) -> crate::Result<Transaction> {
let v = crate::runtime::call_typed(self.core_mut().withdraw(Value::Str(code.to_string()), Value::Float(amount), Value::Str(address.to_string()), &[tag.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Transaction::from_value(v))
}
pub async fn create_deposit_address(&mut self, code: &str, params: impl Into<Params>) -> crate::Result<DepositAddress> {
let v = crate::runtime::call_typed(self.core_mut().create_deposit_address(Value::Str(code.to_string()), &[params.into().into_value()])).await?;
Ok(DepositAddress::from_value(v))
}
pub async fn fetch_leverage(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<Leverage> {
let v = crate::runtime::call_typed(self.core_mut().fetch_leverage(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(Leverage::from_value(v))
}
pub async fn fetch_leverages(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Leverages> {
let v = crate::runtime::call_typed(self.core_mut().fetch_leverages(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, Leverage::from_value))
}
pub async fn add_margin(&mut self, symbol: &str, amount: f64, params: impl Into<Params>) -> crate::Result<MarginModification> {
let v = crate::runtime::call_typed(self.core_mut().add_margin(Value::Str(symbol.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(MarginModification::from_value(v))
}
pub async fn reduce_margin(&mut self, symbol: &str, amount: f64, params: impl Into<Params>) -> crate::Result<MarginModification> {
let v = crate::runtime::call_typed(self.core_mut().reduce_margin(Value::Str(symbol.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(MarginModification::from_value(v))
}
pub async fn set_margin(&mut self, symbol: &str, amount: f64, params: impl Into<Params>) -> crate::Result<MarginModification> {
let v = crate::runtime::call_typed(self.core_mut().set_margin(Value::Str(symbol.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(MarginModification::from_value(v))
}
pub async fn fetch_long_short_ratio(&mut self, symbol: &str, timeframe: Option<&str>, params: impl Into<Params>) -> crate::Result<LongShortRatio> {
let v = crate::runtime::call_typed(self.core_mut().fetch_long_short_ratio(Value::Str(symbol.to_string()), &[timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(LongShortRatio::from_value(v))
}
pub async fn fetch_long_short_ratio_history(&mut self, symbol: Option<&str>, timeframe: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<LongShortRatio>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_long_short_ratio_history(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, LongShortRatio::from_value))
}
pub async fn fetch_margin_adjustment_history(&mut self, symbol: Option<&str>, type_: Option<&str>, since: Option<f64>, limit: Option<f64>, params: impl Into<Params>) -> crate::Result<Vec<MarginModification>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_margin_adjustment_history(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), type_.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Float).unwrap_or(Value::Null), limit.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, MarginModification::from_value))
}
pub async fn fetch_deposit_addresses_by_network(&mut self, code: &str, params: impl Into<Params>) -> crate::Result<DepositAddresses> {
let v = crate::runtime::call_typed(self.core_mut().fetch_deposit_addresses_by_network(Value::Str(code.to_string()), &[params.into().into_value()])).await?;
Ok(dict_from_value(&v, DepositAddress::from_value))
}
pub async fn fetch_open_interest_history(&mut self, symbol: &str, timeframe: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<OpenInterest>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_open_interest_history(Value::Str(symbol.to_string()), &[timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, OpenInterest::from_value))
}
pub async fn fetch_open_interests(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<OpenInterests> {
let v = crate::runtime::call_typed(self.core_mut().fetch_open_interests(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, OpenInterest::from_value))
}
pub async fn repay_cross_margin(&mut self, code: &str, amount: f64, params: impl Into<Params>) -> crate::Result<MarginLoan> {
let v = crate::runtime::call_typed(self.core_mut().repay_cross_margin(Value::Str(code.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(MarginLoan::from_value(v))
}
pub async fn repay_isolated_margin(&mut self, symbol: &str, code: &str, amount: f64, params: impl Into<Params>) -> crate::Result<MarginLoan> {
let v = crate::runtime::call_typed(self.core_mut().repay_isolated_margin(Value::Str(symbol.to_string()), Value::Str(code.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(MarginLoan::from_value(v))
}
pub async fn borrow_cross_margin(&mut self, code: &str, amount: f64, params: impl Into<Params>) -> crate::Result<MarginLoan> {
let v = crate::runtime::call_typed(self.core_mut().borrow_cross_margin(Value::Str(code.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(MarginLoan::from_value(v))
}
pub async fn borrow_isolated_margin(&mut self, symbol: &str, code: &str, amount: f64, params: impl Into<Params>) -> crate::Result<MarginLoan> {
let v = crate::runtime::call_typed(self.core_mut().borrow_isolated_margin(Value::Str(symbol.to_string()), Value::Str(code.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(MarginLoan::from_value(v))
}
pub async fn borrow_margin(&mut self, code: &str, amount: f64, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<MarginLoan> {
let v = crate::runtime::call_typed(self.core_mut().borrow_margin(Value::Str(code.to_string()), Value::Float(amount), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(MarginLoan::from_value(v))
}
pub async fn repay_margin(&mut self, code: &str, amount: f64, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<MarginLoan> {
let v = crate::runtime::call_typed(self.core_mut().repay_margin(Value::Str(code.to_string()), Value::Float(amount), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(MarginLoan::from_value(v))
}
pub async fn fetch_ohlcv(&mut self, symbol: &str, timeframe: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<OHLCV>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_ohlcv(Value::Str(symbol.to_string()), &[timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(match v { Value::Arr(arr) => arr.iter().map(|c| { let mut out = [0.0f64; 6]; if let Value::Arr(fields) = c { for (i, slot) in out.iter_mut().enumerate() { if let Some(f) = fields.get(i).and_then(|x| x.as_f64()) { *slot = f; } } } out }).collect(), _ => Vec::new() })
}
pub async fn fetch_spot_ohlcv(&mut self, symbol: &str, timeframe: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<OHLCV>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_spot_ohlcv(Value::Str(symbol.to_string()), &[timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(match v { Value::Arr(arr) => arr.iter().map(|c| { let mut out = [0.0f64; 6]; if let Value::Arr(fields) = c { for (i, slot) in out.iter_mut().enumerate() { if let Some(f) = fields.get(i).and_then(|x| x.as_f64()) { *slot = f; } } } out }).collect(), _ => Vec::new() })
}
pub async fn fetch_contract_ohlcv(&mut self, symbol: &str, timeframe: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<OHLCV>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_contract_ohlcv(Value::Str(symbol.to_string()), &[timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(match v { Value::Arr(arr) => arr.iter().map(|c| { let mut out = [0.0f64; 6]; if let Value::Arr(fields) = c { for (i, slot) in out.iter_mut().enumerate() { if let Some(f) = fields.get(i).and_then(|x| x.as_f64()) { *slot = f; } } } out }).collect(), _ => Vec::new() })
}
pub async fn fetch_borrow_interest(&mut self, code: Option<&str>, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<BorrowInterest>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_borrow_interest(&[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, BorrowInterest::from_value))
}
pub async fn fetch_ledger(&mut self, code: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<LedgerEntry>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_ledger(&[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, LedgerEntry::from_value))
}
pub async fn fetch_ledger_entry(&mut self, id: &str, code: Option<&str>, params: impl Into<Params>) -> crate::Result<LedgerEntry> {
let v = crate::runtime::call_typed(self.core_mut().fetch_ledger_entry(Value::Str(id.to_string()), &[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(LedgerEntry::from_value(v))
}
pub async fn fetch_balance(&mut self, params: impl Into<Params>) -> crate::Result<Balances> {
let v = crate::runtime::call_typed(self.core_mut().fetch_balance(&[params.into().into_value()])).await?;
Ok(Balances::from_value(v))
}
pub async fn fetch_partial_balance(&mut self, part: Value, params: impl Into<Params>) -> crate::Result<Balances> {
let v = crate::runtime::call_typed(self.core_mut().fetch_partial_balance(part, &[params.into().into_value()])).await?;
Ok(Balances::from_value(v))
}
pub async fn fetch_free_balance(&mut self, params: impl Into<Params>) -> crate::Result<Balances> {
let v = crate::runtime::call_typed(self.core_mut().fetch_free_balance(&[params.into().into_value()])).await?;
Ok(Balances::from_value(v))
}
pub async fn fetch_used_balance(&mut self, params: impl Into<Params>) -> crate::Result<Balances> {
let v = crate::runtime::call_typed(self.core_mut().fetch_used_balance(&[params.into().into_value()])).await?;
Ok(Balances::from_value(v))
}
pub async fn fetch_total_balance(&mut self, params: impl Into<Params>) -> crate::Result<Balances> {
let v = crate::runtime::call_typed(self.core_mut().fetch_total_balance(&[params.into().into_value()])).await?;
Ok(Balances::from_value(v))
}
pub async fn fetch_status(&mut self, params: impl Into<Params>) -> crate::Result<Status> {
let v = crate::runtime::call_typed(self.core_mut().fetch_status(&[params.into().into_value()])).await?;
Ok(Status::from_value(v))
}
pub async fn fetch_deposit_withdraw_fees(&mut self, codes: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<DepositWithdrawFees> {
let v = crate::runtime::call_typed(self.core_mut().fetch_deposit_withdraw_fees(&[match codes { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, DepositWithdrawFee::from_value))
}
pub async fn fetch_deposit_withdraw_fee(&mut self, code: &str, params: impl Into<Params>) -> crate::Result<DepositWithdrawFee> {
let v = crate::runtime::call_typed(self.core_mut().fetch_deposit_withdraw_fee(Value::Str(code.to_string()), &[params.into().into_value()])).await?;
Ok(DepositWithdrawFee::from_value(v))
}
pub async fn fetch_cross_borrow_rate(&mut self, code: &str, params: impl Into<Params>) -> crate::Result<BorrowRate> {
let v = crate::runtime::call_typed(self.core_mut().fetch_cross_borrow_rate(Value::Str(code.to_string()), &[params.into().into_value()])).await?;
Ok(BorrowRate::from_value(v))
}
pub async fn fetch_isolated_borrow_rate(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<IsolatedBorrowRate> {
let v = crate::runtime::call_typed(self.core_mut().fetch_isolated_borrow_rate(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(IsolatedBorrowRate::from_value(v))
}
pub async fn fetch_spot_tickers(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Tickers> {
let v = crate::runtime::call_typed(self.core_mut().fetch_spot_tickers(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, Ticker::from_value))
}
pub async fn fetch_contract_tickers(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Tickers> {
let v = crate::runtime::call_typed(self.core_mut().fetch_contract_tickers(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, Ticker::from_value))
}
pub async fn fetch_order_books(&mut self, symbols: Option<Vec<String>>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<OrderBooks> {
let v = crate::runtime::call_typed(self.core_mut().fetch_order_books(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(dict_from_value(&v, OrderBook::from_value))
}
pub async fn create_twap_order(&mut self, symbol: &str, side: &str, amount: f64, duration: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_twap_order(Value::Str(symbol.to_string()), Value::Str(side.to_string()), Value::Float(amount), Value::Float(duration), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_convert_trade(&mut self, id: &str, from_code: &str, to_code: &str, amount: Option<f64>, params: impl Into<Params>) -> crate::Result<Conversion> {
let v = crate::runtime::call_typed(self.core_mut().create_convert_trade(Value::Str(id.to_string()), Value::Str(from_code.to_string()), Value::Str(to_code.to_string()), &[amount.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Conversion::from_value(v))
}
pub async fn fetch_convert_trade(&mut self, id: &str, code: Option<&str>, params: impl Into<Params>) -> crate::Result<Conversion> {
let v = crate::runtime::call_typed(self.core_mut().fetch_convert_trade(Value::Str(id.to_string()), &[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Conversion::from_value(v))
}
pub async fn fetch_convert_trade_history(&mut self, code: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Conversion>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_convert_trade_history(&[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Conversion::from_value))
}
pub async fn fetch_position_mode(&mut self, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<PositionModeInfo> {
let v = crate::runtime::call_typed(self.core_mut().fetch_position_mode(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(PositionModeInfo::from_value(v))
}
pub async fn fetch_adl_rank(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<ADL> {
let v = crate::runtime::call_typed(self.core_mut().fetch_adl_rank(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(ADL::from_value(v))
}
pub async fn fetch_positions_adl_rank(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Vec<ADL>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_positions_adl_rank(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(vec_from_value(&v, ADL::from_value))
}
pub async fn fetch_position_adl_rank(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<ADL> {
let v = crate::runtime::call_typed(self.core_mut().fetch_position_adl_rank(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(ADL::from_value(v))
}
pub async fn create_spot_orders(&mut self, orders: Value, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().create_spot_orders(orders, &[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn create_contract_orders(&mut self, orders: Value, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().create_contract_orders(orders, &[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn cancel_spot_order(&mut self, id: &str, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().cancel_spot_order(Value::Str(id.to_string()), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn cancel_contract_order(&mut self, id: &str, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().cancel_contract_order(Value::Str(id.to_string()), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn cancel_all_spot_orders(&mut self, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().cancel_all_spot_orders(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn cancel_all_contract_orders(&mut self, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().cancel_all_contract_orders(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn cancel_orders_for_symbols(&mut self, orders: Value, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().cancel_orders_for_symbols(orders, &[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn fetch_my_liquidations(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Liquidation>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_my_liquidations(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Liquidation::from_value))
}
pub async fn fetch_liquidations(&mut self, symbol: &str, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Liquidation>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_liquidations(Value::Str(symbol.to_string()), &[since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Liquidation::from_value))
}
pub async fn fetch_greeks(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<Greeks> {
let v = crate::runtime::call_typed(self.core_mut().fetch_greeks(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(Greeks::from_value(v))
}
pub async fn fetch_all_greeks(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<AllGreeks> {
let v = crate::runtime::call_typed(self.core_mut().fetch_all_greeks(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, Greeks::from_value))
}
pub async fn fetch_option_chain(&mut self, code: &str, params: impl Into<Params>) -> crate::Result<OptionChain> {
let v = crate::runtime::call_typed(self.core_mut().fetch_option_chain(Value::Str(code.to_string()), &[params.into().into_value()])).await?;
Ok(dict_from_value(&v, OptionContract::from_value))
}
pub async fn fetch_option(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<OptionContract> {
let v = crate::runtime::call_typed(self.core_mut().fetch_option(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(OptionContract::from_value(v))
}
pub async fn fetch_convert_quote(&mut self, from_code: &str, to_code: &str, amount: Option<f64>, params: impl Into<Params>) -> crate::Result<Conversion> {
let v = crate::runtime::call_typed(self.core_mut().fetch_convert_quote(Value::Str(from_code.to_string()), Value::Str(to_code.to_string()), &[amount.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Conversion::from_value(v))
}
pub async fn fetch_deposits_withdrawals(&mut self, code: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Transaction>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_deposits_withdrawals(&[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Transaction::from_value))
}
pub async fn fetch_deposits(&mut self, code: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Transaction>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_deposits(&[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Transaction::from_value))
}
pub async fn fetch_withdrawals(&mut self, code: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Transaction>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_withdrawals(&[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Transaction::from_value))
}
pub async fn fetch_funding_rate_history(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<FundingRateHistory>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_funding_rate_history(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, FundingRateHistory::from_value))
}
pub async fn fetch_funding_history(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<FundingHistory>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_funding_history(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, FundingHistory::from_value))
}
pub async fn fetch_deposit_address(&mut self, code: &str, params: impl Into<Params>) -> crate::Result<DepositAddress> {
let v = crate::runtime::call_typed(self.core_mut().fetch_deposit_address(Value::Str(code.to_string()), &[params.into().into_value()])).await?;
Ok(DepositAddress::from_value(v))
}
pub async fn fetch_contract_deposit_address(&mut self, code: &str, params: impl Into<Params>) -> crate::Result<DepositAddress> {
let v = crate::runtime::call_typed(self.core_mut().fetch_contract_deposit_address(Value::Str(code.to_string()), &[params.into().into_value()])).await?;
Ok(DepositAddress::from_value(v))
}
pub async fn fetch_market_leverage_tiers(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<Vec<LeverageTier>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_market_leverage_tiers(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(vec_from_value(&v, LeverageTier::from_value))
}
pub async fn fetch_last_prices(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<LastPrices> {
let v = crate::runtime::call_typed(self.core_mut().fetch_last_prices(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, LastPrice::from_value))
}
pub async fn fetch_trading_fees(&mut self, params: impl Into<Params>) -> crate::Result<TradingFees> {
let v = crate::runtime::call_typed(self.core_mut().fetch_trading_fees(&[params.into().into_value()])).await?;
Ok(dict_from_value(&v, TradingFee::from_value))
}
pub async fn fetch_convert_currencies(&mut self, params: impl Into<Params>) -> crate::Result<Currencies> {
let v = crate::runtime::call_typed(self.core_mut().fetch_convert_currencies(&[params.into().into_value()])).await?;
Ok(dict_from_value(&v, Currency::from_value))
}
pub async fn fetch_funding_rate(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<FundingRate> {
let v = crate::runtime::call_typed(self.core_mut().fetch_funding_rate(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(FundingRate::from_value(v))
}
pub async fn fetch_funding_interval(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<FundingRate> {
let v = crate::runtime::call_typed(self.core_mut().fetch_funding_interval(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(FundingRate::from_value(v))
}
pub async fn fetch_mark_ohlcv(&mut self, symbol: &str, timeframe: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<OHLCV>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_mark_ohlcv(Value::Str(symbol.to_string()), &[timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(match v { Value::Arr(arr) => arr.iter().map(|c| { let mut out = [0.0f64; 6]; if let Value::Arr(fields) = c { for (i, slot) in out.iter_mut().enumerate() { if let Some(f) = fields.get(i).and_then(|x| x.as_f64()) { *slot = f; } } } out }).collect(), _ => Vec::new() })
}
pub async fn fetch_index_ohlcv(&mut self, symbol: &str, timeframe: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<OHLCV>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_index_ohlcv(Value::Str(symbol.to_string()), &[timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(match v { Value::Arr(arr) => arr.iter().map(|c| { let mut out = [0.0f64; 6]; if let Value::Arr(fields) = c { for (i, slot) in out.iter_mut().enumerate() { if let Some(f) = fields.get(i).and_then(|x| x.as_f64()) { *slot = f; } } } out }).collect(), _ => Vec::new() })
}
pub async fn fetch_premium_index_ohlcv(&mut self, symbol: &str, timeframe: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<OHLCV>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_premium_index_ohlcv(Value::Str(symbol.to_string()), &[timeframe.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(match v { Value::Arr(arr) => arr.iter().map(|c| { let mut out = [0.0f64; 6]; if let Value::Arr(fields) = c { for (i, slot) in out.iter_mut().enumerate() { if let Some(f) = fields.get(i).and_then(|x| x.as_f64()) { *slot = f; } } } out }).collect(), _ => Vec::new() })
}
pub async fn fetch_transactions(&mut self, code: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Transaction>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_transactions(&[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Transaction::from_value))
}
pub async fn fetch_transfer(&mut self, id: &str, code: Option<&str>, params: impl Into<Params>) -> crate::Result<Transfer> {
let v = crate::runtime::call_typed(self.core_mut().fetch_transfer(Value::Str(id.to_string()), &[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Transfer::from_value(v))
}
pub async fn fetch_transfers(&mut self, code: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Transfer>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_transfers(&[code.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Transfer::from_value))
}
pub async fn close_position(&mut self, symbol: &str, side: Option<&str>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().close_position(Value::Str(symbol.to_string()), &[side.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn close_all_positions(&mut self, params: impl Into<Params>) -> crate::Result<Vec<Position>> {
let v = crate::runtime::call_typed(self.core_mut().close_all_positions(&[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Position::from_value))
}
pub async fn edit_orders(&mut self, orders: Value, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().edit_orders(orders, &[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn fetch_canceled_and_closed_orders(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_canceled_and_closed_orders(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn fetch_position_history(&mut self, symbol: &str, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Position>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_position_history(Value::Str(symbol.to_string()), &[since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Position::from_value))
}
pub async fn fetch_positions_history(&mut self, symbols: Option<Vec<String>>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Position>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_positions_history(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Position::from_value))
}
pub async fn fetch_positions_risk(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Vec<Position>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_positions_risk(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(vec_from_value(&v, Position::from_value))
}
pub async fn fetch_positions_for_symbol(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<Vec<Position>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_positions_for_symbol(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Position::from_value))
}
pub async fn fetch_bids_asks(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Tickers> {
let v = crate::runtime::call_typed(self.core_mut().fetch_bids_asks(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, Ticker::from_value))
}
pub async fn fetch_mark_price(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<Ticker> {
let v = crate::runtime::call_typed(self.core_mut().fetch_mark_price(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(Ticker::from_value(v))
}
pub async fn fetch_mark_prices(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Tickers> {
let v = crate::runtime::call_typed(self.core_mut().fetch_mark_prices(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, Ticker::from_value))
}
pub async fn fetch_l3_order_book(&mut self, symbol: &str, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<OrderBook> {
let v = crate::runtime::call_typed(self.core_mut().fetch_l3_order_book(Value::Str(symbol.to_string()), &[limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(OrderBook::from_value(v))
}
pub async fn fetch_trades(&mut self, symbol: &str, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Trade>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_trades(Value::Str(symbol.to_string()), &[since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Trade::from_value))
}
pub async fn fetch_order_book(&mut self, symbol: &str, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<OrderBook> {
let v = crate::runtime::call_typed(self.core_mut().fetch_order_book(Value::Str(symbol.to_string()), &[limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(OrderBook::from_value(v))
}
pub async fn fetch_open_interest(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<OpenInterest> {
let v = crate::runtime::call_typed(self.core_mut().fetch_open_interest(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(OpenInterest::from_value(v))
}
pub async fn edit_limit_buy_order(&mut self, id: &str, symbol: &str, amount: f64, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().edit_limit_buy_order(Value::Str(id.to_string()), Value::Str(symbol.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn edit_limit_sell_order(&mut self, id: &str, symbol: &str, amount: f64, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().edit_limit_sell_order(Value::Str(id.to_string()), Value::Str(symbol.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn edit_limit_order(&mut self, id: &str, symbol: &str, side: &str, amount: f64, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().edit_limit_order(Value::Str(id.to_string()), Value::Str(symbol.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn edit_order(&mut self, id: &str, symbol: &str, type_: &str, side: &str, amount: Option<f64>, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().edit_order(Value::Str(id.to_string()), Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), &[amount.map(Value::Float).unwrap_or(Value::Null), price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn edit_order_with_client_order_id(&mut self, client_order_id: &str, symbol: &str, type_: &str, side: &str, amount: Option<f64>, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().edit_order_with_client_order_id(Value::Str(client_order_id.to_string()), Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), &[amount.map(Value::Float).unwrap_or(Value::Null), price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn fetch_position(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<Position> {
let v = crate::runtime::call_typed(self.core_mut().fetch_position(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(Position::from_value(v))
}
pub async fn fetch_positions(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Vec<Position>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_positions(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(vec_from_value(&v, Position::from_value))
}
pub async fn fetch_ticker(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<Ticker> {
let v = crate::runtime::call_typed(self.core_mut().fetch_ticker(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(Ticker::from_value(v))
}
pub async fn fetch_tickers(&mut self, symbols: Option<Vec<String>>, params: impl Into<Params>) -> crate::Result<Tickers> {
let v = crate::runtime::call_typed(self.core_mut().fetch_tickers(&[match symbols { Some(list) => Value::Arr(std::sync::Arc::new(list.into_iter().map(Value::Str).collect())), None => Value::Null }, params.into().into_value()])).await?;
Ok(dict_from_value(&v, Ticker::from_value))
}
pub async fn fetch_order(&mut self, id: &str, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().fetch_order(Value::Str(id.to_string()), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn fetch_order_with_client_order_id(&mut self, client_order_id: &str, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().fetch_order_with_client_order_id(Value::Str(client_order_id.to_string()), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn fetch_order_status(&mut self, id: &str, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Option<String>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_order_status(Value::Str(id.to_string()), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(match v { Value::Str(s) => Some(s), _ => None })
}
pub async fn fetch_unified_order(&mut self, order: Value, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().fetch_unified_order(order, &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_trailing_amount_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, trailing_amount: Option<f64>, trailing_trigger_price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_trailing_amount_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), trailing_amount.map(Value::Float).unwrap_or(Value::Null), trailing_trigger_price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_trailing_percent_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, trailing_percent: Option<f64>, trailing_trigger_price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_trailing_percent_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), trailing_percent.map(Value::Float).unwrap_or(Value::Null), trailing_trigger_price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_market_order_with_cost(&mut self, symbol: &str, side: &str, cost: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_market_order_with_cost(Value::Str(symbol.to_string()), Value::Str(side.to_string()), Value::Float(cost), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_market_buy_order_with_cost(&mut self, symbol: &str, cost: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_market_buy_order_with_cost(Value::Str(symbol.to_string()), Value::Float(cost), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_market_sell_order_with_cost(&mut self, symbol: &str, cost: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_market_sell_order_with_cost(Value::Str(symbol.to_string()), Value::Float(cost), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_trigger_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, trigger_price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_trigger_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), trigger_price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_stop_loss_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, stop_loss_price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_stop_loss_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), stop_loss_price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_take_profit_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, take_profit_price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_take_profit_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), take_profit_price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_order_with_take_profit_and_stop_loss(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, take_profit: Option<f64>, stop_loss: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_order_with_take_profit_and_stop_loss(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), take_profit.map(Value::Float).unwrap_or(Value::Null), stop_loss.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_orders(&mut self, orders: Value, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().create_orders(orders, &[params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn cancel_order(&mut self, id: &str, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().cancel_order(Value::Str(id.to_string()), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn cancel_order_with_client_order_id(&mut self, client_order_id: &str, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().cancel_order_with_client_order_id(Value::Str(client_order_id.to_string()), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn cancel_orders(&mut self, ids: Vec<String>, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().cancel_orders(Value::Arr(std::sync::Arc::new(ids.into_iter().map(Value::Str).collect())), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn cancel_orders_with_client_order_ids(&mut self, client_order_ids: Vec<String>, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().cancel_orders_with_client_order_ids(Value::Arr(std::sync::Arc::new(client_order_ids.into_iter().map(Value::Str).collect())), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn cancel_all_orders(&mut self, symbol: Option<&str>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().cancel_all_orders(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn cancel_unified_order(&mut self, order: Value, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().cancel_unified_order(order, &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn fetch_orders(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_orders(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn fetch_order_trades(&mut self, id: &str, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Trade>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_order_trades(Value::Str(id.to_string()), &[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Trade::from_value))
}
pub async fn fetch_open_orders(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_open_orders(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn fetch_closed_orders(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_closed_orders(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn fetch_canceled_orders(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Order>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_canceled_orders(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Order::from_value))
}
pub async fn fetch_my_trades(&mut self, symbol: Option<&str>, since: Option<i64>, limit: Option<i64>, params: impl Into<Params>) -> crate::Result<Vec<Trade>> {
let v = crate::runtime::call_typed(self.core_mut().fetch_my_trades(&[symbol.map(|s| Value::Str(s.to_string())).unwrap_or(Value::Null), since.map(Value::Int).unwrap_or(Value::Null), limit.map(Value::Int).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(vec_from_value(&v, Trade::from_value))
}
pub async fn create_limit_order(&mut self, symbol: &str, side: &str, amount: f64, price: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_limit_order(Value::Str(symbol.to_string()), Value::Str(side.to_string()), Value::Float(amount), Value::Float(price), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_market_order(&mut self, symbol: &str, side: &str, amount: f64, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_market_order(Value::Str(symbol.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_limit_buy_order(&mut self, symbol: &str, amount: f64, price: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_limit_buy_order(Value::Str(symbol.to_string()), Value::Float(amount), Value::Float(price), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_limit_sell_order(&mut self, symbol: &str, amount: f64, price: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_limit_sell_order(Value::Str(symbol.to_string()), Value::Float(amount), Value::Float(price), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_market_buy_order(&mut self, symbol: &str, amount: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_market_buy_order(Value::Str(symbol.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_market_sell_order(&mut self, symbol: &str, amount: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_market_sell_order(Value::Str(symbol.to_string()), Value::Float(amount), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_post_only_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_post_only_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_reduce_only_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_reduce_only_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_stop_order(&mut self, symbol: &str, type_: &str, side: &str, amount: f64, price: Option<f64>, trigger_price: Option<f64>, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_stop_order(Value::Str(symbol.to_string()), Value::Str(type_.to_string()), Value::Str(side.to_string()), Value::Float(amount), &[price.map(Value::Float).unwrap_or(Value::Null), trigger_price.map(Value::Float).unwrap_or(Value::Null), params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_stop_limit_order(&mut self, symbol: &str, side: &str, amount: f64, price: f64, trigger_price: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_stop_limit_order(Value::Str(symbol.to_string()), Value::Str(side.to_string()), Value::Float(amount), Value::Float(price), Value::Float(trigger_price), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn create_stop_market_order(&mut self, symbol: &str, side: &str, amount: f64, trigger_price: f64, params: impl Into<Params>) -> crate::Result<Order> {
let v = crate::runtime::call_typed(self.core_mut().create_stop_market_order(Value::Str(symbol.to_string()), Value::Str(side.to_string()), Value::Float(amount), Value::Float(trigger_price), &[params.into().into_value()])).await?;
Ok(Order::from_value(v))
}
pub async fn fetch_trading_fee(&mut self, symbol: &str, params: impl Into<Params>) -> crate::Result<TradingFee> {
let v = crate::runtime::call_typed(self.core_mut().fetch_trading_fee(Value::Str(symbol.to_string()), &[params.into().into_value()])).await?;
Ok(TradingFee::from_value(v))
}
}
#[async_trait::async_trait]
impl crate::typed::TypedExchange for Myriad {
async fn call_raw(&mut self, method: &str, args: Vec<Value>) -> crate::Result<Value> {
crate::runtime::call_typed(self.core_mut().call_dynamic(method, args)).await
}
fn market(&self, symbol: &str) -> crate::Result<Market> { Myriad::market(self, symbol) }
fn markets(&self) -> Vec<Market> { Myriad::markets(self) }
}