mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-20 23:34:21 +01:00
models: create position object
This commit is contained in:
25
bfxapi/models/Position.py
Normal file
25
bfxapi/models/Position.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
class Position:
|
||||||
|
|
||||||
|
def __init__(self, symbol, status, amount, bPrice, mFunding, mFundingType,
|
||||||
|
profit_loss, profit_loss_perc, lPrice, lev):
|
||||||
|
# [['tBTCUSD', 'ACTIVE', -2.37709587, 20720, -0.00066105, 0, 13115.99728968, 26.6296139, 104156.986252, -1.2332]]
|
||||||
|
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)
|
||||||
@@ -5,3 +5,4 @@ from .Trade import *
|
|||||||
from .OrderBook import *
|
from .OrderBook import *
|
||||||
from .Subscription import *
|
from .Subscription import *
|
||||||
from .Wallet import *
|
from .Wallet import *
|
||||||
|
from .Position import *
|
||||||
|
|||||||
Reference in New Issue
Block a user