Skip to content

bybit

Classes

Bybit

Bases: Exchange

Functions

__init__
__init__(use_testnet, api_key=None, secret_key=None)
adjust_order
adjust_order(symbol, asset_size=None, category='linear', custom_order_id=None, orderIv=None, order_id=None, price=None, slLimitPrice=None, slTriggerBy=None, stopLoss=None, takeProfit=None, tpLimitPrice=None, tpslMode=None, tpTriggerBy=None, triggerBy=None, triggerPrice=None)
cancel_all_open_orders
cancel_all_open_orders(symbol=None, category='linear', baseCoin=None, settleCoin=None, orderFilter=None, stopOrderType=None)
close_hedge_positions_and_orders
close_hedge_positions_and_orders(symbol=None, settleCoin=None)

Parameters:

Name Type Description Default
symbol str
None
create_order
create_order(symbol, buy_sell, position_mode, order_type, asset_size, category='linear', time_in_force='GTC', price=None, triggerDirection=None, triggerPrice=None, triggerBy=None, tpTriggerBy=None, slTriggerBy=None, custom_order_id=None, takeProfit=None, stopLoss=None, reduce_only=None, closeOnTrigger=None, isLeverage=None)
get_all_symbols_info
get_all_symbols_info(category='linear', limit=500, symbol=None, status=None, baseCoin=None)
get_candles
get_candles(symbol, timeframe, since_datetime=None, until_datetime=None, candles_to_dl=1000, category='linear')
Summary

Bybit candle docs

Explainer Video

Coming Soon but if you want/need it now please let me know in discord or telegram and i will make it for you

Parameters:

Name Type Description Default
symbol str required
timeframe str

"1m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "d", "w"

required
since_datetime datetime

The start date, in datetime format, of candles you want to download. EX: datetime(year, month, day, hour, minute)

None
until_datetime datetime

The until date, in datetime format, of candles you want to download minus one candle so if you are on the 5 min if you say your until date is 1200 your last candle will be 1155. EX: datetime(year, month, day, hour, minute)

None
candles_to_dl int

The amount of candles you want to download

1000
category str 'linear'

Returns:

Type Description
array

a 2 dim array with the following columns "timestamp", "open", "high", "low", "close", "volume"

get_closed_pnl
get_closed_pnl(symbol, limit=50, since_datetime=None, until_datetime=None, category='linear')
get_open_orders
get_open_orders(symbol, baseCoin=None, category='linear', custom_order_id=None, limit=50, orderFilter=None, orderStatus=None, order_id=None, settleCoin=None, since_datetime=None, until_datetime=None)
get_order_history
get_order_history(baseCoin=None, category='linear', custom_order_id=None, limit=50, orderFilter=None, orderStatus=None, order_id=None, settleCoin=None, since_datetime=None, symbol=None, until_datetime=None)
get_position_info
get_position_info(symbol=None, baseCoin=None, category='linear', limit=50, settleCoin=None)
get_risk_limit_info
get_risk_limit_info(symbol, category='linear')
get_symbols_list
get_symbols_list()

Returns a list of the symbols in alphabetical order

Parameters:

Name Type Description Default
None
required

Returns:

Type Description
list

symbols

get_trading_fee_rates
get_trading_fee_rates(symbol=None, baseCoin=None, category='linear')
get_wallet_info
get_wallet_info(accountType='UNIFIED', trading_with=None)
set_leverage
set_leverage(symbol, leverage, category='linear')
set_leverage_mode
set_leverage_mode(setMarginMode='ISOLATED_MARGIN')

ISOLATED_MARGIN, REGULAR_MARGIN(i.e. Cross margin), PORTFOLIO_MARGIN

set_position_mode
set_position_mode(position_mode, symbol, category='linear', trading_with=None)