mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 06:44:22 +01:00
keep taken funding
This commit is contained in:
@@ -133,8 +133,10 @@ class _RestAuthenticatedEndpoints(_Requests):
|
||||
def cancel_funding_offer(self, id: int) -> Notification[FundingOffer]:
|
||||
return serializers._Notification[FundingOffer](serializer=serializers.FundingOffer).parse(*self._POST("auth/w/funding/offer/cancel", data={ "id": id }))
|
||||
|
||||
def cancel_all_funding_offers(self, currency: str) -> Notification:
|
||||
return serializers._Notification().parse(*self._POST("auth/w/funding/offer/cancel/all", data={ "currency": currency }))
|
||||
def cancel_all_funding_offers(self, currency: str) -> Notification[Literal[None]]:
|
||||
return serializers._Notification[Literal[None]](serializer=None).parse(
|
||||
*self._POST("auth/w/funding/offer/cancel/all", data={ "currency": currency })
|
||||
)
|
||||
|
||||
def get_funding_offers_history(self, symbol: Optional[str] = None, start: Optional[str] = None, end: Optional[str] = None, limit: Optional[int] = None) -> List[FundingOffer]:
|
||||
if symbol == None:
|
||||
@@ -187,7 +189,7 @@ class _RestAuthenticatedEndpoints(_Requests):
|
||||
return [ serializers.FundingCredit.parse(*sub_data) for sub_data in self._POST(endpoint, data=data) ]
|
||||
|
||||
def submit_funding_close(self, id: int) -> Notification[Literal[None]]:
|
||||
return serializers._Notification[Literal[None]]().parse(
|
||||
return serializers._Notification[Literal[None]](serializer=None).parse(
|
||||
*self._POST("auth/w/funding/close", data={ "id": id })
|
||||
)
|
||||
|
||||
@@ -198,6 +200,13 @@ class _RestAuthenticatedEndpoints(_Requests):
|
||||
"rate": rate, "period": period
|
||||
}))
|
||||
|
||||
def submit_funding_toggle_keep(self, type: Literal["credit", "loan"], ids: Optional[List[int]] = None, changes: Optional[Dict[int, bool]] = None) -> Notification[Literal[None]]:
|
||||
return serializers._Notification[Literal[None]](serializer=None).parse(*self._POST("auth/w/funding/keep", data={
|
||||
"type": type,
|
||||
"id": ids,
|
||||
"changes": changes
|
||||
}))
|
||||
|
||||
def submit_wallet_transfer(self, from_wallet: str, to_wallet: str, currency: str, currency_to: str, amount: Union[Decimal, float, str]) -> Notification[Transfer]:
|
||||
data = {
|
||||
"from": from_wallet, "to": to_wallet,
|
||||
|
||||
26
examples/rest/keep_taken_funding.py
Normal file
26
examples/rest/keep_taken_funding.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# python -c "import examples.rest.keep_taken_funding"
|
||||
|
||||
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")
|
||||
)
|
||||
|
||||
loans = bfx.rest.auth.get_funding_loans(symbol="fUSD")
|
||||
|
||||
for loan in loans:
|
||||
print(f"Loan {loan}")
|
||||
|
||||
notification = bfx.rest.auth.submit_funding_toggle_keep(
|
||||
funding_type="loan",
|
||||
ids=[loan.id],
|
||||
changes={
|
||||
loan.id: 2 # (1 if true, 2 if false)
|
||||
}
|
||||
)
|
||||
|
||||
print("Funding keep notification:", notification)
|
||||
Reference in New Issue
Block a user