Skip to content

Releases: tigusigalpa/bybit-php

v1.1.16

18 Jan 09:24

Choose a tag to compare

Release Notes - v1.1.16

🎉 What's New

This release significantly expands the Bybit PHP SDK with comprehensive market data endpoints and full demo trading support, bringing the library closer to feature parity with the official Bybit V5 API.


✨ New Features

📊 Market Data Endpoints

Added six new market data endpoints for comprehensive market analysis:

  • getOpenInterest() - Retrieve open interest data for derivatives markets

    • Supports multiple interval times: 5min, 15min, 30min, 1h, 4h, 1d
    • Essential for analyzing market sentiment and positioning
  • getRecentTrades() - Fetch recent public trades

    • Access up to 1000 recent trades per request
    • Real-time market activity monitoring
  • getFundingRateHistory() - Get historical funding rate data

    • Track funding rates over time for perpetual contracts
    • Up to 200 records per request with pagination support
  • getHistoricalVolatility() - Retrieve historical volatility for options

    • Multiple period options: 7, 14, 21, 30, 60, 90, 180, 270 days
    • Critical for options pricing and risk assessment
  • getInsurancePool() - Access insurance pool data

    • Monitor the health of Bybit's insurance fund
    • Available for all supported coins
  • getRiskLimit() - Get risk limit information

    • Understand position size limits and margin requirements
    • Essential for risk management

🎮 Demo Trading Support

Full implementation of Bybit's demo trading environment:

  • Demo Trading Mode - New demoTrading parameter in BybitClient constructor

    • Automatically routes requests to https://api-demo.bybit.com
    • Seamless switching between live and demo environments
  • createDemoAccount() - Programmatically create demo trading accounts

    • Use production API keys to generate demo accounts
    • Returns demo account UID for API key creation
  • requestDemoFunds() - Request virtual funds for demo trading

    • Add or reduce demo funds for any supported coin
    • Rate limit: 1 request per minute
  • Laravel Integration - New BYBIT_DEMO_TRADING environment variable

    • Easy configuration via .env file
    • Works seamlessly with facades and dependency injection

🔧 Improvements

Configuration Enhancements

  • Added demo_trading configuration option in config/bybit.php
  • Added BYBIT_DEMO_TRADING environment variable support
  • Updated BybitServiceProvider to pass demo trading flag to client instances

Code Architecture

  • Extended baseUri() method to support demo trading domain
  • Maintained backward compatibility - all existing code continues to work
  • No breaking changes to existing API

📚 Documentation Updates

README.md & README-ru.md

  • New Market Data Section - Comprehensive examples for all 6 new endpoints
  • Demo Trading Section - Complete guide with Pure PHP and Laravel examples
  • Configuration Table - Updated with BYBIT_DEMO_TRADING parameter
  • Environment Variables - Added demo trading configuration examples

Code Examples

Added practical examples for:

  • Open interest analysis
  • Recent trades monitoring
  • Funding rate tracking
  • Historical volatility analysis
  • Insurance pool monitoring
  • Risk limit management
  • Demo account creation and funding

🚀 Usage Examples

Market Data

// Get open interest
$openInterest = $client->getOpenInterest([
    'category' => 'linear',
    'symbol' => 'BTCUSDT',
    'intervalTime' => '5min'
]);

// Get recent trades
$trades = $client->getRecentTrades([
    'category' => 'linear',
    'symbol' => 'BTCUSDT',
    'limit' => 60
]);

// Get funding rate history
$funding = $client->getFundingRateHistory([
    'category' => 'linear',
    'symbol' => 'BTCUSDT',
    'limit' => 200
]);

Demo Trading

// Pure PHP
$demoClient = new BybitClient(
    apiKey: 'your_demo_api_key',
    apiSecret: 'your_demo_api_secret',
    testnet: false,
    region: 'global',
    recvWindow: 5000,
    signature: 'hmac',
    rsaPrivateKey: null,
    http: null,
    fees: null,
    demoTrading: true
);

// Request demo funds
$demoClient->requestDemoFunds([
    'adjustType' => 0,
    'utaDemoApplyMoney' => [
        ['coin' => 'USDT', 'amountStr' => '10000'],
        ['coin' => 'BTC', 'amountStr' => '1']
    ]
]);

// Laravel - Just set in .env
BYBIT_DEMO_TRADING=true

📋 API Reference

New Methods

Method Endpoint Description
getOpenInterest() GET /v5/market/open-interest Get open interest data
getRecentTrades() GET /v5/market/recent-trade Get recent public trades
getFundingRateHistory() GET /v5/market/funding/history Get funding rate history
getHistoricalVolatility() GET /v5/market/historical-volatility Get historical volatility
getInsurancePool() GET /v5/market/insurance Get insurance pool data
getRiskLimit() GET /v5/market/risk-limit Get risk limit info
createDemoAccount() POST /v5/user/create-demo-member Create demo account
requestDemoFunds() POST /v5/account/demo-apply-money Request demo funds

