Repository navigation
v1.3.5
v1.3.5 — TradFi Support
What's New
This release adds a dedicated TradFi module (BybitTradFi) for trading traditional financial instruments — gold, silver, forex pairs, stock CFDs, and indices — all available on Bybit as linear perpetuals through the standard V5 API.
New Class: BybitTradFi
Instantiate via composition: $tradfi = new BybitTradFi($client)
Market Data
getInstruments— fetch all available TradFi instruments; accepts optional asset class filter:metal,forex,stock,index,commoditygetTicker— get a ticker snapshot for a single TradFi symbolgetTickers— get tickers for a list of symbols (or all linear instruments when empty)getMetalsTickers— shortcut for gold (XAUUSD), silver (XAGUSD), and platinum (XPTUSD)getForexTickers— shortcut for major forex pairs: EURUSD, GBPUSD, USDJPY, and moregetStockTickers— shortcut for US stock CFDs: AAPL, TSLA, NVDA, META, and moregetIndexTickers— shortcut for major indices: US500USD, US100USD, DE40USD, and moregetKline— candlestick data; supports all V5 intervals (1,5,15,60,D,W, etc.)getOrderbook— order book depth for a TradFi symbol; configurable depth up to 200getSwapFee— overnight swap/financing fee info via instruments-info endpoint
Trading
placeOrder— place a limit or market order; supportstakeProfit,stopLoss,reduceOnly,positionIdx, andorderLinkIdclosePosition— close an open position at market price withreduceOnly=truesetLeverage— set leverage for a TradFi symbolcancelOrder— cancel byorderIdororderLinkIdgetOpenOrders— query open/untriggered TradFi orders; optionally filtered by symbolgetOrderHistory— order history with configurable limitgetTradeHistory— execution history for TradFi instrumentsgetPositions— list open positions; optionally filtered by symbolgetFeeRate— trading fee rate for a TradFi symbol or all linear instruments
Utilities
isTradFiSymbol— static helper to detect whether a symbol is a TradFi instrument (metal, forex, or index) vs. a crypto perpetual- Predefined symbol constants:
METALS,FOREX_MAJORS,FOREX_MINORS,US_STOCKS,INDICES
New Example
- examples/13-tradfi.php — demonstrates market data fetching, kline and orderbook retrieval, open position inspection, order placement with TP/SL, order cancellation, and isTradFiSymbol detection across forex, metals, and index symbols
Notes
- All methods use
category=linearinternally — no new API endpoints required beyond the standard V5 REST API - BybitTradFi uses composition, not inheritance — pass an existing
BybitClientinstance to the constructor - TradFi instruments are subject to market hours (unlike 24/7 crypto); outside trading sessions the API may return empty order books or stale prices
- Swap fees apply when holding TradFi positions past daily market close — use
getSwapFeeto check the rate before sizing a position - Fully compatible with PHP 7.4+ — no
str_starts_with/str_ends_withdependencies