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

Commit

Permalink
fixed array body logic to be super generic
Browse files Browse the repository at this point in the history
  • Loading branch information
nicelgueta committed Dec 20, 2022
1 parent 61372fa commit 8f2cbbe
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 90 deletions.
29 changes: 28 additions & 1 deletion pyokx/Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def get_manual_borrow_and_repay_history_in_quick_margin_mode(
return self.request(details)

def vip_loans_borrow_and_repay(
self, ccy: str, side: str, amt: str, use_proxy: bool = False
self, ccy: str, side: str, amt: str, ordId: str = None, use_proxy: bool = False
) -> APIReturn:
"""
VIP loans borrow and repay
Expand Down Expand Up @@ -668,6 +668,33 @@ def get_vip_interest_accrued_data(
)
return self.request(details)

def get_vip_interest_deducted_data(
self,
ccy: str = None,
ordId: str = None,
after: str = None,
before: str = None,
limit: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get VIP interest deducted data
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/account/vip-interest-deducted",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_vip_loan_order_list(
self,
ordId: str = None,
Expand Down
206 changes: 206 additions & 0 deletions pyokx/CopyTrading.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# auto-generated code #
from .base import APIComponent, APIReturn, EndpointDetails


class CopyTrading(APIComponent):
def get_existing_leading_positions(
self, instId: str = None, use_proxy: bool = False
) -> APIReturn:
"""
Get existing leading positions
Returns reverse chronological order with openTime
Rate limit: 2 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/copytrading/current-subpositions",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_leading_position_history(
self,
instId: str = None,
after: str = None,
before: str = None,
limit: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get leading position history
Returns reverse chronological order with closeTime.
Rate limit: 2 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/copytrading/subpositions-history",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def place_leading_stop_order(
self,
subPosId: str,
tpTriggerPxType: str = None,
slTriggerPxType: str = None,
tpTriggerPx: str = None,
slTriggerPx: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Place leading stop order
Rate limit: 1 request 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/copytrading/algo-order",
method="POST",
body=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def close_leading_position(
self, subPosId: str, use_proxy: bool = False
) -> APIReturn:
"""
Close leading position
Rate limit: 2 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/copytrading/close-subposition",
method="POST",
body=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_leading_instruments(self, use_proxy: bool = False) -> APIReturn:
"""
Get leading instruments
Rate limit: 2 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/copytrading/instruments",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def amend_leading_instruments(
self, instId: str, use_proxy: bool = False
) -> APIReturn:
"""
Amend leading instruments
Rate limit: 2 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/copytrading/set-instruments",
method="POST",
body=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_profit_sharing_details(
self,
after: str = None,
before: str = None,
limit: str = None,
use_proxy: bool = False,
) -> APIReturn:
"""
Get profit sharing details
Rate limit: 2 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/copytrading/profit-sharing-details",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_total_profit_sharing(self, use_proxy: bool = False) -> APIReturn:
"""
Get total profit sharing
Rate limit: 2 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/copytrading/total-profit-sharing",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)

def get_unrealized_profit_sharing_details(
self, use_proxy: bool = False
) -> APIReturn:
"""
Get unrealized profit sharing details
Rate limit: 2 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/copytrading/unrealized-profit-sharing-details",
method="GET",
params=kwargs,
use_proxy=use_proxy,
)
return self.request(details)
1 change: 1 addition & 0 deletions pyokx/Earn.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def purchase(
investData: list,
ccy: str,
amt: str,
tag: str = None,
term: str = None,
use_proxy: bool = False,
) -> APIReturn:
Expand Down
2 changes: 1 addition & 1 deletion pyokx/Funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def withdrawal(
) -> APIReturn:
"""
Withdrawal
Withdrawal of tokens. Sub-account does not support withdrawal.
Withdrawal of tokens. Common sub-account does not support withdrawal.
Rate Limit: 6 requests per second
Rate limit rule: UserID
"""
Expand Down
14 changes: 3 additions & 11 deletions pyokx/Gridtrading.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# auto-generated code #
from .base import APIComponent, APIReturn, EndpointDetails
from typing import *


class Gridtrading(APIComponent):
Expand Down Expand Up @@ -69,12 +70,7 @@ def amend_grid_algo_order(
return self.request(details)

def stop_grid_algo_order(
self,
algoId: str,
instId: str,
algoOrdType: str,
stopType: str,
use_proxy: bool = False,
self, body: List[dict] = None, use_proxy: bool = False
) -> APIReturn:
"""
Stop grid algo order
Expand All @@ -83,11 +79,7 @@ def stop_grid_algo_order(
Rate limit rule (except Options): UserID + Instrument ID
Rate limit rule (Options only): UserID + Instrument Family
"""
kwargs = {
k: v
for k, v in locals().items()
if k not in ["use_proxy", "self"] and v is not None
}
kwargs = body
details = EndpointDetails(
request_path="/api/v5/tradingBot/grid/stop-order-algo",
method="POST",
Expand Down
2 changes: 1 addition & 1 deletion pyokx/Marketdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_order_book(
"""
Get order book
Retrieve order book of the instrument.
Rate Limit: 20 requests per 2 seconds
Rate Limit: 40 requests per 2 seconds
Rate limit rule: IP
"""
kwargs = {
Expand Down
Loading

0 comments on commit 8f2cbbe

Please sign in to comment.