mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 22:34:21 +01:00
Drop modules bfxapi.enums, bfxapi.rest.enums and bfxapi.websocket.enums.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
from .client import Client
|
from ._client import \
|
||||||
|
Client, \
|
||||||
from .urls import REST_HOST, PUB_REST_HOST, \
|
REST_HOST, \
|
||||||
WSS_HOST, PUB_WSS_HOST
|
WSS_HOST, \
|
||||||
|
PUB_REST_HOST, \
|
||||||
from .version import __version__
|
PUB_WSS_HOST
|
||||||
|
|||||||
@@ -7,12 +7,17 @@ from bfxapi._exceptions import IncompleteCredentialError
|
|||||||
|
|
||||||
from bfxapi.rest import BfxRestInterface
|
from bfxapi.rest import BfxRestInterface
|
||||||
from bfxapi.websocket import BfxWebSocketClient
|
from bfxapi.websocket import BfxWebSocketClient
|
||||||
from bfxapi.urls import REST_HOST, WSS_HOST
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from bfxapi.websocket._client.bfx_websocket_client import \
|
from bfxapi.websocket._client.bfx_websocket_client import \
|
||||||
_Credentials
|
_Credentials
|
||||||
|
|
||||||
|
REST_HOST = "https://api.bitfinex.com/v2"
|
||||||
|
WSS_HOST = "wss://api.bitfinex.com/ws/2"
|
||||||
|
|
||||||
|
PUB_REST_HOST = "https://api-pub.bitfinex.com/v2"
|
||||||
|
PUB_WSS_HOST = "wss://api-pub.bitfinex.com/ws/2"
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
from enum import Enum
|
|
||||||
|
|
||||||
class OrderType(str, Enum):
|
|
||||||
LIMIT = "LIMIT"
|
|
||||||
EXCHANGE_LIMIT = "EXCHANGE LIMIT"
|
|
||||||
MARKET = "MARKET"
|
|
||||||
EXCHANGE_MARKET = "EXCHANGE MARKET"
|
|
||||||
STOP = "STOP"
|
|
||||||
EXCHANGE_STOP = "EXCHANGE STOP"
|
|
||||||
STOP_LIMIT = "STOP LIMIT"
|
|
||||||
EXCHANGE_STOP_LIMIT = "EXCHANGE STOP LIMIT"
|
|
||||||
TRAILING_STOP = "TRAILING STOP"
|
|
||||||
EXCHANGE_TRAILING_STOP = "EXCHANGE TRAILING STOP"
|
|
||||||
FOK = "FOK"
|
|
||||||
EXCHANGE_FOK = "EXCHANGE FOK"
|
|
||||||
IOC = "IOC"
|
|
||||||
EXCHANGE_IOC = "EXCHANGE IOC"
|
|
||||||
|
|
||||||
class FundingOfferType(str, Enum):
|
|
||||||
LIMIT = "LIMIT"
|
|
||||||
FRR_DELTA_FIX = "FRRDELTAFIX"
|
|
||||||
FRR_DELTA_VAR = "FRRDELTAVAR"
|
|
||||||
|
|
||||||
class Flag(int, Enum):
|
|
||||||
HIDDEN = 64
|
|
||||||
CLOSE = 512
|
|
||||||
REDUCE_ONLY = 1024
|
|
||||||
POST_ONLY = 4096
|
|
||||||
OCO = 16384
|
|
||||||
NO_VAR_RATES = 524288
|
|
||||||
|
|
||||||
class Error(int, Enum):
|
|
||||||
ERR_UNK = 10000
|
|
||||||
ERR_GENERIC = 10001
|
|
||||||
ERR_CONCURRENCY = 10008
|
|
||||||
ERR_PARAMS = 10020
|
|
||||||
ERR_CONF_FAIL = 10050
|
|
||||||
ERR_AUTH_FAIL = 10100
|
|
||||||
ERR_AUTH_PAYLOAD = 10111
|
|
||||||
ERR_AUTH_SIG = 10112
|
|
||||||
ERR_AUTH_HMAC = 10113
|
|
||||||
ERR_AUTH_NONCE = 10114
|
|
||||||
ERR_UNAUTH_FAIL = 10200
|
|
||||||
ERR_SUB_FAIL = 10300
|
|
||||||
ERR_SUB_MULTI = 10301
|
|
||||||
ERR_SUB_UNK = 10302
|
|
||||||
ERR_SUB_LIMIT = 10305
|
|
||||||
ERR_UNSUB_FAIL = 10400
|
|
||||||
ERR_UNSUB_NOT = 10401
|
|
||||||
ERR_READY = 11000
|
|
||||||
@@ -4,8 +4,6 @@ from decimal import Decimal
|
|||||||
|
|
||||||
from ..middleware import Middleware
|
from ..middleware import Middleware
|
||||||
|
|
||||||
from ..enums import Sort, OrderType, FundingOfferType
|
|
||||||
|
|
||||||
from ...types import Notification, \
|
from ...types import Notification, \
|
||||||
UserInfo, LoginHistory, BalanceAvailable, \
|
UserInfo, LoginHistory, BalanceAvailable, \
|
||||||
Order, Position, Trade, \
|
Order, Position, Trade, \
|
||||||
@@ -63,7 +61,7 @@ class RestAuthEndpoints(Middleware):
|
|||||||
for sub_data in self._post(endpoint, body={ "id": ids }) ]
|
for sub_data in self._post(endpoint, body={ "id": ids }) ]
|
||||||
|
|
||||||
def submit_order(self,
|
def submit_order(self,
|
||||||
type: OrderType,
|
type: str,
|
||||||
symbol: str,
|
symbol: str,
|
||||||
amount: Union[Decimal, float, str],
|
amount: Union[Decimal, float, str],
|
||||||
*,
|
*,
|
||||||
@@ -163,7 +161,7 @@ class RestAuthEndpoints(Middleware):
|
|||||||
def get_trades_history(self,
|
def get_trades_history(self,
|
||||||
*,
|
*,
|
||||||
symbol: Optional[str] = None,
|
symbol: Optional[str] = None,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> List[Trade]:
|
limit: Optional[int] = None) -> List[Trade]:
|
||||||
@@ -285,7 +283,7 @@ class RestAuthEndpoints(Middleware):
|
|||||||
|
|
||||||
#pylint: disable-next=too-many-arguments
|
#pylint: disable-next=too-many-arguments
|
||||||
def submit_funding_offer(self,
|
def submit_funding_offer(self,
|
||||||
type: FundingOfferType,
|
type: str,
|
||||||
symbol: str,
|
symbol: str,
|
||||||
amount: Union[Decimal, float, str],
|
amount: Union[Decimal, float, str],
|
||||||
rate: Union[Decimal, float, str],
|
rate: Union[Decimal, float, str],
|
||||||
@@ -397,7 +395,7 @@ class RestAuthEndpoints(Middleware):
|
|||||||
def get_funding_trades_history(self,
|
def get_funding_trades_history(self,
|
||||||
*,
|
*,
|
||||||
symbol: Optional[str] = None,
|
symbol: Optional[str] = None,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> List[FundingTrade]:
|
limit: Optional[int] = None) -> List[FundingTrade]:
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ from decimal import Decimal
|
|||||||
|
|
||||||
from bfxapi.rest.middleware import Middleware
|
from bfxapi.rest.middleware import Middleware
|
||||||
|
|
||||||
from bfxapi.rest.enums import MerchantSettingsKey
|
|
||||||
|
|
||||||
from bfxapi.types import \
|
from bfxapi.types import \
|
||||||
InvoiceSubmission, \
|
InvoiceSubmission, \
|
||||||
InvoicePage, \
|
InvoicePage, \
|
||||||
@@ -140,16 +138,16 @@ class RestMerchantEndpoints(Middleware):
|
|||||||
body={ "baseCcy": base_ccy, "convertCcy": convert_ccy }))
|
body={ "baseCcy": base_ccy, "convertCcy": convert_ccy }))
|
||||||
|
|
||||||
def set_merchant_settings(self,
|
def set_merchant_settings(self,
|
||||||
key: MerchantSettingsKey,
|
key: str,
|
||||||
val: Any) -> bool:
|
val: Any) -> bool:
|
||||||
return bool(self._post("auth/w/ext/pay/settings/set", \
|
return bool(self._post("auth/w/ext/pay/settings/set", \
|
||||||
body={ "key": key, "val": val }))
|
body={ "key": key, "val": val }))
|
||||||
|
|
||||||
def get_merchant_settings(self, key: MerchantSettingsKey) -> Any:
|
def get_merchant_settings(self, key: str) -> Any:
|
||||||
return self._post("auth/r/ext/pay/settings/get", body={ "key": key })
|
return self._post("auth/r/ext/pay/settings/get", body={ "key": key })
|
||||||
|
|
||||||
#pylint: disable-next=dangerous-default-value
|
#pylint: disable-next=dangerous-default-value
|
||||||
def list_merchant_settings(self, keys: List[MerchantSettingsKey] = []) -> Dict[MerchantSettingsKey, Any]:
|
def list_merchant_settings(self, keys: List[str] = []) -> Dict[str, Any]:
|
||||||
return self._post("auth/r/ext/pay/settings/list", body={ "keys": keys })
|
return self._post("auth/r/ext/pay/settings/list", body={ "keys": keys })
|
||||||
|
|
||||||
def get_deposits(self,
|
def get_deposits(self,
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ from decimal import Decimal
|
|||||||
|
|
||||||
from ..middleware import Middleware
|
from ..middleware import Middleware
|
||||||
|
|
||||||
from ..enums import Config, Sort
|
|
||||||
|
|
||||||
from ...types import \
|
from ...types import \
|
||||||
PlatformStatus, TradingPairTicker, FundingCurrencyTicker, \
|
PlatformStatus, TradingPairTicker, FundingCurrencyTicker, \
|
||||||
TickersHistory, TradingPairTrade, FundingCurrencyTrade, \
|
TickersHistory, TradingPairTrade, FundingCurrencyTrade, \
|
||||||
@@ -19,7 +17,7 @@ from ...types import serializers
|
|||||||
|
|
||||||
#pylint: disable-next=too-many-public-methods
|
#pylint: disable-next=too-many-public-methods
|
||||||
class RestPublicEndpoints(Middleware):
|
class RestPublicEndpoints(Middleware):
|
||||||
def conf(self, config: Config) -> Any:
|
def conf(self, config: str) -> Any:
|
||||||
return self._get(f"conf/{config}")[0]
|
return self._get(f"conf/{config}")[0]
|
||||||
|
|
||||||
def get_platform_status(self) -> PlatformStatus:
|
def get_platform_status(self) -> PlatformStatus:
|
||||||
@@ -84,7 +82,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
limit: Optional[int] = None,
|
limit: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
sort: Optional[Sort] = None) -> List[TradingPairTrade]:
|
sort: Optional[int] = None) -> List[TradingPairTrade]:
|
||||||
params = { "limit": limit, "start": start, "end": end, "sort": sort }
|
params = { "limit": limit, "start": start, "end": end, "sort": sort }
|
||||||
data = self._get(f"trades/{pair}/hist", params=params)
|
data = self._get(f"trades/{pair}/hist", params=params)
|
||||||
return [ serializers.TradingPairTrade.parse(*sub_data) for sub_data in data ]
|
return [ serializers.TradingPairTrade.parse(*sub_data) for sub_data in data ]
|
||||||
@@ -95,7 +93,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
limit: Optional[int] = None,
|
limit: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
sort: Optional[Sort] = None) -> List[FundingCurrencyTrade]:
|
sort: Optional[int] = None) -> List[FundingCurrencyTrade]:
|
||||||
params = { "limit": limit, "start": start, "end": end, "sort": sort }
|
params = { "limit": limit, "start": start, "end": end, "sort": sort }
|
||||||
data = self._get(f"trades/{currency}/hist", params=params)
|
data = self._get(f"trades/{currency}/hist", params=params)
|
||||||
return [ serializers.FundingCurrencyTrade.parse(*sub_data) for sub_data in data ]
|
return [ serializers.FundingCurrencyTrade.parse(*sub_data) for sub_data in data ]
|
||||||
@@ -133,7 +131,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
def get_stats_hist(self,
|
def get_stats_hist(self,
|
||||||
resource: str,
|
resource: str,
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> List[Statistic]:
|
limit: Optional[int] = None) -> List[Statistic]:
|
||||||
@@ -144,7 +142,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
def get_stats_last(self,
|
def get_stats_last(self,
|
||||||
resource: str,
|
resource: str,
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> Statistic:
|
limit: Optional[int] = None) -> Statistic:
|
||||||
@@ -156,7 +154,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
symbol: str,
|
symbol: str,
|
||||||
tf: str = "1m",
|
tf: str = "1m",
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> List[Candle]:
|
limit: Optional[int] = None) -> List[Candle]:
|
||||||
@@ -168,7 +166,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
symbol: str,
|
symbol: str,
|
||||||
tf: str = "1m",
|
tf: str = "1m",
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> Candle:
|
limit: Optional[int] = None) -> Candle:
|
||||||
@@ -192,7 +190,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
def get_derivatives_status_history(self,
|
def get_derivatives_status_history(self,
|
||||||
key: str,
|
key: str,
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> List[DerivativesStatus]:
|
limit: Optional[int] = None) -> List[DerivativesStatus]:
|
||||||
@@ -202,7 +200,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
|
|
||||||
def get_liquidations(self,
|
def get_liquidations(self,
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> List[Liquidation]:
|
limit: Optional[int] = None) -> List[Liquidation]:
|
||||||
@@ -214,7 +212,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
symbol: str,
|
symbol: str,
|
||||||
tf: str = "1m",
|
tf: str = "1m",
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> List[Candle]:
|
limit: Optional[int] = None) -> List[Candle]:
|
||||||
@@ -225,7 +223,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
def get_leaderboards_hist(self,
|
def get_leaderboards_hist(self,
|
||||||
resource: str,
|
resource: str,
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> List[Leaderboard]:
|
limit: Optional[int] = None) -> List[Leaderboard]:
|
||||||
@@ -236,7 +234,7 @@ class RestPublicEndpoints(Middleware):
|
|||||||
def get_leaderboards_last(self,
|
def get_leaderboards_last(self,
|
||||||
resource: str,
|
resource: str,
|
||||||
*,
|
*,
|
||||||
sort: Optional[Sort] = None,
|
sort: Optional[int] = None,
|
||||||
start: Optional[str] = None,
|
start: Optional[str] = None,
|
||||||
end: Optional[str] = None,
|
end: Optional[str] = None,
|
||||||
limit: Optional[int] = None) -> Leaderboard:
|
limit: Optional[int] = None) -> Leaderboard:
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
#pylint: disable-next=wildcard-import,unused-wildcard-import
|
|
||||||
from ..enums import *
|
|
||||||
|
|
||||||
class Config(str, Enum):
|
|
||||||
MAP_CURRENCY_SYM = "pub:map:currency:sym"
|
|
||||||
MAP_CURRENCY_LABEL = "pub:map:currency:label"
|
|
||||||
MAP_CURRENCY_UNIT = "pub:map:currency:unit"
|
|
||||||
MAP_CURRENCY_UNDL = "pub:map:currency:undl"
|
|
||||||
MAP_CURRENCY_POOL = "pub:map:currency:pool"
|
|
||||||
MAP_CURRENCY_EXPLORER = "pub:map:currency:explorer"
|
|
||||||
MAP_CURRENCY_TX_FEE = "pub:map:currency:tx:fee"
|
|
||||||
MAP_TX_METHOD = "pub:map:tx:method"
|
|
||||||
|
|
||||||
LIST_PAIR_EXCHANGE = "pub:list:pair:exchange"
|
|
||||||
LIST_PAIR_MARGIN = "pub:list:pair:margin"
|
|
||||||
LIST_PAIR_FUTURES = "pub:list:pair:futures"
|
|
||||||
LIST_PAIR_SECURITIES = "pub:list:pair:securities"
|
|
||||||
LIST_CURRENCY = "pub:list:currency"
|
|
||||||
LIST_COMPETITIONS = "pub:list:competitions"
|
|
||||||
|
|
||||||
INFO_PAIR = "pub:info:pair"
|
|
||||||
INFO_PAIR_FUTURES = "pub:info:pair:futures"
|
|
||||||
INFO_TX_STATUS = "pub:info:tx:status"
|
|
||||||
|
|
||||||
SPEC_MARGIN = "pub:spec:margin"
|
|
||||||
FEES = "pub:fees"
|
|
||||||
|
|
||||||
class Precision(str, Enum):
|
|
||||||
P0 = "P0"
|
|
||||||
P1 = "P1"
|
|
||||||
P2 = "P2"
|
|
||||||
P3 = "P3"
|
|
||||||
P4 = "P4"
|
|
||||||
|
|
||||||
class Sort(int, Enum):
|
|
||||||
ASCENDING = +1
|
|
||||||
DESCENDING = -1
|
|
||||||
|
|
||||||
class MerchantSettingsKey(str, Enum):
|
|
||||||
PREFERRED_FIAT = "bfx_pay_preferred_fiat"
|
|
||||||
RECOMMEND_STORE = "bfx_pay_recommend_store"
|
|
||||||
NOTIFY_PAYMENT_COMPLETED = "bfx_pay_notify_payment_completed"
|
|
||||||
NOTIFY_PAYMENT_COMPLETED_EMAIL = "bfx_pay_notify_payment_completed_email"
|
|
||||||
NOTIFY_AUTOCONVERT_EXECUTED = "bfx_pay_notify_autoconvert_executed"
|
|
||||||
DUST_BALANCE_UI = "bfx_pay_dust_balance_ui"
|
|
||||||
MERCHANT_CUSTOMER_SUPPORT_URL = "bfx_pay_merchant_customer_support_url"
|
|
||||||
MERCHANT_UNDERPAID_THRESHOLD = "bfx_pay_merchant_underpaid_threshold"
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
from typing import TYPE_CHECKING, Optional, Any
|
from typing import TYPE_CHECKING, Optional, Any
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
|
||||||
import time, hmac, hashlib, json, requests
|
import time, hmac, hashlib, json, requests
|
||||||
|
|
||||||
from ..enums import Error
|
|
||||||
from ..exceptions import ResourceNotFound, RequestParametersError, InvalidCredentialError, UnknownGenericError
|
from ..exceptions import ResourceNotFound, RequestParametersError, InvalidCredentialError, UnknownGenericError
|
||||||
from ..._utils.json_encoder import JSONEncoder
|
from ..._utils.json_encoder import JSONEncoder
|
||||||
from ..._utils.json_decoder import JSONDecoder
|
from ..._utils.json_decoder import JSONDecoder
|
||||||
@@ -12,6 +13,12 @@ from ..._utils.json_decoder import JSONDecoder
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from requests.sessions import _Params
|
from requests.sessions import _Params
|
||||||
|
|
||||||
|
class _Error(Enum):
|
||||||
|
ERR_UNK = 10000
|
||||||
|
ERR_GENERIC = 10001
|
||||||
|
ERR_PARAMS = 10020
|
||||||
|
ERR_AUTH_FAIL = 10100
|
||||||
|
|
||||||
class Middleware:
|
class Middleware:
|
||||||
TIMEOUT = 30
|
TIMEOUT = 30
|
||||||
|
|
||||||
@@ -53,11 +60,11 @@ class Middleware:
|
|||||||
data = response.json(cls=JSONDecoder)
|
data = response.json(cls=JSONDecoder)
|
||||||
|
|
||||||
if len(data) and data[0] == "error":
|
if len(data) and data[0] == "error":
|
||||||
if data[1] == Error.ERR_PARAMS:
|
if data[1] == _Error.ERR_PARAMS:
|
||||||
raise RequestParametersError("The request was rejected with the " \
|
raise RequestParametersError("The request was rejected with the " \
|
||||||
f"following parameter error: <{data[2]}>")
|
f"following parameter error: <{data[2]}>")
|
||||||
|
|
||||||
if data[1] is None or data[1] == Error.ERR_UNK or data[1] == Error.ERR_GENERIC:
|
if data[1] is None or data[1] == _Error.ERR_UNK or data[1] == _Error.ERR_GENERIC:
|
||||||
raise UnknownGenericError("The server replied to the request with " \
|
raise UnknownGenericError("The server replied to the request with " \
|
||||||
f"a generic error with message: <{data[2]}>.")
|
f"a generic error with message: <{data[2]}>.")
|
||||||
|
|
||||||
@@ -86,14 +93,14 @@ class Middleware:
|
|||||||
data = response.json(cls=JSONDecoder)
|
data = response.json(cls=JSONDecoder)
|
||||||
|
|
||||||
if isinstance(data, list) and len(data) and data[0] == "error":
|
if isinstance(data, list) and len(data) and data[0] == "error":
|
||||||
if data[1] == Error.ERR_PARAMS:
|
if data[1] == _Error.ERR_PARAMS:
|
||||||
raise RequestParametersError("The request was rejected with the " \
|
raise RequestParametersError("The request was rejected with the " \
|
||||||
f"following parameter error: <{data[2]}>")
|
f"following parameter error: <{data[2]}>")
|
||||||
|
|
||||||
if data[1] == Error.ERR_AUTH_FAIL:
|
if data[1] == _Error.ERR_AUTH_FAIL:
|
||||||
raise InvalidCredentialError("Cannot authenticate with given API-KEY and API-SECRET.")
|
raise InvalidCredentialError("Cannot authenticate with given API-KEY and API-SECRET.")
|
||||||
|
|
||||||
if data[1] is None or data[1] == Error.ERR_UNK or data[1] == Error.ERR_GENERIC:
|
if data[1] is None or data[1] == _Error.ERR_UNK or data[1] == _Error.ERR_GENERIC:
|
||||||
raise UnknownGenericError("The server replied to the request with " \
|
raise UnknownGenericError("The server replied to the request with " \
|
||||||
f"a generic error with message: <{data[2]}>.")
|
f"a generic error with message: <{data[2]}>.")
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
REST_HOST = "https://api.bitfinex.com/v2"
|
|
||||||
PUB_REST_HOST = "https://api-pub.bitfinex.com/v2"
|
|
||||||
|
|
||||||
WSS_HOST = "wss://api.bitfinex.com/ws/2"
|
|
||||||
PUB_WSS_HOST = "wss://api-pub.bitfinex.com/ws/2"
|
|
||||||
@@ -5,10 +5,6 @@ from typing import \
|
|||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from bfxapi.enums import \
|
|
||||||
OrderType, \
|
|
||||||
FundingOfferType
|
|
||||||
|
|
||||||
_Handler = Callable[[str, Any], Awaitable[None]]
|
_Handler = Callable[[str, Any], Awaitable[None]]
|
||||||
|
|
||||||
class BfxWebSocketInputs:
|
class BfxWebSocketInputs:
|
||||||
@@ -16,7 +12,7 @@ class BfxWebSocketInputs:
|
|||||||
self.__handle_websocket_input = handle_websocket_input
|
self.__handle_websocket_input = handle_websocket_input
|
||||||
|
|
||||||
async def submit_order(self,
|
async def submit_order(self,
|
||||||
type: OrderType,
|
type: str,
|
||||||
symbol: str,
|
symbol: str,
|
||||||
amount: Union[str, float, Decimal],
|
amount: Union[str, float, Decimal],
|
||||||
price: Union[str, float, Decimal],
|
price: Union[str, float, Decimal],
|
||||||
@@ -79,7 +75,7 @@ class BfxWebSocketInputs:
|
|||||||
|
|
||||||
#pylint: disable-next=too-many-arguments
|
#pylint: disable-next=too-many-arguments
|
||||||
async def submit_funding_offer(self,
|
async def submit_funding_offer(self,
|
||||||
type: FundingOfferType,
|
type: str,
|
||||||
symbol: str,
|
symbol: str,
|
||||||
amount: Union[str, float, Decimal],
|
amount: Union[str, float, Decimal],
|
||||||
rate: Union[str, float, Decimal],
|
rate: Union[str, float, Decimal],
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
#pylint: disable-next=wildcard-import,unused-wildcard-import
|
|
||||||
from bfxapi.enums import *
|
|
||||||
|
|
||||||
class Channel(str, Enum):
|
|
||||||
TICKER = "ticker"
|
|
||||||
TRADES = "trades"
|
|
||||||
BOOK = "book"
|
|
||||||
CANDLES = "candles"
|
|
||||||
STATUS = "status"
|
|
||||||
8
setup.py
8
setup.py
@@ -1,12 +1,12 @@
|
|||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
version = {}
|
_version = {}
|
||||||
with open("bfxapi/version.py", encoding="utf-8") as fp:
|
with open("bfxapi/_version.py", encoding="utf-8") as fp:
|
||||||
exec(fp.read(), version) #pylint: disable=exec-used
|
exec(fp.read(), _version) #pylint: disable=exec-used
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="bitfinex-api-py",
|
name="bitfinex-api-py",
|
||||||
version=version["__version__"],
|
version=_version["__version__"],
|
||||||
description="Official Bitfinex Python API",
|
description="Official Bitfinex Python API",
|
||||||
long_description="A Python reference implementation of the Bitfinex API for both REST and websocket interaction",
|
long_description="A Python reference implementation of the Bitfinex API for both REST and websocket interaction",
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|||||||
Reference in New Issue
Block a user