Skip to content

Commit 52a2d76

Browse files
committed
-) Added User Settings Write/Read/Delete endpoints (REST)
-) Added Balance Available for Orders/Offers endpoint (REST)
1 parent 04ef752 commit 52a2d76

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.0.1
2+
-) Added User Settings Write/Read/Delete endpoints (REST)
3+
-) Added Balance Available for Orders/Offers endpoint (REST)
4+
15
2.0.0
26
-) Implemented Movement endpoints (REST)
37
-) Fixed unawaited stop

bfxapi/rest/bfx_rest.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,78 @@ async def claim_position(self, position_id, amount):
10051005
message = await self.post(endpoint, payload)
10061006
return message
10071007

1008+
async def calc_order_avail(self, symbol, type, lev, dir=None, rate=None):
1009+
"""
1010+
Calculate the balance available for orders/offers
1011+
1012+
# Attributes
1013+
@param symbol str: Symbol (tBTCUSD, tBTCUST, fUSD, .... )
1014+
@param dir int: Direction of the order (1 for by, -1 for sell) (Mandator for EXCHANGE and MARGIN type, not used for FUNDING)
1015+
@param rate str: Order price (Mandator for EXCHANGE and MARGIN type, not used for FUNDING)
1016+
@param type str: Type of the order/offer EXCHANGE, MARGIN, DERIV, or FUNDING
1017+
@param lev str: Leverage that you want to use in calculating the max order amount (DERIV only)
1018+
"""
1019+
endpoint = f"auth/calc/order/avail"
1020+
payload = {
1021+
"symbol": symbol,
1022+
"type": type,
1023+
"lev": lev
1024+
}
1025+
1026+
if dir:
1027+
payload["dir"] = dir
1028+
1029+
if rate:
1030+
payload["rate"] = rate
1031+
1032+
message = await self.post(endpoint, payload)
1033+
return message
1034+
1035+
async def write_user_settings(self, settings):
1036+
"""
1037+
Allows you to create custom settings by creating key: value pairs
1038+
1039+
# Attributes
1040+
@param Settings object: object of keys and values to be set. Must follow regex pattern /^api:[A-Za-z0-9_-]*$/
1041+
"""
1042+
endpoint = f"auth/w/settings/set"
1043+
payload = {
1044+
"Settings": settings
1045+
}
1046+
1047+
message = await self.post(endpoint, payload)
1048+
return message
1049+
1050+
async def read_user_settings(self, keys):
1051+
"""
1052+
Allows you to read custom settings by providing a key
1053+
1054+
# Attributes
1055+
@param Keys array: the keys for which you wish to retrieve the values
1056+
"""
1057+
endpoint = f"auth/w/settings"
1058+
payload = {
1059+
"Keys": keys
1060+
}
1061+
1062+
message = await self.post(endpoint, payload)
1063+
return message
1064+
1065+
async def delete_user_settings(self, settings):
1066+
"""
1067+
Allows you to delete custom settings
1068+
1069+
# Attributes
1070+
@param settings object: object of keys to be deleted followed by value 1. Must follow regex pattern /^api:[A-Za-z0-9_-]*$/
1071+
"""
1072+
endpoint = f"auth/w/settings/del"
1073+
payload = {
1074+
"Settings": settings
1075+
}
1076+
1077+
message = await self.post(endpoint, payload)
1078+
return message
1079+
10081080
async def get_auth_pulse_hist(self, is_public=None):
10091081
"""
10101082
Allows you to retrieve your private pulse history or the public pulse history with an additional UID_LIKED field.

bfxapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
This module contains the current version of the bfxapi lib
33
"""
44

5-
__version__ = '2.0.0'
5+
__version__ = '2.0.1'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
here = path.abspath(path.dirname(__file__))
1212
setup(
1313
name='bitfinex-api-py',
14-
version='2.0.0',
14+
version='2.0.1',
1515
description='Official Bitfinex Python API',
1616
long_description='A Python reference implementation of the Bitfinex API for both REST and websocket interaction',
1717
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)