🔄 Migration Guide

From v1.1.15 to v1.1.16

No breaking changes! This is a backward-compatible release.

To Use New Market Data Endpoints

Simply call the new methods - they follow the same pattern as existing methods:

$result = $client->getOpenInterest(['category' => 'linear', 'symbol' => 'BTCUSDT']);

To Enable Demo Trading

Pure PHP:

$client = new BybitClient($key, $secret, false, 'global', 5000, 'hmac', null, null, null, true);

Laravel:

BYBIT_DEMO_TRADING=true

📖 Documentation


🙏 Acknowledgments

This release implements functionality based on:

  • Bybit V5 API official documentation
  • Community feedback and feature requests
  • Best practices from pybit (official Python SDK)

📦 Installation

composer require tigusigalpa/bybit-php

For Laravel:

composer require tigusigalpa/bybit-php
php artisan vendor:publish --tag=bybit-config

🐛 Bug Fixes

None in this release - focus was on new features.


⚠️ Known Issues

None reported.


🔮 What's Next?

Future releases may include:

  • Additional account management endpoints
  • Batch operations support
  • Enhanced WebSocket features
  • More comprehensive error handling

📝 Full Changelog

Added

  • Market data endpoint: getOpenInterest()
  • Market data endpoint: getRecentTrades()
  • Market data endpoint: getFundingRateHistory()
  • Market data endpoint: getHistoricalVolatility()
  • Market data endpoint: getInsurancePool()
  • Market data endpoint: getRiskLimit()
  • Demo trading support with demoTrading parameter
  • Demo trading endpoint: createDemoAccount()
  • Demo trading endpoint: requestDemoFunds()
  • Configuration option: BYBIT_DEMO_TRADING
  • Comprehensive documentation for all new features
  • Usage examples in both English and Russian READMEs

Changed

  • Updated baseUri() to support demo trading domain
  • Extended BybitClient constructor with demoTrading parameter
  • Updated BybitServiceProvider to support demo trading configuration
  • Enhanced configuration file with demo trading option

Fixed

  • None

Deprecated

  • None

Removed

  • None

Security

  • No security-related changes

Release Date: January 18, 2026
Author: Igor Sazonov (tigusigalpa)
License: MIT

v1.1.4

18 Jan 04:49

Choose a tag to compare

Release Notes

v1.1.4 - 2026-01-18

🎉 Major Updates

This release brings significant enhancements to the Bybit PHP SDK, including comprehensive REST API coverage, WebSocket support, and extensive documentation improvements.

✨ New Features

REST API Methods

  • Order Management

    • amendOrder() - Modify existing orders (price, quantity)
    • cancelAllOrders() - Cancel all orders for a specific symbol
    • getHistoryOrders() - Retrieve closed/cancelled order history
  • Position Management

    • switchPositionMode() - Switch between One-Way Mode and Hedge Mode
    • setTradingStop() - Set Take Profit and Stop Loss for existing positions

WebSocket Real-Time Streaming

  • New BybitWebSocket Class - Complete WebSocket client implementation

    • Public streams: orderbook, trades, tickers, klines
    • Private streams: positions, orders, executions, wallet updates
    • Auto-reconnection handling
    • Automatic ping/pong for connection maintenance
    • Support for multiple topic subscriptions
    • Regional endpoint support
    • Testnet compatibility
  • Laravel Integration

    • BybitWebSocket facade for easy access
    • Service provider registration
    • Background processing support

Helper Methods

  • subscribeOrderbook($symbol, $depth) - Subscribe to orderbook updates
  • subscribeTrade($symbol) - Subscribe to public trades
  • subscribeTicker($symbol) - Subscribe to ticker updates
  • subscribeKline($symbol, $interval) - Subscribe to kline/candlestick data
  • subscribePosition() - Subscribe to position updates (private)
  • subscribeOrder() - Subscribe to order updates (private)
  • subscribeExecution() - Subscribe to execution updates (private)
  • subscribeWallet() - Subscribe to wallet updates (private)

📚 Documentation Improvements

Modern README Design

  • Enhanced Visual Design

    • Added badges (PHP version, Laravel compatibility, License, WebSocket support)
    • Centered header with professional styling
    • Interactive table of contents with anchor links
    • Emoji icons for better readability
    • Two-column feature tables
  • Comprehensive Table of Contents

    • Quick navigation to all sections
    • Organized by feature categories
    • Easy-to-scan structure
  • Pure PHP Examples

    • Complete standalone examples without Laravel
    • WebSocket usage for pure PHP
    • Full initialization examples
    • Trading bot example
  • Enhanced Sections

    • Regional endpoints table with country flags
    • Configuration parameters table
    • Advanced usage examples
    • Complete trading bot example
    • Contributing guidelines
    • Professional footer with call-to-action

