Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
0.3.0: updated latest API changes - fixed pythonic names
Browse files Browse the repository at this point in the history
  • Loading branch information
nicelgueta committed Sep 5, 2022
1 parent 52ce25e commit ac9c298
Show file tree
Hide file tree
Showing 13 changed files with 218 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ api_response = account.get_positions(use_proxy=True)
**It's still a very early version - so issues, feature requests and bugs are very welcome!**

- [x] REST API implementation.
- [ ] Fix pythonic naming conventions when API names contain special characters
- [x] Fix pythonic naming conventions when API names contain special characters
- [ ] Enhance documentation
- [ ] Websocket API implementation.

Expand Down
13 changes: 7 additions & 6 deletions pyokx/Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_account_and_position_risk(
)
return self.request(details)

def get_bills_details__last___days_(
def get_bills_details_last_7_days(
self,
instType: str = None,
ccy: str = None,
Expand Down Expand Up @@ -142,7 +142,7 @@ def get_bills_details__last___days_(
)
return self.request(details)

def get_bills_details__last___months_(
def get_bills_details_last_3_months(
self,
instType: str = None,
ccy: str = None,
Expand Down Expand Up @@ -256,6 +256,7 @@ def get_maximum_buy_sell_amount_or_open_amount(
ccy: str = None,
px: str = None,
leverage: str = None,
unSpotOffset: bool = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Expand Down Expand Up @@ -285,7 +286,7 @@ def get_maximum_available_tradable_amount(
tdMode: str,
ccy: str = None,
reduceOnly: bool = None,
px: str = None,
unSpotOffset: bool = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Expand Down Expand Up @@ -452,7 +453,7 @@ def get_interest_rate(self, ccy: str = None, use_proxy: bool = False) -> APIRetu
)
return self.request(details)

def set_greeks__pa_bs_(self, greeksType: str, use_proxy: bool = False) -> APIReturn:
def set_greeks_pa_bs(self, greeksType: str, use_proxy: bool = False) -> APIReturn:
"""
Set greeks (PA/BS)
Set the display type of Greeks.
Expand Down Expand Up @@ -609,8 +610,8 @@ def position_builder(
instType: str = None,
inclRealPos: bool = None,
simPos: list = None,
__instId: str = None,
__pos: str = None,
instId: str = None,
pos: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Expand Down
46 changes: 34 additions & 12 deletions pyokx/Blocktrading.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ def create_rfq(
self,
counterparties: List[str],
legs: List[dict],
__instId: str,
__sz: str,
__side: str,
instId: str,
sz: str,
side: str,
anonymous: bool = None,
clRfqId: str = None,
__tgtCcy: str = None,
tgtCcy: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Expand Down Expand Up @@ -154,13 +154,15 @@ def set_quote_products(
self,
instType: str,
data: List[dict],
__uly: str = None,
__instId: str = None,
uly: str = None,
instId: str = None,
maxBlockSz: str = None,
makerPxBand: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Set Quote products
Customize the products of which makers want to quote.
Customize the products which makers want to quote and receive RFQs for, and the corresponding price and size limit.
Rate Limit: 5 requests per 2 seconds
Rate limit rule: UserID
"""
Expand All @@ -177,19 +179,39 @@ def set_quote_products(
)
return self.request(details)

def reset_mmp_status(self, use_proxy: bool = False) -> APIReturn:
"""
Reset MMP status
Reset the MMP status to be inactive.
Rate Limit: 5 requests per 2 seconds
Rate limit rule: UserID
"""
kwargs = {
k: v
for k, v in locals().items()
if k not in ["use_proxy", "self"] and v is not None
}
details = EndpointDetails(
request_path="/api/v5/rfq/mmp-reset",
method="POST",
body=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def create_quote(
self,
rfqId: str,
quoteSide: str,
legs: List[dict],
__instId: str,
__sz: str,
__px: str,
__side: str,
instId: str,
sz: str,
px: str,
side: str,
clQuoteId: str = None,
anonymous: bool = None,
expiresIn: str = None,
__tgtCcy: str = None,
tgtCcy: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Expand Down
13 changes: 5 additions & 8 deletions pyokx/Earn.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ def purchase(
self,
productId: str,
investData: list,
_ccy: str,
_amt: str,
ccy: str,
amt: str,
term: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Purchase
When making purchase, assets in both trading and funding account will be used (priority funding account).
Rate Limit: 2 requests per second
Rate limit rule: UserID
Purchase
Rate Limit: 2 requests per second
Rate limit rule: UserID
"""
kwargs = {
k: v
Expand Down
23 changes: 14 additions & 9 deletions pyokx/Funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,19 @@ def funds_transfer(
type: str = None,
loanTrans: bool = None,
clientId: str = None,
omitPosRisk: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Funds transfer
Only API keys with Trade privilege can call this endpoint.
This endpoint supports the transfer of funds between your funding account and trading account, and from the master account to sub-accounts.
Sub-account can transfer out to master account by default. Need to call "Set Permission Of Transfer Out" to grant privilege first if you want sub-account transferring to another sub-account(subaccounts need to belong to same master account.)
Rate Limit: 1 request per second
Rate limit rule: UserID + Currency
Funds transfer
Only API keys with Trade privilege can call this endpoint.
This endpoint supports the transfer of funds between your funding account and trading account, and from the master account to sub-accounts.
Sub-account can transfer out to master account by default. Need to call "Set Permission Of Transfer Out" to grant privilege first if you want sub-account transferring to another sub-account(subaccounts need to belong to same master account.)
Failure of the request does not mean the transfer has failed. Recommend to call "Get funds transfer state" to confirm the status.
Rate Limit: 1 request per second
Rate limit rule: UserID + Currency
"""
kwargs = {
k: v
Expand All @@ -110,6 +114,7 @@ def get_funds_transfer_state(
) -> APIReturn:
"""
Get funds transfer state
Retrieve the transfer state data of the last 2 weeks.
Rate Limit: 1 request per second
Rate limit rule: UserID
"""
Expand Down Expand Up @@ -138,7 +143,7 @@ def asset_bills_details(
) -> APIReturn:
"""
Asset bills details
Query the billing record. You can get the latest 1 month historical data
Query the billing record. You can get the latest 1 month historical data.
Rate Limit: 6 Requests per second
Rate limit rule: UserID
"""
Expand Down Expand Up @@ -438,7 +443,7 @@ def get_lending_history(
)
return self.request(details)

def get_public_borrow_info__public_(
def get_public_borrow_info_public(
self, ccy: str = None, use_proxy: bool = False
) -> APIReturn:
"""
Expand All @@ -460,7 +465,7 @@ def get_public_borrow_info__public_(
)
return self.request(details)

def get_public_borrow_history__public_(
def get_public_borrow_history_public(
self,
ccy: str = None,
after: str = None,
Expand Down
7 changes: 4 additions & 3 deletions pyokx/Gridtrading.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def stop_grid_algo_order(
) -> APIReturn:
"""
Stop grid algo order
A maximum of 10 orders can be canceled per request.
Rate Limit: 20 requests per 2 seconds
Derivatives rate limit rule: UserID +(instrumentType、underlying)
Spot & Margin rate limit rule: UserID +(instrumentType、instrumentID)
Expand Down Expand Up @@ -218,11 +219,11 @@ def get_grid_algo_order_positions(
)
return self.request(details)

def spot_grid_withdraw_income(
def spot_moon_grid_withdraw_income(
self, algoId: str, use_proxy: bool = False
) -> APIReturn:
"""
Spot grid withdraw income
Spot/Moon grid withdraw income
Rate Limit: 20 requests per 2 seconds
Rate limit rule: UserID
"""
Expand Down Expand Up @@ -286,7 +287,7 @@ def adjust_margin_balance(
)
return self.request(details)

def get_grid_ai_parameter__public_(
def get_grid_ai_parameter_public(
self,
algoOrdType: str,
instId: str,
Expand Down
2 changes: 1 addition & 1 deletion pyokx/Marketdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get_trades_history(
)
return self.request(details)

def get___h_total_volume(self, use_proxy: bool = False) -> APIReturn:
def get_24h_total_volume(self, use_proxy: bool = False) -> APIReturn:
"""
Get 24H total volume
The 24-hour trading volume is calculated on a rolling basis, using USD as the pricing unit, including block trading volume.
Expand Down
1 change: 1 addition & 0 deletions pyokx/Publicdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def get_limit_price(self, instId: str, use_proxy: bool = False) -> APIReturn:
Get limit price
Retrieve the highest buy limit and lowest sell limit of the instrument.
Rate Limit: 20 requests per 2 seconds
Rate limit rule: IP
"""
kwargs = {
k: v
Expand Down
1 change: 1 addition & 0 deletions pyokx/SubAccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def master_accounts_manage_the_transfers_between_sub_accounts(
fromSubAccount: str,
toSubAccount: str,
loanTrans: bool = None,
omitPosRisk: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Expand Down
Loading

0 comments on commit ac9c298

Please sign in to comment.