use std::sync::Arc;
use async_trait::async_trait;
use crate::core::types::{
ConnectorStats, ExchangeId, AccountType, Symbol, SymbolInfo, Price, OrderBook, Kline, Ticker,
ExchangeResult, MarketDataCapabilities, TradingCapabilities, AccountCapabilities,
OrderbookCapabilities,
};
use crate::core::traits::{
ExchangeIdentity, MarketData, Trading, Account,
};
use crate::l3::open::crypto::cex::binance::BinanceConnector;
use crate::l3::open::crypto::cex::bybit::BybitConnector;
use crate::l3::open::crypto::cex::okx::OkxConnector;
use crate::l3::open::crypto::cex::kucoin::KuCoinConnector;
use crate::l3::open::crypto::cex::kraken::KrakenConnector;
use crate::l3::open::crypto::cex::coinbase::CoinbaseConnector;
use crate::l3::open::crypto::cex::gateio::GateioConnector;
use crate::l3::open::crypto::cex::bitfinex::BitfinexConnector;
use crate::l3::open::crypto::cex::bitstamp::BitstampConnector;
use crate::l3::open::crypto::cex::gemini::GeminiConnector;
use crate::l3::open::crypto::cex::mexc::MexcConnector;
use crate::l3::open::crypto::cex::htx::HtxConnector;
use crate::l3::open::crypto::cex::bitget::BitgetConnector;
use crate::l3::open::crypto::cex::bingx::BingxConnector;
use crate::l3::open::crypto::cex::crypto_com::CryptoComConnector;
use crate::l3::open::crypto::cex::upbit::UpbitConnector;
use crate::l3::open::crypto::cex::deribit::DeribitConnector;
use crate::l3::open::crypto::cex::hyperliquid::HyperliquidConnector;
use crate::l3::open::crypto::dex::lighter::LighterConnector;
use crate::l3::open::crypto::dex::dydx::DydxConnector;
use crate::l2::paid::polygon::PolygonConnector;
use crate::l1::free::finnhub::FinnhubConnector;
use crate::l1::paid::tiingo::TiingoConnector;
use crate::l1::paid::twelvedata::TwelvedataConnector;
use crate::l3::gated::stocks::us::alpaca::AlpacaConnector;
use crate::l3::gated::stocks::india::angel_one::AngelOneConnector;
use crate::l3::gated::stocks::india::zerodha::ZerodhaConnector;
use crate::l3::gated::stocks::india::upstox::UpstoxConnector;
use crate::l3::gated::stocks::india::dhan::DhanConnector;
use crate::l3::gated::stocks::india::fyers::FyersConnector;
use crate::l1::paid::jquants::JQuantsConnector;
use crate::l1::free::krx::KrxConnector;
use crate::l2::free::moex::MoexConnector;
use crate::l3::gated::stocks::russia::tinkoff::TinkoffConnector;
use crate::l3::gated::forex::oanda::OandaConnector;
use crate::l3::gated::forex::dukascopy::DukascopyConnector;
use crate::l1::paid::alphavantage::AlphaVantageConnector;
use crate::l3::open::prediction::polymarket::PolymarketConnector;
use crate::l3::gated::multi::ib::IBConnector;
use crate::l1::free::yahoo::YahooFinanceConnector;
use crate::l2::paid::cryptocompare::CryptoCompareConnector;
#[derive(Clone)]
pub enum AnyConnector {
Binance(Arc<BinanceConnector>),
Bybit(Arc<BybitConnector>),
OKX(Arc<OkxConnector>),
KuCoin(Arc<KuCoinConnector>),
Kraken(Arc<KrakenConnector>),
Coinbase(Arc<CoinbaseConnector>),
GateIO(Arc<GateioConnector>),
Bitfinex(Arc<BitfinexConnector>),
Bitstamp(Arc<BitstampConnector>),
Gemini(Arc<GeminiConnector>),
MEXC(Arc<MexcConnector>),
HTX(Arc<HtxConnector>),
Bitget(Arc<BitgetConnector>),
BingX(Arc<BingxConnector>),
CryptoCom(Arc<CryptoComConnector>),
Upbit(Arc<UpbitConnector>),
Deribit(Arc<DeribitConnector>),
HyperLiquid(Arc<HyperliquidConnector>),
Lighter(Arc<LighterConnector>),
Dydx(Arc<DydxConnector>),
Polygon(Arc<PolygonConnector>),
Finnhub(Arc<FinnhubConnector>),
Tiingo(Arc<TiingoConnector>),
Twelvedata(Arc<TwelvedataConnector>),
Alpaca(Arc<AlpacaConnector>),
AngelOne(Arc<AngelOneConnector>),
Zerodha(Arc<ZerodhaConnector>),
Upstox(Arc<UpstoxConnector>),
Dhan(Arc<DhanConnector>),
Fyers(Arc<FyersConnector>),
JQuants(Arc<JQuantsConnector>),
Krx(Arc<KrxConnector>),
Moex(Arc<MoexConnector>),
Tinkoff(Arc<TinkoffConnector>),
Oanda(Arc<OandaConnector>),
Dukascopy(Arc<DukascopyConnector>),
AlphaVantage(Arc<AlphaVantageConnector>),
Polymarket(Arc<PolymarketConnector>),
IB(Arc<IBConnector>),
YahooFinance(Arc<YahooFinanceConnector>),
CryptoCompare(Arc<CryptoCompareConnector>),
}
impl AnyConnector {
pub fn id(&self) -> ExchangeId {
match self {
Self::Binance(_) => ExchangeId::Binance,
Self::Bybit(_) => ExchangeId::Bybit,
Self::OKX(_) => ExchangeId::OKX,
Self::KuCoin(_) => ExchangeId::KuCoin,
Self::Kraken(_) => ExchangeId::Kraken,
Self::Coinbase(_) => ExchangeId::Coinbase,
Self::GateIO(_) => ExchangeId::GateIO,
Self::Bitfinex(_) => ExchangeId::Bitfinex,
Self::Bitstamp(_) => ExchangeId::Bitstamp,
Self::Gemini(_) => ExchangeId::Gemini,
Self::MEXC(_) => ExchangeId::MEXC,
Self::HTX(_) => ExchangeId::HTX,
Self::Bitget(_) => ExchangeId::Bitget,
Self::BingX(_) => ExchangeId::BingX,
Self::CryptoCom(_) => ExchangeId::CryptoCom,
Self::Upbit(_) => ExchangeId::Upbit,
Self::Deribit(_) => ExchangeId::Deribit,
Self::HyperLiquid(_) => ExchangeId::HyperLiquid,
Self::Lighter(_) => ExchangeId::Lighter,
Self::Dydx(_) => ExchangeId::Dydx,
Self::Polygon(_) => ExchangeId::Polygon,
Self::Finnhub(_) => ExchangeId::Finnhub,
Self::Tiingo(_) => ExchangeId::Tiingo,
Self::Twelvedata(_) => ExchangeId::Twelvedata,
Self::Alpaca(_) => ExchangeId::Alpaca,
Self::AngelOne(_) => ExchangeId::AngelOne,
Self::Zerodha(_) => ExchangeId::Zerodha,
Self::Upstox(_) => ExchangeId::Upstox,
Self::Dhan(_) => ExchangeId::Dhan,
Self::Fyers(_) => ExchangeId::Fyers,
Self::JQuants(_) => ExchangeId::JQuants,
Self::Krx(_) => ExchangeId::Krx,
Self::Moex(_) => ExchangeId::Moex,
Self::Tinkoff(_) => ExchangeId::Tinkoff,
Self::Oanda(_) => ExchangeId::Oanda,
Self::Dukascopy(_) => ExchangeId::Dukascopy,
Self::AlphaVantage(_) => ExchangeId::AlphaVantage,
Self::Polymarket(_) => ExchangeId::Polymarket,
Self::IB(_) => ExchangeId::Ib,
Self::YahooFinance(_) => ExchangeId::YahooFinance,
Self::CryptoCompare(_) => ExchangeId::CryptoCompare,
}
}
pub fn metrics(&self) -> ConnectorStats {
match self {
Self::Binance(c) => c.metrics(),
Self::Bybit(c) => c.metrics(),
Self::OKX(c) => c.metrics(),
Self::KuCoin(c) => c.metrics(),
Self::Kraken(c) => c.metrics(),
Self::Coinbase(c) => c.metrics(),
Self::GateIO(c) => c.metrics(),
Self::Bitfinex(c) => c.metrics(),
Self::Bitstamp(c) => c.metrics(),
Self::Gemini(c) => c.metrics(),
Self::MEXC(c) => c.metrics(),
Self::HTX(c) => c.metrics(),
Self::Bitget(c) => c.metrics(),
Self::BingX(c) => c.metrics(),
Self::CryptoCom(c) => c.metrics(),
Self::Upbit(c) => c.metrics(),
Self::Deribit(c) => c.metrics(),
Self::HyperLiquid(c) => c.metrics(),
Self::Lighter(c) => c.metrics(),
Self::Dydx(c) => c.metrics(),
Self::Polygon(c) => c.metrics(),
Self::Finnhub(c) => c.metrics(),
Self::Tiingo(c) => c.metrics(),
Self::Twelvedata(c) => c.metrics(),
Self::Alpaca(c) => c.metrics(),
Self::AngelOne(c) => c.metrics(),
Self::Zerodha(c) => c.metrics(),
Self::Upstox(c) => c.metrics(),
Self::Dhan(c) => c.metrics(),
Self::Fyers(c) => c.metrics(),
Self::JQuants(c) => c.metrics(),
Self::Krx(c) => c.metrics(),
Self::Moex(c) => c.metrics(),
Self::Tinkoff(c) => c.metrics(),
Self::Oanda(c) => c.metrics(),
Self::Dukascopy(c) => c.metrics(),
Self::AlphaVantage(c) => c.metrics(),
Self::Polymarket(c) => c.metrics(),
Self::IB(c) => c.metrics(),
Self::YahooFinance(c) => c.metrics(),
Self::CryptoCompare(c) => c.metrics(),
}
}
}
impl ExchangeIdentity for AnyConnector {
fn exchange_id(&self) -> ExchangeId {
self.id()
}
fn is_testnet(&self) -> bool {
match self {
Self::Binance(c) => c.is_testnet(),
Self::Bybit(c) => c.is_testnet(),
Self::OKX(c) => c.is_testnet(),
Self::KuCoin(c) => c.is_testnet(),
Self::Kraken(c) => c.is_testnet(),
Self::Coinbase(c) => c.is_testnet(),
Self::GateIO(c) => c.is_testnet(),
Self::Bitfinex(c) => c.is_testnet(),
Self::Bitstamp(c) => c.is_testnet(),
Self::Gemini(c) => c.is_testnet(),
Self::MEXC(c) => c.is_testnet(),
Self::HTX(c) => c.is_testnet(),
Self::Bitget(c) => c.is_testnet(),
Self::BingX(c) => c.is_testnet(),
Self::CryptoCom(c) => c.is_testnet(),
Self::Upbit(c) => c.is_testnet(),
Self::Deribit(c) => c.is_testnet(),
Self::HyperLiquid(c) => c.is_testnet(),
Self::Lighter(c) => c.is_testnet(),
Self::Dydx(c) => c.is_testnet(),
Self::Polygon(c) => c.is_testnet(),
Self::Finnhub(c) => c.is_testnet(),
Self::Tiingo(c) => c.is_testnet(),
Self::Twelvedata(c) => c.is_testnet(),
Self::Alpaca(c) => c.is_testnet(),
Self::AngelOne(c) => c.is_testnet(),
Self::Zerodha(c) => c.is_testnet(),
Self::Upstox(c) => c.is_testnet(),
Self::Dhan(c) => c.is_testnet(),
Self::Fyers(c) => c.is_testnet(),
Self::JQuants(c) => c.is_testnet(),
Self::Krx(c) => c.is_testnet(),
Self::Moex(c) => c.is_testnet(),
Self::Tinkoff(c) => c.is_testnet(),
Self::Oanda(c) => c.is_testnet(),
Self::Dukascopy(c) => c.is_testnet(),
Self::AlphaVantage(c) => c.is_testnet(),
Self::Polymarket(c) => c.is_testnet(),
Self::IB(c) => c.is_testnet(),
Self::YahooFinance(c) => c.is_testnet(),
Self::CryptoCompare(c) => c.is_testnet(),
}
}
fn supported_account_types(&self) -> Vec<AccountType> {
match self {
Self::Binance(c) => c.supported_account_types(),
Self::Bybit(c) => c.supported_account_types(),
Self::OKX(c) => c.supported_account_types(),
Self::KuCoin(c) => c.supported_account_types(),
Self::Kraken(c) => c.supported_account_types(),
Self::Coinbase(c) => c.supported_account_types(),
Self::GateIO(c) => c.supported_account_types(),
Self::Bitfinex(c) => c.supported_account_types(),
Self::Bitstamp(c) => c.supported_account_types(),
Self::Gemini(c) => c.supported_account_types(),
Self::MEXC(c) => c.supported_account_types(),
Self::HTX(c) => c.supported_account_types(),
Self::Bitget(c) => c.supported_account_types(),
Self::BingX(c) => c.supported_account_types(),
Self::CryptoCom(c) => c.supported_account_types(),
Self::Upbit(c) => c.supported_account_types(),
Self::Deribit(c) => c.supported_account_types(),
Self::HyperLiquid(c) => c.supported_account_types(),
Self::Lighter(c) => c.supported_account_types(),
Self::Dydx(c) => c.supported_account_types(),
Self::Polygon(c) => c.supported_account_types(),
Self::Finnhub(c) => c.supported_account_types(),
Self::Tiingo(c) => c.supported_account_types(),
Self::Twelvedata(c) => c.supported_account_types(),
Self::Alpaca(c) => c.supported_account_types(),
Self::AngelOne(c) => c.supported_account_types(),
Self::Zerodha(c) => c.supported_account_types(),
Self::Upstox(c) => c.supported_account_types(),
Self::Dhan(c) => c.supported_account_types(),
Self::Fyers(c) => c.supported_account_types(),
Self::JQuants(c) => c.supported_account_types(),
Self::Krx(c) => c.supported_account_types(),
Self::Moex(c) => c.supported_account_types(),
Self::Tinkoff(c) => c.supported_account_types(),
Self::Oanda(c) => c.supported_account_types(),
Self::Dukascopy(c) => c.supported_account_types(),
Self::AlphaVantage(c) => c.supported_account_types(),
Self::Polymarket(c) => c.supported_account_types(),
Self::IB(c) => c.supported_account_types(),
Self::YahooFinance(c) => c.supported_account_types(),
Self::CryptoCompare(c) => c.supported_account_types(),
}
}
fn orderbook_capabilities(&self, account_type: AccountType) -> OrderbookCapabilities {
match self {
Self::Binance(c) => c.orderbook_capabilities(account_type),
Self::Bybit(c) => c.orderbook_capabilities(account_type),
Self::OKX(c) => c.orderbook_capabilities(account_type),
Self::KuCoin(c) => c.orderbook_capabilities(account_type),
Self::Kraken(c) => c.orderbook_capabilities(account_type),
Self::Coinbase(c) => c.orderbook_capabilities(account_type),
Self::GateIO(c) => c.orderbook_capabilities(account_type),
Self::Bitfinex(c) => c.orderbook_capabilities(account_type),
Self::Bitstamp(c) => c.orderbook_capabilities(account_type),
Self::Gemini(c) => c.orderbook_capabilities(account_type),
Self::MEXC(c) => c.orderbook_capabilities(account_type),
Self::HTX(c) => c.orderbook_capabilities(account_type),
Self::Bitget(c) => c.orderbook_capabilities(account_type),
Self::BingX(c) => c.orderbook_capabilities(account_type),
Self::CryptoCom(c) => c.orderbook_capabilities(account_type),
Self::Upbit(c) => c.orderbook_capabilities(account_type),
Self::Deribit(c) => c.orderbook_capabilities(account_type),
Self::HyperLiquid(c) => c.orderbook_capabilities(account_type),
Self::Lighter(c) => c.orderbook_capabilities(account_type),
Self::Dydx(c) => c.orderbook_capabilities(account_type),
Self::Polygon(c) => c.orderbook_capabilities(account_type),
Self::Finnhub(c) => c.orderbook_capabilities(account_type),
Self::Tiingo(c) => c.orderbook_capabilities(account_type),
Self::Twelvedata(c) => c.orderbook_capabilities(account_type),
Self::Alpaca(c) => c.orderbook_capabilities(account_type),
Self::AngelOne(c) => c.orderbook_capabilities(account_type),
Self::Zerodha(c) => c.orderbook_capabilities(account_type),
Self::Upstox(c) => c.orderbook_capabilities(account_type),
Self::Dhan(c) => c.orderbook_capabilities(account_type),
Self::Fyers(c) => c.orderbook_capabilities(account_type),
Self::JQuants(c) => c.orderbook_capabilities(account_type),
Self::Krx(c) => c.orderbook_capabilities(account_type),
Self::Moex(c) => c.orderbook_capabilities(account_type),
Self::Tinkoff(c) => c.orderbook_capabilities(account_type),
Self::Oanda(c) => c.orderbook_capabilities(account_type),
Self::Dukascopy(c) => c.orderbook_capabilities(account_type),
Self::AlphaVantage(c) => c.orderbook_capabilities(account_type),
Self::Polymarket(c) => c.orderbook_capabilities(account_type),
Self::IB(c) => c.orderbook_capabilities(account_type),
Self::YahooFinance(c) => c.orderbook_capabilities(account_type),
Self::CryptoCompare(c) => c.orderbook_capabilities(account_type),
}
}
}
#[async_trait]
impl MarketData for AnyConnector {
async fn get_price(
&self,
symbol: Symbol,
account_type: AccountType,
) -> ExchangeResult<Price> {
match self {
Self::Binance(c) => c.get_price(symbol, account_type).await,
Self::Bybit(c) => c.get_price(symbol, account_type).await,
Self::OKX(c) => c.get_price(symbol, account_type).await,
Self::KuCoin(c) => c.get_price(symbol, account_type).await,
Self::Kraken(c) => c.get_price(symbol, account_type).await,
Self::Coinbase(c) => c.get_price(symbol, account_type).await,
Self::GateIO(c) => c.get_price(symbol, account_type).await,
Self::Bitfinex(c) => c.get_price(symbol, account_type).await,
Self::Bitstamp(c) => c.get_price(symbol, account_type).await,
Self::Gemini(c) => c.get_price(symbol, account_type).await,
Self::MEXC(c) => c.get_price(symbol, account_type).await,
Self::HTX(c) => c.get_price(symbol, account_type).await,
Self::Bitget(c) => c.get_price(symbol, account_type).await,
Self::BingX(c) => c.get_price(symbol, account_type).await,
Self::CryptoCom(c) => c.get_price(symbol, account_type).await,
Self::Upbit(c) => c.get_price(symbol, account_type).await,
Self::Deribit(c) => c.get_price(symbol, account_type).await,
Self::HyperLiquid(c) => c.get_price(symbol, account_type).await,
Self::Lighter(c) => c.get_price(symbol, account_type).await,
Self::Dydx(c) => c.get_price(symbol, account_type).await,
Self::Polygon(c) => c.get_price(symbol, account_type).await,
Self::Finnhub(c) => c.get_price(symbol, account_type).await,
Self::Tiingo(c) => c.get_price(symbol, account_type).await,
Self::Twelvedata(c) => c.get_price(symbol, account_type).await,
Self::Alpaca(c) => c.get_price(symbol, account_type).await,
Self::AngelOne(c) => c.get_price(symbol, account_type).await,
Self::Zerodha(c) => c.get_price(symbol, account_type).await,
Self::Upstox(c) => c.get_price(symbol, account_type).await,
Self::Dhan(c) => c.get_price(symbol, account_type).await,
Self::Fyers(c) => c.get_price(symbol, account_type).await,
Self::JQuants(c) => c.get_price(symbol, account_type).await,
Self::Krx(c) => c.get_price(symbol, account_type).await,
Self::Moex(c) => c.get_price(symbol, account_type).await,
Self::Tinkoff(c) => c.get_price(symbol, account_type).await,
Self::Oanda(c) => c.get_price(symbol, account_type).await,
Self::Dukascopy(c) => c.get_price(symbol, account_type).await,
Self::AlphaVantage(c) => c.get_price(symbol, account_type).await,
Self::Polymarket(c) => c.get_price(symbol, account_type).await,
Self::IB(c) => c.get_price(symbol, account_type).await,
Self::YahooFinance(c) => c.get_price(symbol, account_type).await,
Self::CryptoCompare(c) => c.get_price(symbol, account_type).await,
}
}
async fn get_orderbook(
&self,
symbol: Symbol,
depth: Option<u16>,
account_type: AccountType,
) -> ExchangeResult<OrderBook> {
match self {
Self::Binance(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Bybit(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::OKX(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::KuCoin(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Kraken(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Coinbase(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::GateIO(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Bitfinex(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Bitstamp(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Gemini(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::MEXC(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::HTX(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Bitget(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::BingX(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::CryptoCom(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Upbit(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Deribit(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::HyperLiquid(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Lighter(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Dydx(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Polygon(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Finnhub(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Tiingo(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Twelvedata(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Alpaca(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::AngelOne(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Zerodha(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Upstox(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Dhan(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Fyers(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::JQuants(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Krx(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Moex(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Tinkoff(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Oanda(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Dukascopy(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::AlphaVantage(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::Polymarket(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::IB(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::YahooFinance(c) => c.get_orderbook(symbol, depth, account_type).await,
Self::CryptoCompare(c) => c.get_orderbook(symbol, depth, account_type).await,
}
}
async fn get_klines(
&self,
symbol: Symbol,
interval: &str,
limit: Option<u16>,
account_type: AccountType,
end_time: Option<i64>,
) -> ExchangeResult<Vec<Kline>> {
match self {
Self::Binance(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Bybit(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::OKX(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::KuCoin(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Kraken(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Coinbase(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::GateIO(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Bitfinex(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Bitstamp(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Gemini(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::MEXC(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::HTX(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Bitget(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::BingX(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::CryptoCom(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Upbit(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Deribit(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::HyperLiquid(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Lighter(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Dydx(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Polygon(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Finnhub(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Tiingo(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Twelvedata(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Alpaca(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::AngelOne(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Zerodha(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Upstox(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Dhan(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Fyers(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::JQuants(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Krx(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Moex(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Tinkoff(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Oanda(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Dukascopy(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::AlphaVantage(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::Polymarket(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::IB(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::YahooFinance(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
Self::CryptoCompare(c) => c.get_klines(symbol, interval, limit, account_type, end_time).await,
}
}
async fn get_ticker(
&self,
symbol: Symbol,
account_type: AccountType,
) -> ExchangeResult<Ticker> {
match self {
Self::Binance(c) => c.get_ticker(symbol, account_type).await,
Self::Bybit(c) => c.get_ticker(symbol, account_type).await,
Self::OKX(c) => c.get_ticker(symbol, account_type).await,
Self::KuCoin(c) => c.get_ticker(symbol, account_type).await,
Self::Kraken(c) => c.get_ticker(symbol, account_type).await,
Self::Coinbase(c) => c.get_ticker(symbol, account_type).await,
Self::GateIO(c) => c.get_ticker(symbol, account_type).await,
Self::Bitfinex(c) => c.get_ticker(symbol, account_type).await,
Self::Bitstamp(c) => c.get_ticker(symbol, account_type).await,
Self::Gemini(c) => c.get_ticker(symbol, account_type).await,
Self::MEXC(c) => c.get_ticker(symbol, account_type).await,
Self::HTX(c) => c.get_ticker(symbol, account_type).await,
Self::Bitget(c) => c.get_ticker(symbol, account_type).await,
Self::BingX(c) => c.get_ticker(symbol, account_type).await,
Self::CryptoCom(c) => c.get_ticker(symbol, account_type).await,
Self::Upbit(c) => c.get_ticker(symbol, account_type).await,
Self::Deribit(c) => c.get_ticker(symbol, account_type).await,
Self::HyperLiquid(c) => c.get_ticker(symbol, account_type).await,
Self::Lighter(c) => c.get_ticker(symbol, account_type).await,
Self::Dydx(c) => c.get_ticker(symbol, account_type).await,
Self::Polygon(c) => c.get_ticker(symbol, account_type).await,
Self::Finnhub(c) => c.get_ticker(symbol, account_type).await,
Self::Tiingo(c) => c.get_ticker(symbol, account_type).await,
Self::Twelvedata(c) => c.get_ticker(symbol, account_type).await,
Self::Alpaca(c) => c.get_ticker(symbol, account_type).await,
Self::AngelOne(c) => c.get_ticker(symbol, account_type).await,
Self::Zerodha(c) => c.get_ticker(symbol, account_type).await,
Self::Upstox(c) => c.get_ticker(symbol, account_type).await,
Self::Dhan(c) => c.get_ticker(symbol, account_type).await,
Self::Fyers(c) => c.get_ticker(symbol, account_type).await,
Self::JQuants(c) => c.get_ticker(symbol, account_type).await,
Self::Krx(c) => c.get_ticker(symbol, account_type).await,
Self::Moex(c) => c.get_ticker(symbol, account_type).await,
Self::Tinkoff(c) => c.get_ticker(symbol, account_type).await,
Self::Oanda(c) => c.get_ticker(symbol, account_type).await,
Self::Dukascopy(c) => c.get_ticker(symbol, account_type).await,
Self::AlphaVantage(c) => c.get_ticker(symbol, account_type).await,
Self::Polymarket(c) => c.get_ticker(symbol, account_type).await,
Self::IB(c) => c.get_ticker(symbol, account_type).await,
Self::YahooFinance(c) => c.get_ticker(symbol, account_type).await,
Self::CryptoCompare(c) => c.get_ticker(symbol, account_type).await,
}
}
async fn ping(&self) -> ExchangeResult<()> {
match self {
Self::Binance(c) => c.ping().await,
Self::Bybit(c) => c.ping().await,
Self::OKX(c) => c.ping().await,
Self::KuCoin(c) => c.ping().await,
Self::Kraken(c) => c.ping().await,
Self::Coinbase(c) => c.ping().await,
Self::GateIO(c) => c.ping().await,
Self::Bitfinex(c) => c.ping().await,
Self::Bitstamp(c) => c.ping().await,
Self::Gemini(c) => c.ping().await,
Self::MEXC(c) => c.ping().await,
Self::HTX(c) => c.ping().await,
Self::Bitget(c) => c.ping().await,
Self::BingX(c) => c.ping().await,
Self::CryptoCom(c) => c.ping().await,
Self::Upbit(c) => c.ping().await,
Self::Deribit(c) => c.ping().await,
Self::HyperLiquid(c) => c.ping().await,
Self::Lighter(c) => c.ping().await,
Self::Dydx(c) => c.ping().await,
Self::Polygon(c) => c.ping().await,
Self::Finnhub(c) => c.ping().await,
Self::Tiingo(c) => c.ping().await,
Self::Twelvedata(c) => c.ping().await,
Self::Alpaca(c) => c.ping().await,
Self::AngelOne(c) => c.ping().await,
Self::Zerodha(c) => c.ping().await,
Self::Upstox(c) => c.ping().await,
Self::Dhan(c) => c.ping().await,
Self::Fyers(c) => c.ping().await,
Self::JQuants(c) => c.ping().await,
Self::Krx(c) => c.ping().await,
Self::Moex(c) => c.ping().await,
Self::Tinkoff(c) => c.ping().await,
Self::Oanda(c) => c.ping().await,
Self::Dukascopy(c) => c.ping().await,
Self::AlphaVantage(c) => c.ping().await,
Self::Polymarket(c) => c.ping().await,
Self::IB(c) => c.ping().await,
Self::YahooFinance(c) => c.ping().await,
Self::CryptoCompare(c) => c.ping().await,
}
}
async fn get_exchange_info(&self, account_type: AccountType) -> ExchangeResult<Vec<SymbolInfo>> {
match self {
Self::Binance(c) => c.get_exchange_info(account_type).await,
Self::Bybit(c) => c.get_exchange_info(account_type).await,
Self::OKX(c) => c.get_exchange_info(account_type).await,
Self::KuCoin(c) => c.get_exchange_info(account_type).await,
Self::Kraken(c) => c.get_exchange_info(account_type).await,
Self::Coinbase(c) => c.get_exchange_info(account_type).await,
Self::GateIO(c) => c.get_exchange_info(account_type).await,
Self::Bitfinex(c) => c.get_exchange_info(account_type).await,
Self::Bitstamp(c) => c.get_exchange_info(account_type).await,
Self::Gemini(c) => c.get_exchange_info(account_type).await,
Self::MEXC(c) => c.get_exchange_info(account_type).await,
Self::HTX(c) => c.get_exchange_info(account_type).await,
Self::Bitget(c) => c.get_exchange_info(account_type).await,
Self::BingX(c) => c.get_exchange_info(account_type).await,
Self::CryptoCom(c) => c.get_exchange_info(account_type).await,
Self::Upbit(c) => c.get_exchange_info(account_type).await,
Self::Deribit(c) => c.get_exchange_info(account_type).await,
Self::HyperLiquid(c) => c.get_exchange_info(account_type).await,
Self::Lighter(c) => c.get_exchange_info(account_type).await,
Self::Dydx(c) => c.get_exchange_info(account_type).await,
Self::Polygon(c) => c.get_exchange_info(account_type).await,
Self::Finnhub(c) => c.get_exchange_info(account_type).await,
Self::Tiingo(c) => c.get_exchange_info(account_type).await,
Self::Twelvedata(c) => c.get_exchange_info(account_type).await,
Self::Alpaca(c) => c.get_exchange_info(account_type).await,
Self::AngelOne(c) => c.get_exchange_info(account_type).await,
Self::Zerodha(c) => c.get_exchange_info(account_type).await,
Self::Upstox(c) => c.get_exchange_info(account_type).await,
Self::Dhan(c) => c.get_exchange_info(account_type).await,
Self::Fyers(c) => c.get_exchange_info(account_type).await,
Self::JQuants(c) => c.get_exchange_info(account_type).await,
Self::Krx(c) => c.get_exchange_info(account_type).await,
Self::Moex(c) => c.get_exchange_info(account_type).await,
Self::Tinkoff(c) => c.get_exchange_info(account_type).await,
Self::Oanda(c) => c.get_exchange_info(account_type).await,
Self::Dukascopy(c) => c.get_exchange_info(account_type).await,
Self::AlphaVantage(c) => c.get_exchange_info(account_type).await,
Self::Polymarket(c) => c.get_exchange_info(account_type).await,
Self::IB(c) => c.get_exchange_info(account_type).await,
Self::YahooFinance(c) => c.get_exchange_info(account_type).await,
Self::CryptoCompare(c) => c.get_exchange_info(account_type).await,
}
}
fn market_data_capabilities(&self, account_type: AccountType) -> MarketDataCapabilities {
match self {
Self::Binance(c) => c.market_data_capabilities(account_type),
Self::Bybit(c) => c.market_data_capabilities(account_type),
Self::OKX(c) => c.market_data_capabilities(account_type),
Self::KuCoin(c) => c.market_data_capabilities(account_type),
Self::Kraken(c) => c.market_data_capabilities(account_type),
Self::Coinbase(c) => c.market_data_capabilities(account_type),
Self::GateIO(c) => c.market_data_capabilities(account_type),
Self::Bitfinex(c) => c.market_data_capabilities(account_type),
Self::Bitstamp(c) => c.market_data_capabilities(account_type),
Self::Gemini(c) => c.market_data_capabilities(account_type),
Self::MEXC(c) => c.market_data_capabilities(account_type),
Self::HTX(c) => c.market_data_capabilities(account_type),
Self::Bitget(c) => c.market_data_capabilities(account_type),
Self::BingX(c) => c.market_data_capabilities(account_type),
Self::CryptoCom(c) => c.market_data_capabilities(account_type),
Self::Upbit(c) => c.market_data_capabilities(account_type),
Self::Deribit(c) => c.market_data_capabilities(account_type),
Self::HyperLiquid(c) => c.market_data_capabilities(account_type),
Self::Lighter(c) => c.market_data_capabilities(account_type),
Self::Dydx(c) => c.market_data_capabilities(account_type),
Self::Polygon(c) => c.market_data_capabilities(account_type),
Self::Finnhub(c) => c.market_data_capabilities(account_type),
Self::Tiingo(c) => c.market_data_capabilities(account_type),
Self::Twelvedata(c) => c.market_data_capabilities(account_type),
Self::Alpaca(c) => c.market_data_capabilities(account_type),
Self::AngelOne(c) => c.market_data_capabilities(account_type),
Self::Zerodha(c) => c.market_data_capabilities(account_type),
Self::Upstox(c) => c.market_data_capabilities(account_type),
Self::Dhan(c) => c.market_data_capabilities(account_type),
Self::Fyers(c) => c.market_data_capabilities(account_type),
Self::JQuants(c) => c.market_data_capabilities(account_type),
Self::Krx(c) => c.market_data_capabilities(account_type),
Self::Moex(c) => c.market_data_capabilities(account_type),
Self::Tinkoff(c) => c.market_data_capabilities(account_type),
Self::Oanda(c) => c.market_data_capabilities(account_type),
Self::Dukascopy(c) => c.market_data_capabilities(account_type),
Self::AlphaVantage(c) => c.market_data_capabilities(account_type),
Self::Polymarket(c) => c.market_data_capabilities(account_type),
Self::IB(c) => c.market_data_capabilities(account_type),
Self::YahooFinance(c) => c.market_data_capabilities(account_type),
Self::CryptoCompare(c) => c.market_data_capabilities(account_type),
}
}
}
impl AnyConnector {
pub fn trading_capabilities(&self, account_type: AccountType) -> TradingCapabilities {
match self {
Self::Binance(c) => c.trading_capabilities(account_type),
Self::Bybit(c) => c.trading_capabilities(account_type),
Self::OKX(c) => c.trading_capabilities(account_type),
Self::KuCoin(c) => c.trading_capabilities(account_type),
Self::Kraken(c) => c.trading_capabilities(account_type),
Self::Coinbase(c) => c.trading_capabilities(account_type),
Self::GateIO(c) => c.trading_capabilities(account_type),
Self::Bitfinex(c) => c.trading_capabilities(account_type),
Self::Bitstamp(c) => c.trading_capabilities(account_type),
Self::Gemini(c) => c.trading_capabilities(account_type),
Self::MEXC(c) => c.trading_capabilities(account_type),
Self::HTX(c) => c.trading_capabilities(account_type),
Self::Bitget(c) => c.trading_capabilities(account_type),
Self::BingX(c) => c.trading_capabilities(account_type),
Self::CryptoCom(c) => c.trading_capabilities(account_type),
Self::Upbit(c) => c.trading_capabilities(account_type),
Self::Deribit(c) => c.trading_capabilities(account_type),
Self::HyperLiquid(c) => c.trading_capabilities(account_type),
Self::Lighter(c) => c.trading_capabilities(account_type),
Self::Dydx(c) => c.trading_capabilities(account_type),
Self::Polygon(c) => c.trading_capabilities(account_type),
Self::Finnhub(c) => c.trading_capabilities(account_type),
Self::Tiingo(c) => c.trading_capabilities(account_type),
Self::Twelvedata(c) => c.trading_capabilities(account_type),
Self::Alpaca(c) => c.trading_capabilities(account_type),
Self::AngelOne(c) => c.trading_capabilities(account_type),
Self::Zerodha(c) => c.trading_capabilities(account_type),
Self::Upstox(c) => c.trading_capabilities(account_type),
Self::Dhan(c) => c.trading_capabilities(account_type),
Self::Fyers(c) => c.trading_capabilities(account_type),
Self::JQuants(c) => c.trading_capabilities(account_type),
Self::Krx(c) => c.trading_capabilities(account_type),
Self::Moex(c) => c.trading_capabilities(account_type),
Self::Tinkoff(c) => c.trading_capabilities(account_type),
Self::Oanda(c) => c.trading_capabilities(account_type),
Self::Dukascopy(c) => c.trading_capabilities(account_type),
Self::AlphaVantage(c) => c.trading_capabilities(account_type),
Self::Polymarket(_) => TradingCapabilities::permissive(),
Self::IB(_) => TradingCapabilities::permissive(),
Self::YahooFinance(c) => c.trading_capabilities(account_type),
Self::CryptoCompare(c) => c.trading_capabilities(account_type),
}
}
pub fn account_capabilities(&self, account_type: AccountType) -> AccountCapabilities {
match self {
Self::Binance(c) => c.account_capabilities(account_type),
Self::Bybit(c) => c.account_capabilities(account_type),
Self::OKX(c) => c.account_capabilities(account_type),
Self::KuCoin(c) => c.account_capabilities(account_type),
Self::Kraken(c) => c.account_capabilities(account_type),
Self::Coinbase(c) => c.account_capabilities(account_type),
Self::GateIO(c) => c.account_capabilities(account_type),
Self::Bitfinex(c) => c.account_capabilities(account_type),
Self::Bitstamp(c) => c.account_capabilities(account_type),
Self::Gemini(c) => c.account_capabilities(account_type),
Self::MEXC(c) => c.account_capabilities(account_type),
Self::HTX(c) => c.account_capabilities(account_type),
Self::Bitget(c) => c.account_capabilities(account_type),
Self::BingX(c) => c.account_capabilities(account_type),
Self::CryptoCom(c) => c.account_capabilities(account_type),
Self::Upbit(c) => c.account_capabilities(account_type),
Self::Deribit(c) => c.account_capabilities(account_type),
Self::HyperLiquid(c) => c.account_capabilities(account_type),
Self::Lighter(c) => c.account_capabilities(account_type),
Self::Dydx(c) => c.account_capabilities(account_type),
Self::Polygon(c) => c.account_capabilities(account_type),
Self::Finnhub(c) => c.account_capabilities(account_type),
Self::Tiingo(c) => c.account_capabilities(account_type),
Self::Twelvedata(c) => c.account_capabilities(account_type),
Self::Alpaca(c) => c.account_capabilities(account_type),
Self::AngelOne(c) => c.account_capabilities(account_type),
Self::Zerodha(c) => c.account_capabilities(account_type),
Self::Upstox(c) => c.account_capabilities(account_type),
Self::Dhan(c) => c.account_capabilities(account_type),
Self::Fyers(c) => c.account_capabilities(account_type),
Self::JQuants(c) => c.account_capabilities(account_type),
Self::Krx(c) => c.account_capabilities(account_type),
Self::Moex(c) => c.account_capabilities(account_type),
Self::Tinkoff(c) => c.account_capabilities(account_type),
Self::Oanda(c) => c.account_capabilities(account_type),
Self::Dukascopy(c) => c.account_capabilities(account_type),
Self::AlphaVantage(c) => c.account_capabilities(account_type),
Self::Polymarket(_) => AccountCapabilities::permissive(),
Self::IB(_) => AccountCapabilities::permissive(),
Self::YahooFinance(c) => c.account_capabilities(account_type),
Self::CryptoCompare(c) => c.account_capabilities(account_type),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_any_connector_variant_count() {
}
#[test]
fn test_any_connector_memory_size() {
use std::mem::size_of;
let size = size_of::<AnyConnector>();
assert!(size <= 16, "AnyConnector size ({} bytes) should be <= 16 bytes due to Arc", size);
}
#[test]
fn test_any_connector_send_sync() {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<AnyConnector>();
}
#[test]
fn test_exchange_identity_trait() {
fn assert_exchange_identity<T: ExchangeIdentity>() {}
assert_exchange_identity::<AnyConnector>();
}
#[test]
fn test_market_data_trait_implemented() {
fn assert_market_data<T: MarketData>() {}
assert_market_data::<AnyConnector>();
}
#[test]
fn test_any_connector_clone_trait() {
fn assert_clone<T: Clone>() {}
assert_clone::<AnyConnector>();
}
#[test]
fn test_id_method_exhaustive() {
const _: () = {
};
}
#[test]
fn test_trait_delegation_pattern() {
}
#[test]
fn test_cex_variants_exist() {
}
#[test]
fn test_dex_variants_exist() {
}
#[test]
fn test_stock_variants_exist() {
}
#[test]
fn test_forex_variants_exist() {
}
#[test]
fn test_prediction_variants_exist() {
}
#[test]
fn test_aggregator_variants_exist() {
}
}