carpenstar / bybitapi-sdk-derivatives
Requires
- php: >=7.4
- carpenstar/bybitapi-sdk-core: 3.0.5
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-05-09 17:08:01 UTC
README
ByBitAPI - derivatives-trading package
Disclaimer: This is an unofficial SDK for integration with the ByBit exchange. Functional support is provided only within the code's area of responsibility and, if possible, on the part of the developer
Integration development is not yet complete, so functionality (either completely or individual components) is not guaranteed.
Requirements
- PHP >= 7.4
Installation
composer require carpenstar/bybitapi-sdk-derivatives
Contents:
Market Data - Funding Rate History
Funding history for a specified symbol for a certain period
// Endpoint classname Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\FundingRateHistory::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\FundingRateHistory; use Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Response\FundingRateHistoryResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Request\FundingRateHistoryRequest; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new FundingRateHistoryRequest())->setSymbol("BTCUSDT")->setLimit(3); /** @var FundingRateHistoryResponse[] $result */ $result = $bybit->rest(FundingRateHistory::class, $options)->getBody()->all(); foreach ($result as $rateItem) { echo "Symbol: {$rateItem->getSymbol()}" . PHP_EOL; echo "Funding Rate: {$rateItem->getFundingRate()}" . PHP_EOL; echo "Funding Rate Timestamp: {$rateItem->getFundingRateTimestamp()->format("Y-m-d H:i:s")}" . PHP_EOL; echo "-----" . PHP_EOL; } /** * Result: * * Symbol: BTCUSDT * Funding Rate: 0.0001 * Funding Rate Timestamp: 2023-05-09 08:00:00 * ----- * Symbol: BTCUSDT * Funding Rate: 0.00121833 * Funding Rate Timestamp: 2023-05-09 00:00:00 * ----- * Symbol: BTCUSDT * Funding Rate: 0.00375 * Funding Rate Timestamp: 2023-05-08 16:00:00 * ----- */
REQUEST PARAMETERS
new \Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Request\FundingRateHistoryRequest(); $options = (new FundingRateHistoryRequest()) ->setSymbol("BTCUSDT") // Trading pair ->setStartTime((new DateTime("2023-05-09 10:00:00"))->getTimestamp()) // The start timestamp ->setEndTime((new DateTime("2023-05-09 10:00:00"))->getTimestamp()) // The end timestamp ->setLimit(200) // Limit for data size per page. [1, 200]. Default: 200
INTERFACE: \Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Interfaces\IFundingRateHistoryRequest::class |
||
DTO: \Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Request\FundingRateHistoryRequest::class |
||
Method | Required | Description |
---|---|---|
IFundingRateHistoryRequest::setSymbol(string $symbol): self | NO | Trading pair symbol |
IFundingRateHistoryRequest::setStartTime(int $timestamp): self | NO* | Timestamp FROM which the data slice is taken |
IFundingRateHistoryRequest::setEndTime(int $timestamp): self | NO* | Timestamp BEFORE which the data slice is taken |
IFundingRateHistoryRequest::setLimit(int $limit): self | NO | Limiting the records returned per query |
*Warning: When setting time limits on sampling, be sure to specify the upper and lower bounds using
setStartTime(int $timestamp)
andsetEndTime(int $timestamp)
. Otherwise an error will be returned
Warning: By default, a request to the
FundingRateHistory::class
endpoint returns the last 200 records up to the current moment for a specific symbol
RESPONSE STRUCTURE
INTERFACE: \Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Interfaces\IFundingRateHistoryResponse::class |
||
DTO: \Carpenstar\ByBitAPI\Derivatives\MarketData\FundingRateHistory\Response\FundingRateHistoryResponse::class |
||
Method | Type | Description |
---|---|---|
IFundingRateHistoryResponse::getSymbol() | string | Trading pair symbol |
IFundingRateHistoryResponse::getFundingRate() | float | Financing rate |
IFundingRateHistoryResponse::getFundingRateTimestamp() | DateTime | Financing rate holding time |
Market Data - Index Price Kline
Request for the history of the INDEX price calculated based on the prices of the largest exchanges.
Each element represents a group of prices depending on the requested interval.
This data can be used to construct candlestick and other charts.
// Endpoint classname Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\IndexPriceKline::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\IndexPriceKline; use Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\Response\IndexPriceKlineResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\Request\IndexPriceKlineRequest; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new IndexPriceKlineRequest()) ->setSymbol("ETHUSDT") ->setInterval(1) ->setStartTime((new DateTime("2023-05-01 10:00:00"))->getTimestamp()) ->setEndTime((new DateTime("2023-05-01 20:00:00"))->getTimestamp()) ->setLimit(5); /** @var IndexPriceKlineResponse[] $result */ $result = $bybit->rest(IndexPriceKline::class, $options)->getBody()->all(); foreach ($result as $indexPriceKlineItem) { echo "Start: {$indexPriceKlineItem->getStartTime()->format('Y-m-d H:i:s')}" . PHP_EOL; echo "Open: {$indexPriceKlineItem->getOpen()}" . PHP_EOL; echo "High: {$indexPriceKlineItem->getHigh()}" . PHP_EOL; echo "Low: {$indexPriceKlineItem->getLow()}" . PHP_EOL; echo "Close: {$indexPriceKlineItem->getClose()}" . PHP_EOL; echo "-----" . PHP_EOL; } /** * Result: * * Start: 2023-05-01 10:04:00 * Open: 1847.37 * High: 1847.65 * Low: 1847.37 * Close: 1847.4 * ----- * Start: 2023-05-01 10:03:00 * Open: 1847.45 * High: 1847.57 * Low: 1847.36 * Close: 1847.37 * ----- * Start: 2023-05-01 10:02:00 * Open: 1847.65 * High: 1847.79 * Low: 1847.41 * Close: 1847.45 * ----- * Start: 2023-05-01 10:01:00 * Open: 1847.63 * High: 1847.66 * Low: 1847.27 * Close: 1847.65 * ----- * Start: 2023-05-01 10:00:00 * Open: 1847.25 * High: 1847.68 * Low: 1847.25 * Close: 1847.63 * ----- */
REQUEST PARAMETERS:
use Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\Request\IndexPriceKlineRequest; $options = (new IndexPriceKlineRequest()) ->setSymbol("BTCUSDT") // Trading pair ->setInterval(1) // Kline interval. 1 3 5 15 30 60 120 240 360 720 D M W ->setStartTime((new DateTime("2023-05-09 10:00:00"))->getTimestamp()) // The start timestamp ->setEndTime((new DateTime("2023-05-09 11:00:00"))->getTimestamp()) // The end timestamp ->setLimit(200) // Limit for data size per page. [1, 1000]. Default: 200
INTERFACE: \Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\Interfaces\IIndexPriceKlineRequest::class |
||
DTO: \Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\Request\IndexPriceKlineRequest::class |
||
Method | Required | Description |
---|---|---|
IIndexPriceKlineRequest::setSymbol(string $symbol): self | YES | Trading pair |
IIndexPriceKlineRequest::setInterval(int $interval): self | YES | Teak size. Possible values: 1 3 5 15 30 60 120 240 360 720 D M W |
IIndexPriceKlineRequest::setStartTime(int $timestamp): self | YES | Timestamp FROM which the data slice is taken |
IIndexPriceKlineRequest::setEndTime(int $timestamp): self | YES | Timestamp BEFORE which the data slice is taken |
IIndexPriceKlineRequest::setLimit(int $limit): self | NO | Limit the records returned per query. Default: 200 |
RESPONSE STRUCTURE:
Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\Interfaces\IIndexPriceKlineResponse::class interface IIndexPriceKlineResponse { public function getStartTime(): \DateTime; public function getOpen(): float; public function getHigh(): float; public function getLow(): float; public function getClose(): float; }
INTERFACE: \Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\Interfaces\IIndexPriceKlineResponse::class |
||
DTO: \Carpenstar\ByBitAPI\Derivatives\MarketData\IndexPriceKline\Response\IndexPriceKlineResponse::class |
||
Method | Type | Description |
---|---|---|
IIndexPriceKlineResponse::getStartTime() | DateTime | Tick start time |
IIndexPriceKlineResponse::getOpen() | float | Tick opening price |
IIndexPriceKlineResponse::getHigh() | float | Maximum tick price |
IIndexPriceKlineResponse::getLow() | float | Minimum tick price |
IIndexPriceKlineResponse::getClose() | float | Tick closing price |
Market Data - Instrument Info
Endpoint provides the specifications of the trading instrument.
// Endpoint classname \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\InstrumentInfo::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\InstrumentInfo; use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Response\InstrumentInfoResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Request\InstrumentInfoRequest; use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Response\LeverageFilterItemResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Response\PriceFilterItemResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Response\LotSizeFilterItemResponse; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new InstrumentInfoRequest())->setSymbol('BTCUSDT'); /** @var InstrumentInfoResponse $instrumentInfo */ $instrumentInfo = $bybit->rest(InstrumentInfo::class, $options)->getBody()->fetch(); echo "Symbol: {$instrumentInfo->getSymbol()}" . PHP_EOL; echo "Contract Type: {$instrumentInfo->getContractType()}" . PHP_EOL; echo "Status: {$instrumentInfo->getStatus()}" . PHP_EOL; echo "Base Coin: {$instrumentInfo->getBaseCoin()}" . PHP_EOL; echo "Quote Coin: {$instrumentInfo->getQuoteCoin()}" . PHP_EOL; echo "Launch Time: {$instrumentInfo->getLaunchTime()->format("Y-m-d H:i:s")}" . PHP_EOL; echo "Delivery Time: " . ($instrumentInfo->getDeliveryTime() ? $instrumentInfo->getDeliveryTime()->format('Y-m-d H:i:s') : '-') . PHP_EOL; echo "Delivery Fee Rate: {$instrumentInfo->getDeliveryFeeRate()}" . PHP_EOL; echo "Price Scale: {$instrumentInfo->getPriceScale()}" . PHP_EOL; echo "Unified Margin Trade: {$instrumentInfo->getUnifiedMarginTrade()}" . PHP_EOL; echo "Funding Interval: {$instrumentInfo->getFundingInterval()}" . PHP_EOL; echo "Settle Coin: {$instrumentInfo->getSettleCoin()}" . PHP_EOL; echo "Leverage Filter Options:" . PHP_EOL; /** @var LeverageFilterItemResponse $filterItem */ foreach ($instrumentInfo->getLeverageFilter()->all() as $filterItem) { echo " - Minimal Leverage: {$filterItem->getMinLeverage()}" . PHP_EOL; echo " - Maximum Leverage: {$filterItem->getMaxLeverage()}" . PHP_EOL; echo " - Leverage Step: {$filterItem->getLeverageStep()}" . PHP_EOL; } echo "Price Filter Options:" . PHP_EOL; /** @var PriceFilterItemResponse $filterItem */ foreach ($instrumentInfo->getPriceFilter()->all() as $filterItem) { echo " - Minimal Price: {$filterItem->getMinPrice()}" . PHP_EOL; echo " - Maximum Price: {$filterItem->getMinPrice()}" . PHP_EOL; echo " - Tick Size: {$filterItem->getTickSize()}" . PHP_EOL; } echo "Lot Size Filter Options:" . PHP_EOL; /** @var LotSizeFilterItemResponse $filterItem */ foreach ($instrumentInfo->getLotSizeFilter()->all() as $filterItem) { echo " - Minimal Order Qty: {$filterItem->getMinOrderQty()}" . PHP_EOL; echo " - Maximum Order Qty: {$filterItem->getMaxOrderQty()}" . PHP_EOL; echo " - Qty Step: {$filterItem->getQtyStep()}" . PHP_EOL; } /** * Result: * * Symbol: BTCUSDT * Contract Type: LinearPerpetual * Status: Trading * Base Coin: BTC * Quote Coint: USDT * Launch Time: 2020-03-30 00:00:00 * Delivery Time: - * Delivery Fee Rate: 0 * Price Scale: 2 * Unified Margin Trade: 1 * Funding Interval: 480 * Settle Coin: USDT * Leverage Filter Options: * - Minimal Leverage: 1 * - Maximum Leverage: 100 * - Leverage Step: 0.01 * Price Filter Options: * - Minimal Price: 0.1 * - Maximum Price: 0.1 * - Tick Size: 0.1 * Lot Size Filter Options: * - Minimal Order Qty: 0.001 * - Maximum Order Qty: 100 * - Qty Step: 0.001 * */
REQUEST PARAMETERS
use \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Request\InstrumentInfoRequest; $options = (new InstrumentInfoRequest()) ->setSymbol('BTCUSDT'); // Trading pair
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\IInstrumentInfoRequest::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Request\InstrumentInfoRequest::class |
||
Method | Required | Description |
---|---|---|
IInstrumentInfoRequest::setSymbol(string $symbol): self | YES | Trading pair |
RESPONSE STRUCTURE
\Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\IInstrumentInfoResponse::class interface IInstrumentInfoResponse { public function getSymbol(): ?string; // Trading pair public function getContractType(): ?string; // Contract type public function getBaseCoin(): ?string; // Base token. For example: BTC public function getQuoteCoin(): ?string; // Relative token. For example: USDT public function getSettleCoin(): ?string; // Settlement token. For example: USDT public function getFundingInterval(): int; // Interval for debiting the funding rate in milliseconds public function getUnifiedMarginTrade(): bool; // Support for a unified margin trading account public function getPriceScale(): float; // Price scale public function getStatus(): ?string; // Instrument trading status public function getLotSizeFilter(): EntityCollection; // ILotSizeFilterItem[] public function getPriceFilter(): EntityCollection; // IPriceFilterItem[] public function getLeverageFilter(): EntityCollection // ILeverageFilterItem[]; }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\IInstrumentInfoResponse::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Response\InstrumentInfoResponse::class |
||
Method | Type | Description |
---|---|---|
IInstrumentInfoResponse::getSymbol() | string | Trading pair |
IInstrumentInfoResponse::getContractType() | string | Contract type. Note: currently only Linear is supported |
IInstrumentInfoResponse::getBaseCoin() | string | Base token. For example: BTC |
IInstrumentInfoResponse::getQuoteCoin() | string | Relative token. For example: USDT |
IInstrumentInfoResponse::getSettleCoin() | string | Settlement token. For example: USDT |
IInstrumentInfoResponse::getFundingInterval() | int | Interval for debiting the funding rate in milliseconds |
IInstrumentInfoResponse::getUnifiedMarginTrade() | bool | Support for a unified margin trading account |
IInstrumentInfoResponse::getPriceScale() | float | Price scale |
IInstrumentInfoResponse::getLaunchTime() | DateTime | Start time of trading on the instrument |
IInstrumentInfoResponse::getStatus() | string | Instrument trading status |
IInstrumentInfoResponse::getLotSizeFilter() | ILotSizeFilterItem[] | |
IInstrumentInfoResponse::getPriceFilter() | IPriceFilterItem[] | |
IInstrumentInfoResponse::getLeverageFilter() | ILeverageFilterItem[] |
\Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\ILotSizeFilterItem::class interface ILotSizeFilterItem { public function getMaxOrderQty(): float; public function getMinOrderQty(): float; public function getQtyStep(): float; }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\ILotSizeFilterItem:class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Response\LotSizeFilterItemResponse::class |
||
Method | Type | Description |
---|---|---|
ILotSizeFilterItem::getMaxOrderQty() | float | Maximum order size |
ILotSizeFilterItem::getMinOrderQty() | float | Minimum order size |
ILotSizeFilterItem::getQtyStep() | float | Step to change order size |
\Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\ILeverageFilterItem::class interface ILeverageFilterItem { public function getMinLeverage(): int; public function getMaxLeverage(): float; public function getLeverageStep(): float; }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\ILeverageFilterItem::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Response\LeverageFilterItemResponse::class |
||
Method | Type | Description |
---|---|---|
ILeverageFilterItem::getMinLeverage() | int | Minimum leverage |
ILeverageFilterItem::getMaxLeverage() | float | Maximum leverage |
ILeverageFilterItem::getLeverageStep() | float | Leverage step |
\Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\IPriceFilterItem::class interface IPriceFilterItem { public function getMinPrice(): float; public function getMaxPrice(): float; public function getTickSize(): float; }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Interfaces\IPriceFilterItem::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\InstrumentInfo\Response\PriceFilterItemResponse::class |
||
Method | Type | Description |
---|---|---|
IPriceFilterItem::getMinPrice() | int | Minimum price |
IPriceFilterItem::getMaxPrice() | float | Maximum price |
IPriceFilterItem::getTickSize() | float | Tick size |
Market Data - Kline
Endpoint returns historical data for plotting. Candles are returned in groups depending on the requested interval.
// Endpoint classname \Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Kline::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Request\KlineRequest; use Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Response\KlineResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Kline; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new KlineRequest()) ->setSymbol("BTCUSDT") ->setInterval(5) ->setStartTime((new DateTime("2023-05-01 00:00:00"))->getTimestamp()) ->setEndTime((new DateTime("2023-05-05 00:00:00"))->getTimestamp()) ->setLimit(5); $klineData = $bybit->rest(Kline::class, $options)->getBody()->all(); /** @var KlineResponse $klineItem */ foreach ($klineData as $klineItem) { echo "Start: {$klineItem->getStartTime()->format('Y-m-d H:i:s')}" . PHP_EOL; echo "Open: {$klineItem->getOpen()}" . PHP_EOL; echo "High: {$klineItem->getHigh()}" . PHP_EOL; echo "Low: {$klineItem->getLow()}" . PHP_EOL; echo "Close: {$klineItem->getClose()}" . PHP_EOL; echo "-----" . PHP_EOL; } /** * Result: * * Start: 2023-05-01 00:20:00 * Open: 29269.9 * High: 29297.4 * Low: 29263.3 * Close: 29283 * ----- * Start: 2023-05-01 00:15:00 * Open: 29277.8 * High: 29316.3 * Low: 29269.9 * Close: 29269.9 * ----- * Start: 2023-05-01 00:10:00 * Open: 29301 * High: 29320.1 * Low: 29264.7 * Close: 29277.8 * ----- * Start: 2023-05-01 00:05:00 * Open: 29286 * High: 29348.1 * Low: 29269.9 * Close: 29301 * ----- * Start: 2023-05-01 00:00:00 * Open: 29221.2 * High: 29300.4 * Low: 29206.2 * Close: 29286 * ----- */
REQUEST PARAMETERS
\Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Interfaces\IKlineRequestInterface::class $options = (new KlineRequest()) ->setSymbol("BTCUSDT") // Required parameter. Line with the ticker of the trading pair. ->setInterval(1) // Required parameter. Teak size. Possible values: 1 3 5 15 30 60 120 240 360 720 D M W ->setStartTime((new DateTime("2023-05-10 10:00:00"))->getTimestamp()) // Required parameter. Timestamp from which the data slice is taken ->setEndTime((new DateTime("2023-05-10 11:00:00"))->getTimestamp()) // Required parameter. Timestamp BEFORE which the data slice is taken ->setLimit(200) // Optional parameter. Limit the records returned per query. Default 200
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Interfaces\IKlineRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Request\KlineRequest::class |
||
Method | Required | Description |
---|---|---|
IKlineRequestInterface::setSymbol(string $symbol): self | YES | Trading pair |
IKlineRequestInterface::setInterval(int $interval): self | YES | Teak size. Possible values: 1 3 5 15 30 60 120 240 360 720 D M W |
IKlineRequestInterface::setStartTime(int $timestamp): self | YES | Timestamp FROM which the data slice is taken |
IKlineRequestInterface::setEndTime(int $timestamp): self | YES | Timestamp BEFORE which the data slice is taken |
IKlineRequestInterface::setLimit(int $limit): self | NO | Limit the records returned per query. Default 200 |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Interfaces; interface IKlineResponseInterface { public function getStartTime(): \DateTime; // Tick start time public function getOpen(): float; // Opening price public function getHigh(): float; // Highest price public function getLow(): float; // Lowest price public function getClose(): float; // Closing price public function getVolume(): float; // Volume public function getTurnover(): float; // Turnover }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Interfaces\IKlineResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\Kline\Response\KlineResponse::class |
||
Method | Type | Description |
---|---|---|
IKlineResponseInterface::getStartTime() | DateTime | Tick start time |
IKlineResponseInterface::getOpen() | float | Opening price |
IKlineResponseInterface::getHigh() | float | Highest price |
IKlineResponseInterface::getLow() | float | Lowest price |
IKlineResponseInterface::getClose() | float | Closing price |
IKlineResponseInterface::getVolume() | float | Volume |
IKlineResponseInterface::getTurnover() | float | Turnover |
Market Data - Mark Price Kline
Endpoint returns historical data at MARKING price.
Data is returned in groups depending on the requested interval.
Can be used to generate candlestick charts.
// Endpoint classname \Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\MarkPriceKline::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\MarkPriceKline; use Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\Request\MarkPriceKlineRequest; use Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\Response\MarkPriceKlineResponse; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new MarkPriceKlineRequest()) ->setSymbol("APTUSDT") ->setInterval('1') // Kline interval. 1 3 5 15 30 60 120 240 360 720 D M W ->setStartTime('2023-05-08 10:00:00') ->setEndTime('2023-05-08 15:00:00') ->setLimit(5); $result = $bybit->rest(MarkPriceKline::class, $options)->getBody(); /** * @var MarkPriceKlineResponse $markPrice */ foreach ($result->all() as $markPrice) { echo "Start: {$markPrice->getStartTime()->format("Y-m-d H:i:s")}" . PHP_EOL; echo "Open: {$markPrice->getOpen()}" . PHP_EOL; echo "High: {$markPrice->getHigh()}" . PHP_EOL; echo "Low: {$markPrice->getLow()}" . PHP_EOL; echo "Close: {$markPrice->getClose()}" . PHP_EOL; echo "----" . PHP_EOL; } /** * Result: * * Start: 2023-05-08 10:04:00 * Open: 8.7751 * High: 8.7759 * Low: 8.7734 * Close: 8.775 * ---- * Start: 2023-05-08 10:03:00 * Open: 8.7748 * High: 8.7765 * Low: 8.7734 * Close: 8.7751 * ---- * Start: 2023-05-08 10:02:00 * Open: 8.772 * High: 8.7749 * Low: 8.77 * Close: 8.7748 * ---- */
REQUEST PARAMETERS
\Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\MarkPriceKlineRequest::class $options = (new MarkPriceKlineRequest()) ->setSymbol("BTCUSDT") // Required parameter. Line with the ticker of the trading pair. ->setInterval(1) // Required parameter. Teak size. Possible values: 1 3 5 15 30 60 120 240 360 720 D M W ->setStartTime((new DateTime("2023-05-10 10:00:00"))->getTimestamp()) // Required parameter. Timestamp from which the data slice is taken ->setEndTime((new DateTime("2023-05-10 11:00:00"))->getTimestamp()) // Required parameter. Timestamp BEFORE which the data slice is taken ->setLimit(200) // Optional parameter. Limit the records returned per query. Default 200
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\Interfaces\IMarkPriceKline::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\Request\MarkPriceKlineRequest::class |
||
Method | Required | Description |
---|---|---|
IMarkPriceKline::setSymbol(string $symbol): self | YES | Trading pair |
IMarkPriceKline::setInterval(int $interval): self | YES |
Tick size. Possible values: 1 3 5 15 30 60 120 240 360 720 D M W |
IMarkPriceKline::setStartTime(int $timestamp): self | YES | Timestamp string from which the data slice is taken |
IMarkPriceKline::setEndTime(int $timestamp): self | YES | Timestamp BEFORE which the data slice is taken |
IMarkPriceKline::setLimit(int $limit): self | NO | Limit the records returned per query. Default: 200 |
RESPONSE STRUCTURE
Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\Interfaces\IMarkPriceKline::class interface IMarkPriceKline { public function getStartTime(): \DateTime; // Tick start time public function getOpen(): float; // Opening price public function getHigh(): float; // Maximum price public function getLow(): float; // Minimum price public function getClose(): float; // Close price public function getVolume(): float; // Volume }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\Interfaces\IMarkPriceKline::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\MarkPriceKline\Request\MarkPriceKlineRequest::class |
||
Method | Type | Description |
---|---|---|
IMarkPriceKline::getStartTime() | DateTime | Tick start time |
IMarkPriceKline::getOpen() | float | Opening price |
IMarkPriceKline::getHigh() | float | Maximum price |
IMarkPriceKline::getLow() | float | Minimum price |
IMarkPriceKline::getClose() | float | Close price |
IMarkPriceKline::getVolume() | float | Volume |
Market Data - Open Interest
Endpoint returns data about open interest for the specified symbol.
Open Interest is the total number of perpetual contract positions currently held on the platform.
// Endpoint classname \Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\OpenInterest::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\OpenInterest; use Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Response\OpenInterestResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Request\OpenInterestRequest; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new OpenInterestRequest())->setSymbol("ETHUSDT")->setInterval("1h")->setLimit(5); /** @var OpenInterestResponse[] $result */ $result = $bybit->rest(OpenInterest::class, $options)->getBody()->all(); foreach ($result as $interestItem) { echo "Funding Rate: {$interestItem->getOpenInterest()}" . PHP_EOL; echo "Funding Rate Timestamp: {$interestItem->getTimestamp()->format("Y-m-d H:i:s")}" . PHP_EOL; echo "-----" . PHP_EOL; } /** * Result: * * Funding Rate: 1128313.46000000 * Funding Rate Timestamp: 2023-05-09 11:00:00 * ----- * Funding Rate: 1127687.94000000 * Funding Rate Timestamp: 2023-05-09 10:00:00 * ----- * Funding Rate: 1127713.76000000 * Funding Rate Timestamp: 2023-05-09 09:00:00 * ----- * Funding Rate: 1127747.17000000 * Funding Rate Timestamp: 2023-05-09 08:00:00 * ----- * Funding Rate: 1127889.81000000 * Funding Rate Timestamp: 2023-05-09 07:00:00 * ----- */
REQUEST PARAMETERS
\Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Request\OpenInterestRequest::class $options = (new OpenInterestRequest()) ->setSymbol("ETHUSDT") // Trading pair ->setInterval("1h") // Tick size. Possible values: 1h 3h 5h 15h 30h 60h 120h 240h 360h 720h D M W ->setStartTime((new DateTime('2023-05-01 10:00:00'))->getTimestamp()) // Timestamp FROM which the data slice is taken ->setEndTime((new DateTime('2023-05-01 20:00:00'))->getTimestamp()) // Timestamp BEFORE which the data slice is taken ->setLimit(5); // Limit the records returned per query. Default 200
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Interfaces\IOpenInterestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Request\OpenInterestRequest::class |
||
Method | Required | Description |
---|---|---|
IOpenInterestInterface::setSymbol(string $symbol): self | YES | Trding pair |
IOpenInterestInterface::setInterval(int $interval): self | YES |
Tick size. Possible values: 1h 3h 5h 15h 30h 60h 120h 240h 360h 720h D M W |
IOpenInterestInterface::setStartTime(int $startTime): self | Yes | Timestamp FROM which the data slice is taken |
IOpenInterestInterface::setEndTime(string $end): self | YES | Timestamp BEFORE which the data slice is taken |
IOpenInterestInterface::setLimit(int $limit): self | NO | Limit the records returned per query. Default 200 |
RESPONSE STRUCTURE
\Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Interfaces\IOpenInterestResponse::class interface IOpenInterestResponse { public function getTimestamp(): \DateTime; // Request execution time public function getOpenInterest(): float; // Volume of interest }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Interfaces\IOpenInterestResponse::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\OpenInterest\Response\OpenInterestResponse::class |
||
Method | Type | Description |
---|---|---|
:: getTimestamp() | DateTime | Request execution time |
:: getOpenInterest() | float | Volume of interest |
Market Data - Order Book
Endpoint returns a list of orders to buy and sell perpetual contracts, organized and sorted by price level.
// Endpoint classname \Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\OrderBook::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\OrderBook; use Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Request\OrderBookRequest; use Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Response\OrderBookResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Response\OrderBookPriceResponse; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new OrderBookRequest())->setSymbol('APTUSDT')->setLimit(5); /** @var OrderBookResponse $result */ $result = $bybit->rest(OrderBook::class, $options)->getBody()->fetch(); echo "Update ID: " . $result->getUpdateId() . PHP_EOL; echo "Symbol: " . $result->getSymbol() . PHP_EOL; echo "Timestamp: " . $result->getTimestamp()->format("Y-m-d H:i:s") . PHP_EOL; echo "BIDs:" . PHP_EOL; /** @var OrderBookPriceResponse $bid */ foreach ($result->getBid()->all() as $bid) { echo " - Price: {$bid->getPrice()} Quantity: {$bid->getQuantity()}" . PHP_EOL; } echo "ASKs:" . PHP_EOL; /** @var OrderBookPriceResponse $ask */ foreach ($result->getAsk()->all() as $ask) { echo " - Price: {$ask->getPrice()} Quantity: {$ask->getQuantity()}" . PHP_EOL; } /** * Result: * * Update ID: 574349 * Symbol: APTUSDT * Timestamp: 2023-05-08 22:43:21 * BIDs: * - Price: 8.245 Quantity: 10700.04 * - Price: 8.2445 Quantity: 21984.53 * - Price: 8.244 Quantity: 7351.59 * - Price: 8.2435 Quantity: 20129.92 * - Price: 8.243 Quantity: 10495.79 * ASKs: * - Price: 8.2455 Quantity: 20948.03 * - Price: 8.246 Quantity: 12376.44 * - Price: 8.2465 Quantity: 13590.33 * - Price: 8.247 Quantity: 12282.39 * - Price: 8.2475 Quantity: 4626.09 */
REQUEST PARAMETERS
\Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Request\OrderBookRequest::class $options = (new OrderBookRequest()) ->setSymbol("ETHUSDT") // Trading pair ->setLimit(25); // Limit on the number of orders in one direction: limit = 50 (25 - bid + 25 - ask)
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Interfaces\IOrderBookRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Request\OrderBookRequest::class |
||
Method | Required | Description |
---|---|---|
IOrderBookResponse::setSymbol(string $symbol): self | YES | Trading pair |
IOrderBookResponse::setLimit(int $limit): self | NO | Limit on the number of orders in one direction: limit = 50 (25 - bid + 25 - ask) |
RESPONSE STRUCTURE
\Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Interfaces\IOrderBookResponse::class interface IOrderBookResponse { public function getSymbol(): string; // Trading pair public function getTimestamp(): \DateTime; // Execution time public function getUpdateId(): int; // update ID public function getBid(): ICollectionInterface; // IOrderBookPriceResponse[] public function getAsk(): ICollectionInterface; // IOrderBookPriceResponse[] }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Interfaces\IOrderBookResponse::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Response\OrderBookResponse::class |
||
Method | Type | Description |
---|---|---|
IOrderBookResponse::getSymbol() | float | Trading pair |
IOrderBookResponse::getTimestamp() | DateTime | Execution time |
IOrderBookResponse::getUpdateId() | float | update ID |
IOrderBookResponse::getBid() | IOrderBookPriceResponse[] | List of sell orders |
IOrderBookResponse::getAsk() | IOrderBookPriceResponse[] | List of buy orders |
\Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Interfaces\IOrderBookPriceResponse::class interface IOrderBookPriceResponse { public function getPrice(): float; public function getQuantity(): float; }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Interfaces\IOrderBookPriceItemResponse::class | ||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\OrderBook\Interfaces\OrderBookPriceItemResponse::class | ||
Method | Type | Description |
---|---|---|
IOrderBookPriceItemResponse::getPrice() | float | Price |
IOrderBookPriceItemResponse::getQuantity() | float | Volume |
Market Data - Public Trading History
Endpoint returns data on the execution of trading orders
// Endpoint classname Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\PublicTradingHistory::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\PublicTradingHistory; use Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\Response\PublicTradingHistoryResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\Request\PublicTradingHistoryRequest; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new PublicTradingHistoryRequest())->setSymbol("BTCUSDT")->setLimit(3); /** @var PublicTradingHistoryResponse[] $result */ $result = $bybit->rest(PublicTradingHistory::class, $options)->getBody()->all(); foreach ($result as $historyItem) { echo "Exec ID: {$historyItem->getExecId()}" . PHP_EOL; echo "Symbol: {$historyItem->getSymbol()}" . PHP_EOL; echo "Price: {$historyItem->getPrice()}" . PHP_EOL; echo "Size: {$historyItem->getSize()}". PHP_EOL; echo "Side: {$historyItem->getSize()}" . PHP_EOL; echo "Time: {$historyItem->getTime()->format("Y-m-d H:i:s")}" . PHP_EOL; echo "Is Block Trade: {$historyItem->isBlockTrade()}" . PHP_EOL; echo "-----" . PHP_EOL; } /** * Result: * * Exec ID: d275d237-12fb-50ce-b019-14cfa19ec649 * Symbol: BTCUSDT * Price: 27737.8 * Size: 0.003 * Side: Sell * Time: 2023-05-09 10:58:26 * Is Block Trade: * ----- * Exec ID: 9a116105-7cf3-5090-8abd-54f5b423f9df * Symbol: BTCUSDT * Price: 27737.8 * Size: 0.002 * Side: Sell * Time: 2023-05-09 10:58:26 * Is Block Trade: * ----- * Exec ID: c71ccbab-d948-5b69-98b4-29e51a230662 * Symbol: BTCUSDT * Price: 27745.6 * Size: 0.001 * Side: Buy * Time: 2023-05-09 10:58:25 * Is Block Trade: * ----- */
REQUEST PARAMETERS
\Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\Request\PublicTradingHistoryRequest::class $options = (new PublicTradingHistoryRequest()) ->setSymbol("ETHUSDT") // Trading pair ->setLimit(25); // Quantity limit per result set
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\Interfaces\IPublicTradingHistoryRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\Request\PublicTradingHistoryRequest::class |
||
Method | Required | Description |
---|---|---|
IPublicTradingHistoryRequestInterface::setSymbol(string $symbol): self | YES | Trading pair |
IPublicTradingHistoryRequestInterface::setLimit(int $limit): self | NO | Quantity limit per result set |
RESPONSE STRUCTURE
\Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\Interfaces\IPublicTradingHistoryResponse::class; interface IPublicTradingHistoryResponse { public function getExecId(): string; // Execution ID public function getSymbol(): string; // Trading pair public function getPrice(): float; // Execution price public function getSize(): float; // Execution volume public function getSide(): string; // Direction (buy, sell) public function getTime(): \DateTime; // Execution time public function isBlockTrade(): bool; // is OTC trade }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\Interfaces\IPublicTradingHistoryResponse::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\PublicTradingHistory\Response\PublicTradingHistoryResponse::class |
||
Method | Тype | Description |
---|---|---|
IPublicTradingHistoryResponse::getExecId() | string | Execution ID |
IPublicTradingHistoryResponse::getSymbol() | string | Trading pair |
IPublicTradingHistoryResponse::getPrice() | float | Execution price |
IPublicTradingHistoryResponse::getSize() | float | Execution volume |
IPublicTradingHistoryResponse::getSide() | string | Direction (buy, sell) |
IPublicTradingHistoryResponse::getTime() | DateTime | Execution time |
IPublicTradingHistoryResponse::isBlockTrade() | bool | - |
Market Data - Risk Limit
Endpoint returns data on the risk limit for the specified symbol.
Risk limit is a risk management measure to limit traders' exposure to risk.
// Endpoint classname \Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\RiskLimit::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\RiskLimit; use Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Request\RiskLimitsRequest; use Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Response\RiskLimitsResponse; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new RiskLimitsRequest())->setSymbol("BTCUSDT"); /** @var RiskLimitsResponse[] $result */ $result = $bybit->rest(RiskLimit::class, $options)->getBody()->all(); foreach ($result as $riskItem) { echo "Risk ID: {$riskItem->getId()}" . PHP_EOL; echo "Symbol: {$riskItem->getSymbol()}" . PHP_EOL; echo "Limit: {$riskItem->getLimit()}" . PHP_EOL; echo "Maintain Margin: {$riskItem->getMaintainMargin()}". PHP_EOL; echo "Initial Margin: {$riskItem->getInitialMargin()}" . PHP_EOL; echo "isLowerRisk: {$riskItem->getIsLowerRisk()}" . PHP_EOL; echo "maxLeverage: {$riskItem->getMaxLeverage()}" . PHP_EOL; echo "-----" . PHP_EOL; } /** * Result: * * Risk ID: 1 * Symbol: BTCUSDT * Limit: 2000000 * Maintain Margin: 0.005 * Initial Margin: 0.01 * isLowerRisk: 0 * maxLeverage: 100 * ----- * Risk ID: 2 * Symbol: BTCUSDT * Limit: 4000000 * Maintain Margin: 0.01 * Initial Margin: 0.0175 * isLowerRisk: 0 * maxLeverage: 57.14 * ----- * Risk ID: 3 * Symbol: BTCUSDT * Limit: 6000000 * Maintain Margin: 0.015 * Initial Margin: 0.025 * isLowerRisk: 0 * maxLeverage: 40 * ----- * ... */
REQUEST PARAMETERS
\Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Request\RiskLimitsRequest::class $options = (new RiskLimitsRequest()) ->setSymbol("BTCUSDT"); // Trading pair
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Interfaces\IRiskLimitsRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Request\RiskLimitsRequest::class |
||
Method | Required | Description |
---|---|---|
IRiskLimitsRequestInterface::setSymbol(string $symbol): self | YES | Trading pair |
RESPONSE STRUCTURE
\Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Interfaces\IRiskLimitsResponse::class; interface IRiskLimitsResponse { public function getId(): string; // Risk ID public function getSymbol(): string; // Trading pair public function getLimit(): int; // Position limit public function getMaintainMargin(): float; // Margin maintenance public function getInitialMargin(): float; // Initial margin public function getIsLowerRisk(): int; // Is the trading instrument low risk? public function getMaxLeverage(): float; // Maximum leverage }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Interfaces\IRiskLimitsResponse:class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\RiskLimit\Response\RiskLimitsResponse::class |
||
Method | Type | Description |
---|---|---|
IRiskLimitsResponse::getId() | string | Risk ID |
IRiskLimitsResponse::getSymbol() | string | Trading pair |
IRiskLimitsResponse::getLimit() | int | Position limit |
IRiskLimitsResponse::getMaintainMargin() | float | Margin maintenance |
IRiskLimitsResponse::getInitialMargin() | float | Initial margin |
IRiskLimitsResponse::getIsLowerRisk() | int | Is the trading instrument low risk? |
IRiskLimitsResponse::getMaxLeverage() | float | Maximum leverage |
Market Data - Ticker Info
Endpoint returns symbol data (last price snapshot, best bid/ask price and trading volume) for the last 24 hours.
// Endpoint classname Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Request\TickerInfo::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Request\TickerInfoRequest; use Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Response\TickerInfoResponse; use Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\TickerInfo; $bybit = new BybitAPI("https://api-testnet.bybit.com", "apiKey", "secret"); $options = (new TickerInfoRequest()) ->setSymbol("APTUSDT"); $tickerInfo = $bybit->rest(TickerInfo::class, $options)->getBody()->fetch(); /** @var TickerInfoResponse $tickerInfo */ echo "Symbol: {$tickerInfo->getSymbol()}" . PHP_EOL; echo "Bid Price: {$tickerInfo->getBidPrice()}" . PHP_EOL; echo "Ask Price: {$tickerInfo->getAskPrice()}" . PHP_EOL; echo "Last Price: {$tickerInfo->getLastPrice()}" . PHP_EOL; echo "Last Tick Direction: {$tickerInfo->getLastTickDirection()}" . PHP_EOL; echo "Prev Price 24 hours: {$tickerInfo->getPrevPrice24h()}" . PHP_EOL; echo "Prev Price 24 hours(%): {$tickerInfo->getPrice24hPcnt()}" . PHP_EOL; echo "High Price 24 hours: {$tickerInfo->getHighPrice24h()}" . PHP_EOL; echo "Low Price 24 hours: {$tickerInfo->getLowPrice24h()}" . PHP_EOL; echo "Prev price 1 hour: {$tickerInfo->getPrevPrice1h()}" . PHP_EOL; echo "Mark Price: {$tickerInfo->getMarkPrice()}" . PHP_EOL; echo "Index Price: {$tickerInfo->getIndexPrice()}" . PHP_EOL; echo "Open Interest: {$tickerInfo->getOpenInterests()}" . PHP_EOL; echo "Open Interest Value: {$tickerInfo->getOpenInterestValue()}" . PHP_EOL; echo "Turnover 24 hours: {$tickerInfo->getTurnover24h()}" . PHP_EOL; echo "Volume 24 hours: {$tickerInfo->getVolume24h()}" . PHP_EOL; echo "Funding Rate: {$tickerInfo->getFundingRate()}" . PHP_EOL; echo "Next Funding Time: {$tickerInfo->getNextFundingTime()->format("Y-m-d H:i:s")}" . PHP_EOL; echo "Predicted Delivery Price: {$tickerInfo->getPredictedDeliveryPrice()}" . PHP_EOL; echo "Basis Rate: {$tickerInfo->getBasisRate()}" . PHP_EOL; echo "Delivery Fee Rate: {$tickerInfo->getDeliveryFeeRate()}" . PHP_EOL; echo "Delivery Time: {$tickerInfo->getDeliveryTime()->format("Y-m-d H:i:s")}" . PHP_EOL; /** * Result: * * Symbol: APTUSDT * Bid Price: 8.285 * Ask Price: 8.2855 * Last Price: 8.2855 * Last Tick Direction: ZeroMinusTick * Prev Price 24 hours: 8.667 * Prev Price 24 hours(%): -0.044017 * High Price 24 hours: 8.667 * Low Price 24 hours: 7.505 * Prev price 1 hour: 8.254 * Mark Price: 8.2872 * Index Price: 8.2919 * Open Interest: 403884.9 * Open Interest Value: 3347074.94 * Turnover 24 hours: 12624160.9399 * Volume 24 hours: 1535221.53 * Funding Rate: 2.8E-5 * Next Funding Time: 2023-05-10 00:00:00 * Predicted Delivery Price: 0 * Basis Rate: 0 * Delivery Fee Rate: 0 * Delivery Time: 1970-01-01 00:00:00 */
REQUEST PARAMETERS
\Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Request\TickerInfoRequest::class $options = (new TickerInfoRequest()) ->setSymbol("APTUSDT"); // Trading pair
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Interfaces\ITickerInfoRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Request\TickerInfoRequest::class |
||
Method | Required | Description |
---|---|---|
ITickerInfoRequestInterface::setSymbol(string $symbol): self | YES | Trading pair |
RESPONSE STRUCTURE
\Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Interfaces\ITickerInfoResponse::class; interface ITickerInfoResponse { public function getSymbol(): string; // Trading pair public function getBidPrice(): float; // Best selling price public function getAskPrice(): float; // Best purchase price public function getLastPrice(): float; // Last transaction price public function getLastTickDirection(): string; // Direction of last price change public function getPrevPrice24h(): float; // Price 24 hours ago public function getPrice24hPcnt(): float; // Price change over the last 24 hours as a percentage public function getHighPrice24h(): float; // Maximum price for 24 hours public function getLowPrice24h(): float; // Minimum price for 24 hours public function getPrevPrice1h(): float; // Hourly market price an hour ago public function getMarkPrice(): float; // Marking price (liquidation occurs according to this indicator) public function getIndexPrice(): float; // Index price public function getOpenInterests(): float; // Open interest volume for a trading pair public function getTurnover24h(): float; // Turnover in 24 hours public function getVolume24h(): float; // Cumulative volume for 24 hours public function getFundingRate(): float; // Funding rate public function getNextFundingTime(): \DateTime; // Time of next funding rate debit }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Interfaces\ITickerInfoResponse::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\MarketData\TickerInfo\Response\TickerInfoResponse::class |
||
Method | Type | Description |
---|---|---|
ITickerInfoResponse::getSymbol() | string | Trading pair |
ITickerInfoResponse::getBidPrice() | float | Best selling price |
ITickerInfoResponse::getAskPrice() | float | Best purchase price |
ITickerInfoResponse::getLastPrice() | float | Last transaction price |
ITickerInfoResponse::getLastTickDirection() | string | Direction of last price change |
ITickerInfoResponse::getPrevPrice24h() | float | Price 24 hours ago |
ITickerInfoResponse::getPrice24hPcnt() | float | Price change over the last 24 hours as a percentage |
ITickerInfoResponse::getHighPrice24h() | float | Maximum price for 24 hours |
ITickerInfoResponse::getLowPrice24h() | float | Minimum price for 24 hours |
ITickerInfoResponse::getPrevPrice1h() | float | Hourly market price an hour ago |
ITickerInfoResponse::getMarkPrice() | float | Marking price (liquidation occurs according to this indicator) |
ITickerInfoResponse::getIndexPrice() | float | Index price |
ITickerInfoResponse::getOpenInterests() | float | Open interest volume for a trading pair |
ITickerInfoResponse::getTurnover24h() | float | Turnover in 24 hours |
ITickerInfoResponse::getVolume24h() | float | Cumulative volume for 24 hours |
ITickerInfoResponse::getFundingRate() | float | Funding rate |
ITickerInfoResponse::getNextFundingTime() | DateTime | Time of next funding rate debit |
Contract - Account - Get Trading Fee Rate
Endpoint returns data on the trading commission rate for ALL symbols
// Endpoint classname Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\GetTradingFeeRate::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\GetTradingFeeRate; use Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\Request\GetTradingFeeRateRequest; use Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\Response\GetTradingFeeRateResponse; $bybit = new BybitAPI('https://api-testnet.bybit.com',"apiKey", "secret"); $feeRateData = $bybit->rest(GetTradingFeeRate::class, (new GetTradingFeeRateRequest()))->getBody()->all(); $feeRateData = array_slice($feeRateData, 0, 3); /** @var GetTradingFeeRateResponse $feeRate */ foreach ($feeRateData as $feeRate) { echo "Symbol: {$feeRate->getSymbol()}" . PHP_EOL; echo "Taker Fee Rate: {$feeRate->getTakerFeeRate()}" . PHP_EOL; echo "Maker Fee Rate: {$feeRate->getMakerFeeRate()}" . PHP_EOL; echo "---" . PHP_EOL; } /** * Result: * * Symbol: CTKUSDT * Taker Fee Rate: 0.0006 * Maker Fee Rate: 0.0001 * --- * Symbol: FILUSDT * Taker Fee Rate: 0.0006 * Maker Fee Rate: 0.0001 * --- * Symbol: BLURUSDT * Taker Fee Rate: 0.0006 * Maker Fee Rate: 0.0001 * --- */
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\Interfaces\IGetTradingFeeRateRequestInterface; interface IGetTradingFeeRateRequestInterface { public function setSymbol(string $symbol): self; // Trading pair }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\Interfaces\IGetTradingFeeRateRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\Request\GetTradingFeeRateRequest::class |
||
Method | Required | Description |
---|---|---|
IGetTradingFeeRateRequestInterface::setSymbol(string $symbol): self | NO | Trading pair |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\Interfaces\IGetTradingFeeRateResponseInterface; interface IGetTradingFeeRateResponseInterface { public function getSymbol(): string; // Trading pair public function getTakerFeeRate(): float; // Taker (buyer) commission public function getMakerFeeRate(): float; // Maker (seller) commission }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\Interfaces\IGetTradingFeeRateResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Account\GetTradingFeeRate\Response\GetTradingFeeRateResponse::class |
||
Method | Type | Description |
---|---|---|
IGetTradingFeeRateResponseInterface::getSymbol() | string | Trading pair |
IGetTradingFeeRateResponseInterface::getTakerFeeRate() | float | Taker (buyer) commission |
IGetTradingFeeRateResponseInterface::getMakerFeeRate() | float | Maker (seller) commission |
Contract - Account - Wallet Balance
Официальная страница документации
Endpoint returns the derivatives wallet balance, information about assets in each currency, and information about the risk level of the account.
By default, currency information with assets or liabilities equal to 0 is not returned.
// Endpoint classname \Carpenstar\ByBitAPI\Derivatives\Contract\Account\WalletBalance\WalletBalance::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\Contract\Account\WalletBalance\WalletBalance; use Carpenstar\ByBitAPI\Derivatives\Contract\Account\WalletBalance\Request\WalletBalanceRequest; use Carpenstar\ByBitAPI\Derivatives\Contract\Account\WalletBalance\Response\WalletBalanceResponse; $bybit = new BybitAPI('https://api-testnet.bybit.com',"apiKey", "secret"); $walletBalance = $bybit->rest(WalletBalance::class, (new WalletBalanceRequest()))->getBody()->all(); $walletBalance = array_slice($walletBalance, 0, 2); /** @var WalletBalanceResponse $feeRate */ foreach ($walletBalance as $feeRate) { echo "Coin: {$feeRate->getCoin()}" . PHP_EOL; echo "Equity: {$feeRate->getEquity()}" . PHP_EOL; echo "Wallet Balance: {$feeRate->getWalletBalance()}" . PHP_EOL; echo "Position Margin: {$feeRate->getPositionMargin()}" . PHP_EOL; echo "Available Balance: {$feeRate->getAvailableBalance()}" . PHP_EOL; echo "Order Margin: {$feeRate->getOrderMargin()}" . PHP_EOL; echo "Occ Closing Fee: {$feeRate->getOccClosingFee()}" . PHP_EOL; echo "Occ Funding Fee: {$feeRate->getOccFundingFee()}" . PHP_EOL; echo "Unrealised PnL: {$feeRate->getUnrealisedPnl()}" . PHP_EOL; echo "Cumulative Realised PnL: {$feeRate->getCumRealisedPnl()}" . PHP_EOL; echo "Given Cash: {$feeRate->getGivenCash()}" . PHP_EOL; echo "Service Cash: {$feeRate->getServiceCash()}" . PHP_EOL; echo "Account IM: {$feeRate->getAccountIM()}" . PHP_EOL; echo "Account MM: {$feeRate->getAccountMM()}" . PHP_EOL; echo "-----" . PHP_EOL; } /** * Result: * * Coin: BTC * Equity: 0.2 * Wallet Balance: 0.2 * Position Margin: 0 * Available Balance: 0.2 * Order Margin: 0 * Occ Closing Fee: 0 * Occ Funding Fee: 0 * Unrealised PnL: 0 * Cumulative Realised PnL: 0 * Given Cash: 0 * Service Cash: 0 * Account IM: * Account MM: * ----- * Coin: ETH * Equity: 0 * Wallet Balance: 0 * Position Margin: 0 * Available Balance: 0 * Order Margin: 0 * Occ Closing Fee: 0 * Occ Funding Fee: 0 * Unrealised PnL: 0 * Cumulative Realised PnL: 0 * Given Cash: 0 * Service Cash: 0 * Account IM * Account MM * ----- */
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Account\WalletBalance\Interfaces\IWalletBalanceResponseInterface; interface IWalletBalanceResponseInterface { public function getCoin(): string; // Coin public function getEquity(): float; // Total capital public function getWalletBalance(): float; // Wallet balance public function getPositionMargin(): float; // Position Margin public function getAvailableBalance(): float; // Available balance public function getOrderMargin(): float; // Pre-occupied margin public function getOccClosingFee(): float; // The fee for closing a position has been charged. public function getOccFundingFee(): float; // Pre-financing fee public function getUnrealisedPnl(): float; // Unrealized PnL public function getCumRealisedPnl(): float; // Cumulative realized PnL (all time) public function getGivenCash(): float; public function getServiceCash(): float; public function getAccountIM(): string; // USDC Account Initial Margin public function getAccountMM(): string; // USDC Account Maintenance Margin }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Account\WalletBalance\Interfaces\IWalletBalanceResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Account\WalletBalance\Response\WalletBalanceResponse::class |
||
Method | Type | Description |
---|---|---|
IWalletBalanceResponseInterface::getCoin() | string | Coin |
IWalletBalanceResponseInterface::getEquity() | float | Total capital |
IWalletBalanceResponseInterface::getWalletBalance() | float | Wallet balance |
IWalletBalanceResponseInterface::getPositionMargin() | float | Position Margin |
IWalletBalanceResponseInterface::getAvailableBalance() | float | Available balance |
IWalletBalanceResponseInterface::getOrderMargin() | float | Pre-occupied margin |
IWalletBalanceResponseInterface::getOccClosingFee() | float |
The fee for closing a position has been charged. Formula: opening fee + expected maximum closing fee |
IWalletBalanceResponseInterface::getOccFundingFee() | float | Pre-financing fee |
IWalletBalanceResponseInterface::getUnrealisedPnl() | float | Unrealized PnL |
IWalletBalanceResponseInterface::getCumRealisedPnl() | float | Cumulative realized PnL (all time) |
IWalletBalanceResponseInterface::getGivenCash() | float | - |
IWalletBalanceResponseInterface::getServiceCash() | float | - |
IWalletBalanceResponseInterface::getAccountIM() | string | USDC Account Initial Margin |
IWalletBalanceResponseInterface::getAccountMM() | string | USDC Account Maintenance Margin |
Contract - Account - Order - Place Order
// Endpoint classname \Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\PlaceOrder::class
EXAMPLE
use Carpenstar\ByBitAPI\BybitAPI; use Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\PlaceOrder; use Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Request\PlaceOrderRequestRequest; use Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Response\PlaceOrderResponse; $bybit = new BybitAPI('https://api-testnet.bybit.com',"apiKey", "apiSecret"); $order = $bybit->rest(PlaceOrder::class, (new PlaceOrderRequestRequest()) ->setSymbol("LTCUSDT") ->setSide("Buy") ->setOrderType("Market") ->setQty(1) ->setTimeInForce("GoodTillCancel") ->setOrderLinkId(uniqid()) )->getBody()->fetch(); /** @var PlaceOrderResponse $order */ echo "Order ID: " . $order->getOrderId() . PHP_EOL; echo "Order Link ID: " . $order->getOrderLinkId() . PHP_EOL; /** * Result: * * Order ID: b75cea8a-6373-4fbb-b82f-ab36e56dbe85 * Order Link ID: 64728f00c100d */
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Interfaces\IPlaceOrderRequestInterface; interface IPlaceOrderRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setSide(string $side): self; // Enum: 'Buy' or 'Sell' public function setOrderType(string $orderType): self; // Enum: 'Market' or 'Limit' public function setQty(float $quantity): self; // Quantity public function setTimeInForce(string $timeInForce): self; // Order execution mode. For possible values see official documentation public function setPrice(float $price): self; // Limit order price. Leave empty if orderType = Market public function setTriggerDirection(int $triggerDirection): self; // Conditional order parameter. Used to determine the expected direction of a conditional order. public function setTriggerPrice(string $triggerPrice): self; // Conditional order parameter. public function setTriggerBy(string $triggerBy): self; // Trigger price type. Default: LastPrice. public function setPositionIdx(int $positionIdx): self; // Position index. Required if hedging mode is enabled. public function setOrderLinkId(string $orderLinkId): self; // Custom order ID. Maximum 36 characters. public function setTakeProfit(float $takeProfit): self; // Take profit price public function setStopLoss(float $stopLoss): self; // Stop loss price public function setTpTriggerBy(string $tpTriggerBy): self; // The type of price at which the take profit is activated. Default: LastPrice public function setSlTriggerBy(string $slTriggerBy): self; // The type of price at which the stop loss is activated. Default: LastPrice public function setReduceOnly(bool $reduceOnly): self; // true - means that your position can only decrease in size if this order is triggered public function setSmpType(string $smpType): self; // Execution type SMP. public function setCloseOnTrigger(bool $closeOnTrigger): self; // Parameter for closing an order. public function setTpslMode(string $tpslMode): self; // TP/SL mode public function setTpLimitPrice(string $tpLimitPrice): self; // The limit order price when the take profit price is triggered. Only works when tpslMode=Partial or tpOrderType=Limit. public function setSlLimitPrice(string $slLimitPrice): self; // Limit order price when stop loss is triggered. Only works when tpslMode=Partial and slOrderType=Limit. public function setTpOrderType(string $tpOrderType): self; // The type of order that triggers the take profit. public function setSlOrderType(string $slOrderType): self; // The type of order that triggers the stop loss. // ... Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Interfaces\IPlaceOrderRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Request\PlaceOrderRequest::class |
||
Method | Required | Description |
---|---|---|
IPlaceOrderRequestInterface::setSymbol(string $symbol) | YES | Trading pair |
IPlaceOrderRequestInterface::setSide(string $side) | YES | Enum: 'Buy' or 'Sell' |
IPlaceOrderRequestInterface::setOrderType(string $orderType) | YES | Enum: 'Market' or 'Limit' |
IPlaceOrderRequestInterface::setQty(float $quantity) | YES | Quantity |
IPlaceOrderRequestInterface::setTimeInForce(string $timeInForce) | YES | Order execution mode. For possible values see official documentation |
IPlaceOrderRequestInterface::setPrice(float $price) | NO | Limit order price. Leave empty if orderType = Market |
IPlaceOrderRequestInterface::setTriggerDirection(int $triggerDirection) | NO |
Conditional order parameter. Used to determine the expected direction of a conditional order. 1: Triggered when the market price rises to the trigger price. 2: Triggered when the market price falls to the trigger price |
IPlaceOrderRequestInterface::setTriggerPrice(string $triggerPrice) | NO |
Conditional order parameter. If you expect the price to rise and trigger your conditional order, make sure that: triggerPrice > markPrice Otherwise, triggerPrice < markPrice |
IPlaceOrderRequestInterface::setTriggerBy(string $triggerBy) | NO |
Trigger price type. Default: LastPrice. Possible values: - LastPrice - MarkPrice - IndexPrice |
IPlaceOrderRequestInterface::setPositionIdx(int $positionIdx) | NO |
Position index. Required if hedging mode is enabled. Possible values: - 0: Unidirectional mode (default) - 1: Long - 2: Short |
IPlaceOrderRequestInterface::setOrderLinkId(string $orderLinkId) | NO |
Custom order ID. Maximum 36 characters. Combinations of numbers, letters (uppercase and lowercase), dashes and underscores are supported. The OrderLinkId can be reused after the original order is filled or cancelled. |
IPlaceOrderRequestInterface::setTakeProfit(float $takeProfit) | NO | Take profit price |
IPlaceOrderRequestInterface::setStopLoss(float $stopLoss) | NO | Stop loss price |
IPlaceOrderRequestInterface::setTpTriggerBy(string $tpTriggerBy) | NO |
The type of price at which the take profit is activated. Default: LastPrice Possible values: - LastPrice - MarkPrice - IndexPrice |
IPlaceOrderRequestInterface::setSlTriggerBy(string $slTriggerBy) | NO |
The type of price at which the stop loss is activated. Default: LastPrice Possible values: - LastPrice - MarkPrice - IndexPrice |
IPlaceOrderRequestInterface::setReduceOnly(bool $reduceOnly) | NO |
Description of the parameter in the official documentation true means that your position can only decrease in size if this order is triggered. If "reduce_only" is true, then take profit/stop loss cannot be set. |
IPlaceOrderRequestInterface::setSmpType(string $smpType) | NO |
Description of the parameter in the official documentation Execution type SMP. |
IPlaceOrderRequestInterface::setCloseOnTrigger(bool $closeOnTrigger) | NO |
What is closing with a trigger order? Parameter for closing an order. This can only reduce your position, but not increase it. If there is not enough available balance in the account when the close order is triggered, then other active orders of similar contracts will be canceled or reduced. It can be used to ensure that your stop loss reduces your position regardless of your current available margin. |
IPlaceOrderRequestInterface::setTpslMode(string $tpslMode) | NO |
TP/SL mode - Full: entire position by TP/SL. Then tpOrderType or slOrderType should be Market. - Partial: partial execution of tp/sl. TP/SL limit orders are supported. Note: When creating a tp/sl constraint, the tpslMode parameter is required. |
IPlaceOrderRequestInterface::setTpLimitPrice(string $tpLimitPrice) | NO |
The limit order price when the take profit price is triggered. Only works when tpslMode=Partial or tpOrderType=Limit. |
IPlaceOrderRequestInterface::setSlLimitPrice(string $slLimitPrice) | NO |
Limit order price when stop loss is triggered. Only works when tpslMode=Partial and slOrderType=Limit. |
IPlaceOrderRequestInterface::setTpOrderType(string $tpOrderType) | NO |
The type of order that triggers the take profit. Possible values: Market (- default) or Limit. For tpslMode=Full only tpOrderType=Market is supported. |
IPlaceOrderRequestInterface::setSlOrderType(string $slOrderType) | NO |
The type of order that triggers the stop loss. Possible values: Market (- default) or Limit. For tpslMode=Full only tpOrderType=Market is supported. |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Interfaces\IPlaceOrderResponseInterface; interface IPlaceOrderResponseInterface { public function getOrderId(): ?string; // Order ID public function getOrderLinkId(): string; // Custom Order ID }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Interfaces\IPlaceOrderResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\PlaceOrder\Response\PlaceOrderResponse::class |
||
Method | Type | Description |
---|---|---|
IPlaceOrderResponseInterface::getOrderId() | string | Order ID |
IPlaceOrderResponseInterface::getOrderLinkId() | string | Custom Order ID |
Contract - Account - Order - Cancel All Order
This endpoint allows you to cancel all open orders.
EXAMPLE
...
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelAllOrder\Interfaces; interface ICancelAllOrderRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setBaseCoin(string $baseCoin): self; // Cancel all open orders for the base coin public function setSettleCoin(string $settleCoin): self; // Cancel all open orders with settlement coin // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelAllOrder\Interfaces\ICancelAllOrderRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelAllOrder\Request\CancelAllOrderRequest::class |
||
Method | Required | Description |
---|---|---|
ICancelAllOrderRequestInterface::setSymbol(string $symbol) | NO | Trading pair |
ICancelAllOrderRequestInterface::setBaseCoin(string $baseCoin) | NO | Cancel all open orders for the base coin |
ICancelAllOrderRequestInterface::setSettleCoin(string $settleCoin) | NO | Cancel all open orders with settlement coin |
RESPONSE STRUCTURE
The result is a numbered array of objects that implement the ICancelAllOrder ResponseInterface interface
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelAllOrder\Interfaces; interface ICancelAllOrderResponseInterface { public function getOrderId(): string; // Order ID public function getOrderLinkId(): string; // Custom Order ID }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelAllOrder\Interfaces\ICancelAllOrderResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelAllOrder\Response\CancelAllOrderResponse::class |
||
Method | Type | Description |
---|---|---|
ICancelAllOrderResponseInterface::getOrderId() | string | Order ID |
ICancelAllOrderResponseInterface::getOrderLinkId() | string | Custom Order ID |
Contract - Account - Order - Cancel Order
This endpoint allows you to cancel the specified open order.
You can cancel the specified partially completed order.
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelOrder\Interfaces; interface ICancelOrderRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setOrderId(string $orderId): self; // Order ID public function setOrderLinkId(string $orderLinkId): self; // Custom order ID // ... Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelOrder\Interfaces\ICancelOrderRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelOrder\Request\CancelOrderRequest::class |
||
Method | Required | Description |
---|---|---|
ICancelOrderRequestInterface::setSymbol(string $symbol) | NO | Trading pair |
ICancelOrderRequestInterface::setOrderId(string $orderId) | NO | Order ID |
ICancelOrderRequestInterface::setOrderLinkId(string $orderLinkId) | NO | Custom order ID |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelOrder\Interfaces; interface ICancelOrderResponseInterface { public function getOrderId(): string; // Order ID public function getOrderLinkId(): string; // Custom Order ID }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelOrder\Interfaces\ICancelOrderResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\CancelOrder\Response\CancelOrderResponse::class |
||
Method | Type | Description |
---|---|---|
ICancelOrderResponseInterface::getOrderId() | string | Order ID |
ICancelOrderResponseInterface::getOrderLinkId() | string | Custom Order ID |
Contract - Account - Order - Get Open Orders
Endpoint returns data on open or partially filled orders in real time.
If neither orderId nor orderLinkId is passed, no more than 500 open or partially filled orders will be returned. Entries are sorted by creation time from newest to oldest.
EXAMPLE
...
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOpenOrders\Interfaces; interface IGetOpenOrdersRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setBaseCoin(string $baseCoin): self; // Base token public function setSettleCoin(string $settleCoin): self; // Settle coin public function setOrderId(string $orderId): self; // Order ID public function setOrderLinkId(string $orderLinkId): self; // Custom order ID public function setOrderFilter(string $orderFilter): self; // Possible values: Order: active order, StopOrder: conditional order public function setCursor(string $cursor): self; // Next page cursor // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOpenOrders\Interfaces\IGetOpenOrdersRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOpenOrders\Request\GetOpenOrdersRequest::class |
||
Method | Required | Description |
---|---|---|
IGetOpenOrdersRequestInterface::setBaseCoin(string $baseCoin) | NO | Base token |
IGetOpenOrdersRequestInterface::setSettleCoin(string $settleCoin) | NO | Settle coin |
IGetOpenOrdersRequestInterface::setOrderId(string $orderId) | NO | Order ID |
IGetOpenOrdersRequestInterface::setOrderLinkId(string $orderLinkId) | NO | Custom order ID |
IGetOpenOrdersRequestInterface::setOrderFilter(string $orderFilter) | NO | Possible values: Order: active order, StopOrder: conditional order |
IGetOpenOrdersRequestInterface::setCursor(string $cursor) | NO | Next page cursor |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOpenOrders\Interfaces; interface IGetOpenOrdersResponseInterface { public function getSymbol(): string; // Trading pair public function getOrderId(): string; // Order ID public function getOrderLinkId(): string; // Custom Order ID public function getSide(): string; // Side. Buy,Sell public function getOrderType(): string; // Order type. Market,Limit. For TP/SL order, it means the order type after triggered public function getPrice(): float; // Order price public function getQty(): float; // Order qty public function getTimeInForce(): string; // Time in force public function getOrderStatus(): string; // Order status public function getLastPriceOnCreated(): string; // Last price when create the order public function getCreatedTime(): \DateTime; // Created timestamp public function getUpdatedTime(): \DateTime; // Updated timestamp public function getCancelType(): string; // Cancel type public function getStopOrderType(): string; // Stop order type public function getTriggerDirection(): int; // 1: rise, 2: fall public function getTriggerBy(): string; // The trigger type of trigger price public function getTriggerPrice(): ?float; // Trigger price public function getCumExecValue(): float; // Cumulative executed position value public function getCumExecFee(): float; // Cumulative trading fee public function getCumExecQty(): float; // Cumulative executed qty public function getLeavesValue(): float; // The remaining value waiting to be traded public function getLeavesQty(): float; // The remaining quantity waiting to be traded public function getTakeProfit(): float; // Take profit price public function getStopLoss(): float; // Stop loss price public function getTpslMode(): string; // TP/SL mode, Full: entire position for TP/SL. Partial: partial position tp/sl public function getTpLimitPrice(): float; // The limit order price when take profit price is triggered public function getSlLimitPrice(): float; // The limit order price when stop loss price is triggered public function getTpTriggerBy(): string; // Trigger type of take profit public function getSlTriggerBy(): string; // The limit order price when stop loss price is triggered public function isReduceOnly(): bool; // Reduce only. true means reduce position size public function isCloseOnTrigger(): bool; // Close on trigger. What is a close on trigger order? public function getSmpType(): string; // SMP execution type public function getSmpGroup(): int; // Smp group ID. If the uid has no group, it is 0 by default public function getSmpOrderId(): string; // The counterparty's orderID which triggers this SMP execution }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOpenOrders\Interfaces\IGetOpenOrdersResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOpenOrders\Request\GetOpenOrdersRequest::class |
||
Method | Type | Description |
---|---|---|
IGetOpenOrdersResponseInterface::getSymbol() | string | Trading pair |
IGetOpenOrdersResponseInterface::getOrderId() | string | Order ID |
IGetOpenOrdersResponseInterface::getOrderLinkId() | string | Custom Order ID |
IGetOpenOrdersResponseInterface::getSide() | string | Side. Buy,Sell |
IGetOpenOrdersResponseInterface::getOrderType() | string | Order type. Market,Limit. For TP/SL order, it means the order type after triggered |
IGetOpenOrdersResponseInterface::getPrice() | float | Order price |
IGetOpenOrdersResponseInterface::getQty() | float | Order qty |
IGetOpenOrdersResponseInterface::getTimeInForce() | string | Time in force |
IGetOpenOrdersResponseInterface::getLastPriceOnCreated() | string | Last price when create the order |
IGetOpenOrdersResponseInterface::getCreatedTime() | DateTime | Created timestamp (ms) |
IGetOpenOrdersResponseInterface::getUpdatedTime() | DateTime | Updated timestamp (ms) |
IGetOpenOrdersResponseInterface::getCancelType() | string | Cancel type |
IGetOpenOrdersResponseInterface::getStopOrderType() | string | Stop order type |
IGetOpenOrdersResponseInterface::getTriggerDirection() | int | 1: rise, 2: fall |
IGetOpenOrdersResponseInterface::getTriggerBy() | string | The trigger type of trigger price |
IGetOpenOrdersResponseInterface::getTriggerPrice() | null|float | Trigger price |
IGetOpenOrdersResponseInterface::getCumExecValue() | float | Cumulative executed position value |
IGetOpenOrdersResponseInterface::getCumExecFee() | float | Cumulative trading fee |
IGetOpenOrdersResponseInterface::getCumExecQty() | float | Cumulative executed qty |
IGetOpenOrdersResponseInterface::getLeavesValue() | float | The remaining value waiting to be traded |
IGetOpenOrdersResponseInterface::getLeavesQty() | float | The remaining quantity waiting to be traded |
IGetOpenOrdersResponseInterface::getTakeProfit() | float | Take profit price |
IGetOpenOrdersResponseInterface::getStopLoss() | float | Stop loss price |
IGetOpenOrdersResponseInterface::getTpslMode() | string | TP/SL mode, Full: entire position for TP/SL. Partial: partial position tp/sl |
IGetOpenOrdersResponseInterface::getSlTriggerBy() | string | The limit order price when stop loss price is triggered |
IGetOpenOrdersResponseInterface::isReduceOnly() | bool | Reduce only. true means reduce position size |
IGetOpenOrdersResponseInterface::isCloseOnTrigger() | string | Close on trigger. What is a close on trigger order? |
IGetOpenOrdersResponseInterface::getSmpType() | string | SMP execution type |
IGetOpenOrdersResponseInterface::getSmpGroup() | string | Smp group ID. If the uid has no group, it is 0 by default |
IGetOpenOrdersResponseInterface::getSmpOrderId() | string | The counterparty's orderID which triggers this SMP execution |
Contract - Account - Order - Get Order List
List of orders
Since order creation/cancellation is asynchronous, the data returned from this endpoint may be delayed.
EXAMPLE
...
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Interfaces; interface IGetOrderListRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setOrderId(string $orderId): self; // Order ID public function setOrderLinkId(string $orderLinkId): self; // Custom order ID public function setOrderStatus(string $orderStatus): self; // Order status. Return all status orders if not passed public function setOrderFilter(string $orderFilter): self; // Possible values: Order: active order, StopOrder: conditional order public function setLimit(int $limit): self; // Limit for data size per page. [1, 50]. Default: 20 public function setCursor(string $cursor): self; // Next page cursor // .. getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Interfaces\IGetOrderListRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Request\GetOrderListRequest::class |
||
Method | Required | Description |
---|---|---|
IGetOrderListRequestInterface::setSymbol(string $symbol) | NO | Trading pair |
IGetOrderListRequestInterface::setOrderId(string $orderId) | NO | order ID |
IGetOrderListRequestInterface::setOrderLinkId(string $orderLinkId) | NO | Custom order ID |
IGetOrderListRequestInterface::setOrderStatus(string $orderStatus) | NO | Order status. Return all status orders if not passed |
IGetOrderListRequestInterface::setOrderFilter(string $orderFilter) | NO | Possible values: Order: active order, StopOrder: conditional order |
IGetOrderListRequestInterface::setLimit(int $limit) | NO | Limit for data size per page. [1, 50]. Default: 20 |
IGetOrderListRequestInterface::setCursor(string $cursor) | NO | Next page cursor |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Interfaces; interface IGetOrderListResponseInterface { public function getSymbol(): string; // Trading pair public function getOrderId(): string; // Order ID public function getOrderLinkId(): string; // Custom Order ID public function getSide(): string; // Buy,Sell public function getOrderType(): string; // Order type. Market,Limit. For TP/SL order, it means the order type after triggered public function getPrice(): float; // Order price public function getQty(): float; // Order quantity public function getTimeInForce(): string; // Time in force public function getOrderStatus(): string; // Order status public function getLastPriceOnCreated(): string; // Last price when place the order public function getCreatedTime(): \DateTime; // Order created timestamp public function getUpdatedTime(): \DateTime; // Order updated timestamp public function getCancelType(): string; // Cancel type public function getStopOrderType(): string; // Stop order type public function getTriggerDirection(): int; // Trigger direction. 1: rise, 2: fall public function getTriggerBy(): string; // The trigger type of trigger price public function getTriggerPrice(): ?float; // Trigger price public function getCumExecValue(): float; // Cumulative executed order value public function getCumExecFee(): float; // Cumulative executed trading fee public function getCumExecQty(): float; // Cumulative executed order qty public function getLeavesValue(): float; // The estimated value not executed public function getLeavesQty(): float; // The remaining qty not executed public function getTakeProfit(): float; // Take profit price public function getStopLoss(): float; // Stop loss price public function getTpslMode(): string; // TP/SL mode, Full: entire position for TP/SL. Partial: partial position tp/sl public function getTpLimitPrice(): float; // The limit order price when take profit price is triggered public function getSlLimitPrice(): float; // The limit order price when stop loss price is triggered public function getTpTriggerBy(): string; // The price type to trigger take profit public function getSlTriggerBy(): string; // The price type to trigger stop loss public function isReduceOnly(): bool; // Reduce only. true means reduce position size public function isCloseOnTrigger(): bool; // Close on trigger public function getSmpType(): string; // SMP execution type public function getSmpGroup(): int; // Smp group ID. If the uid has no group, it is 0 by default public function getSmpOrderId(): string; // The counterparty's orderID which triggers this SMP execution }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Interfaces\IGetOrderListResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\GetOrderList\Response\GetOrderListResponse::class |
||
Method | Type | Description |
---|---|---|
IGetOrderListResponseInterface::getSymbol() | string | Trading pair |
IGetOrderListResponseInterface::getOrderId() | string | Order ID |
IGetOrderListResponseInterface::getOrderLinkId() | string | Custom Order ID |
IGetOrderListResponseInterface::getSide() | string | Buy,Sell |
IGetOrderListResponseInterface::getOrderType() | string | Order type. Market,Limit. For TP/SL order, it means the order type after triggered |
IGetOrderListResponseInterface::getPrice() | float | Order price |
IGetOrderListResponseInterface::getQty() | float | Order quantity |
IGetOrderListResponseInterface::getTimeInForce() | string | Time in force |
IGetOrderListResponseInterface::getLastPriceOnCreated() | string | Last price when place the order |
IGetOrderListResponseInterface::getCreatedTime() | DateTime | Order created timestamp (ms) |
IGetOrderListResponseInterface::getUpdatedTime() | DateTime | Order updated timestamp (ms) |
IGetOrderListResponseInterface::getCancelType() | string | Cancel type |
IGetOrderListResponseInterface::getStopOrderType() | string | Stop order type |
IGetOrderListResponseInterface::getTriggerDirection() | int | Trigger direction. 1: rise, 2: fall |
IGetOrderListResponseInterface::getTriggerBy() | string | The trigger type of trigger price |
IGetOrderListResponseInterface::getTriggerPrice() | null|float | Trigger price |
IGetOrderListResponseInterface::getCumExecValue() | float | Cumulative executed order value |
IGetOrderListResponseInterface::getCumExecFee() | float | Cumulative executed trading fee |
IGetOrderListResponseInterface::getCumExecQty() | float | Cumulative executed order qty |
IGetOrderListResponseInterface::getLeavesValue() | float | The estimated value not executed |
IGetOrderListResponseInterface::getLeavesQty() | float | The remaining qty not executed |
IGetOrderListResponseInterface::getTakeProfit() | float | Take profit price |
IGetOrderListResponseInterface::getStopLoss() | float | Stop loss price |
IGetOrderListResponseInterface::getTpslMode() | string | TP/SL mode, Full: entire position for TP/SL. Partial: partial position tp/sl |
IGetOrderListResponseInterface::getSlTriggerBy() | string | The price type to trigger stop loss |
IGetOrderListResponseInterface::isReduceOnly() | bool | Reduce only. true means reduce position size |
IGetOrderListResponseInterface::isCloseOnTrigger() | string | Close on trigger |
IGetOrderListResponseInterface::getSmpType() | string | SMP execution type |
IGetOrderListResponseInterface::getSmpGroup() | string | Smp group ID. If the uid has no group, it is 0 by default |
IGetOrderListResponseInterface::getSmpOrderId() | string | The counterparty's orderID which triggers this SMP execution |
Contract - Account - Order - Replace Order
Order modification
You can change open or partially filled orders.
EXAMPLE
...
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\ReplaceOrder\Interfaces; interface IReplaceOrderRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setOrderId(string $orderId): self; // Order ID public function setOrderLinkId(string $orderLinkId): self; // Custom order ID public function setPrice(float $price): self; // New order price public function setQty(float $qty): self; // New order quantity public function setTriggerPrice(float $triggerPrice): self; // Setting/changing trigger price public function setTakeProfit(float $takeProfit): self; // Setting/changing take profit public function setStopLoss(float $stopLoss): self; // Setting/changing stop loss public function setTpTriggerBy(string $tpTriggerBy): self; // The price type to trigger take profit. When set a take profit, this param is required if no initial value for the order public function setSlTriggerBy(string $slTriggerBy): self; // The price type to trigger stop loss. When set a stop loss, this param is required if no initial value for the order public function setTriggerBy(string $triggerBy): self; // Trigger price type. LastPrice, IndexPrice, MarkPrice, LastPrice public function setTpLimitPrice(float $tpLimitPrice): self; // Limit order price when take profit is triggered. Only working when original order sets partial limit tp/sl // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\ReplaceOrder\Interfaces\IReplaceOrderRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\ReplaceOrder\Request\ReplaceOrderRequest::class |
||
Method | Required | Description |
---|---|---|
IReplaceOrderRequestInterface::setSymbol(string $symbol) | NO | Trading pair |
IReplaceOrderRequestInterface::setOrderId(string $orderId) | NO | Order ID |
IReplaceOrderRequestInterface::setOrderLinkId(string $orderLinkId) | NO | Custom order ID |
IReplaceOrderRequestInterface::setPrice(float $price) | NO | New order price |
IReplaceOrderRequestInterface::setQty(float $qty) | NO | New order quantity |
IReplaceOrderRequestInterface::setTriggerPrice(float $triggerPrice) | NO | Setting/changing trigger price |
IReplaceOrderRequestInterface::setTakeProfit(float $takeProfit) | NO | Setting/changing take profit |
IReplaceOrderRequestInterface::setStopLoss(float $stopLoss) | NO | Setting/changing stop loss |
IReplaceOrderRequestInterface::setTpTriggerBy(string $tpTriggerBy) | NO | The price type to trigger take profit. When set a take profit, this param is required if no initial value for the order |
IReplaceOrderRequestInterface::setSlTriggerBy(string $slTriggerBy) | NO | The price type to trigger stop loss. When set a stop loss, this param is required if no initial value for the order |
IReplaceOrderRequestInterface::setTriggerBy(string $triggerBy) | NO | Trigger price type. LastPrice, IndexPrice, MarkPrice, LastPrice |
IReplaceOrderRequestInterface::setTpLimitPrice(float $tpLimitPrice) | NO | Limit order price when take profit is triggered. Only working when original order sets partial limit tp/sl |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Order\ReplaceOrder\Interfaces; interface IReplaceOrderResponseInterface { public function getOrderId(): string; public function getOrderLinkId(): string; }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Order\ReplaceOrder\Interfaces\IReplaceOrderRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Order\ReplaceOrder\Request\ReplaceOrderRequest::class |
||
Method | Type | Description |
---|---|---|
IReplaceOrderRequestInterface::getOrderId() | string | Order ID |
IReplaceOrderRequestInterface::getOrderLinkId() | string | User customised order id |
Contract - Position - Get Closed PnL
Request information about closed positions with data on the user's profits and losses.
The result is sorted by createdAt in descending order.
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Interfaces; interface IGetClosedPnLRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setStartTime(int $startTime): self; // Lower limit of the date from which to take records public function setEndTime(int $endTime): self; // Upper limit of the date from which to take records public function setLimit(int $limit): self; // Record limit per request public function setCursor(string $cursor): self; // Next page cursor // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Interfaces\IGetClosedPnLRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Request\GetClosedPnLRequest::class |
||
Method | Required | Description |
---|---|---|
IGetClosedPnLRequestInterface::setSymbol(string $symbol) | YES | Trading pair |
IGetClosedPnLRequestInterface::setStartTime(int $startTime) | NO | Lower limit of the date from which to take records |
IGetClosedPnLRequestInterface::setEndTime(int $endTime) | NO | Upper limit of the date from which to take records |
IGetClosedPnLRequestInterface::setLimit(int $limit) | NO | Record limit per request |
IGetClosedPnLRequestInterface::setCursor(string $cursor) | NO | Next page cursor |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Interfaces; interface IGetClosedPnLResponseInterface { public function getSymbol(): string; // Trading pair public function getOrderId(): string; // order ID public function getSide(): string; // Order direction public function getQty(): float; // Order volume public function getLeverage(): float; // Leverage public function getOrderPrice(): float; // Order price public function getOrderType(): string; // Order type. Market,Limit public function getExecType(): string; // Execution type public function getClosedSize(): float; // Closed size public function getCumEntryValue(): float; // Cumulated entry position value public function getAvgEntryPrice(): float; // Average entry price public function getCumExitValue(): float; // Cumulated exit position value public function getAvgExitPrice(): float; // Average exit price public function getClosedPnl(): float; // Closed PnL public function getFillCount(): int; // The number of fills in a single order public function getCreatedAt(): \DateTime; // The created time }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Interfaces\IGetClosedPnLResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetClosedPnL\Response\GetClosedPnLResponse::class |
||
Method | Type | Description |
---|---|---|
IGetClosedPnLResponseInterface::getSymbol() | string | Trading pair |
IGetClosedPnLResponseInterface::getOrderId() | string | order ID |
IGetClosedPnLResponseInterface::getSide() | string | Order direction |
IGetClosedPnLResponseInterface::getQty() | float | Order volume |
IGetClosedPnLResponseInterface::getLeverage() | float | Leverage |
IGetClosedPnLResponseInterface::getOrderPrice() | float | Order price |
IGetClosedPnLResponseInterface::getExecType() | string | Execution type |
IGetClosedPnLResponseInterface::getClosedSize() | float | Closed size |
IGetClosedPnLResponseInterface::getCumEntryValue() | float | Cumulated entry position value |
IGetClosedPnLResponseInterface::getAvgEntryPrice() | float | Average entry price |
IGetClosedPnLResponseInterface::getCumExitValue() | float | Cumulated exit position value |
IGetClosedPnLResponseInterface::getAvgExitPrice() | float | Average exit price |
IGetClosedPnLResponseInterface::getClosedPnl() | float | Closed PnL |
IGetClosedPnLResponseInterface::getFillCount() | float | The number of fills in a single order |
IGetClosedPnLResponseInterface::getCreatedAt() | DateTime | The created time |
Contract - Position - Get Execution List
List of executed user orders, sorted by execution time in descending order. Supports USDT perpetual currency pairs
A user can have multiple executions in one order.
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetExecutionList\Interfaces; interface IGetExecutionListRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setStartTime(int $startTime): self; // Lower limit of the date from which to take records public function setEndTime(int $endTime): self; // Upper limit of the date from which to take records public function setLimit(int $limit): self; // Record limit per request public function setCursor(string $cursor): self; // Next page cursor // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetExecutionList\Interfaces\IGetExecutionListRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetExecutionList\Request\GetExecutionListRequest::class |
||
Method | Required | Description |
---|---|---|
IGetExecutionListRequestInterface::setSymbol(string $symbol) | YES | Trading pair |
IGetExecutionListRequestInterface::setStartTime(int $startTime) | NO | Lower limit of the date from which to take records |
IGetExecutionListRequestInterface::setEndTime(int $endTime) | NO | Upper limit of the date from which to take records |
IGetExecutionListRequestInterface::setLimit(int $limit) | NO | Record limit per request |
IGetExecutionListRequestInterface::setCursor(string $cursor) | NO | Next page cursor |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetExecutionList\Interfaces; interface IGetExecutionListResponseInterface { public function getSymbol(): string; // Trading pair public function getOrderId(): string; // order ID public function getSide(): string; // Order direction public function getQty(): float; // Order volume public function getLeverage(): float; // Leverage public function getOrderPrice(): float; // Order price public function getOrderType(): string; // Market,Limit public function getExecType(): string; // Execution type public function getClosedSize(): float; // Close size public function getCumEntryValue(): float; // public function getAvgEntryPrice(): float; // public function getCumExitValue(): float; // public function getAvgExitPrice(): float; // public function getClosedPnl(): float; // public function getFillCount(): int; // public function getCreatedAt(): \DateTime; // }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetExecutionList\Interfaces\IGetExecutionListResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\GetExecutionList\Response\GetExecutionListResponse::class |
||
Method | Type | Description |
---|---|---|
IGetExecutionListResponseInterface::getSymbol() | string | Trading pair |
IGetExecutionListResponseInterface::getOrderId() | string | order ID |
IGetExecutionListResponseInterface::getSide() | string | Order direction |
IGetExecutionListResponseInterface::getQty() | float | Order volume |
IGetExecutionListResponseInterface::getLeverage() | float | Leverage |
IGetExecutionListResponseInterface::getOrderPrice() | float | Order price |
IGetExecutionListResponseInterface::getExecType() | string | Execution type |
IGetExecutionListResponseInterface::getClosedSize() | float | Close size |
IGetExecutionListResponseInterface::getCumEntryValue() | float | - |
IGetExecutionListResponseInterface::getAvgEntryPrice() | float | - |
IGetExecutionListResponseInterface::getCumExitValue() | float | - |
IGetExecutionListResponseInterface::getAvgExitPrice() | float | - |
IGetExecutionListResponseInterface::getClosedPnl() | float | - |
IGetExecutionListResponseInterface::getFillCount() | float | - |
IGetExecutionListResponseInterface::getCreatedAt() | DateTime | - |
Contract - Position - My Position
Getting a list of the user's open positions
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Interfaces; interface IMyPositionRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setSettleCoin(string $symbol): self; // Calculation coin // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Interfaces\IMyPositionRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Request\MyPositionRequest::class |
||
Method | Required | Description |
---|---|---|
IMyPositionRequestInterface::setSymbol(string $symbol) | NO | Trading pair |
IMyPositionRequestInterface::setSettleCoin(string $symbol) | NO | Calculation coin |
RESPONSE STRUCTURE
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Interfaces; interface IMyPositionResponseInterface { public function getSymbol(): string; // Trading pair public function getSide(): string; // Side. Buy, Sell. Return None when zero position of one-way mode public function getSize(): float; // Position size public function getEntryPrice(): float; // Entry price public function getLeverage(): float; // leverage public function getPositionValue(): float; // Position value public function getPositionIdx(): int; // Position index public function getRiskId(): int; // Risk limit id public function getRiskLimitValue(): string; // Position limit value corresponding to the risk id public function getTradeMode(): int; // 0: cross margin mode. 1: isolated margin mode public function getAutoAddMargin(): int; // 0: false. 1: true public function getPositionBalance(): float; // Position margin public function getLiqPrice(): float; // Estimated liquidation price. It returns value only when minPrice < liqPrice < maxPrice public function getBustPrice(): float; // Estimated bankruptcy price public function getTpSlMode(): string; // Depreciated, meaningless here, always "Full" public function getTakeProfit(): float; // Take profit price public function getStopLoss(): float; // Stop loss price public function getCreatedTime(): \DateTime; // Position created timestamp public function getUpdatedTime(): \DateTime; // Position data updated timestamp public function getTrailingStop(): string; // Trailing stop public function getActivePrice(): float; // Activate price of trailing stop public function getMarkPrice(): float; // Real-time mark price public function getUnrealizedPnl(): float; // unrealised PNL public function getCumRealisedPnl(): float; // cumulative realised PNL public function getPositionMM(): float; // Position maintenance margin public function getPositionIM(): float; // Position initial margin public function getPositionStatus(): string; // Position status public function getSessionAvgPrice(): float; // Settlement price public function getOccClosingFee(): float; // Pre-occupancy closing fee public function getAdlRankIndicator(): int; // Auto-deleverage rank indicator. }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Interfaces\IMyPositionResponseInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\MyPosition\Response\MyPositionResponse::class |
||
Method | Type | Description |
---|---|---|
IMyPositionResponseInterface::getSymbol() | string | Trading pair |
IMyPositionResponseInterface::getSide() | string | Side. Buy, Sell. Return None when zero position of one-way mode |
IMyPositionResponseInterface::getSize() | float | Position size |
IMyPositionResponseInterface::getEntryPrice() | float | Entry price |
IMyPositionResponseInterface::getLeverage() | float | leverage |
IMyPositionResponseInterface::getPositionValue() | float | Position value |
IMyPositionResponseInterface::getPositionIdx() | int | Position index |
IMyPositionResponseInterface::getRiskId() | int | Risk limit id |
IMyPositionResponseInterface::getRiskLimitValue() | string | Position limit value corresponding to the risk id |
IMyPositionResponseInterface::getTradeMode() | int | 0: cross margin mode. 1: isolated margin mode |
IMyPositionResponseInterface::getAutoAddMargin() | int | 0: false. 1: true |
IMyPositionResponseInterface::getPositionBalance() | float | Position margin |
IMyPositionResponseInterface::getLiqPrice() | float | Estimated liquidation price. It returns value only when minPrice < liqPrice < maxPrice |
IMyPositionResponseInterface::getBustPrice() | float | Estimated bankruptcy price |
IMyPositionResponseInterface::getTpSlMode() | string | Depreciated, meaningless here, always "Full" |
IMyPositionResponseInterface::getTakeProfit() | float | Take profit price |
IMyPositionResponseInterface::getStopLoss() | float | Stop loss price |
IMyPositionResponseInterface::getCreatedTime() | DateTime | Position created timestamp |
IMyPositionResponseInterface::getUpdatedTime() | DateTime | Position data updated timestamp |
IMyPositionResponseInterface::getTrailingStop() | string | Trailing stop |
IMyPositionResponseInterface::getActivePrice() | float | Activate price of trailing stop |
IMyPositionResponseInterface::getMarkPrice() | float | Real-time mark price |
IMyPositionResponseInterface::getUnrealisedPnl() | float | unrealised PNL |
IMyPositionResponseInterface::getCumRealisedPnl() | float | cumulative realised PNL |
IMyPositionResponseInterface::getPositionMM() | float | Position maintenance margin |
IMyPositionResponseInterface::getPositionIM() | float | Position initial margin |
IMyPositionResponseInterface::getPositionStatus() | string | Position status |
IMyPositionResponseInterface::getSessionAvgPrice() | float | Settlement price |
IMyPositionResponseInterface::getOccClosingFee() | float | Pre-occupancy closing fee |
IMyPositionResponseInterface::getAdlRankIndicator() | string | Auto-deleverage rank indicator |
Contract - Position - Set Auto Add Margin
Enable/disable automatic addition of position margin. To understand more, please read here
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetAutoAddMargin\Interfaces; interface ISetAutoAddMarginRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setSide(string $side): self; // Side. Buy,Sell public function setAutoAddMargin(int $autoAddMargin): self; // Turn on/off auto add margin. 0: off. 1: on public function setPositionIdx(int $positionIdx): self; // Position index // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetAutoAddMargin\Interfaces\ISetAutoAddMarginRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetAutoAddMargin\Request\SetAutoAddMarginRequest::class |
||
Method | Required | Description |
---|---|---|
ISetAutoAddMarginRequestInterface::setSymbol(string $symbol) | YES | Trading pair |
ISetAutoAddMarginRequestInterface::setSide(string $side) | YES | Side. Buy,Sell |
ISetAutoAddMarginRequestInterface::setAutoAddMargin(int $autoAddMargin) | YES | Turn on/off auto add margin. 0: off. 1: on |
ISetAutoAddMarginRequestInterface::setPositionIdx(int $positionIdx) | YES | Position index |
RESPONSE STRUCTURE
Endpoint returns an empty array as a successful response
Contract - Position - Set Leverage
Set position leverage
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetLeverage\Interfaces; interface ISetLeverageRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setBuyLeverage(float $buyLeverage): self; // (0, max leverage of corresponding risk limit]. For one-way mode, make sure buyLeverage=sellLeverage public function setSellLeverage(float $sellLeverage): self; // (0, max leverage of corresponding risk limit]. For one-way mode, make sure buyLeverage=sellLeverage // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetLeverage\Interfaces\ISetLeverageRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetLeverage\Request\SetLeverageRequest::class |
||
Method | Required | Description |
---|---|---|
ISetLeverageRequestInterface::setSymbol(string $symbol) | YES | Trading pair |
ISetLeverageRequestInterface::setBuyLeverage(float $buyLeverage) | YES | (0, max leverage of corresponding risk limit]. For one-way mode, make sure buyLeverage=sellLeverage |
ISetLeverageRequestInterface::setSellLeverage(float $sellLeverage) | YES | (0, max leverage of corresponding risk limit]. For one-way mode, make sure buyLeverage=sellLeverage |
RESPONSE STRUCTURE
Endpoint returns an empty array as a successful response
Contract - Position - Set Risk Limit
The risk limit will limit the maximum position amount you can hold under various margin requirements.
If you want to hold a larger position, you will need more margin.
This request can set the risk limit for a single position. If an order is placed above the current risk limit, it will be rejected.
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetRiskLimit\Interfaces; interface ISetRiskLimitRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setRiskId(int $riskId): self; // Risk limit id public function setPositionIdx(int $positionIdx): self; // Used to identify positions in different position modes // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetRiskLimit\Interfaces\ISetRiskLimitRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetRiskLimit\Request\SetRiskLimitRequest::class |
||
Method | Required | Description |
---|---|---|
ISetRiskLimitRequestInterface::setSymbol(string $symbol) | YES | Trading pair |
ISetRiskLimitRequestInterface::setRiskId(int $riskId) | YES | Risk limit id |
ISetRiskLimitRequestInterface::setPositionIdx(int $positionIdx) | YES | Used to identify positions in different position modes. For hedge-mode, this param is required 0: one-way mode 1: hedge-mode Buy side 2: hedge-mode Sell side |
RESPONSE STRUCTURE
Endpoint returns an empty array as a successful response
Contract - Position - Set Trading Stop
The request sets the value of take profit, stop loss or trailing
Passing these parameters will create conditional orders within the system.
The system will cancel these orders if the position is closed and adjust the quantity according to the size of the open position.
Supports USDT and USDC Perpetual. Note: USDC Perpetual does not support partial TP/SL mode.
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetTradingStop\Interfaces; interface ISetTradingStopRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setTakeProfit(float $takeProfit): self; // Cannot be less than 0, 0 means cancel TP. Partial TP/SL cannot be cancelled by set it 0 public function setStopLoss(float $stopLoss): self; // Cannot be less than 0, 0 means cancel SL. Partial TP/SL cannot be cancelled by set it 0 public function setTpslMode(string $tpslMode): self; // TP/SL mode public function setTpSize(float $tpSize): self; // Take profit size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal public function setSlSize(float $slSize): self; // Stop loss size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal public function setTpTriggerBy(string $tpTriggerBy): self; // Take profit trigger price type. default: LastPrice public function setSlTriggerBy(string $slTriggerBy): self; // Stop loss trigger price type. default: LastPrice public function setTrailingStop(float $trailingStop): self; // Cannot be less than 0, 0 means cancel TS public function setActivePrice(float $activePrice): self; // Trailing stop trigger price. Trailing stop will be triggered when this price is reached only public function setTpLimitPrice(float $tpLimitPrice): self; // The limit order price when take profit price is triggered. Only works when tpslMode=Partial and tpOrderType=Limit public function setSlLimitPrice(float $slLimitPrice): self; // The limit order price when stop loss price is triggered. Only works when tpslMode=Partial and slOrderType=Limit public function setTpOrderType(string $tpOrderType): self; // The order type when take profit is triggered. Market(default), Limit. For tpslMode=Full, it only supports tpOrderType=Market public function setSlOrderType(string $slOrderType): self; // The order type when take profit is triggered public function setPositionIdx(int $positionIdx): self; // Used to identify positions in different position modes. For hedge-mode, this param is required // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetTradingStop\Interfaces\ISetTradingStopRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SetTradingStop\Request\SetTradingStopRequest::class |
||
Method | Required | Description |
---|---|---|
:: setSymbol(string $symbol) | YES | Trading pair |
:: setTakeProfit(float $takeProfit) | NO | Cannot be less than 0, 0 means cancel TP. Partial TP/SL cannot be cancelled by set it 0 |
:: setStopLoss(float $stopLoss) | NO | Cannot be less than 0, 0 means cancel SL. Partial TP/SL cannot be cancelled by set it 0 |
:: setTpslMode(string $tpslMode) | NO | TP/SL mode. Full: entire position TP/SL, Partial: partial position TP/SL. As each contract has an initial full TP/SL mode, if it has been modified before, it may be partial. Therefore, if not provided, the system will automatically retrieve the current TP/SL mode configuration for the contract. |
:: setTpSize(float $tpSize) | NO | Take profit size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal |
:: setSlSize(float $slSize) | NO | Stop loss size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal |
:: setTpTriggerBy(string $tpTriggerBy) | NO | Take profit trigger price type. default: LastPrice |
:: setSlTriggerBy(string $slTriggerBy) | NO | Stop loss trigger price type. default: LastPrice |
:: setTrailingStop(float $trailingStop) | NO | Cannot be less than 0, 0 means cancel TS |
::setActivePrice(float $activePrice) | NO | Trailing stop trigger price. Trailing stop will be triggered when this price is reached only |
:: setTpLimitPrice(float $tpLimitPrice) | NO | The limit order price when take profit price is triggered. Only works when tpslMode=Partial and tpOrderType=Limit |
:: setSlLimitPrice(float $slLimitPrice) | NO | The limit order price when stop loss price is triggered. Only works when tpslMode=Partial and slOrderType=Limit |
:: setTpOrderType(string $tpOrderType) | NO | The order type when take profit is triggered. Market(default), Limit. For tpslMode=Full, it only supports tpOrderType=Market |
:: setSlOrderType(string $slOrderType) | NO | The order type when stop loss is triggered. Market(default), Limit. For tpslMode=Full, it only supports slOrderType=Market |
::setPositionIdx(int $positionIdx) | NO | Used to identify positions in different position modes. For hedge-mode, this param is required 0: one-way mode 1: hedge-mode Buy side 2: hedge-mode Sell side |
RESPONSE STRUCTURE
Endpoint returns an empty array as a successful response
Contract - Position - Switch Cross Isolated Margin
The request changes the margin mode (Cross or Isolated)
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchCrossIsolatedMargin\Interfaces; interface ISwitchCrossIsolatedMarginRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setTradeMode(int $tradeMode): self; // 0: cross margin. 1: isolated margin public function setBuyLeverage(float $buyLeverage): self; // Buy side leverage. Make sure buyLeverage equals to sellLeverage public function setSellLeverage(float $sellLeverage): self; // Sell side leverage. Make sure buyLeverage equals to sellLeverage // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchCrossIsolatedMargin\Interfaces\ISwitchCrossIsolatedMarginRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchCrossIsolatedMargin\Request\SwitchCrossIsolatedMarginRequest::class |
||
Method | Required | Description |
---|---|---|
ISwitchCrossIsolatedMarginRequestInterface::setSymbol(string $symbol) | YES | Trading pair |
ISwitchCrossIsolatedMarginRequestInterface::setTradeMode(int $tradeMode) | YES | 0: cross margin. 1: isolated margin |
ISwitchCrossIsolatedMarginRequestInterface::setBuyLeverage(float $buyLeverage) | YES | Buy side leverage. Make sure buyLeverage equals to sellLeverage |
ISwitchCrossIsolatedMarginRequestInterface::setSellLeverage(float $sellLeverage) | YES | Sell side leverage. Make sure buyLeverage equals to sellLeverage |
RESPONSE STRUCTURE
Endpoint returns an empty array as a successful response
Contract - Position - Switch Position Mode
The request supports position mode switching for perpetual and inverse USDT futures.
If you are in one-way mode, you can only open one position on the buy or sell side.
If you are in hedging mode, you can open buy and sell positions simultaneously.
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchPositionMode\Interfaces; interface ISwitchPositionModeRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setCoin(string $coin): self; // Coin public function setPositionMode(int $positionMode): self; // Position mode. 0: Merged Single. 3: Both Side // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchPositionMode\Interfaces\ISwitchPositionModeRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchPositionMode\Request\SwitchPositionModeRequest::class |
||
Method | Required | Description |
---|---|---|
ISwitchPositionModeRequestInterface::setSymbol(string $symbol) | NO | Trading pair |
ISwitchPositionModeRequestInterface::setCoin(string $coin) | NO | Coin |
ISwitchPositionModeRequestInterface::setPositionMode(int $positionMode) | YES | Position mode. 0: Merged Single. 3: Both Side |
RESPONSE STRUCTURE
Endpoint returns an empty array as a successful response
Contract - Position - Switch TpSl Mode
The request sets the implicit tpsl mode for a specific trading instrument. It makes sense to use if you did not pass “tpslMode” in the order when placing or in a request to stop trading, because in this case the system will set tpslMode by default.
EXAMPLE
---
REQUEST PARAMETERS
namespace Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchTpSlMode\Interfaces; interface ISwitchTpSlModeRequestInterface { public function setSymbol(string $symbol): self; // Trading pair public function setTpSlMode(string $tpSlMode): self; // Full: set TP/SL to full position. Partial: set TP/SL to partial mode // .. Getters }
INTERFACE \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchTpSlMode\Interface\ISwitchTpSlModeRequestInterface::class |
||
DTO \Carpenstar\ByBitAPI\Derivatives\Contract\Position\SwitchTpSlMode\Request\SwitchTpSlModeRequest::class |
||
Method | Required | Description |
---|---|---|
ISwitchTpSlModeRequestInterface::setSymbol(string $symbol) | YES | Trading pair |
ISwitchTpSlModeRequestInterface::setTpSlMode(string $tpSlMode) | YES | Full: set TP/SL to full position. Partial: set TP/SL to partial mode |
RESPONSE STRUCTURE
Endpoint returns an empty array as a successful response