mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 23:04:21 +01:00
Add support to new calculation endpoints.
This commit is contained in:
@@ -62,13 +62,13 @@ class _Requests(object):
|
||||
|
||||
return data
|
||||
|
||||
def _POST(self, endpoint, params = None, data = None, _append_authentication_headers = True):
|
||||
def _POST(self, endpoint, params = None, data = None):
|
||||
headers = { "Content-Type": "application/json" }
|
||||
|
||||
if isinstance(data, dict):
|
||||
data = json.dumps({ key: value for key, value in data.items() if value != None}, cls=JSONEncoder)
|
||||
|
||||
if _append_authentication_headers:
|
||||
if self.API_KEY and self.API_SECRET:
|
||||
headers = { **headers, **self.__build_authentication_headers(endpoint, data) }
|
||||
|
||||
response = requests.post(f"{self.host}/{endpoint}", params=params, data=data, headers=headers)
|
||||
@@ -268,6 +268,21 @@ class _RestPublicEndpoints(_Requests):
|
||||
|
||||
return messages
|
||||
|
||||
def get_trading_market_average_price(self, symbol: str, amount: Union[Decimal, str], price_limit: Optional[Union[Decimal, str]] = None) -> TradingMarketAveragePrice:
|
||||
data = {
|
||||
"symbol": symbol, "amount": amount, "price_limit": price_limit
|
||||
}
|
||||
|
||||
return serializers.TradingMarketAveragePrice.parse(*self._POST("calc/trade/avg", data=data))
|
||||
|
||||
def get_funding_market_average_price(self, symbol: str, amount: Union[Decimal, str], period: int, rate_limit: Optional[Union[Decimal, str]] = None) -> FundingMarketAveragePrice:
|
||||
data = {
|
||||
"symbol": symbol, "amount": amount, "period": period,
|
||||
"rate_limit": rate_limit
|
||||
}
|
||||
|
||||
return serializers.FundingMarketAveragePrice.parse(*self._POST("calc/trade/avg", data=data))
|
||||
|
||||
class _RestAuthenticatedEndpoints(_Requests):
|
||||
def get_wallets(self) -> List[Wallet]:
|
||||
return [ serializers.Wallet.parse(*subdata) for subdata in self._POST("auth/r/wallets") ]
|
||||
|
||||
Reference in New Issue
Block a user