mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
increase position
This commit is contained in:
@@ -498,4 +498,14 @@ class _RestAuthenticatedEndpoints(_Requests):
|
||||
return serializers.BaseMarginInfo.parse(*(self._POST(f"auth/r/info/margin/base")[1]))
|
||||
|
||||
def claim_position(self, id: int, amount: Optional[Union[Decimal, float, str]] = None) -> Notification[Claim]:
|
||||
return serializers._Notification[Claim](serializer=serializers.Claim).parse(*self._POST("auth/w/position/claim", data={ "id": id, "amount": amount }))
|
||||
return serializers._Notification[Claim](serializer=serializers.Claim).parse(*self._POST("auth/w/position/claim", data={ "id": id, "amount": amount }))
|
||||
|
||||
def get_increase_position_info(self, symbol: str, amount: Union[Decimal, float, str]) -> IncreaseInfo:
|
||||
data = self._POST(f"auth/r/position/increase/info", data={ "symbol": symbol, "amount": amount })
|
||||
|
||||
return serializers.IncreaseInfo.parse(*(
|
||||
data[0] + [data[1][0]] + data[1][1] + [data[1][2]] + data[4] + data[5]
|
||||
))
|
||||
|
||||
def increase_position(self, symbol: str, amount: Union[Decimal, float, str]) -> Notification[Increase]:
|
||||
return serializers._Notification[Increase](serializer=serializers.Increase).parse(*self._POST("auth/w/position/increase", data={ "symbol": symbol, "amount": amount }))
|
||||
@@ -511,4 +511,30 @@ Claim = generate_labeler_serializer("Claim", klass=types.Claim, labels=[
|
||||
"META"
|
||||
])
|
||||
|
||||
IncreaseInfo = generate_labeler_serializer("IncreaseInfo", klass=types.IncreaseInfo, labels=[
|
||||
"MAX_POS",
|
||||
"CURRENT_POS",
|
||||
"BASE_CURRENCY_BALANCE",
|
||||
"TRADABLE_BALANCE_QUOTE_CURRENCY",
|
||||
"TRADABLE_BALANCE_QUOTE_TOTAL",
|
||||
"TRADABLE_BALANCE_BASE_CURRENCY",
|
||||
"TRADABLE_BALANCE_BASE_TOTAL",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"FUNDING_AVAIL",
|
||||
"FUNDING_VALUE",
|
||||
"FUNDING_REQUIRED",
|
||||
"FUNDING_VALUE_CURRENCY",
|
||||
"FUNDING_REQUIRED_CURRENCY"
|
||||
])
|
||||
|
||||
Increase = generate_labeler_serializer("Increase", klass=types.Increase, labels=[
|
||||
"SYMBOL",
|
||||
"_PLACEHOLDER",
|
||||
"AMOUNT",
|
||||
"BASE_PRICE"
|
||||
])
|
||||
|
||||
#endregion
|
||||
@@ -404,4 +404,25 @@ class Claim(_Type):
|
||||
MIN_COLLATERAL: str
|
||||
META: JSON
|
||||
|
||||
@dataclass
|
||||
class IncreaseInfo(_Type):
|
||||
MAX_POS: int
|
||||
CURRENT_POS: float
|
||||
BASE_CURRENCY_BALANCE: float
|
||||
TRADABLE_BALANCE_QUOTE_CURRENCY: float
|
||||
TRADABLE_BALANCE_QUOTE_TOTAL: float
|
||||
TRADABLE_BALANCE_BASE_CURRENCY: float
|
||||
TRADABLE_BALANCE_BASE_TOTAL: float
|
||||
FUNDING_AVAIL: float
|
||||
FUNDING_VALUE: float
|
||||
FUNDING_REQUIRED: float
|
||||
FUNDING_VALUE_CURRENCY: str
|
||||
FUNDING_REQUIRED_CURRENCY: str
|
||||
|
||||
@dataclass
|
||||
class Increase(_Type):
|
||||
SYMBOL: str
|
||||
AMOUNT: float
|
||||
BASE_PRICE: float
|
||||
|
||||
#endregion
|
||||
18
examples/rest/increase_position.py
Normal file
18
examples/rest/increase_position.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# python -c "import examples.rest.increase_position"
|
||||
|
||||
import os
|
||||
|
||||
from bfxapi.client import Client, Constants
|
||||
|
||||
bfx = Client(
|
||||
REST_HOST=Constants.REST_HOST,
|
||||
API_KEY=os.getenv("BFX_API_KEY"),
|
||||
API_SECRET=os.getenv("BFX_API_SECRET")
|
||||
)
|
||||
|
||||
increase_info = bfx.rest.auth.get_increase_position_info(symbol="tBTCUSD", amount=0.0001)
|
||||
print(increase_info)
|
||||
|
||||
# increase a margin position
|
||||
notification = bfx.rest.auth.increase_position(symbol="tBTCUSD", amount=0.0001)
|
||||
print(notification.NOTIFY_INFO)
|
||||
Reference in New Issue
Block a user