Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.1 #19

Merged
merged 4 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 73 additions & 27 deletions bpx/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ def get_balances(self, window: Optional[int] = None):

https://docs.backpack.exchange/#tag/Capital/operation/get_balances
"""
url, headers = super().get_balances(window)
return self.http_client.get(url, headers=headers)
request_config = super().get_balances(window)
return self.http_client.get(
url=request_config.url, headers=request_config.headers
)

def get_deposits(
self,
Expand All @@ -41,17 +43,25 @@ def get_deposits(

https://docs.backpack.exchange/#tag/Capital/operation/get_deposits
"""
url, headers, params = super().get_deposits(limit, offset, window, from_, to)
return self.http_client.get(url, headers=headers, params=params)
request_config = super().get_deposits(limit, offset, window, from_, to)
return self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

def get_deposit_address(self, blockchain: str, window: Optional[int] = None):
"""
Returns the deposit address for a specified blockchain

https://docs.backpack.exchange/#tag/Capital/operation/get_deposit_address
"""
url, headers, params = super().get_deposit_address(blockchain, window)
return self.http_client.get(url, headers=headers, params=params)
request_config = super().get_deposit_address(blockchain, window)
return self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

def get_withdrawals(
self,
Expand All @@ -66,8 +76,12 @@ def get_withdrawals(

https://docs.backpack.exchange/#tag/Capital/operation/get_withdrawals
"""
url, headers, params = super().get_withdrawals(limit, offset, from_, to, window)
return self.http_client.get(url, headers=headers, params=params)
request_config = super().get_withdrawals(limit, offset, from_, to, window)
return self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

def withdrawal(
self,
Expand All @@ -82,23 +96,33 @@ def withdrawal(

https://docs.backpack.exchange/#tag/Capital/operation/request_withdrawal
"""
url, headers, params = super().withdrawal(
request_config = super().withdrawal(
address, symbol, blockchain, quantity, window
)
return self.http_client.post(url, headers=headers, data=params)
return self.http_client.post(
url=request_config.url,
headers=request_config.headers,
data=request_config.data,
)

def get_order_history_query(
self, symbol: str, limit: int = 100, offset: int = 0, window: Optional[int] = None
self,
symbol: str,
limit: int = 100,
offset: int = 0,
window: Optional[int] = None,
):
"""
Returns orders history of a specified symbol

https://docs.backpack.exchange/#tag/History/operation/get_order_history
"""
url, headers, params = super().get_order_history_query(
symbol, limit, offset, window
request_config = super().get_order_history_query(symbol, limit, offset, window)
return self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)
return self.http_client.get(url, headers=headers, params=params)

def get_fill_history_query(
self,
Expand All @@ -114,10 +138,14 @@ def get_fill_history_query(

https://docs.backpack.exchange/#tag/History/operation/get_fills
"""
url, headers, params = super().get_fill_history_query(
request_config = super().get_fill_history_query(
symbol, limit, offset, from_, to, window
)
return self.http_client.get(url, headers=headers, params=params)
return self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

def get_open_order(
self,
Expand All @@ -131,10 +159,12 @@ def get_open_order(

https://docs.backpack.exchange/#tag/Order/operation/get_order
"""
url, headers, params = super().get_open_order(
symbol, order_id, client_id, window
request_config = super().get_open_order(symbol, order_id, client_id, window)
return self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)
return self.http_client.get(url, headers=headers, params=params)

def execute_order(
self,
Expand All @@ -156,7 +186,7 @@ def execute_order(

https://docs.backpack.exchange/#tag/Order/operation/execute_order
"""
url, headers, params = super().execute_order(
request_config = super().execute_order(
symbol,
side,
order_type,
Expand All @@ -170,7 +200,11 @@ def execute_order(
post_only,
window,
)
return self.http_client.post(url, headers=headers, data=params)
return self.http_client.post(
url=request_config.url,
headers=request_config.headers,
data=request_config.data,
)

def cancel_order(
self,
Expand All @@ -184,23 +218,35 @@ def cancel_order(

https://docs.backpack.exchange/#tag/Order/operation/cancel_order
"""
url, headers, params = super().cancel_order(symbol, order_id, client_id, window)
return self.http_client.delete(url, headers=headers, data=params)
request_config = super().cancel_order(symbol, order_id, client_id, window)
return self.http_client.delete(
url=request_config.url,
headers=request_config.headers,
data=request_config.data,
)

def get_open_orders(self, symbol: str, window: Optional[int] = None):
"""
Returns open orders of a specified symbol

https://docs.backpack.exchange/#tag/Order/operation/get_open_orders
"""
url, headers, params = super().get_open_orders(symbol, window)
return self.http_client.get(url, headers=headers, params=params)
request_config = super().get_open_orders(symbol, window)
return self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

def cancel_all_orders(self, symbol: str, window: Optional[int] = None):
"""
Cancels all existing orders of a specified symbol

https://docs.backpack.exchange/#tag/Order/operation/cancel_open_orders
"""
url, headers, params = super().cancel_all_orders(symbol, window)
return self.http_client.delete(url, headers=headers, data=params)
request_config = super().cancel_all_orders(symbol, window)
return self.http_client.delete(
url=request_config.url,
headers=request_config.headers,
data=request_config.data,
)
100 changes: 73 additions & 27 deletions bpx/async_/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ async def get_balances(self, window: Optional[int] = None):

https://docs.backpack.exchange/#tag/Capital/operation/get_balances
"""
url, headers = super().get_balances(window)
return await self.http_client.get(url, headers=headers)
request_config = super().get_balances(window)
return await self.http_client.get(
url=request_config.url, headers=request_config.headers
)

async def get_deposits(
self,
Expand All @@ -41,17 +43,25 @@ async def get_deposits(

https://docs.backpack.exchange/#tag/Capital/operation/get_deposits
"""
url, headers, params = super().get_deposits(limit, offset, window)
return await self.http_client.get(url, headers=headers, params=params)
request_config = super().get_deposits(limit, offset, window)
return await self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

async def get_deposit_address(self, blockchain: str, window: Optional[int] = None):
"""
Returns the deposit address for a specified blockchain

https://docs.backpack.exchange/#tag/Capital/operation/get_deposit_address
"""
url, headers, params = super().get_deposit_address(blockchain, window)
return await self.http_client.get(url, headers=headers, params=params)
request_config = super().get_deposit_address(blockchain, window)
return await self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

async def get_withdrawals(
self,
Expand All @@ -66,8 +76,12 @@ async def get_withdrawals(

https://docs.backpack.exchange/#tag/Capital/operation/get_withdrawals
"""
url, headers, params = super().get_withdrawals(limit, offset, from_, to, window)
return await self.http_client.get(url, headers=headers, params=params)
request_config = super().get_withdrawals(limit, offset, from_, to, window)
return await self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

async def withdrawal(
self,
Expand All @@ -82,23 +96,33 @@ async def withdrawal(

https://docs.backpack.exchange/#tag/Capital/operation/request_withdrawal
"""
url, headers, params = super().withdrawal(
request_config = super().withdrawal(
address, symbol, blockchain, quantity, window
)
return await self.http_client.post(url, headers=headers, data=params)
return await self.http_client.post(
url=request_config.url,
headers=request_config.headers,
data=request_config.data,
)

async def get_order_history_query(
self, symbol: str, limit: int = 100, offset: int = 0, window: Optional[int] = None
self,
symbol: str,
limit: int = 100,
offset: int = 0,
window: Optional[int] = None,
):
"""
Returns orders history of a specified symbol

https://docs.backpack.exchange/#tag/History/operation/get_order_history
"""
url, headers, params = super().get_order_history_query(
symbol, limit, offset, window
request_config = super().get_order_history_query(symbol, limit, offset, window)
return await self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)
return await self.http_client.get(url, headers=headers, params=params)

async def get_fill_history_query(
self,
Expand All @@ -114,10 +138,14 @@ async def get_fill_history_query(

https://docs.backpack.exchange/#tag/History/operation/get_fills
"""
url, headers, params = super().get_fill_history_query(
request_config = super().get_fill_history_query(
symbol, limit, offset, from_, to, window
)
return await self.http_client.get(url, headers=headers, params=params)
return await self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

async def get_open_order(
self,
Expand All @@ -131,10 +159,12 @@ async def get_open_order(

https://docs.backpack.exchange/#tag/Order/operation/get_order
"""
url, headers, params = super().get_open_order(
symbol, order_id, client_id, window
request_config = super().get_open_order(symbol, order_id, client_id, window)
return await self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)
return await self.http_client.get(url, headers=headers, params=params)

async def execute_order(
self,
Expand All @@ -156,7 +186,7 @@ async def execute_order(

https://docs.backpack.exchange/#tag/Order/operation/execute_order
"""
url, headers, params = super().execute_order(
request_config = super().execute_order(
symbol,
side,
order_type,
Expand All @@ -170,7 +200,11 @@ async def execute_order(
post_only,
window,
)
return await self.http_client.post(url, headers=headers, data=params)
return await self.http_client.post(
url=request_config.url,
headers=request_config.headers,
data=request_config.data,
)

async def cancel_order(
self,
Expand All @@ -184,23 +218,35 @@ async def cancel_order(

https://docs.backpack.exchange/#tag/Order/operation/cancel_order
"""
url, headers, params = super().cancel_order(symbol, order_id, client_id, window)
return await self.http_client.delete(url, headers=headers, data=params)
request_config = super().cancel_order(symbol, order_id, client_id, window)
return await self.http_client.delete(
url=request_config.url,
headers=request_config.headers,
data=request_config.data,
)

async def get_open_orders(self, symbol: str, window: Optional[int] = None):
"""
Returns open orders of a specified symbol

https://docs.backpack.exchange/#tag/Order/operation/get_open_orders
"""
url, headers, params = super().get_open_orders(symbol, window)
return await self.http_client.get(url, headers=headers, params=params)
request_config = super().get_open_orders(symbol, window)
return await self.http_client.get(
url=request_config.url,
headers=request_config.headers,
params=request_config.params,
)

async def cancel_all_orders(self, symbol: str, window: Optional[int] = None):
"""
Cancels all existing orders of a specified symbol

https://docs.backpack.exchange/#tag/Order/operation/cancel_open_orders
"""
url, headers, params = super().cancel_all_orders(symbol, window)
return await self.http_client.delete(url, headers=headers, data=params)
request_config = super().cancel_all_orders(symbol, window)
return await self.http_client.delete(
url=request_config.url,
headers=request_config.headers,
data=request_config.data,
)
Loading
Loading