Files
bitfinex-api-py/bfxapi/models/Position.py
2018-12-05 14:55:20 +00:00

37 lines
1.3 KiB
Python

class Position:
"""
SYMBOL string Pair (tBTCUSD, …).
STATUS string Status (ACTIVE, CLOSED).
±AMOUNT float Size of the position. Positive values means a long position, negative values means a short position.
BASE_PRICE float The price at which you entered your position.
MARGIN_FUNDING float The amount of funding being used for this position.
MARGIN_FUNDING_TYPE int 0 for daily, 1 for term.
PL float Profit & Loss
PL_PERC float Profit & Loss Percentage
PRICE_LIQ float Liquidation price
LEVERAGE float Beta value
"""
def __init__(self, symbol, status, amount, bPrice, mFunding, mFundingType,
profit_loss, profit_loss_perc, lPrice, lev):
self.symbol = symbol
self.status = status
self.amount = amount
self.base_price = bPrice
self.margin_funding = mFunding
self.margin_funding_type = mFundingType
self.profit_loss = profit_loss
self.profit_loss_percentage = profit_loss_perc
self.liquidation_price = lPrice
self.leverage = lev
@staticmethod
def from_raw_rest_position(raw_position):
return Position(*raw_position)
def __str__(self):
''' Allow us to print the Trade object in a pretty format '''
return "Position '{}' {} x {} <Sstatus='{}' p&l={}>".format(
self.symbol, self.base_price, self.amount, self.status, self.profit_loss)