Converted kwargs to params

This commit is contained in:
Arunavo Ray 2021-09-17 08:17:15 +05:30
parent f0aa76d799
commit 13331e4dc7

View File

@ -65,7 +65,21 @@ def binance(
margin_mode: MarginMode, margin_mode: MarginMode,
trading_mode: TradingMode, trading_mode: TradingMode,
collateral: Collateral, collateral: Collateral,
**kwargs wallet_balance: float,
maintenance_margin_ex_1: float,
unrealized_pnl_ex_1: float,
maintenance_amount_both: float,
maintenance_amount_long: float,
maintenance_amount_short: float,
position_1_both: float,
entry_price_1_both: float,
position_1_long: float,
entry_price_1_long: float,
position_1_short: float,
entry_price_1_short: float,
maintenance_margin_rate_both: float,
maintenance_margin_rate_long: float,
maintenance_margin_rate_short: float,
): ):
r""" r"""
Calculates the liquidation price on Binance Calculates the liquidation price on Binance
@ -76,79 +90,58 @@ def binance(
:param trading_mode: spot, margin, futures :param trading_mode: spot, margin, futures
:param collateral: cross, isolated :param collateral: cross, isolated
:param \**kwargs: :param wallet_balance: Wallet Balance is crossWalletBalance in Cross-Margin Mode.
See below Wallet Balance is isolatedWalletBalance in Isolated Margin Mode
:Keyword Arguments: :param maintenance_margin_ex_1: Maintenance Margin of all other contracts, excluding Contract 1.
* *wallet_balance* (``float``) -- If it is an isolated margin mode, then TMM=0
Wallet Balance is crossWalletBalance in Cross-Margin Mode
Wallet Balance is isolatedWalletBalance in Isolated Margin Mode
* *maintenance_margin_ex_1* (``float``) -- :param unrealized_pnl_ex_1: Unrealized PNL of all other contracts, excluding Contract 1.
Maintenance Margin of all other contracts, excluding Contract 1. If it is an isolated margin mode, then UPNL=0
If it is an isolated margin mode, then TMM=0
* *unrealized_pnl_ex_1* (``float``) -- :param maintenance_amount_both: Maintenance Amount of BOTH position (one-way mode)
Unrealized PNL of all other contracts, excluding Contract 1.
If it is an isolated margin mode, then UPNL=0
* *maintenance_amount_both* (``float``) -- :param maintenance_amount_long: Maintenance Amount of LONG position (hedge mode)
Maintenance Amount of BOTH position (one-way mode)
* *maintenance_amount_long* (``float``) -- :param maintenance_amount_short: Maintenance Amount of SHORT position (hedge mode)
Maintenance Amount of LONG position (hedge mode)
* *maintenance_amount_short* (``float``) -- :param side_1_both: Direction of BOTH position, 1 as long position, -1 as short position derived from is_short
Maintenance Amount of SHORT position (hedge mode)
* *side_1_both* (``int``) -- :param position_1_both: Absolute value of BOTH position size (one-way mode)
Direction of BOTH position, 1 as long position, -1 as short position
Derived from is_short
* *position_1_both* (``float``) -- :param entry_price_1_both: Entry Price of BOTH position (one-way mode)
Absolute value of BOTH position size (one-way mode)
* *entry_price_1_both* (``float``) -- :param position_1_long: Absolute value of LONG position size (hedge mode)
Entry Price of BOTH position (one-way mode)
* *position_1_long* (``float``) -- :param entry_price_1_long: Entry Price of LONG position (hedge mode)
Absolute value of LONG position size (hedge mode)
* *entry_price_1_long* (``float``) -- :param position_1_short: Absolute value of SHORT position size (hedge mode)
Entry Price of LONG position (hedge mode)
* *position_1_short* (``float``) -- :param entry_price_1_short: Entry Price of SHORT position (hedge mode)
Absolute value of SHORT position size (hedge mode)
* *entry_price_1_short* (``float``) -- :param maintenance_margin_rate_both: Maintenance margin rate of BOTH position (one-way mode)
Entry Price of SHORT position (hedge mode)
* *maintenance_margin_rate_both* (``float``) -- :param maintenance_margin_rate_long: Maintenance margin rate of LONG position (hedge mode)
Maintenance margin rate of BOTH position (one-way mode)
* *maintenance_margin_rate_long* (``float``) -- :param maintenance_margin_rate_short: Maintenance margin rate of SHORT position (hedge mode)
Maintenance margin rate of LONG position (hedge mode)
* *maintenance_margin_rate_short* (``float``) --
Maintenance margin rate of SHORT position (hedge mode)
""" """
# TODO-lev: Additional arguments, fill in formulas # TODO-lev: Additional arguments, fill in formulas
wb = kwargs.get("wallet_balance") wb = wallet_balance
tmm_1 = 0.0 if collateral == Collateral.ISOLATED else kwargs.get("maintenance_margin_ex_1") tmm_1 = 0.0 if collateral == Collateral.ISOLATED else maintenance_margin_ex_1
upnl_1 = 0.0 if collateral == Collateral.ISOLATED else kwargs.get("unrealized_pnl_ex_1") upnl_1 = 0.0 if collateral == Collateral.ISOLATED else unrealized_pnl_ex_1
cum_b = kwargs.get("maintenance_amount_both") cum_b = maintenance_amount_both
cum_l = kwargs.get("maintenance_amount_long") cum_l = maintenance_amount_long
cum_s = kwargs.get("maintenance_amount_short") cum_s = maintenance_amount_short
side_1_both = -1 if is_short else 1 side_1_both = -1 if is_short else 1
position_1_both = abs(kwargs.get("position_1_both")) position_1_both = abs(position_1_both)
ep1_both = kwargs.get("entry_price_1_both") ep1_both = entry_price_1_both
position_1_long = abs(kwargs.get("position_1_long")) position_1_long = abs(position_1_long)
ep1_long = kwargs.get("entry_price_1_long") ep1_long = entry_price_1_long
position_1_short = abs(kwargs.get("position_1_short")) position_1_short = abs(position_1_short)
ep1_short = kwargs.get("entry_price_1_short") ep1_short = entry_price_1_short
mmr_b = kwargs.get("maintenance_margin_rate_both") mmr_b = maintenance_margin_rate_both
mmr_l = kwargs.get("maintenance_margin_rate_long") mmr_l = maintenance_margin_rate_long
mmr_s = kwargs.get("maintenance_margin_rate_short") mmr_s = maintenance_margin_rate_short
if trading_mode == TradingMode.MARGIN and collateral == Collateral.CROSS: if trading_mode == TradingMode.MARGIN and collateral == Collateral.CROSS:
# TODO-lev: perform a calculation based on this formula # TODO-lev: perform a calculation based on this formula