Bilingual Documentation

  • English (README.md) - Fully modernized with all new features
  • Russian (README-ru.md) - Complete translation with identical structure

New Documentation Files

  • INSTALLATION.md - Comprehensive installation and setup guide
    • Prerequisites and requirements
    • Step-by-step installation
    • Configuration instructions
    • API key setup
    • Troubleshooting section

📁 Examples Directory

Added complete examples/ folder with 12+ practical examples:

Basic Examples

  • 01-basic-client.php - Client initialization and connection testing
  • 02-market-data.php - Fetching tickers, orderbook, and klines
  • 03-account-info.php - Account balance and fee information

Order Management

  • 04-place-order.php - Placing limit, market, and conditional orders
  • 05-manage-orders.php - Getting, amending, and canceling orders

Position Management

  • 07-positions.php - Viewing and monitoring positions
  • 08-leverage.php - Setting leverage and position modes
  • 09-trading-stops.php - Managing Take Profit and Stop Loss

WebSocket Examples

  • 10-websocket-public.php - Public stream subscriptions
  • 11-websocket-private.php - Private account updates
  • 12-websocket-advanced.php - Advanced multi-symbol monitoring

Laravel Examples

  • laravel/TradingController.php - Controller with DI and facades
  • laravel/BybitWebSocketCommand.php - Artisan command for WebSocket
  • laravel/routes.example.php - API route examples

Configuration

  • config.example.php - Example configuration template
  • README.md - Examples documentation

🔧 Infrastructure

  • .gitignore - Added comprehensive gitignore file
    • Vendor directory exclusion
    • IDE files (VSCode, PHPStorm)
    • Environment files
    • Build artifacts
    • Logs and cache
    • Example configuration files

📦 Dependencies

  • Added: textalk/websocket: ^1.6 - WebSocket client library for real-time streaming

🔄 Updated Files

  • composer.json - Added WebSocket dependency and facade alias
  • src/BybitServiceProvider.php - Registered WebSocket client
  • src/BybitClient.php - Added new REST API methods
  • CHANGELOG.md - Updated with v0.2.0 changes

📖 API Coverage

The SDK now covers the following Bybit V5 API endpoints:

Market Data:

  • ✅ Server Time
  • ✅ Tickers
  • ✅ Orderbook
  • ✅ Klines
  • ✅ Risk Limit

Trading:

  • ✅ Place Order
  • ✅ Amend Order
  • ✅ Cancel Order
  • ✅ Cancel All Orders
  • ✅ Get Open Orders
  • ✅ Get Order History

Position:

  • ✅ Get Positions
  • ✅ Set Leverage
  • ✅ Switch Position Mode
  • ✅ Set Trading Stop

Account:

  • ✅ Get Wallet Balance
  • ✅ Get Fee Rate

WebSocket:

  • ✅ Public: Orderbook, Trade, Ticker, Kline
  • ✅ Private: Position, Order, Execution, Wallet

🎯 Usage Highlights

Quick Start with WebSocket

use Tigusigalpa\ByBit\BybitWebSocket;

$ws = new BybitWebSocket(
    apiKey: null,
    apiSecret: null,
    testnet: false,
    region: 'global',
    isPrivate: false
);

$ws->subscribeOrderbook('BTCUSDT', 50);
$ws->subscribeTrade('BTCUSDT');

$ws->onMessage(function($data) {
    print_r($data);
});

$ws->listen();

Laravel WebSocket Command

php artisan bybit:listen BTCUSDT

🔗 Links

🙏 Acknowledgments

Special thanks to the Bybit team for their comprehensive API documentation and to the crypto trading community for their feedback and support.

📝 Notes

  • All WebSocket streams support both Testnet and Mainnet environments
  • Regional endpoints are fully supported for both REST and WebSocket
  • Examples include comprehensive error handling
  • All code follows PSR-12 coding standards

⚠️ Breaking Changes

None. This release is fully backward compatible with v0.1.0.

🐛 Bug Fixes

  • Improved error handling in WebSocket connections
  • Fixed signature generation for edge cases
  • Enhanced timestamp synchronization

🔜 Coming Soon

  • Retry mechanisms for failed requests
  • Rate limit handling
  • Request logging and tracing
  • Additional helper methods for common trading patterns

Full Changelog: v0.1.0...v1.1.4

v0.1.0

18 Jan 04:27

Choose a tag to compare