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

Commit

Permalink
0.4.0: updated to conform to latest OKX changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicelgueta committed Nov 1, 2022
1 parent 9710c85 commit fb25401
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 45 deletions.
7 changes: 6 additions & 1 deletion pyokx/Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ def get_fee_rates(
instType: str,
instId: str = None,
uly: str = None,
instFamily: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Expand Down Expand Up @@ -655,7 +656,11 @@ def get_greeks(self, ccy: str = None, use_proxy: bool = False) -> APIReturn:
return self.request(details)

def get_pm_limitation(
self, instType: str, uly: str, use_proxy: bool = False
self,
instType: str,
uly: str = None,
instFamily: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get PM limitation
Expand Down
14 changes: 12 additions & 2 deletions pyokx/Blocktrading.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def create_rfq(
side: str,
anonymous: bool = None,
clRfqId: str = None,
allowPartialExecution: bool = None,
tgtCcy: str = None,
use_proxy: bool = False,
) -> APIReturn:
Expand Down Expand Up @@ -129,7 +130,13 @@ def cancel_all_rfqs(self, use_proxy: bool = False) -> APIReturn:
return self.request(details)

def execute_quote(
self, rfqId: str, quoteId: str, use_proxy: bool = False
self,
rfqId: str,
quoteId: str,
instId: str,
sz: str,
legs: List[dict] = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Execute Quote
Expand All @@ -154,8 +161,9 @@ def set_quote_products(
self,
instType: str,
data: List[dict],
uly: str = None,
instFamily: str = None,
instId: str = None,
includeAll: bool = None,
maxBlockSz: str = None,
makerPxBand: str = None,
use_proxy: bool = False,
Expand Down Expand Up @@ -370,6 +378,8 @@ def get_trades(
state: str = None,
beginId: str = None,
endId: str = None,
beginTs: str = None,
endTs: str = None,
limit: str = None,
use_proxy: bool = False,
) -> APIReturn:
Expand Down
4 changes: 2 additions & 2 deletions pyokx/Convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def estimate_quote(
) -> APIReturn:
"""
Estimate quote
Rate Limit: 2 requests per second
Rate Limit: 10 requests per second
Rate limit rule: UserID
"""
kwargs = {
Expand Down Expand Up @@ -86,7 +86,7 @@ def convert_trade(
) -> APIReturn:
"""
Convert trade
Rate Limit: 2 requests per second
Rate Limit: 10 requests per second
Rate limit rule: UserID
"""
kwargs = {
Expand Down
4 changes: 3 additions & 1 deletion pyokx/Funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def funds_transfer(
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
Rate limit rule: UserID + Currency
"""
kwargs = {
k: v
Expand Down Expand Up @@ -207,6 +207,7 @@ def get_deposit_history(
ccy: str = None,
depId: str = None,
txId: str = None,
type: str = None,
state: str = None,
after: str = None,
before: str = None,
Expand Down Expand Up @@ -310,6 +311,7 @@ def get_withdrawal_history(
wdId: str = None,
clientId: str = None,
txId: str = None,
type: str = None,
state: str = None,
after: str = None,
before: str = None,
Expand Down
10 changes: 5 additions & 5 deletions pyokx/Gridtrading.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def place_grid_algo_order(
"""
Place grid algo order
Rate Limit: 20 requests per 2 seconds
Derivatives rate limit rule: UserID +(instrumentTypeunderlying)
Spot & Margin rate limit rule: UserID +(instrumentTypeinstrumentID)
Derivatives rate limit rule: UserID + (instrumentType + underlying)
Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID)
"""
kwargs = {
k: v
Expand All @@ -47,7 +47,7 @@ def amend_grid_algo_order(
Amend grid algo order
Supported contract grid algo order amendment.
Rate Limit: 20 requests per 2 seconds
Derivatives rate limit rule: UserID +(instrumentTypeunderlying)
Derivatives rate limit rule: UserID + (instrumentType + underlying)
"""
kwargs = {
k: v
Expand All @@ -74,8 +74,8 @@ def stop_grid_algo_order(
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 +(instrumentTypeunderlying)
Spot & Margin rate limit rule: UserID +(instrumentTypeinstrumentID)
Derivatives rate limit rule: UserID + (instrumentType + underlying)
Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID)
"""
kwargs = {
k: v
Expand Down
88 changes: 86 additions & 2 deletions pyokx/Marketdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

class Marketdata(APIComponent):
def get_tickers(
self, instType: str, uly: str = None, use_proxy: bool = False
self,
instType: str,
uly: str = None,
instFamily: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get tickers
Expand Down Expand Up @@ -89,6 +93,26 @@ def get_order_book(
)
return self.request(details)

def get_order_lite_book(self, instId: str, use_proxy: bool = False) -> APIReturn:
"""
Get order lite book
Retrieve order top 25 book of the instrument more quickly
Rate Limit: 6 requests per 1 seconds
Rate limit rule: IP
"""
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/market/books-lite",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_candlesticks(
self,
instId: str,
Expand Down Expand Up @@ -173,6 +197,34 @@ def get_index_candlesticks(
)
return self.request(details)

def get_index_candlesticks_history(
self,
instId: str,
after: str = None,
before: str = None,
bar: str = None,
limit: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get index candlesticks history
Retrieve the candlestick charts of the index from recent years.
Rate Limit: 10 requests per 2 seconds
Rate limit rule: IP
"""
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/market/history-index-candles",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_mark_price_candlesticks(
self,
instId: str,
Expand Down Expand Up @@ -201,6 +253,34 @@ def get_mark_price_candlesticks(
)
return self.request(details)

def get_mark_price_candlesticks_history(
self,
instId: str,
after: str = None,
before: str = None,
bar: str = None,
limit: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get mark price candlesticks history
Retrieve the candlestick charts of mark price from recent years.
Rate Limit: 10 requests per 2 seconds
Rate limit rule: IP
"""
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/market/history-mark-price-candles",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_trades(
self, instId: str, limit: str = None, use_proxy: bool = False
) -> APIReturn:
Expand Down Expand Up @@ -332,7 +412,11 @@ def get_index_components(self, index: str, use_proxy: bool = False) -> APIReturn
return self.request(details)

def get_block_tickers(
self, instType: str, uly: str = None, use_proxy: bool = False
self,
instType: str,
uly: str = None,
instFamily: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get block tickers
Expand Down
27 changes: 19 additions & 8 deletions pyokx/Publicdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ def get_instruments(
self,
instType: str,
uly: str = None,
instFamily: str = None,
instId: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get instruments
Retrieve a list of instruments with open contracts.
Rate Limit: 20 requests per 2 seconds
Rate limit rule: IP +instrumentType
Rate limit rule: IP + instrumentType
"""
kwargs = {
k: v
Expand All @@ -32,17 +33,18 @@ def get_instruments(
def get_delivery_exercise_history(
self,
instType: str,
uly: str,
uly: str = None,
instFamily: str = None,
after: str = None,
before: str = None,
limit: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get delivery/exercise history
Retrieve the estimated delivery price of the last 3 months, which will only have a return value one hour before the delivery/exercise.
Retrieve delivery records of Futures and exercise records of Options in the last 3 months.
Rate Limit: 40 requests per 2 seconds
Rate limit rule: IP +(instrumentTypeuly)
Rate limit rule: IP + (instrumentType + uly)
"""
kwargs = {
k: v
Expand All @@ -61,6 +63,7 @@ def get_open_interest(
self,
instType: str,
uly: str = None,
instFamily: str = None,
instId: str = None,
use_proxy: bool = False,
) -> APIReturn:
Expand Down Expand Up @@ -151,7 +154,11 @@ def get_limit_price(self, instId: str, use_proxy: bool = False) -> APIReturn:
return self.request(details)

def get_option_market_data(
self, uly: str, expTime: str = None, use_proxy: bool = False
self,
uly: str = None,
instFamily: str = None,
expTime: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get option market data
Expand Down Expand Up @@ -240,6 +247,7 @@ def get_liquidation_orders(
self,
instType: str,
uly: str = None,
instFamily: str = None,
alias: str = None,
mgnMode: str = None,
instId: str = None,
Expand Down Expand Up @@ -273,6 +281,7 @@ def get_mark_price(
self,
instType: str,
uly: str = None,
instFamily: str = None,
instId: str = None,
use_proxy: bool = False,
) -> APIReturn:
Expand Down Expand Up @@ -301,14 +310,15 @@ def get_position_tiers(
instType: str,
tdMode: str,
uly: str = None,
instFamily: str = None,
instId: str = None,
ccy: str = None,
tier: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get position tiers
Retrieve position tiers information maximum leverage depends on your borrowings and margin ratio.
Retrieve position tiers information, maximum leverage depends on your borrowings and margin ratio.
Rate Limit: 10 requests per 2 seconds
Rate limit rule: IP
"""
Expand Down Expand Up @@ -388,9 +398,10 @@ def get_underlying(self, instType: str, use_proxy: bool = False) -> APIReturn:
def get_insurance_fund(
self,
instType: str,
type: str = None,
uly: str = None,
instFamily: str = None,
ccy: str = None,
type: str = None,
before: str = None,
after: str = None,
limit: str = None,
Expand Down Expand Up @@ -426,7 +437,7 @@ def unit_convert(
) -> APIReturn:
"""
Unit convert
Convert currency to contract, or contract to currency.
Convert the crypto value to the number of contracts, or vice versa
Rate Limit: 10 requests per 2 seconds
Rate limit rule: IP
"""
Expand Down
Loading

0 comments on commit fb25401

Please sign in to comment.