// 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 BitflyerCore {
pub exchange: crate::exchange::Exchange,
}
impl BitflyerCore {
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 = BitflyerCore::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 BitflyerCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitflyerCore.
BitflyerCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitflyerCore.
BitflyerCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitflyerCore.
BitflyerCore::parse_order(self, order, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on BitflyerCore.
BitflyerCore::parse_balance(self, response)
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitflyerCore.
BitflyerCore::parse_funding_rate(self, rate, &[market.clone()])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitflyerCore.
BitflyerCore::parse_transaction(self, transaction, &[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 BitflyerCore.
BitflyerCore::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 BitflyerCore.
BitflyerCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BitflyerCore {
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_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).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_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).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_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&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)),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_status" => self.parse_deposit_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_expiry_date" => self.parse_expiry_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_funding_rate" => self.parse_funding_rate(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_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"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()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_withdrawal_status" => self.parse_withdrawal_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"safe_market" => self.safe_market(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"withdraw" => self.withdraw(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..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BitflyerCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BitflyerCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BitflyerCore {
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("bitflyer".to_string()));
m.insert("name".to_string(), Value::Str("bitFlyer".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("JP".to_string())]));
m.insert("version".to_string(), Value::Str("v1".to_string()));
m.insert("rateLimit".to_string(), Value::Int(1000));
m.insert("hostname".to_string(), Value::Str("bitflyer.com".to_string()));
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::Null);
m.insert("future".to_string(), Value::Null);
m.insert("option".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::Null);
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("fetchAllGreeks".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("fetchClosedOrders".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchFundingRate".to_string(), Value::Bool(true));
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("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOpenOrders".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchOption".to_string(), Value::Bool(false));
m.insert("fetchOptionChain".to_string(), Value::Bool(false));
m.insert("fetchOrder".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(true));
m.insert("fetchTradingFees".to_string(), Value::Bool(false));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(true));
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/d0217747-e54d-4533-8416-0d553dca74bb".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api.{hostname}".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://bitflyer.com".to_string()));
m.insert("doc".to_string(), Value::Str("https://lightning.bitflyer.com/docs?lang=en".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("getmarkets/usa".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getmarkets/eu".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getmarkets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getboard".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getexecutions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("gethealth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getboardstate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getchats".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getfundingrate".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("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("getpermissions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getbalance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getbalancehistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getcollateral".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getcollateralhistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getcollateralaccounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getaddresses".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getcoinins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getcoinouts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getbankaccounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getdeposits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getwithdrawals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getchildorders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getparentorders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getparentorder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getexecutions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("getpositions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("gettradingcommission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sendcoin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sendchildorder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cancelchildorder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sendparentorder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cancelparentorder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cancelallchildorders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
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("maker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
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(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(true));
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::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("symbolRequired".to_string(), Value::Bool(true));
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(true));
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::Int(100));
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::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::Null);
m.insert("untilDays".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("fetchClosedOrders".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::Null);
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".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("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("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("-2".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m
}));
m
}));
m
})]);
Value::Null
}
pub fn parse_expiry_date(&self, mut expiry: Value) -> Value {
let mut day: Value = slice(&expiry, &Value::Int(0), &Value::Int(2));
let mut monthName: Value = slice(&expiry, &Value::Int(2), &Value::Int(5));
let mut year: Value = slice(&expiry, &Value::Int(5), &Value::Int(9));
let mut months: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("JAN".to_string(), Value::Str("01".to_string()));
m.insert("FEB".to_string(), Value::Str("02".to_string()));
m.insert("MAR".to_string(), Value::Str("03".to_string()));
m.insert("APR".to_string(), Value::Str("04".to_string()));
m.insert("MAY".to_string(), Value::Str("05".to_string()));
m.insert("JUN".to_string(), Value::Str("06".to_string()));
m.insert("JUL".to_string(), Value::Str("07".to_string()));
m.insert("AUG".to_string(), Value::Str("08".to_string()));
m.insert("SEP".to_string(), Value::Str("09".to_string()));
m.insert("OCT".to_string(), Value::Str("10".to_string()));
m.insert("NOV".to_string(), Value::Str("11".to_string()));
m.insert("DEC".to_string(), Value::Str("12".to_string()));
m
});
let mut month: Value = self.safe_string(months.clone(), monthName.clone(), &[]);
return self.parse8601(add(&add(&add(&add(&add(&year, &Value::Str("-".to_string())), &month), &Value::Str("-".to_string())), &day), &Value::Str("T00:00:00Z".to_string())));
Value::Null
}
pub fn safe_market(&self, optional_args: &[Value]) -> Value {
let mut marketId = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
let mut delimiter = get_arg(optional_args, 2, Value::Null);
let mut marketType = get_arg(optional_args, 3, Value::Null);
return self.super_safe_market(marketId.clone(), market.clone(), delimiter.clone(), Value::Str("spot".to_string()));
Value::Null
}
/*
* @method
* @name bitflyer#fetchMarkets
* @description retrieves data on all markets for bitflyer
* @see https://lightning.bitflyer.com/docs?lang=en#market-list
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut jp_markets: Value = self.public_get_getmarkets(&[params.clone()]).await;
//
// [
// // spot
// { "product_code": "BTC_JPY", "market_type": "Spot" },
// { "product_code": "BCH_BTC", "market_type": "Spot" },
// // forex swap
// { "product_code": "FX_BTC_JPY", "market_type": "FX" },
//
// // future
// {
// "product_code": "BTCJPY11FEB2022",
// "alias": "BTCJPY_MAT1WK",
// "market_type": "Futures",
// },
// ];
//
let mut us_markets: Value = self.public_get_getmarkets_usa(&[params.clone()]).await;
//
// [
// { "product_code": "BTC_USD", "market_type": "Spot" },
// { "product_code": "BTC_JPY", "market_type": "Spot" },
// ];
//
let mut eu_markets: Value = self.public_get_getmarkets_eu(&[params.clone()]).await;
//
// [
// { "product_code": "BTC_EUR", "market_type": "Spot" },
// { "product_code": "BTC_JPY", "market_type": "Spot" },
// ];
//
let mut markets: Value = self.array_concat(self.to_array(jp_markets.clone()), self.to_array(us_markets.clone()));
markets = self.array_concat(markets.clone(), self.to_array(eu_markets.clone()));
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_336: bool = true;
while { if !__for_first_336 { i = add(&i, &Value::Int(1)); } __for_first_336 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut market: Value = get_value(&markets, &i);
let mut market: Value = get_value(&markets, &i);
let mut id: Value = self.safe_string_k(market.clone(), "product_code", &[]);
let mut currencies: Value = split(&id, &Value::Str("_".to_string()));
let mut marketType: Value = self.safe_string_k(market.clone(), "market_type", &[]);
let mut swap: Value = Value::Bool(is_equal(&marketType, &Value::Str("FX".to_string())));
let mut future: Value = Value::Bool(is_equal(&marketType, &Value::Str("Futures".to_string())));
let mut spot: Value = Value::Bool(!is_true(&swap) && !is_true(&future));
let mut type_var: Value = Value::Str("spot".to_string());
let mut settle: Value = Value::Null;
let mut baseId: Value = Value::Null;
let mut quoteId: Value = Value::Null;
let mut expiry: Value = Value::Null;
if is_true(&spot) {
baseId = self.safe_string(currencies.clone(), Value::Int(0), &[]);
quoteId = self.safe_string(currencies.clone(), Value::Int(1), &[]);
} else if is_true(&swap) {
type_var = Value::Str("swap".to_string());
baseId = self.safe_string(currencies.clone(), Value::Int(1), &[]);
quoteId = self.safe_string(currencies.clone(), Value::Int(2), &[]);
} else if is_true(&future) {
let mut alias: Value = self.safe_string_k(market.clone(), "alias", &[]);
if is_equal(&alias, &Value::Null) {
// no alias:
// { product_code: 'BTCJPY11MAR2022', market_type: 'Futures' }
// TODO this will break if there are products with 4 chars
baseId = slice(&id, &Value::Int(0), &Value::Int(3));
quoteId = slice(&id, &Value::Int(3), &Value::Int(6));
// last 9 chars are expiry date
let mut expiryDate: Value = slice(&id, &negate(&Value::Int(9)), &Value::Null);
expiry = self.parse_expiry_date(expiryDate.clone());
} else {
let mut splitAlias: Value = split(&alias, &Value::Str("_".to_string()));
let mut currencyIds: Value = self.safe_string(splitAlias.clone(), Value::Int(0), &[]);
baseId = slice(¤cyIds, &Value::Int(0), &negate(&Value::Int(3)));
quoteId = slice(¤cyIds, &negate(&Value::Int(3)), &Value::Null);
let mut splitId: Value = split(&id, ¤cyIds);
let mut expiryDate: Value = self.safe_string(splitId.clone(), Value::Int(1), &[]);
expiry = self.parse_expiry_date(expiryDate.clone());
}
type_var = Value::Str("future".to_string());
}
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut taker: Value = get_value(&get_value(&self.fees, &Value::Str("trading".to_string())), &Value::Str("taker".to_string()));
let mut maker: Value = get_value(&get_value(&self.fees, &Value::Str("trading".to_string())), &Value::Str("maker".to_string()));
let mut contract: Value = Value::Bool(is_true(&swap) || is_true(&future));
if is_true(&contract) {
maker = Value::Int(0);
taker = Value::Int(0);
settle = Value::Str("JPY".to_string());
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
if is_true(&future) {
symbol = add(&add(&symbol, &Value::Str("-".to_string())), &self.yymmdd(expiry.clone(), &[]));
}
}
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), type_var.clone());
m.insert("spot".to_string(), spot.clone());
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), swap.clone());
m.insert("future".to_string(), future.clone());
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool(true));
m.insert("contract".to_string(), contract.clone());
m.insert("linear".to_string(), ternary(is_true(&spot), Value::Null, Value::Bool(true)));
m.insert("inverse".to_string(), ternary(is_true(&spot), Value::Null, Value::Bool(false)));
m.insert("taker".to_string(), taker.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), expiry.clone());
m.insert("expiryDatetime".to_string(), self.iso8601(expiry.clone()));
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Null);
m.insert("price".to_string(), Value::Null);
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
}));
}
}
return result;
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
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_337: bool = true;
while { if !__for_first_337 { i = add(&i, &Value::Int(1)); } __for_first_337 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut balance: Value = get_value(&response, &i);
let mut balance: Value = get_value(&response, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency_code", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "amount", &[]));
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "available", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name bitflyer#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://lightning.bitflyer.com/docs?lang=en#get-account-asset-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_getbalance(&[params.clone()]).await;
return self.parse_balance(response.clone());
Value::Null
}
/*
* @method
* @name bitflyer#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://lightning.bitflyer.com/docs?lang=en#order-book
* @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("product_code".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_getboard(&[__ws_arg_0]).await;
return self.parse_order_book(orderbook.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[Value::Null, Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("size".to_string())]);
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 timestamp: Value = self.parse8601(self.safe_string_k(ticker.clone(), "timestamp", &[]));
let mut last: Value = self.safe_string_k(ticker.clone(), "ltp", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
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(), "best_bid", &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "best_ask", &[]));
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(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string_k(ticker.clone(), "volume_by_product", &[]));
m.insert("quoteVolume".to_string(), Value::Null);
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitflyer#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://lightning.bitflyer.com/docs?lang=en#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("product_code".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_getticker(&[__ws_arg_1]).await;
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades (public) v1
//
// {
// "id":2278466664,
// "side":"SELL",
// "price":56810.7,
// "size":0.08798,
// "exec_date":"2021-11-19T11:46:39.323",
// "buy_child_order_acceptance_id":"JRF20211119-114209-236525",
// "sell_child_order_acceptance_id":"JRF20211119-114639-236919"
// }
//
// fetchMyTrades
//
// {
// "id": 37233,
// "side": "BUY",
// "price": 33470,
// "size": 0.01,
// "exec_date": "2015-07-07T09:57:40.397",
// "child_order_id": "JOR20150707-060559-021935",
// "child_order_acceptance_id": "JRF20150707-060559-396699"
// "commission": 0,
// },
//
let mut side: Value = self.safe_string_lower(trade.clone(), Value::Str("side".to_string()), &[]);
if !is_equal(&side, &Value::Null) {
if is_less_than(&get_array_length(&side), &Value::Int(1)) {
side = Value::Null;
}
}
let mut order: Value = Value::Null;
if !is_equal(&side, &Value::Null) {
let mut idInner: Value = add(&side, &Value::Str("_child_order_acceptance_id".to_string()));
if is_true(&Value::Bool(in_op(&trade, &idInner))) {
order = get_value(&trade, &idInner);
}
}
if is_equal(&order, &Value::Null) {
order = self.safe_string_k(trade.clone(), "child_order_acceptance_id", &[]);
}
let mut timestamp: Value = self.parse8601(self.safe_string_k(trade.clone(), "exec_date", &[]));
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "size", &[]);
let mut id: Value = self.safe_string_k(trade.clone(), "id", &[]);
market = self.safe_market(&[Value::Null, market.clone()]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("info".to_string(), trade.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(), order.clone());
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitflyer#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://lightning.bitflyer.com/docs?lang=en#list-executions
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_code".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone());
}
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_getexecutions(&[__ws_arg_2]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bitflyer#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://lightning.bitflyer.com/docs?lang=en#get-trading-commission
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_trading_fee(&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("product_code".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_gettradingcommission(&[__ws_arg_3]).await;
//
// {
// commission_rate: '0.0020'
// }
//
let mut fee: Value = self.safe_number_k(response.clone(), "commission_rate", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("maker".to_string(), fee.clone());
m.insert("taker".to_string(), fee.clone());
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name bitflyer#createOrder
* @description create a trade order
* @see https://lightning.bitflyer.com/docs?lang=en#send-a-new-order
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_code".to_string(), self.market_id(symbol.clone()));
m.insert("child_order_type".to_string(), to_upper(&type_var));
m.insert("side".to_string(), to_upper(&side));
m.insert("price".to_string(), price.clone());
m.insert("size".to_string(), amount.clone());
m
});
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut result: Value = self.private_post_sendchildorder(&[__ws_arg_4]).await;
// { "status": - 200, "error_message": "Insufficient funds", "data": null }
let mut id: Value = self.safe_string_k(result.clone(), "child_order_acceptance_id", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("info".to_string(), result.clone());
m
}), &[]);
Value::Null
}
/*
* @method
* @name bitflyer#cancelOrder
* @description cancels an open order
* @see https://lightning.bitflyer.com/docs?lang=en#cancel-order
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @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
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_code".to_string(), self.market_id(symbol.clone()));
m.insert("child_order_acceptance_id".to_string(), id.clone());
m
});
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_cancelchildorder(&[__ws_arg_5]).await;
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
}), &[]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ACTIVE".to_string(), Value::Str("open".to_string()));
m.insert("COMPLETED".to_string(), Value::Str("closed".to_string()));
m.insert("CANCELED".to_string(), Value::Str("canceled".to_string()));
m.insert("EXPIRED".to_string(), Value::Str("canceled".to_string()));
m.insert("REJECTED".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.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);
let mut timestamp: Value = self.parse8601(self.safe_string_k(order.clone(), "child_order_date", &[]));
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "size", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "executed_size", &[]);
let mut remaining: Value = self.safe_string_k(order.clone(), "outstanding_size", &[]);
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "child_order_state", &[]));
let mut type_var: Value = self.safe_string_lower(order.clone(), Value::Str("child_order_type".to_string()), &[]);
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "product_code", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_number_k(order.clone(), "total_commission", &[]);
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::Null);
m.insert("rate".to_string(), Value::Null);
m
});
}
let mut id: Value = self.safe_string_k(order.clone(), "child_order_acceptance_id", &[]);
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("info".to_string(), order.clone());
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("cost".to_string(), Value::Null);
m.insert("amount".to_string(), amount.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), remaining.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("average".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitflyer#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://lightning.bitflyer.com/docs?lang=en#list-orders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of 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_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::Int(100));
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(" fetchOrders() 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("product_code".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("count".to_string(), limit.clone());
m
});
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_getchildorders(&[__ws_arg_6]).await;
let mut orders: Value = self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
if !is_equal(&symbol, &Value::Null) {
orders = self.filter_by(orders.clone(), Value::Str("symbol".to_string()), symbol.clone(), &[]);
}
return orders;
Value::Null
}
/*
* @method
* @name bitflyer#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://lightning.bitflyer.com/docs?lang=en#list-orders
* @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 orders 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::Int(100));
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("child_order_state".to_string(), Value::Str("ACTIVE".to_string()));
m
});
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_7]).await;
Value::Null
}
/*
* @method
* @name bitflyer#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://lightning.bitflyer.com/docs?lang=en#list-orders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of 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_closed_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::Int(100));
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("child_order_state".to_string(), Value::Str("COMPLETED".to_string()));
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_8]).await;
Value::Null
}
/*
* @method
* @name bitflyer#fetchOrder
* @description fetches information on an order made by the user
* @see https://lightning.bitflyer.com/docs?lang=en#list-orders
* @param {string} id the order id
* @param {string} symbol unified symbol of the market the order was made in
* @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(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a symbol argument".to_string()))));
}
let mut orders: Value = self.fetch_orders(&[symbol.clone()]).await;
let mut ordersById: Value = self.index_by(orders.clone(), Value::Str("id".to_string()));
if is_true(&Value::Bool(in_op(&ordersById, &id))) {
return get_value(&ordersById, &id);
}
panic!("{}", crate::exchange_errors::order_not_found(add(&add(&self.id, &Value::Str(" No order found with id ".to_string())), &id)));
Value::Null
}
/*
* @method
* @name bitflyer#fetchMyTrades
* @description fetch all trades made by the user
* @see https://lightning.bitflyer.com/docs?lang=en#list-executions
* @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(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() 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("product_code".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone());
}
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_getexecutions(&[__ws_arg_9]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bitflyer#fetchPositions
* @description fetch all open positions
* @see https://lightning.bitflyer.com/docs?lang=en#get-open-interest-summary
* @param {string[]} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = 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(&symbols, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPositions() requires a `symbols` argument, exactly one symbol in an array".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_code".to_string(), self.market_ids(&[symbols.clone()]));
m
});
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_getpositions(&[__ws_arg_10]).await;
return response;
Value::Null
}
/*
* @method
* @name bitflyer#withdraw
* @description make a withdrawal
* @see https://lightning.bitflyer.com/docs?lang=en#withdrawing-funds
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.check_address(&[address.clone()]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if !is_equal(&code, &Value::Str("JPY".to_string())) && !is_equal(&code, &Value::Str("USD".to_string())) && !is_equal(&code, &Value::Str("EUR".to_string())) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&add(&self.id, &Value::Str(" allows withdrawing JPY, USD, EUR only, ".to_string())), &code), &Value::Str(" is not supported".to_string()))));
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency_code".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amount.clone());
m
});
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_withdraw(&[__ws_arg_11]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name bitflyer#fetchDeposits
* @description fetch all deposits made to an account
* @see https://lightning.bitflyer.com/docs?lang=en#get-crypto-assets-deposit-history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = 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 currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone()); // default 100
}
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_getcoinins(&[__ws_arg_12]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bitflyer#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://lightning.bitflyer.com/docs?lang=en#get-crypto-assets-transaction-history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = 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 currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone()); // default 100
}
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_getcoinouts(&[__ws_arg_13]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_deposit_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("PENDING".to_string(), Value::Str("pending".to_string()));
m.insert("COMPLETED".to_string(), Value::Str("ok".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_withdrawal_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("PENDING".to_string(), Value::Str("pending".to_string()));
m.insert("COMPLETED".to_string(), Value::Str("ok".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDeposits
//
// {
// "id": 100,
// "order_id": "CDP20151227-024141-055555",
// "currency_code": "BTC",
// "amount": 0.00002,
// "address": "1WriteySQufKZ2pVuM1oMhPrTtTVFq35j",
// "tx_hash": "9f92ee65a176bb9545f7becb8706c50d07d4cee5ffca34d8be3ef11d411405ae",
// "status": "COMPLETED",
// "event_date": "2015-11-27T08:59:20.301"
// }
//
// fetchWithdrawals
//
// {
// "id": 500,
// "order_id": "CWD20151224-014040-077777",
// "currency_code": "BTC",
// "amount": 0.1234,
// "address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
// "tx_hash": "724c07dfd4044abcb390b0412c3e707dd5c4f373f0a52b3bd295ce32b478c60a",
// "fee": 0.0005,
// "additional_fee": 0.0001,
// "status": "COMPLETED",
// "event_date": "2015-12-24T01:40:40.397"
// }
//
// withdraw
//
// {
// "message_id": "69476620-5056-4003-bcbe-42658a2b041b"
// }
//
let mut id: Value = self.safe_string2(transaction.clone(), Value::Str("id".to_string()), Value::Str("message_id".to_string()), &[]);
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "currency_code", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(transaction.clone(), "event_date", &[]));
let mut amount: Value = self.safe_number_k(transaction.clone(), "amount", &[]);
let mut txId: Value = self.safe_string_k(transaction.clone(), "tx_hash", &[]);
let mut rawStatus: Value = self.safe_string_k(transaction.clone(), "status", &[]);
let mut type_var: Value = Value::Null;
let mut status: Value = Value::Null;
let mut fee: Value = Value::Null;
if is_true(&Value::Bool(in_op(&transaction, &Value::Str("fee".to_string())))) {
type_var = Value::Str("withdrawal".to_string());
status = self.parse_withdrawal_status(rawStatus.clone());
let mut feeCost: Value = self.safe_string_k(transaction.clone(), "fee", &[]);
let mut additionalFee: Value = self.safe_string_k(transaction.clone(), "additional_fee", &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), self.parse_number(crate::precise::Precise::stringAdd(&feeCost, &additionalFee), &[]));
m
});
} else {
type_var = Value::Str("deposit".to_string());
status = self.parse_deposit_status(rawStatus.clone());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), id.clone());
m.insert("txid".to_string(), txId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), address.clone());
m.insert("addressFrom".to_string(), Value::Null);
m.insert("tag".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("type".to_string(), type_var.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), status.clone());
m.insert("updated".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
});
Value::Null
}
/*
* @method
* @name bitflyer#fetchFundingRate
* @description fetch the current funding rate
* @see https://lightning.bitflyer.com/docs#funding-rate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_rate(&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("product_code".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_getfundingrate(&[__ws_arg_14]).await;
return self.parse_funding_rate(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "current_funding_rate": -0.003750000000
// "next_funding_rate_settledate": "2024-04-15T13:00:00"
// }
//
let mut nextFundingDatetime: Value = self.safe_string_k(contract.clone(), "next_funding_rate_settledate", &[]);
let mut nextFundingTimestamp: Value = self.parse8601(nextFundingDatetime.clone());
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("markPrice".to_string(), Value::Null);
m.insert("indexPrice".to_string(), Value::Null);
m.insert("interestRate".to_string(), Value::Null);
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("fundingRate".to_string(), Value::Null);
m.insert("fundingTimestamp".to_string(), Value::Null);
m.insert("fundingDatetime".to_string(), Value::Null);
m.insert("nextFundingRate".to_string(), self.safe_number_k(contract.clone(), "current_funding_rate", &[]));
m.insert("nextFundingTimestamp".to_string(), nextFundingTimestamp.clone());
m.insert("nextFundingDatetime".to_string(), self.iso8601(nextFundingTimestamp.clone()));
m.insert("previousFundingRate".to_string(), Value::Null);
m.insert("previousFundingTimestamp".to_string(), Value::Null);
m.insert("previousFundingDatetime".to_string(), Value::Null);
m.insert("interval".to_string(), Value::Null);
m
});
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 request: Value = add(&add(&Value::Str("/".to_string()), &self.version), &Value::Str("/".to_string()));
if is_equal(&api, &Value::Str("private".to_string())) {
request = add(&request, &Value::Str("me/".to_string()));
}
request = add(&request, &path);
if is_equal(&method, &Value::Str("GET".to_string())) {
if is_greater_than(&get_array_length(&object_keys(¶ms)), &Value::Int(0)) {
request = add(&request, &add(&Value::Str("?".to_string()), &self.urlencode(params.clone(), &[])));
}
}
let mut baseUrl: Value = self.implode_hostname(get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())));
let mut url: Value = add(&baseUrl, &request);
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut nonce: Value = to_string_val(&self.nonce());
let mut content: Value = Value::List(vec![nonce.clone(), method.clone(), request.clone()]);
let mut auth: Value = join(&content, &Value::Str("".to_string()));
if is_greater_than(&get_array_length(&object_keys(¶ms)), &Value::Int(0)) {
if !is_equal(&method, &Value::Str("GET".to_string())) {
body = self.json(params.clone());
auth = add(&auth, &body);
}
}
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ACCESS-KEY".to_string(), self.apiKey.clone());
m.insert("ACCESS-TIMESTAMP".to_string(), nonce.clone());
m.insert("ACCESS-SIGN".to_string(), self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]));
m.insert("Content-Type".to_string(), Value::Str("application/json".to_string()));
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 code: 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;
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
// i.e. {"status":-2,"error_message":"Under maintenance","data":null}
let mut errorMessage: Value = self.safe_string_k(response.clone(), "error_message", &[]);
let mut statusCode: Value = self.safe_integer_k(response.clone(), "status", &[]);
if !is_equal(&errorMessage, &Value::Null) {
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), statusCode.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}