mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 14:54:21 +01:00
Merge bfxapi.rest.types and bfxapi.websocket.types in bfxapi.tests sub-package.
This commit is contained in:
26
bfxapi/types/__init__.py
Normal file
26
bfxapi/types/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from . dataclasses import JSON, \
|
||||
PlatformStatus, TradingPairTicker, FundingCurrencyTicker, \
|
||||
TickersHistory, TradingPairTrade, FundingCurrencyTrade, \
|
||||
TradingPairBook, FundingCurrencyBook, TradingPairRawBook, \
|
||||
FundingCurrencyRawBook, Statistic, Candle, \
|
||||
DerivativesStatus, Liquidation, Leaderboard, \
|
||||
FundingStatistic, PulseProfile, PulseMessage, \
|
||||
TradingMarketAveragePrice, FundingMarketAveragePrice, FxRate
|
||||
|
||||
from . dataclasses import \
|
||||
UserInfo, LoginHistory, BalanceAvailable, \
|
||||
Order, Position, Trade, \
|
||||
FundingTrade, OrderTrade, Ledger, \
|
||||
FundingOffer, FundingCredit, FundingLoan, \
|
||||
FundingAutoRenew, FundingInfo, Wallet, \
|
||||
Transfer, Withdrawal, DepositAddress, \
|
||||
LightningNetworkInvoice, Movement, SymbolMarginInfo, \
|
||||
BaseMarginInfo, PositionClaim, PositionIncreaseInfo, \
|
||||
PositionIncrease, PositionHistory, PositionSnapshot, \
|
||||
PositionAudit, DerivativePositionCollateral, DerivativePositionCollateralLimits
|
||||
|
||||
from . dataclasses import \
|
||||
InvoiceSubmission, InvoicePage, InvoiceStats, \
|
||||
CurrencyConversion, MerchantDeposit, MerchantUnlinkedDeposit
|
||||
|
||||
from . notification import Notification
|
||||
694
bfxapi/types/dataclasses.py
Normal file
694
bfxapi/types/dataclasses.py
Normal file
@@ -0,0 +1,694 @@
|
||||
from typing import Union, Type, \
|
||||
List, Dict, Literal, Optional, Any
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from . labeler import _Type, partial, compose
|
||||
|
||||
JSON = Union[Dict[str, "JSON"], List["JSON"], bool, int, float, str, Type[None]]
|
||||
|
||||
#region Dataclass definitions for types of public use
|
||||
|
||||
@dataclass
|
||||
class PlatformStatus(_Type):
|
||||
status: int
|
||||
|
||||
@dataclass
|
||||
class TradingPairTicker(_Type):
|
||||
bid: float
|
||||
bid_size: float
|
||||
ask: float
|
||||
ask_size: float
|
||||
daily_change: float
|
||||
daily_change_relative: float
|
||||
last_price: float
|
||||
volume: float
|
||||
high: float
|
||||
low: float
|
||||
|
||||
@dataclass
|
||||
class FundingCurrencyTicker(_Type):
|
||||
frr: float
|
||||
bid: float
|
||||
bid_period: int
|
||||
bid_size: float
|
||||
ask: float
|
||||
ask_period: int
|
||||
ask_size: float
|
||||
daily_change: float
|
||||
daily_change_relative: float
|
||||
last_price: float
|
||||
volume: float
|
||||
high: float
|
||||
low: float
|
||||
frr_amount_available: float
|
||||
|
||||
@dataclass
|
||||
class TickersHistory(_Type):
|
||||
symbol: str
|
||||
bid: float
|
||||
ask: float
|
||||
mts: int
|
||||
|
||||
@dataclass
|
||||
class TradingPairTrade(_Type):
|
||||
id: int
|
||||
mts: int
|
||||
amount: float
|
||||
price: float
|
||||
|
||||
@dataclass
|
||||
class FundingCurrencyTrade(_Type):
|
||||
id: int
|
||||
mts: int
|
||||
amount: float
|
||||
rate: float
|
||||
period: int
|
||||
|
||||
@dataclass
|
||||
class TradingPairBook(_Type):
|
||||
price: float
|
||||
count: int
|
||||
amount: float
|
||||
|
||||
@dataclass
|
||||
class FundingCurrencyBook(_Type):
|
||||
rate: float
|
||||
period: int
|
||||
count: int
|
||||
amount: float
|
||||
|
||||
@dataclass
|
||||
class TradingPairRawBook(_Type):
|
||||
order_id: int
|
||||
price: float
|
||||
amount: float
|
||||
|
||||
@dataclass
|
||||
class FundingCurrencyRawBook(_Type):
|
||||
offer_id: int
|
||||
period: int
|
||||
rate: float
|
||||
amount: float
|
||||
|
||||
@dataclass
|
||||
class Statistic(_Type):
|
||||
mts: int
|
||||
value: float
|
||||
|
||||
@dataclass
|
||||
class Candle(_Type):
|
||||
mts: int
|
||||
open: int
|
||||
close: int
|
||||
high: int
|
||||
low: int
|
||||
volume: float
|
||||
|
||||
@dataclass
|
||||
class DerivativesStatus(_Type):
|
||||
mts: int
|
||||
deriv_price: float
|
||||
spot_price: float
|
||||
insurance_fund_balance: float
|
||||
next_funding_evt_mts: int
|
||||
next_funding_accrued: float
|
||||
next_funding_step: int
|
||||
current_funding: float
|
||||
mark_price: float
|
||||
open_interest: float
|
||||
clamp_min: float
|
||||
clamp_max: float
|
||||
|
||||
@dataclass
|
||||
class Liquidation(_Type):
|
||||
pos_id: int
|
||||
mts: int
|
||||
symbol: str
|
||||
amount: float
|
||||
base_price: float
|
||||
is_match: int
|
||||
is_market_sold: int
|
||||
price_acquired: float
|
||||
|
||||
@dataclass
|
||||
class Leaderboard(_Type):
|
||||
mts: int
|
||||
username: str
|
||||
ranking: int
|
||||
value: float
|
||||
twitter_handle: Optional[str]
|
||||
|
||||
@dataclass
|
||||
class FundingStatistic(_Type):
|
||||
mts: int
|
||||
frr: float
|
||||
avg_period: float
|
||||
funding_amount: float
|
||||
funding_amount_used: float
|
||||
funding_below_threshold: float
|
||||
|
||||
@dataclass
|
||||
class PulseProfile(_Type):
|
||||
puid: str
|
||||
mts: int
|
||||
nickname: str
|
||||
picture: str
|
||||
text: str
|
||||
twitter_handle: str
|
||||
followers: int
|
||||
following: int
|
||||
tipping_status: int
|
||||
|
||||
@dataclass
|
||||
class PulseMessage(_Type):
|
||||
pid: str
|
||||
mts: int
|
||||
puid: str
|
||||
title: str
|
||||
content: str
|
||||
is_pin: int
|
||||
is_public: int
|
||||
comments_disabled: int
|
||||
tags: List[str]
|
||||
attachments: List[str]
|
||||
meta: List[JSON]
|
||||
likes: int
|
||||
profile: PulseProfile
|
||||
comments: int
|
||||
|
||||
@dataclass
|
||||
class TradingMarketAveragePrice(_Type):
|
||||
price_avg: float
|
||||
amount: float
|
||||
|
||||
@dataclass
|
||||
class FundingMarketAveragePrice(_Type):
|
||||
rate_avg: float
|
||||
amount: float
|
||||
|
||||
@dataclass
|
||||
class FxRate(_Type):
|
||||
current_rate: float
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dataclass definitions for types of auth use
|
||||
|
||||
@dataclass
|
||||
class UserInfo(_Type):
|
||||
id: int
|
||||
email: str
|
||||
username: str
|
||||
mts_account_create: int
|
||||
verified: int
|
||||
verification_level: int
|
||||
timezone: str
|
||||
locale: str
|
||||
company: str
|
||||
email_verified: int
|
||||
mts_master_account_create: int
|
||||
group_id: int
|
||||
master_account_id: int
|
||||
inherit_master_account_verification: int
|
||||
is_group_master: int
|
||||
group_withdraw_enabled: int
|
||||
ppt_enabled: int
|
||||
merchant_enabled: int
|
||||
competition_enabled: int
|
||||
two_factors_authentication_modes: List[str]
|
||||
is_securities_master: int
|
||||
securities_enabled: int
|
||||
allow_disable_ctxswitch: int
|
||||
time_last_login: int
|
||||
ctxtswitch_disabled: int
|
||||
comp_countries: List[str]
|
||||
compl_countries_resid: List[str]
|
||||
is_merchant_enterprise: int
|
||||
|
||||
@dataclass
|
||||
class LoginHistory(_Type):
|
||||
id: int
|
||||
time: int
|
||||
ip: str
|
||||
extra_info: JSON
|
||||
|
||||
@dataclass
|
||||
class BalanceAvailable(_Type):
|
||||
amount: float
|
||||
|
||||
@dataclass
|
||||
class Order(_Type):
|
||||
id: int
|
||||
gid: int
|
||||
cid: int
|
||||
symbol: str
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
amount: float
|
||||
amount_orig: float
|
||||
order_type: str
|
||||
type_prev: str
|
||||
mts_tif: int
|
||||
flags: int
|
||||
order_status: str
|
||||
price: float
|
||||
price_avg: float
|
||||
price_trailing: float
|
||||
price_aux_limit: float
|
||||
notify: int
|
||||
hidden: int
|
||||
placed_id: int
|
||||
routing: str
|
||||
meta: JSON
|
||||
|
||||
@dataclass
|
||||
class Position(_Type):
|
||||
symbol: str
|
||||
status: str
|
||||
amount: float
|
||||
base_price: float
|
||||
margin_funding: float
|
||||
margin_funding_type: int
|
||||
pl: float
|
||||
pl_perc: float
|
||||
price_liq: float
|
||||
leverage: float
|
||||
position_id: int
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
type: int
|
||||
collateral: float
|
||||
collateral_min: float
|
||||
meta: JSON
|
||||
|
||||
@dataclass
|
||||
class Trade(_Type):
|
||||
id: int
|
||||
symbol: str
|
||||
mts_create: int
|
||||
order_id: int
|
||||
exec_amount: float
|
||||
exec_price: float
|
||||
order_type: str
|
||||
order_price: float
|
||||
maker:int
|
||||
fee: float
|
||||
fee_currency: str
|
||||
cid: int
|
||||
|
||||
@dataclass()
|
||||
class FundingTrade(_Type):
|
||||
id: int
|
||||
currency: str
|
||||
mts_create: int
|
||||
offer_id: int
|
||||
amount: float
|
||||
rate: float
|
||||
period: int
|
||||
|
||||
@dataclass
|
||||
class OrderTrade(_Type):
|
||||
id: int
|
||||
symbol: str
|
||||
mts_create: int
|
||||
order_id: int
|
||||
exec_amount: float
|
||||
exec_price: float
|
||||
maker:int
|
||||
fee: float
|
||||
fee_currency: str
|
||||
cid: int
|
||||
|
||||
@dataclass
|
||||
class Ledger(_Type):
|
||||
id: int
|
||||
currency: str
|
||||
mts: int
|
||||
amount: float
|
||||
balance: float
|
||||
description: str
|
||||
|
||||
@dataclass
|
||||
class FundingOffer(_Type):
|
||||
id: int
|
||||
symbol: str
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
amount: float
|
||||
amount_orig: float
|
||||
offer_type: str
|
||||
flags: int
|
||||
offer_status: str
|
||||
rate: float
|
||||
period: int
|
||||
notify: int
|
||||
hidden: int
|
||||
renew: int
|
||||
|
||||
@dataclass
|
||||
class FundingCredit(_Type):
|
||||
id: int
|
||||
symbol: str
|
||||
side: int
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
amount: float
|
||||
flags: int
|
||||
status: str
|
||||
rate_type: str
|
||||
rate: float
|
||||
period: int
|
||||
mts_opening: int
|
||||
mts_last_payout: int
|
||||
notify: int
|
||||
hidden: int
|
||||
renew: int
|
||||
no_close: int
|
||||
position_pair: str
|
||||
|
||||
@dataclass
|
||||
class FundingLoan(_Type):
|
||||
id: int
|
||||
symbol: str
|
||||
side: int
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
amount: float
|
||||
flags: int
|
||||
status: str
|
||||
rate_type: str
|
||||
rate: float
|
||||
period: int
|
||||
mts_opening: int
|
||||
mts_last_payout: int
|
||||
notify: int
|
||||
hidden: int
|
||||
renew: int
|
||||
no_close: int
|
||||
|
||||
@dataclass
|
||||
class FundingAutoRenew(_Type):
|
||||
currency: str
|
||||
period: int
|
||||
rate: float
|
||||
threshold: float
|
||||
|
||||
@dataclass()
|
||||
class FundingInfo(_Type):
|
||||
yield_loan: float
|
||||
yield_lend: float
|
||||
duration_loan: float
|
||||
duration_lend: float
|
||||
|
||||
@dataclass
|
||||
class Wallet(_Type):
|
||||
wallet_type: str
|
||||
currency: str
|
||||
balance: float
|
||||
unsettled_interest: float
|
||||
available_balance: float
|
||||
last_change: str
|
||||
trade_details: JSON
|
||||
|
||||
@dataclass
|
||||
class Transfer(_Type):
|
||||
mts: int
|
||||
wallet_from: str
|
||||
wallet_to: str
|
||||
currency: str
|
||||
currency_to: str
|
||||
amount: int
|
||||
|
||||
@dataclass
|
||||
class Withdrawal(_Type):
|
||||
withdrawal_id: int
|
||||
method: str
|
||||
payment_id: str
|
||||
wallet: str
|
||||
amount: float
|
||||
withdrawal_fee: float
|
||||
|
||||
@dataclass
|
||||
class DepositAddress(_Type):
|
||||
method: str
|
||||
currency_code: str
|
||||
address: str
|
||||
pool_address: str
|
||||
|
||||
@dataclass
|
||||
class LightningNetworkInvoice(_Type):
|
||||
invoice_hash: str
|
||||
invoice: str
|
||||
amount: str
|
||||
|
||||
@dataclass
|
||||
class Movement(_Type):
|
||||
id: str
|
||||
currency: str
|
||||
currency_name: str
|
||||
mts_start: int
|
||||
mts_update: int
|
||||
status: str
|
||||
amount: int
|
||||
fees: int
|
||||
destination_address: str
|
||||
transaction_id: str
|
||||
withdraw_transaction_note: str
|
||||
|
||||
@dataclass
|
||||
class SymbolMarginInfo(_Type):
|
||||
symbol: str
|
||||
tradable_balance: float
|
||||
gross_balance: float
|
||||
buy: float
|
||||
sell: float
|
||||
|
||||
@dataclass
|
||||
class BaseMarginInfo(_Type):
|
||||
user_pl: float
|
||||
user_swaps: float
|
||||
margin_balance: float
|
||||
margin_net: float
|
||||
margin_min: float
|
||||
|
||||
@dataclass
|
||||
class PositionClaim(_Type):
|
||||
symbol: str
|
||||
position_status: str
|
||||
amount: float
|
||||
base_price: float
|
||||
margin_funding: float
|
||||
margin_funding_type: int
|
||||
position_id: int
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
pos_type: int
|
||||
collateral: str
|
||||
min_collateral: str
|
||||
meta: JSON
|
||||
|
||||
@dataclass
|
||||
class PositionIncreaseInfo(_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 PositionIncrease(_Type):
|
||||
symbol: str
|
||||
amount: float
|
||||
base_price: float
|
||||
|
||||
@dataclass
|
||||
class PositionHistory(_Type):
|
||||
symbol: str
|
||||
status: str
|
||||
amount: float
|
||||
base_price: float
|
||||
funding: float
|
||||
funding_type: int
|
||||
position_id: int
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
|
||||
@dataclass
|
||||
class PositionSnapshot(_Type):
|
||||
symbol: str
|
||||
status: str
|
||||
amount: float
|
||||
base_price: float
|
||||
funding: float
|
||||
funding_type: int
|
||||
position_id: int
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
|
||||
@dataclass
|
||||
class PositionAudit(_Type):
|
||||
symbol: str
|
||||
status: str
|
||||
amount: float
|
||||
base_price: float
|
||||
funding: float
|
||||
funding_type: int
|
||||
position_id: int
|
||||
mts_create: int
|
||||
mts_update: int
|
||||
type: int
|
||||
collateral: float
|
||||
collateral_min: float
|
||||
meta: JSON
|
||||
|
||||
@dataclass
|
||||
class DerivativePositionCollateral(_Type):
|
||||
status: int
|
||||
|
||||
@dataclass
|
||||
class DerivativePositionCollateralLimits(_Type):
|
||||
min_collateral: float
|
||||
max_collateral: float
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dataclass definitions for types of merchant use
|
||||
|
||||
@compose(dataclass, partial)
|
||||
class InvoiceSubmission(_Type):
|
||||
id: str
|
||||
t: int
|
||||
type: Literal["ECOMMERCE", "POS"]
|
||||
duration: int
|
||||
amount: float
|
||||
currency: str
|
||||
order_id: str
|
||||
pay_currencies: List[str]
|
||||
webhook: str
|
||||
redirect_url: str
|
||||
status: Literal["CREATED", "PENDING", "COMPLETED", "EXPIRED"]
|
||||
customer_info: "CustomerInfo"
|
||||
invoices: List["Invoice"]
|
||||
payment: "Payment"
|
||||
additional_payments: List["Payment"]
|
||||
merchant_name: str
|
||||
|
||||
@classmethod
|
||||
def parse(cls, data: Dict[str, Any]) -> "InvoiceSubmission":
|
||||
if "customer_info" in data and data["customer_info"] is not None:
|
||||
data["customer_info"] = InvoiceSubmission.CustomerInfo(**data["customer_info"])
|
||||
|
||||
for index, invoice in enumerate(data["invoices"]):
|
||||
data["invoices"][index] = InvoiceSubmission.Invoice(**invoice)
|
||||
|
||||
if "payment" in data and data["payment"] is not None:
|
||||
data["payment"] = InvoiceSubmission.Payment(**data["payment"])
|
||||
|
||||
if "additional_payments" in data and data["additional_payments"] is not None:
|
||||
for index, additional_payment in enumerate(data["additional_payments"]):
|
||||
data["additional_payments"][index] = InvoiceSubmission.Payment(**additional_payment)
|
||||
|
||||
return InvoiceSubmission(**data)
|
||||
|
||||
@compose(dataclass, partial)
|
||||
class CustomerInfo:
|
||||
nationality: str
|
||||
resid_country: str
|
||||
resid_state: str
|
||||
resid_city: str
|
||||
resid_zip_code: str
|
||||
resid_street: str
|
||||
resid_building_no: str
|
||||
full_name: str
|
||||
email: str
|
||||
tos_accepted: bool
|
||||
|
||||
@compose(dataclass, partial)
|
||||
class Invoice:
|
||||
amount: float
|
||||
currency: str
|
||||
pay_currency: str
|
||||
pool_currency: str
|
||||
address: str
|
||||
ext: JSON
|
||||
|
||||
@compose(dataclass, partial)
|
||||
class Payment:
|
||||
txid: str
|
||||
amount: float
|
||||
currency: str
|
||||
method: str
|
||||
status: Literal["CREATED", "COMPLETED", "PROCESSING"]
|
||||
confirmations: int
|
||||
created_at: str
|
||||
updated_at: str
|
||||
deposit_id: int
|
||||
ledger_id: int
|
||||
force_completed: bool
|
||||
amount_diff: str
|
||||
|
||||
@dataclass
|
||||
class InvoicePage(_Type):
|
||||
page: int
|
||||
page_size: int
|
||||
sort: Literal["asc", "desc"]
|
||||
sort_field: Literal["t", "amount", "status"]
|
||||
total_pages: int
|
||||
total_items: int
|
||||
items: List[InvoiceSubmission]
|
||||
|
||||
@classmethod
|
||||
def parse(cls, data: Dict[str, Any]) -> "InvoicePage":
|
||||
for index, item in enumerate(data["items"]):
|
||||
data["items"][index] = InvoiceSubmission.parse(item)
|
||||
|
||||
return InvoicePage(**data)
|
||||
|
||||
@dataclass
|
||||
class InvoiceStats(_Type):
|
||||
time: str
|
||||
count: float
|
||||
|
||||
@dataclass
|
||||
class CurrencyConversion(_Type):
|
||||
base_currency: str
|
||||
convert_currency: str
|
||||
created: int
|
||||
|
||||
@dataclass
|
||||
class MerchantDeposit(_Type):
|
||||
id: int
|
||||
invoice_id: Optional[str]
|
||||
order_id: Optional[str]
|
||||
type: Literal["ledger", "deposit"]
|
||||
amount: float
|
||||
t: int
|
||||
txid: str
|
||||
currency: str
|
||||
method: str
|
||||
pay_method: str
|
||||
|
||||
@dataclass
|
||||
class MerchantUnlinkedDeposit(_Type):
|
||||
id: int
|
||||
method: str
|
||||
currency: str
|
||||
created_at: int
|
||||
updated_at: int
|
||||
amount: float
|
||||
fee: float
|
||||
txid: str
|
||||
address: str
|
||||
payment_id: Optional[int]
|
||||
status: str
|
||||
note: Optional[str]
|
||||
|
||||
#endregion
|
||||
96
bfxapi/types/labeler.py
Normal file
96
bfxapi/types/labeler.py
Normal file
@@ -0,0 +1,96 @@
|
||||
from typing import Type, Generic, TypeVar, Iterable, \
|
||||
Dict, List, Tuple, Any, cast
|
||||
|
||||
T = TypeVar("T", bound="_Type")
|
||||
|
||||
def compose(*decorators):
|
||||
def wrapper(function):
|
||||
for decorator in reversed(decorators):
|
||||
function = decorator(function)
|
||||
return function
|
||||
|
||||
return wrapper
|
||||
|
||||
def partial(cls):
|
||||
def __init__(self, **kwargs):
|
||||
for annotation in self.__annotations__.keys():
|
||||
if annotation not in kwargs:
|
||||
self.__setattr__(annotation, None)
|
||||
else: self.__setattr__(annotation, kwargs[annotation])
|
||||
|
||||
kwargs.pop(annotation, None)
|
||||
|
||||
if len(kwargs) != 0:
|
||||
raise TypeError(f"{cls.__name__}.__init__() got an unexpected keyword argument '{list(kwargs.keys())[0]}'")
|
||||
|
||||
cls.__init__ = __init__
|
||||
|
||||
return cls
|
||||
|
||||
class _Type:
|
||||
"""
|
||||
Base class for any dataclass serializable by the _Serializer generic class.
|
||||
"""
|
||||
|
||||
class _Serializer(Generic[T]):
|
||||
def __init__(self, name: str, klass: Type[_Type], labels: List[str],
|
||||
*, flat: bool = False, ignore: List[str] = [ "_PLACEHOLDER" ]):
|
||||
self.name, self.klass, self.__labels, self.__flat, self.__ignore = name, klass, labels, flat, ignore
|
||||
|
||||
def _serialize(self, *args: Any) -> Iterable[Tuple[str, Any]]:
|
||||
if self.__flat:
|
||||
args = tuple(_Serializer.__flatten(list(args)))
|
||||
|
||||
if len(self.__labels) > len(args):
|
||||
raise AssertionError(f"{self.name} -> <labels> and <*args> " \
|
||||
"arguments should contain the same amount of elements.")
|
||||
|
||||
for index, label in enumerate(self.__labels):
|
||||
if label not in self.__ignore:
|
||||
yield label, args[index]
|
||||
|
||||
def parse(self, *values: Any) -> T:
|
||||
return cast(T, self.klass(**dict(self._serialize(*values))))
|
||||
|
||||
def get_labels(self) -> List[str]:
|
||||
return [ label for label in self.__labels if label not in self.__ignore ]
|
||||
|
||||
@classmethod
|
||||
def __flatten(cls, array: List[Any]) -> List[Any]:
|
||||
if len(array) == 0:
|
||||
return array
|
||||
|
||||
if isinstance(array[0], list):
|
||||
return cls.__flatten(array[0]) + cls.__flatten(array[1:])
|
||||
|
||||
return array[:1] + cls.__flatten(array[1:])
|
||||
|
||||
class _RecursiveSerializer(_Serializer, Generic[T]):
|
||||
def __init__(self, name: str, klass: Type[_Type], labels: List[str],
|
||||
*, serializers: Dict[str, _Serializer[Any]],
|
||||
flat: bool = False, ignore: List[str] = [ "_PLACEHOLDER" ]):
|
||||
super().__init__(name, klass, labels, flat=flat, ignore=ignore)
|
||||
|
||||
self.serializers = serializers
|
||||
|
||||
def parse(self, *values: Any) -> T:
|
||||
serialization = dict(self._serialize(*values))
|
||||
|
||||
for key in serialization:
|
||||
if key in self.serializers.keys():
|
||||
serialization[key] = self.serializers[key].parse(*serialization[key])
|
||||
|
||||
return cast(T, self.klass(**serialization))
|
||||
|
||||
def generate_labeler_serializer(name: str, klass: Type[T], labels: List[str],
|
||||
*, flat: bool = False, ignore: List[str] = [ "_PLACEHOLDER" ]
|
||||
) -> _Serializer[T]:
|
||||
return _Serializer[T](name, klass, labels, \
|
||||
flat=flat, ignore=ignore)
|
||||
|
||||
def generate_recursive_serializer(name: str, klass: Type[T], labels: List[str],
|
||||
*, serializers: Dict[str, _Serializer[Any]],
|
||||
flat: bool = False, ignore: List[str] = [ "_PLACEHOLDER" ]
|
||||
) -> _RecursiveSerializer[T]:
|
||||
return _RecursiveSerializer[T](name, klass, labels, \
|
||||
serializers=serializers, flat=flat, ignore=ignore)
|
||||
38
bfxapi/types/notification.py
Normal file
38
bfxapi/types/notification.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from typing import List, Optional, Any, Generic, TypeVar, cast
|
||||
from dataclasses import dataclass
|
||||
from . labeler import _Type, _Serializer
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
@dataclass
|
||||
class Notification(_Type, Generic[T]):
|
||||
mts: int
|
||||
type: str
|
||||
message_id: Optional[int]
|
||||
data: T
|
||||
code: Optional[int]
|
||||
status: str
|
||||
text: str
|
||||
|
||||
class _Notification(_Serializer, Generic[T]):
|
||||
__LABELS = [ "mts", "type", "message_id", "_PLACEHOLDER", "data", "code", "status", "text" ]
|
||||
|
||||
def __init__(self, serializer: Optional[_Serializer] = None, is_iterable: bool = False):
|
||||
super().__init__("Notification", Notification, _Notification.__LABELS, ignore = [ "_PLACEHOLDER" ])
|
||||
|
||||
self.serializer, self.is_iterable = serializer, is_iterable
|
||||
|
||||
def parse(self, *values: Any) -> Notification[T]:
|
||||
notification = cast(Notification[T], Notification(**dict(self._serialize(*values))))
|
||||
|
||||
if isinstance(self.serializer, _Serializer):
|
||||
data = cast(List[Any], notification.data)
|
||||
|
||||
if not self.is_iterable:
|
||||
if len(data) == 1 and isinstance(data[0], list):
|
||||
data = data[0]
|
||||
|
||||
notification.data = self.serializer.parse(*data)
|
||||
else: notification.data = cast(T, [ self.serializer.parse(*sub_data) for sub_data in data ])
|
||||
|
||||
return notification
|
||||
959
bfxapi/types/serializers.py
Normal file
959
bfxapi/types/serializers.py
Normal file
@@ -0,0 +1,959 @@
|
||||
from . import dataclasses
|
||||
|
||||
from . labeler import \
|
||||
generate_labeler_serializer, generate_recursive_serializer
|
||||
|
||||
#pylint: disable-next=unused-import
|
||||
from . notification import _Notification
|
||||
|
||||
__serializers__ = [
|
||||
"PlatformStatus", "TradingPairTicker", "FundingCurrencyTicker",
|
||||
"TickersHistory", "TradingPairTrade", "FundingCurrencyTrade",
|
||||
"TradingPairBook", "FundingCurrencyBook", "TradingPairRawBook",
|
||||
"FundingCurrencyRawBook", "Statistic", "Candle",
|
||||
"DerivativesStatus", "Liquidation", "Leaderboard",
|
||||
"FundingStatistic", "PulseProfile", "PulseMessage",
|
||||
"TradingMarketAveragePrice", "FundingMarketAveragePrice", "FxRate",
|
||||
|
||||
"UserInfo", "LoginHistory", "BalanceAvailable",
|
||||
"Order", "Position", "Trade",
|
||||
"FundingTrade", "OrderTrade", "Ledger",
|
||||
"FundingOffer", "FundingCredit", "FundingLoan",
|
||||
"FundingAutoRenew", "FundingInfo", "Wallet",
|
||||
"Transfer", "Withdrawal", "DepositAddress",
|
||||
"LightningNetworkInvoice", "Movement", "SymbolMarginInfo",
|
||||
"BaseMarginInfo", "PositionClaim", "PositionIncreaseInfo",
|
||||
"PositionIncrease", "PositionHistory", "PositionSnapshot",
|
||||
"PositionAudit", "DerivativePositionCollateral", "DerivativePositionCollateralLimits",
|
||||
]
|
||||
|
||||
#region Serializer definitions for types of public use
|
||||
|
||||
PlatformStatus = generate_labeler_serializer(
|
||||
name="PlatformStatus",
|
||||
klass=dataclasses.PlatformStatus,
|
||||
labels=[
|
||||
"status"
|
||||
]
|
||||
)
|
||||
|
||||
TradingPairTicker = generate_labeler_serializer(
|
||||
name="TradingPairTicker",
|
||||
klass=dataclasses.TradingPairTicker,
|
||||
labels=[
|
||||
"bid",
|
||||
"bid_size",
|
||||
"ask",
|
||||
"ask_size",
|
||||
"daily_change",
|
||||
"daily_change_relative",
|
||||
"last_price",
|
||||
"volume",
|
||||
"high",
|
||||
"low"
|
||||
]
|
||||
)
|
||||
|
||||
FundingCurrencyTicker = generate_labeler_serializer(
|
||||
name="FundingCurrencyTicker",
|
||||
klass=dataclasses.FundingCurrencyTicker,
|
||||
labels=[
|
||||
"frr",
|
||||
"bid",
|
||||
"bid_period",
|
||||
"bid_size",
|
||||
"ask",
|
||||
"ask_period",
|
||||
"ask_size",
|
||||
"daily_change",
|
||||
"daily_change_relative",
|
||||
"last_price",
|
||||
"volume",
|
||||
"high",
|
||||
"low",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"frr_amount_available"
|
||||
]
|
||||
)
|
||||
|
||||
TickersHistory = generate_labeler_serializer(
|
||||
name="TickersHistory",
|
||||
klass=dataclasses.TickersHistory,
|
||||
labels=[
|
||||
"symbol",
|
||||
"bid",
|
||||
"_PLACEHOLDER",
|
||||
"ask",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"mts"
|
||||
]
|
||||
)
|
||||
|
||||
TradingPairTrade = generate_labeler_serializer(
|
||||
name="TradingPairTrade",
|
||||
klass=dataclasses.TradingPairTrade,
|
||||
labels=[
|
||||
"id",
|
||||
"mts",
|
||||
"amount",
|
||||
"price"
|
||||
]
|
||||
)
|
||||
|
||||
FundingCurrencyTrade = generate_labeler_serializer(
|
||||
name="FundingCurrencyTrade",
|
||||
klass=dataclasses.FundingCurrencyTrade,
|
||||
labels=[
|
||||
"id",
|
||||
"mts",
|
||||
"amount",
|
||||
"rate",
|
||||
"period"
|
||||
]
|
||||
)
|
||||
|
||||
TradingPairBook = generate_labeler_serializer(
|
||||
name="TradingPairBook",
|
||||
klass=dataclasses.TradingPairBook,
|
||||
labels=[
|
||||
"price",
|
||||
"count",
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
FundingCurrencyBook = generate_labeler_serializer(
|
||||
name="FundingCurrencyBook",
|
||||
klass=dataclasses.FundingCurrencyBook,
|
||||
labels=[
|
||||
"rate",
|
||||
"period",
|
||||
"count",
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
TradingPairRawBook = generate_labeler_serializer(
|
||||
name="TradingPairRawBook",
|
||||
klass=dataclasses.TradingPairRawBook,
|
||||
labels=[
|
||||
"order_id",
|
||||
"price",
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
FundingCurrencyRawBook = generate_labeler_serializer(
|
||||
name="FundingCurrencyRawBook",
|
||||
klass=dataclasses.FundingCurrencyRawBook,
|
||||
labels=[
|
||||
"offer_id",
|
||||
"period",
|
||||
"rate",
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
Statistic = generate_labeler_serializer(
|
||||
name="Statistic",
|
||||
klass=dataclasses.Statistic,
|
||||
labels=[
|
||||
"mts",
|
||||
"value"
|
||||
]
|
||||
)
|
||||
|
||||
Candle = generate_labeler_serializer(
|
||||
name="Candle",
|
||||
klass=dataclasses.Candle,
|
||||
labels=[
|
||||
"mts",
|
||||
"open",
|
||||
"close",
|
||||
"high",
|
||||
"low",
|
||||
"volume"
|
||||
]
|
||||
)
|
||||
|
||||
DerivativesStatus = generate_labeler_serializer(
|
||||
name="DerivativesStatus",
|
||||
klass=dataclasses.DerivativesStatus,
|
||||
labels=[
|
||||
"mts",
|
||||
"_PLACEHOLDER",
|
||||
"deriv_price",
|
||||
"spot_price",
|
||||
"_PLACEHOLDER",
|
||||
"insurance_fund_balance",
|
||||
"_PLACEHOLDER",
|
||||
"next_funding_evt_mts",
|
||||
"next_funding_accrued",
|
||||
"next_funding_step",
|
||||
"_PLACEHOLDER",
|
||||
"current_funding",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"mark_price",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"open_interest",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"clamp_min",
|
||||
"clamp_max"
|
||||
]
|
||||
)
|
||||
|
||||
Liquidation = generate_labeler_serializer(
|
||||
name="Liquidation",
|
||||
klass=dataclasses.Liquidation,
|
||||
labels=[
|
||||
"_PLACEHOLDER",
|
||||
"pos_id",
|
||||
"mts",
|
||||
"_PLACEHOLDER",
|
||||
"symbol",
|
||||
"amount",
|
||||
"base_price",
|
||||
"_PLACEHOLDER",
|
||||
"is_match",
|
||||
"is_market_sold",
|
||||
"_PLACEHOLDER",
|
||||
"price_acquired"
|
||||
]
|
||||
)
|
||||
|
||||
Leaderboard = generate_labeler_serializer(
|
||||
name="Leaderboard",
|
||||
klass=dataclasses.Leaderboard,
|
||||
labels=[
|
||||
"mts",
|
||||
"_PLACEHOLDER",
|
||||
"username",
|
||||
"ranking",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"value",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"twitter_handle"
|
||||
]
|
||||
)
|
||||
|
||||
FundingStatistic = generate_labeler_serializer(
|
||||
name="FundingStatistic",
|
||||
klass=dataclasses.FundingStatistic,
|
||||
labels=[
|
||||
"mts",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"frr",
|
||||
"avg_period",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"funding_amount",
|
||||
"funding_amount_used",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"funding_below_threshold"
|
||||
]
|
||||
)
|
||||
|
||||
PulseProfile = generate_labeler_serializer(
|
||||
name="PulseProfile",
|
||||
klass=dataclasses.PulseProfile,
|
||||
labels=[
|
||||
"puid",
|
||||
"mts",
|
||||
"_PLACEHOLDER",
|
||||
"nickname",
|
||||
"_PLACEHOLDER",
|
||||
"picture",
|
||||
"text",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"twitter_handle",
|
||||
"_PLACEHOLDER",
|
||||
"followers",
|
||||
"following",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"tipping_status"
|
||||
]
|
||||
)
|
||||
|
||||
PulseMessage = generate_recursive_serializer(
|
||||
name="PulseMessage",
|
||||
klass=dataclasses.PulseMessage,
|
||||
serializers={ "profile": PulseProfile },
|
||||
labels=[
|
||||
"pid",
|
||||
"mts",
|
||||
"_PLACEHOLDER",
|
||||
"puid",
|
||||
"_PLACEHOLDER",
|
||||
"title",
|
||||
"content",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"is_pin",
|
||||
"is_public",
|
||||
"comments_disabled",
|
||||
"tags",
|
||||
"attachments",
|
||||
"meta",
|
||||
"likes",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"profile",
|
||||
"comments",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER"
|
||||
]
|
||||
)
|
||||
|
||||
TradingMarketAveragePrice = generate_labeler_serializer(
|
||||
name="TradingMarketAveragePrice",
|
||||
klass=dataclasses.TradingMarketAveragePrice,
|
||||
labels=[
|
||||
"price_avg",
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
FundingMarketAveragePrice = generate_labeler_serializer(
|
||||
name="FundingMarketAveragePrice",
|
||||
klass=dataclasses.FundingMarketAveragePrice,
|
||||
labels=[
|
||||
"rate_avg",
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
FxRate = generate_labeler_serializer(
|
||||
name="FxRate",
|
||||
klass=dataclasses.FxRate,
|
||||
labels=[
|
||||
"current_rate"
|
||||
]
|
||||
)
|
||||
|
||||
#endregion
|
||||
|
||||
#region Serializer definitions for types of auth use
|
||||
|
||||
UserInfo = generate_labeler_serializer(
|
||||
name="UserInfo",
|
||||
klass=dataclasses.UserInfo,
|
||||
labels=[
|
||||
"id",
|
||||
"email",
|
||||
"username",
|
||||
"mts_account_create",
|
||||
"verified",
|
||||
"verification_level",
|
||||
"_PLACEHOLDER",
|
||||
"timezone",
|
||||
"locale",
|
||||
"company",
|
||||
"email_verified",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"mts_master_account_create",
|
||||
"group_id",
|
||||
"master_account_id",
|
||||
"inherit_master_account_verification",
|
||||
"is_group_master",
|
||||
"group_withdraw_enabled",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"ppt_enabled",
|
||||
"merchant_enabled",
|
||||
"competition_enabled",
|
||||
"two_factors_authentication_modes",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"is_securities_master",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"securities_enabled",
|
||||
"allow_disable_ctxswitch",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"time_last_login",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"ctxtswitch_disabled",
|
||||
"_PLACEHOLDER",
|
||||
"comp_countries",
|
||||
"compl_countries_resid",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"is_merchant_enterprise"
|
||||
]
|
||||
)
|
||||
|
||||
LoginHistory = generate_labeler_serializer(
|
||||
name="LoginHistory",
|
||||
klass=dataclasses.LoginHistory,
|
||||
labels=[
|
||||
"id",
|
||||
"_PLACEHOLDER",
|
||||
"time",
|
||||
"_PLACEHOLDER",
|
||||
"ip",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"extra_info"
|
||||
]
|
||||
)
|
||||
|
||||
BalanceAvailable = generate_labeler_serializer(
|
||||
name="BalanceAvailable",
|
||||
klass=dataclasses.BalanceAvailable,
|
||||
labels=[
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
Order = generate_labeler_serializer(
|
||||
name="Order",
|
||||
klass=dataclasses.Order,
|
||||
labels=[
|
||||
"id",
|
||||
"gid",
|
||||
"cid",
|
||||
"symbol",
|
||||
"mts_create",
|
||||
"mts_update",
|
||||
"amount",
|
||||
"amount_orig",
|
||||
"order_type",
|
||||
"type_prev",
|
||||
"mts_tif",
|
||||
"_PLACEHOLDER",
|
||||
"flags",
|
||||
"order_status",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"price",
|
||||
"price_avg",
|
||||
"price_trailing",
|
||||
"price_aux_limit",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"notify",
|
||||
"hidden",
|
||||
"placed_id",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"routing",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"meta"
|
||||
]
|
||||
)
|
||||
|
||||
Position = generate_labeler_serializer(
|
||||
name="Position",
|
||||
klass=dataclasses.Position,
|
||||
labels=[
|
||||
"symbol",
|
||||
"status",
|
||||
"amount",
|
||||
"base_price",
|
||||
"margin_funding",
|
||||
"margin_funding_type",
|
||||
"pl",
|
||||
"pl_perc",
|
||||
"price_liq",
|
||||
"leverage",
|
||||
"_PLACEHOLDER",
|
||||
"position_id",
|
||||
"mts_create",
|
||||
"mts_update",
|
||||
"_PLACEHOLDER",
|
||||
"type",
|
||||
"_PLACEHOLDER",
|
||||
"collateral",
|
||||
"collateral_min",
|
||||
"meta"
|
||||
]
|
||||
)
|
||||
|
||||
Trade = generate_labeler_serializer(
|
||||
name="Trade",
|
||||
klass=dataclasses.Trade,
|
||||
labels=[
|
||||
"id",
|
||||
"symbol",
|
||||
"mts_create",
|
||||
"order_id",
|
||||
"exec_amount",
|
||||
"exec_price",
|
||||
"order_type",
|
||||
"order_price",
|
||||
"maker",
|
||||
"fee",
|
||||
"fee_currency",
|
||||
"cid"
|
||||
]
|
||||
)
|
||||
|
||||
FundingTrade = generate_labeler_serializer(
|
||||
name="FundingTrade",
|
||||
klass=dataclasses.FundingTrade,
|
||||
labels=[
|
||||
"id",
|
||||
"currency",
|
||||
"mts_create",
|
||||
"offer_id",
|
||||
"amount",
|
||||
"rate",
|
||||
"period"
|
||||
]
|
||||
)
|
||||
|
||||
OrderTrade = generate_labeler_serializer(
|
||||
name="OrderTrade",
|
||||
klass=dataclasses.OrderTrade,
|
||||
labels=[
|
||||
"id",
|
||||
"symbol",
|
||||
"mts_create",
|
||||
"order_id",
|
||||
"exec_amount",
|
||||
"exec_price",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"maker",
|
||||
"fee",
|
||||
"fee_currency",
|
||||
"cid"
|
||||
]
|
||||
)
|
||||
|
||||
Ledger = generate_labeler_serializer(
|
||||
name="Ledger",
|
||||
klass=dataclasses.Ledger,
|
||||
labels=[
|
||||
"id",
|
||||
"currency",
|
||||
"_PLACEHOLDER",
|
||||
"mts",
|
||||
"_PLACEHOLDER",
|
||||
"amount",
|
||||
"balance",
|
||||
"_PLACEHOLDER",
|
||||
"description"
|
||||
]
|
||||
)
|
||||
|
||||
FundingOffer = generate_labeler_serializer(
|
||||
name="FundingOffer",
|
||||
klass=dataclasses.FundingOffer,
|
||||
labels=[
|
||||
"id",
|
||||
"symbol",
|
||||
"mts_create",
|
||||
"mts_update",
|
||||
"amount",
|
||||
"amount_orig",
|
||||
"offer_type",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"flags",
|
||||
"offer_status",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"rate",
|
||||
"period",
|
||||
"notify",
|
||||
"hidden",
|
||||
"_PLACEHOLDER",
|
||||
"renew",
|
||||
"_PLACEHOLDER"
|
||||
]
|
||||
)
|
||||
|
||||
FundingCredit = generate_labeler_serializer(
|
||||
name="FundingCredit",
|
||||
klass=dataclasses.FundingCredit,
|
||||
labels=[
|
||||
"id",
|
||||
"symbol",
|
||||
"side",
|
||||
"mts_create",
|
||||
"mts_update",
|
||||
"amount",
|
||||
"flags",
|
||||
"status",
|
||||
"rate_type",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"rate",
|
||||
"period",
|
||||
"mts_opening",
|
||||
"mts_last_payout",
|
||||
"notify",
|
||||
"hidden",
|
||||
"_PLACEHOLDER",
|
||||
"renew",
|
||||
"_PLACEHOLDER",
|
||||
"no_close",
|
||||
"position_pair"
|
||||
]
|
||||
)
|
||||
|
||||
FundingLoan = generate_labeler_serializer(
|
||||
name="FundingLoan",
|
||||
klass=dataclasses.FundingLoan,
|
||||
labels=[
|
||||
"id",
|
||||
"symbol",
|
||||
"side",
|
||||
"mts_create",
|
||||
"mts_update",
|
||||
"amount",
|
||||
"flags",
|
||||
"status",
|
||||
"rate_type",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"rate",
|
||||
"period",
|
||||
"mts_opening",
|
||||
"mts_last_payout",
|
||||
"notify",
|
||||
"hidden",
|
||||
"_PLACEHOLDER",
|
||||
"renew",
|
||||
"_PLACEHOLDER",
|
||||
"no_close"
|
||||
]
|
||||
)
|
||||
|
||||
FundingAutoRenew = generate_labeler_serializer(
|
||||
name="FundingAutoRenew",
|
||||
klass=dataclasses.FundingAutoRenew,
|
||||
labels=[
|
||||
"currency",
|
||||
"period",
|
||||
"rate",
|
||||
"threshold"
|
||||
]
|
||||
)
|
||||
|
||||
FundingInfo = generate_labeler_serializer(
|
||||
name="FundingInfo",
|
||||
klass=dataclasses.FundingInfo,
|
||||
labels=[
|
||||
"yield_loan",
|
||||
"yield_lend",
|
||||
"duration_loan",
|
||||
"duration_lend"
|
||||
]
|
||||
)
|
||||
|
||||
Wallet = generate_labeler_serializer(
|
||||
name="Wallet",
|
||||
klass=dataclasses.Wallet,
|
||||
labels=[
|
||||
"wallet_type",
|
||||
"currency",
|
||||
"balance",
|
||||
"unsettled_interest",
|
||||
"available_balance",
|
||||
"last_change",
|
||||
"trade_details"
|
||||
]
|
||||
)
|
||||
|
||||
Transfer = generate_labeler_serializer(
|
||||
name="Transfer",
|
||||
klass=dataclasses.Transfer,
|
||||
labels=[
|
||||
"mts",
|
||||
"wallet_from",
|
||||
"wallet_to",
|
||||
"_PLACEHOLDER",
|
||||
"currency",
|
||||
"currency_to",
|
||||
"_PLACEHOLDER",
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
Withdrawal = generate_labeler_serializer(
|
||||
name="Withdrawal",
|
||||
klass=dataclasses.Withdrawal,
|
||||
labels=[
|
||||
"withdrawal_id",
|
||||
"_PLACEHOLDER",
|
||||
"method",
|
||||
"payment_id",
|
||||
"wallet",
|
||||
"amount",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"withdrawal_fee"
|
||||
]
|
||||
)
|
||||
|
||||
DepositAddress = generate_labeler_serializer(
|
||||
name="DepositAddress",
|
||||
klass=dataclasses.DepositAddress,
|
||||
labels=[
|
||||
"_PLACEHOLDER",
|
||||
"method",
|
||||
"currency_code",
|
||||
"_PLACEHOLDER",
|
||||
"address",
|
||||
"pool_address"
|
||||
]
|
||||
)
|
||||
|
||||
LightningNetworkInvoice = generate_labeler_serializer(
|
||||
name="LightningNetworkInvoice",
|
||||
klass=dataclasses.LightningNetworkInvoice,
|
||||
labels=[
|
||||
"invoice_hash",
|
||||
"invoice",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"amount"
|
||||
]
|
||||
)
|
||||
|
||||
Movement = generate_labeler_serializer(
|
||||
name="Movement",
|
||||
klass=dataclasses.Movement,
|
||||
labels=[
|
||||
"id",
|
||||
"currency",
|
||||
"currency_name",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"mts_start",
|
||||
"mts_update",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"status",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"amount",
|
||||
"fees",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"destination_address",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"transaction_id",
|
||||
"withdraw_transaction_note"
|
||||
]
|
||||
)
|
||||
|
||||
SymbolMarginInfo = generate_labeler_serializer(
|
||||
name="SymbolMarginInfo",
|
||||
klass=dataclasses.SymbolMarginInfo,
|
||||
labels=[
|
||||
"_PLACEHOLDER",
|
||||
"symbol",
|
||||
"tradable_balance",
|
||||
"gross_balance",
|
||||
"buy",
|
||||
"sell"
|
||||
],
|
||||
|
||||
flat=True
|
||||
)
|
||||
|
||||
BaseMarginInfo = generate_labeler_serializer(
|
||||
name="BaseMarginInfo",
|
||||
klass=dataclasses.BaseMarginInfo,
|
||||
labels=[
|
||||
"user_pl",
|
||||
"user_swaps",
|
||||
"margin_balance",
|
||||
"margin_net",
|
||||
"margin_min"
|
||||
]
|
||||
)
|
||||
|
||||
PositionClaim = generate_labeler_serializer(
|
||||
name="PositionClaim",
|
||||
klass=dataclasses.PositionClaim,
|
||||
labels=[
|
||||
"symbol",
|
||||
"position_status",
|
||||
"amount",
|
||||
"base_price",
|
||||
"margin_funding",
|
||||
"margin_funding_type",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"position_id",
|
||||
"mts_create",
|
||||
"mts_update",
|
||||
"_PLACEHOLDER",
|
||||
"pos_type",
|
||||
"_PLACEHOLDER",
|
||||
"collateral",
|
||||
"min_collateral",
|
||||
"meta"
|
||||
]
|
||||
)
|
||||
|
||||
PositionIncreaseInfo = generate_labeler_serializer(
|
||||
name="PositionIncreaseInfo",
|
||||
klass=dataclasses.PositionIncreaseInfo,
|
||||
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",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"funding_value",
|
||||
"funding_required",
|
||||
"funding_value_currency",
|
||||
"funding_required_currency"
|
||||
],
|
||||
|
||||
flat=True
|
||||
)
|
||||
|
||||
PositionIncrease = generate_labeler_serializer(
|
||||
name="PositionIncrease",
|
||||
klass=dataclasses.PositionIncrease,
|
||||
labels=[
|
||||
"symbol",
|
||||
"_PLACEHOLDER",
|
||||
"amount",
|
||||
"base_price"
|
||||
]
|
||||
)
|
||||
|
||||
PositionHistory = generate_labeler_serializer(
|
||||
name="PositionHistory",
|
||||
klass=dataclasses.PositionHistory,
|
||||
labels=[
|
||||
"symbol",
|
||||
"status",
|
||||
"amount",
|
||||
"base_price",
|
||||
"funding",
|
||||
"funding_type",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"position_id",
|
||||
"mts_create",
|
||||
"mts_update"
|
||||
]
|
||||
)
|
||||
|
||||
PositionSnapshot = generate_labeler_serializer(
|
||||
name="PositionSnapshot",
|
||||
klass=dataclasses.PositionSnapshot,
|
||||
labels=[
|
||||
"symbol",
|
||||
"status",
|
||||
"amount",
|
||||
"base_price",
|
||||
"funding",
|
||||
"funding_type",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"position_id",
|
||||
"mts_create",
|
||||
"mts_update"
|
||||
]
|
||||
)
|
||||
|
||||
PositionAudit = generate_labeler_serializer(
|
||||
name="PositionAudit",
|
||||
klass=dataclasses.PositionAudit,
|
||||
labels=[
|
||||
"symbol",
|
||||
"status",
|
||||
"amount",
|
||||
"base_price",
|
||||
"funding",
|
||||
"funding_type",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"_PLACEHOLDER",
|
||||
"position_id",
|
||||
"mts_create",
|
||||
"mts_update",
|
||||
"_PLACEHOLDER",
|
||||
"type",
|
||||
"_PLACEHOLDER",
|
||||
"collateral",
|
||||
"collateral_min",
|
||||
"meta"
|
||||
]
|
||||
)
|
||||
|
||||
DerivativePositionCollateral = generate_labeler_serializer(
|
||||
name="DerivativePositionCollateral",
|
||||
klass=dataclasses.DerivativePositionCollateral,
|
||||
labels=[
|
||||
"status"
|
||||
]
|
||||
)
|
||||
|
||||
DerivativePositionCollateralLimits = generate_labeler_serializer(
|
||||
name="DerivativePositionCollateralLimits",
|
||||
klass=dataclasses.DerivativePositionCollateralLimits,
|
||||
labels=[
|
||||
"min_collateral",
|
||||
"max_collateral"
|
||||
]
|
||||
)
|
||||
|
||||
#endregion
|
||||
Reference in New Issue
Block a user