// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct Bit2cCore {
pub exchange: crate::exchange::Exchange,
}
impl Bit2cCore {
pub fn new(config: Option<crate::Value>) -> Self {
let mut s = Self { exchange: crate::exchange::Exchange::new(config) };
s.init();
s
}
pub fn init(&mut self) {
let described = Bit2cCore::describe(self);
self.initialize_properties(described);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for Bit2cCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on Bit2cCore.
Bit2cCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on Bit2cCore.
Bit2cCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on Bit2cCore.
Bit2cCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on Bit2cCore.
Bit2cCore::parse_order(self, order, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on Bit2cCore.
Bit2cCore::parse_balance(self, response)
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on Bit2cCore.
Bit2cCore::parse_deposit_address(self, depositAddress, &[currency.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on Bit2cCore.
Bit2cCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on Bit2cCore.
Bit2cCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for Bit2cCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"is_fiat" => self.is_fiat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"remove_comma_from_value" => self.remove_comma_from_value(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for Bit2cCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for Bit2cCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl Bit2cCore {
pub fn describe(&self) -> Value {
return self.deep_extend(self.super_describe(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("bit2c".to_string()));
m.insert("name".to_string(), Value::Str("Bit2C".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("IL".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(3000));
m.insert("pro".to_string(), Value::Bool(false));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(false));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(false));
m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Bool(false));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingInterval".to_string(), Value::Bool(false));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverages".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarginModes".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMarkPrices".to_string(), Value::Bool(false));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenInterests".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOption".to_string(), Value::Bool(false));
m.insert("fetchOptionChain".to_string(), Value::Bool(false));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchUnderlyingAssets".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("repayMargin".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(false));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("ws".to_string(), Value::Bool(false));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/db0bce50-6842-4c09-a1d5-0c87d22118aa".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://bit2c.co.il".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.bit2c.co.il".to_string()));
m.insert("referral".to_string(), Value::Str("https://bit2c.co.il/Aff/63bfed10-e359-420c-ab5a-ad368dab0baf".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://www.bit2c.co.il/home/api".to_string()), Value::Str("https://github.com/OferE/bit2c".to_string())]));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Exchanges/{pair}/Ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Exchanges/{pair}/orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Exchanges/{pair}/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Exchanges/{pair}/lasttrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Merchant/CreateCheckout".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Funds/AddCoinFundsRequest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/AddFund".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/AddOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/GetById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/AddOrderMarketPriceBuy".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/AddOrderMarketPriceSell".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/CancelOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/AddCoinFundsRequest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/AddStopOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Payment/GetMyId".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Payment/Send".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Payment/Pay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Account/Balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Account/Balance/v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/MyOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/GetById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/AccountHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Order/OrderHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("markets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BTC/NIS".to_string(), self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("BtcNis".to_string()));
m.insert("symbol".to_string(), Value::Str("BTC/NIS".to_string()));
m.insert("base".to_string(), Value::Str("BTC".to_string()));
m.insert("quote".to_string(), Value::Str("NIS".to_string()));
m.insert("baseId".to_string(), Value::Str("Btc".to_string()));
m.insert("quoteId".to_string(), Value::Str("Nis".to_string()));
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m
})]));
m.insert("ETH/NIS".to_string(), self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("EthNis".to_string()));
m.insert("symbol".to_string(), Value::Str("ETH/NIS".to_string()));
m.insert("base".to_string(), Value::Str("ETH".to_string()));
m.insert("quote".to_string(), Value::Str("NIS".to_string()));
m.insert("baseId".to_string(), Value::Str("Eth".to_string()));
m.insert("quoteId".to_string(), Value::Str("Nis".to_string()));
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m
})]));
m.insert("LTC/NIS".to_string(), self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("LtcNis".to_string()));
m.insert("symbol".to_string(), Value::Str("LTC/NIS".to_string()));
m.insert("base".to_string(), Value::Str("LTC".to_string()));
m.insert("quote".to_string(), Value::Str("NIS".to_string()));
m.insert("baseId".to_string(), Value::Str("Ltc".to_string()));
m.insert("quoteId".to_string(), Value::Str("Nis".to_string()));
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m
})]));
m.insert("USDC/NIS".to_string(), self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("UsdcNis".to_string()));
m.insert("symbol".to_string(), Value::Str("USDC/NIS".to_string()));
m.insert("base".to_string(), Value::Str("USDC".to_string()));
m.insert("quote".to_string(), Value::Str("NIS".to_string()));
m.insert("baseId".to_string(), Value::Str("Usdc".to_string()));
m.insert("quoteId".to_string(), Value::Str("Nis".to_string()));
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m
})]));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.025".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.03".to_string()), &[]));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.03".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("20000".to_string()), &[]), self.parse_number(Value::Str("0.0275".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("0.025".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("75000".to_string()), &[]), self.parse_number(Value::Str("0.0225".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("0.02".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250000".to_string()), &[]), self.parse_number(Value::Str("0.015".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("500000".to_string()), &[]), self.parse_number(Value::Str("0.0125".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("750000".to_string()), &[]), self.parse_number(Value::Str("0.01".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000000".to_string()), &[]), self.parse_number(Value::Str("0.008".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("2000000".to_string()), &[]), self.parse_number(Value::Str("0.006".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("3000000".to_string()), &[]), self.parse_number(Value::Str("0.004".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("4000000".to_string()), &[]), self.parse_number(Value::Str("0.002".to_string()), &[])])]));
m.insert("maker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.025".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("20000".to_string()), &[]), self.parse_number(Value::Str("0.0225".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("0.02".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("75000".to_string()), &[]), self.parse_number(Value::Str("0.0175".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("0.015".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250000".to_string()), &[]), self.parse_number(Value::Str("0.01".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("500000".to_string()), &[]), self.parse_number(Value::Str("0.0075".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("750000".to_string()), &[]), self.parse_number(Value::Str("0.005".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000000".to_string()), &[]), self.parse_number(Value::Str("0.004".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("2000000".to_string()), &[]), self.parse_number(Value::Str("0.003".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("3000000".to_string()), &[]), self.parse_number(Value::Str("0.002".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("4000000".to_string()), &[]), self.parse_number(Value::Str("0.001".to_string()), &[])])]));
m
}));
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fetchTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("public_get_exchanges_pair_trades".to_string()));
m
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(false));
m.insert("FOK".to_string(), Value::Bool(false));
m.insert("PO".to_string(), Value::Bool(false));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(30));
m.insert("untilDays".to_string(), Value::Int(30));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Null);
m.insert("fetchOHLCV".to_string(), Value::Null);
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Please provide valid APIkey".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("No order found.".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Please provide valid nonce".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("please approve new terms of use on site".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m
}));
m
}));
m
})]);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
let mut codes: Value = object_keys(&self.currencies);
{
let mut i: Value = Value::Int(0);
let mut __for_first_304: bool = true;
while { if !__for_first_304 { i = add(&i, &Value::Int(1)); } __for_first_304 = false; is_less_than(&i, &get_array_length(&codes)) } {
let mut code: Value = get_value(&codes, &i);
let mut code: Value = get_value(&codes, &i);
let mut account: Value = self.account();
let mut currency: Value = self.currency(code.clone());
let mut uppercase: Value = to_upper(&get_value(¤cy, &Value::Str("id".to_string())));
if is_true(&Value::Bool(in_op(&response, &uppercase))) {
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string(response.clone(), add(&Value::Str("AVAILABLE_".to_string()), &uppercase), &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string(response.clone(), uppercase.clone(), &[]));
}
add_element_to_object(&mut result, &code, account.clone());
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name bit2c#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://bit2c.co.il/home/api#balance
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_account_balance_v2(&[params.clone()]).await;
return self.parse_balance(response.clone());
Value::Null
}
/*
* @method
* @name bit2c#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://bit2c.co.il/home/api#orderb
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut orderbook: Value = self.public_get_exchanges_pair_orderbook(&[__ws_arg_0]).await;
// the full orderbook.json snapshot can contain dead orders - rows
// published with a zero amount at their limit price, hours-stable and
// sometimes crossing the real market. per the api docs the endpoint
// contains open orders only, and the venue's own orderbook-top.json ui
// feed filters these rows out, so a non-positive amount is a dead order
// their full snapshot failed to purge - it is removed here, which also
// uncrosses the book. rows are positional price and amount pairs
let mut rawBids: Value = self.safe_list_k(orderbook.clone(), "bids", &[Value::List(vec![])]);
let mut rawAsks: Value = self.safe_list_k(orderbook.clone(), "asks", &[Value::List(vec![])]);
let mut bids: Value = Value::List(vec![]);
let mut asks: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_305: bool = true;
while { if !__for_first_305 { i = add(&i, &Value::Int(1)); } __for_first_305 = false; is_less_than(&i, &get_array_length(&rawBids)) } {
let mut bidRow: Value = get_value(&rawBids, &i);
let mut bidRow: Value = get_value(&rawBids, &i);
let mut bidAmount: Value = self.safe_string(bidRow.clone(), Value::Int(1), &[]);
if is_true(&crate::precise::Precise::stringGt(&bidAmount, &Value::Str("0".to_string()))) {
append_to_array(&mut bids, bidRow.clone());
}
}
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_306: bool = true;
while { if !__for_first_306 { i = add(&i, &Value::Int(1)); } __for_first_306 = false; is_less_than(&i, &get_array_length(&rawAsks)) } {
let mut askRow: Value = get_value(&rawAsks, &i);
let mut askRow: Value = get_value(&rawAsks, &i);
let mut askAmount: Value = self.safe_string(askRow.clone(), Value::Int(1), &[]);
if is_true(&crate::precise::Precise::stringGt(&askAmount, &Value::Str("0".to_string()))) {
append_to_array(&mut asks, askRow.clone());
}
}
}
let mut filtered: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("bids".to_string(), bids.clone());
m.insert("asks".to_string(), asks.clone());
m
});
return self.parse_order_book(filtered.clone(), symbol.clone(), &[]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut symbol: Value = self.safe_symbol(Value::Null, &[market.clone()]);
let mut averagePrice: Value = self.safe_string_k(ticker.clone(), "av", &[]);
let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "a", &[]);
let mut last: Value = self.safe_string_k(ticker.clone(), "ll", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("high".to_string(), Value::Null);
m.insert("low".to_string(), Value::Null);
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "h", &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "l", &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), Value::Null);
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), averagePrice.clone());
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), Value::Null);
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bit2c#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://bit2c.co.il/home/api#ticker
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_exchanges_pair_ticker(&[__ws_arg_1]).await;
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bit2c#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://bit2c.co.il/home/api#transactions
* @see https://bit2c.co.il/home/api#trades
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut optionValue: Value = self.safe_string_k(self.options.clone(), "fetchTradesMethod", &[]); // kept here for backward compatibility #29154
let mut method: Value = self.handle_option(Value::Str("fetchTrades".to_string()), Value::Str("method".to_string()), &[optionValue.clone()]); // public_get_exchanges_pair_trades or public_get_exchanges_pair_lasttrades
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("date".to_string()), self.parse_to_int(since.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // max 100000
}
let mut responseList: Value = Value::List(vec![]);
if is_equal(&method, &Value::Str("public_get_exchanges_pair_trades".to_string())) {
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_exchanges_pair_trades(&[__ws_arg_2]).await;
//
// [
// {"date":1651785980,"price":127975.68,"amount":0.3750321,"isBid":true,"tid":1261018},
// {"date":1651785980,"price":127987.70,"amount":0.0389527820303982335802581029,"isBid":true,"tid":1261020},
// {"date":1651786701,"price":128084.03,"amount":0.0015614749161156156626239821,"isBid":true,"tid":1261022},
// ]
//
if is_string(&response) {
panic!("{}", crate::exchange_errors::exchange_error(response));
}
responseList = self.to_array(response.clone());
} else {
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_exchanges_pair_lasttrades(&[__ws_arg_3]).await;
if is_string(&response) {
panic!("{}", crate::exchange_errors::exchange_error(response));
}
responseList = self.to_array(response.clone());
}
return self.parse_trades(responseList.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bit2c#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://bit2c.co.il/home/api#balance
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_account_balance(&[params.clone()]).await;
//
// {
// "AVAILABLE_NIS": 0.0,
// "NIS": 0.0,
// "LOCKED_NIS": 0.0,
// "AVAILABLE_BTC": 0.0,
// "BTC": 0.0,
// "LOCKED_BTC": 0.0,
// ...
// "Fees": {
// "BtcNis": { "FeeMaker": 1.0, "FeeTaker": 1.0 },
// "EthNis": { "FeeMaker": 1.0, "FeeTaker": 1.0 },
// ...
// }
// }
//
let mut fees: Value = self.safe_value_k(response.clone(), "Fees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut keys: Value = object_keys(&fees);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_307: bool = true;
while { if !__for_first_307 { i = add(&i, &Value::Int(1)); } __for_first_307 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut marketId: Value = get_value(&keys, &i);
let mut marketId: Value = get_value(&keys, &i);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[]);
let mut fee: Value = self.safe_value(fees.clone(), marketId.clone(), &[]);
let mut makerString: Value = self.safe_string_k(fee.clone(), "FeeMaker", &[]);
let mut takerString: Value = self.safe_string_k(fee.clone(), "FeeTaker", &[]);
let mut maker: Value = self.parse_number(crate::precise::Precise::stringDiv(&makerString, &Value::Str("100".to_string())), &[]);
let mut taker: Value = self.parse_number(crate::precise::Precise::stringDiv(&takerString, &Value::Str("100".to_string())), &[]);
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("taker".to_string(), taker.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name bit2c#createOrder
* @description create a trade order
* @see https://bit2c.co.il/home/api#addo
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Amount".to_string(), amount.clone());
m.insert("Pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("market".to_string())) {
if is_equal(&side, &Value::Str("buy".to_string())) {
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_order_add_order_market_price_buy(&[__ws_arg_4]).await;
} else {
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_order_add_order_market_price_sell(&[__ws_arg_5]).await;
}
} else {
add_element_to_object(&mut request, &Value::Str("Price".to_string()), price.clone());
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
add_element_to_object(&mut request, &Value::Str("Total".to_string()), self.parse_to_numeric(crate::precise::Precise::stringMul(&amountString, &priceString)));
add_element_to_object(&mut request, &Value::Str("IsBid".to_string()), Value::Bool((is_equal(&side, &Value::Str("buy".to_string())))));
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_order_add_order(&[__ws_arg_6]).await;
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bit2c#cancelOrder
* @description cancels an open order
* @see https://bit2c.co.il/home/api#cancelo
* @param {string} id order id
* @param {string} symbol Not used by bit2c cancelOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
});
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_order_cancel_order(&[__ws_arg_7]).await;
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name bit2c#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://bit2c.co.il/home/api#geto
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOpenOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_order_my_orders(&[__ws_arg_8]).await;
let mut orders: Value = self.safe_value(response.clone(), get_value(&market, &Value::Str("id".to_string())), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut asks: Value = self.safe_value_k(orders.clone(), "ask", &[Value::List(vec![])]);
let mut bids: Value = self.safe_list_k(orders.clone(), "bid", &[Value::List(vec![])]);
return self.parse_orders(self.array_concat(asks.clone(), bids.clone()), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bit2c#fetchOrder
* @description fetches information on an order made by the user
* @see https://bit2c.co.il/home/api#getoid
* @param {string} id the order id
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_order_get_by_id(&[__ws_arg_9]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder
// {
// "OrderResponse": {"pair": "BtcNis", "HasError": False, "Error": "", "Message": ""},
// "NewOrder": {
// "created": 1505531577,
// "type": 0,
// "order_type": 0,
// "status_type": 0,
// "amount": 0.01,
// "price": 10000,
// "stop": 0,
// "id": 9244416,
// "initialAmount": None,
// },
// }
// fetchOrder, fetchOpenOrders
// {
// "pair": "BtcNis",
// "status": "Completed",
// "created": 1535555837,
// "type": 0,
// "order_type": 0,
// "amount": 0.00000000,
// "price": 120000.00000000,
// "stop": 0,
// "id": 10555173,
// "initialAmount": 2.00000000
// }
//
let mut orderUnified: Value = Value::Null;
let mut isNewOrder: bool = false;
if is_true(&Value::Bool(in_op(&order, &Value::Str("NewOrder".to_string())))) {
orderUnified = get_value(&order, &Value::Str("NewOrder".to_string()));
isNewOrder = true;
} else {
orderUnified = order.clone();
}
let mut id: Value = self.safe_string_k(orderUnified.clone(), "id", &[]);
let mut symbol: Value = self.safe_symbol(Value::Null, &[market.clone()]);
let mut timestamp: Value = self.safe_integer_product(orderUnified.clone(), Value::Str("created".to_string()), Value::Int(1000), &[]);
// status field vary between responses
// bit2c status type:
// 0 = New
// 1 = Open
// 5 = Completed
let mut status: Value = Value::Null;
if is_true(&isNewOrder) {
let mut tempStatus: Value = self.safe_integer_k(orderUnified.clone(), "status_type", &[]);
if is_equal(&tempStatus, &Value::Int(0)) || is_equal(&tempStatus, &Value::Int(1)) {
status = Value::Str("open".to_string());
} else if is_equal(&tempStatus, &Value::Int(5)) {
status = Value::Str("closed".to_string());
}
} else {
let mut tempStatus: Value = self.safe_string_k(orderUnified.clone(), "status", &[]);
if is_equal(&tempStatus, &Value::Str("New".to_string())) || is_equal(&tempStatus, &Value::Str("Open".to_string())) {
status = Value::Str("open".to_string());
} else if is_equal(&tempStatus, &Value::Str("Completed".to_string())) {
status = Value::Str("closed".to_string());
}
}
// bit2c order type:
// 0 = LMT, 1 = MKT
let mut type_var: Value = self.safe_string_k(orderUnified.clone(), "order_type", &[]);
if is_equal(&type_var, &Value::Str("0".to_string())) {
type_var = Value::Str("limit".to_string());
} else if is_equal(&type_var, &Value::Str("1".to_string())) {
type_var = Value::Str("market".to_string());
}
// bit2c side:
// 0 = buy, 1 = sell
let mut side: Value = self.safe_string_k(orderUnified.clone(), "type", &[]);
if is_equal(&side, &Value::Str("0".to_string())) {
side = Value::Str("buy".to_string());
} else if is_equal(&side, &Value::Str("1".to_string())) {
side = Value::Str("sell".to_string());
}
let mut price: Value = self.safe_string_k(orderUnified.clone(), "price", &[]);
let mut amount: Value = Value::Null;
let mut remaining: Value = Value::Null;
if is_true(&isNewOrder) {
amount = self.safe_string_k(orderUnified.clone(), "amount", &[]); // NOTE:'initialAmount' is currently not set on new order
remaining = self.safe_string_k(orderUnified.clone(), "amount", &[]);
} else {
amount = self.safe_string_k(orderUnified.clone(), "initialAmount", &[]);
remaining = self.safe_string_k(orderUnified.clone(), "amount", &[]);
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), Value::Null);
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("amount".to_string(), amount.clone());
m.insert("filled".to_string(), Value::Null);
m.insert("remaining".to_string(), remaining.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("info".to_string(), order.clone());
m.insert("average".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bit2c#fetchMyTrades
* @description fetch all trades made by the user
* @see https://bit2c.co.il/home/api#orderh
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("take".to_string()), limit.clone());
}
add_element_to_object(&mut request, &Value::Str("take".to_string()), limit.clone());
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("toTime".to_string()), self.yyyymmdd(self.milliseconds(), &[Value::Str(".".to_string())]));
add_element_to_object(&mut request, &Value::Str("fromTime".to_string()), self.yyyymmdd(since.clone(), &[Value::Str(".".to_string())]));
}
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("pair".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_order_order_history(&[__ws_arg_10]).await;
//
// [
// {
// "ticks":1574767951,
// "created":"26/11/19 13:32",
// "action":1,
// "price":"1000",
// "pair":"EthNis",
// "reference":"EthNis|10867390|10867377",
// "fee":"0.5",
// "feeAmount":"0.08",
// "feeCoin":"₪",
// "firstAmount":"-0.015",
// "firstAmountBalance":"9",
// "secondAmount":"14.93",
// "secondAmountBalance":"130,233.28",
// "firstCoin":"ETH",
// "secondCoin":"₪"
// },
// {
// "ticks":1574767951,
// "created":"26/11/19 13:32",
// "action":0,
// "price":"1000",
// "pair":"EthNis",
// "reference":"EthNis|10867390|10867377",
// "fee":"0.5",
// "feeAmount":"0.08",
// "feeCoin":"₪",
// "firstAmount":"0.015",
// "firstAmountBalance":"9.015",
// "secondAmount":"-15.08",
// "secondAmountBalance":"130,218.35",
// "firstCoin":"ETH",
// "secondCoin":"₪"
// }
// ]
//
let mut responseList: Value = Value::List(vec![]);
if !is_equal(&response, &Value::Null) {
responseList = self.to_array(response.clone());
}
return self.parse_trades(responseList.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn remove_comma_from_value(&self, mut str_val: Value) -> Value {
let mut newString: Value = Value::Str("".to_string());
let mut strParts: Value = split(&str_val, &Value::Str(",".to_string()));
{
let mut i: Value = Value::Int(0);
let mut __for_first_308: bool = true;
while { if !__for_first_308 { i = add(&i, &Value::Int(1)); } __for_first_308 = false; is_less_than(&i, &get_array_length(&strParts)) } {
newString = add(&newString, &get_value(&strParts, &i));
}
}
return newString;
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// public fetchTrades
//
// {
// "date":1651785980,
// "price":127975.68,
// "amount":0.3750321,
// "isBid":true,
// "tid":1261018
// }
//
// private fetchMyTrades
//
// {
// "ticks":1574767951,
// "created":"26/11/19 13:32",
// "action":1,
// "price":"1,000",
// "pair":"EthNis",
// "reference":"EthNis|10867390|10867377",
// "fee":"0.5",
// "feeAmount":"0.08",
// "feeCoin":"₪",
// "firstAmount":"-0.015",
// "firstAmountBalance":"9",
// "secondAmount":"14.93",
// "secondAmountBalance":"130,233.28",
// "firstCoin":"ETH",
// "secondCoin":"₪"
// "isMaker": True,
// }
//
let mut timestamp: Value = Value::Null;
let mut id: Value = Value::Null;
let mut price: Value = Value::Null;
let mut amount: Value = Value::Null;
let mut orderId: Value = Value::Null;
let mut fee: Value = Value::Null;
let mut side: Value = Value::Null;
let mut makerOrTaker: Value = Value::Null;
let mut reference: Value = self.safe_string_k(trade.clone(), "reference", &[]);
if !is_equal(&reference, &Value::Null) {
id = reference.clone();
timestamp = self.safe_timestamp(trade.clone(), Value::Str("ticks".to_string()), &[]);
price = self.safe_string_k(trade.clone(), "price", &[]);
price = self.remove_comma_from_value(price.clone());
amount = self.safe_string_k(trade.clone(), "firstAmount", &[]);
let mut reference_parts: Value = split(&reference, &Value::Str("|".to_string())); // reference contains 'pair|orderId_by_taker|orderId_by_maker'
let mut marketId: Value = self.safe_string_k(trade.clone(), "pair", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
market = self.safe_market(&[get_value(&reference_parts, &Value::Int(0)), market.clone()]);
let mut isMaker: Value = self.safe_value_k(trade.clone(), "isMaker", &[]);
makerOrTaker = ternary(is_true(&(is_equal(&isMaker, &Value::Bool(true)))), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
orderId = ternary(is_true(&(is_equal(&isMaker, &Value::Bool(true)))), get_value(&reference_parts, &Value::Int(2)), get_value(&reference_parts, &Value::Int(1)));
let mut action: Value = self.safe_integer_k(trade.clone(), "action", &[]);
if is_equal(&action, &Value::Int(0)) {
side = Value::Str("buy".to_string());
} else {
side = Value::Str("sell".to_string());
}
let mut feeCost: Value = self.safe_string_k(trade.clone(), "feeAmount", &[]);
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m.insert("currency".to_string(), Value::Str("NIS".to_string()));
m
});
}
} else {
timestamp = self.safe_timestamp(trade.clone(), Value::Str("date".to_string()), &[]);
id = self.safe_string_k(trade.clone(), "tid", &[]);
price = self.safe_string_k(trade.clone(), "price", &[]);
amount = self.safe_string_k(trade.clone(), "amount", &[]);
side = self.safe_value_k(trade.clone(), "isBid", &[]);
if !is_equal(&side, &Value::Null) {
if is_true(&(!is_equal(&side, &Value::Null))) && is_true(&(!is_equal(&side, &Value::Str("".to_string())))) {
side = Value::Str("buy".to_string());
} else {
side = Value::Str("sell".to_string());
}
}
}
market = self.safe_market(&[Value::Null, market.clone()]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("id".to_string(), id.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("order".to_string(), orderId.clone());
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), makerOrTaker.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn is_fiat(&self, mut code: Value) -> Value {
return Value::Bool(is_equal(&code, &Value::Str("NIS".to_string())));
Value::Null
}
/*
* @method
* @name bit2c#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://bit2c.co.il/home/api#addc
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
if is_true(&self.is_fiat(code.clone())) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddress() does not support fiat currencies".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Coin".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_funds_add_coin_funds_request(&[__ws_arg_11]).await;
return self.parse_deposit_address(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "address": "0xf14b94518d74aff2b1a6d3429471bcfcd3881d42",
// "hasTx": False
// }
//
let mut address: Value = self.safe_string_k(depositAddress.clone(), "address", &[]);
self.check_address(&[address.clone()]);
let mut code: Value = self.safe_currency_code(Value::Null, &[currency.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), Value::Null);
m
});
Value::Null
}
pub fn nonce(&self) -> Value {
return self.milliseconds();
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut url: Value = add(&add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
if is_equal(&api, &Value::Str("public".to_string())) {
url = add(&url, &Value::Str(".json".to_string()));
} else {
self.check_required_credentials(&[]);
let mut nonce: Value = self.nonce();
let mut query: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("nonce".to_string(), nonce.clone());
m
}), &[params.clone()]);
let mut auth: Value = self.urlencode(query.clone(), &[]);
if is_equal(&method, &Value::Str("GET".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &auth));
}
} else {
body = auth.clone();
}
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha512".to_string()), &[Value::Str("base64".to_string())]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/x-www-form-urlencoded".to_string()));
m.insert("key".to_string(), self.apiKey.clone());
m.insert("sign".to_string(), signature.clone());
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn handle_errors(&self, mut httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
//
// { "error" : "please approve new terms of use on site." }
// { "error": "Please provide valid nonce in Request Nonce (1598218490) is not bigger than last nonce (1598218490)."}
// { "Error" : "No order found." }
//
let mut error: Value = self.safe_string_k(response.clone(), "error", &[]);
if is_equal(&error, &Value::Null) {
error = self.safe_string_k(response.clone(), "Error", &[]);
}
if !is_equal(&error, &Value::Null) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), error.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), error.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}