diff --git a/coinspot/coinspot.py b/coinspot/coinspot.py index 44647df..95a01f4 100644 --- a/coinspot/coinspot.py +++ b/coinspot/coinspot.py @@ -48,7 +48,7 @@ class CoinSpot: _api_key = "" _api_secret = "" - _endpoint = "www.coinspot.com.au" + _endpoint = "https://www.coinspot.com.au" _logging = "coinspot.log" _debug = False @@ -114,7 +114,7 @@ def start_logging(self): ) def _get_signed_request(self, data): - print(self) + # print(self) # print(hmac.new(key.encode('utf-8'), data.encode('utf-8'), hashlib.sha512).hexdigest() return hmac.new( str((self._api_secret)).encode("utf-8"), @@ -122,211 +122,845 @@ def _get_signed_request(self, data): hashlib.sha512, ).hexdigest() + def _request_public(self, path, postdata): + """ + The public API uses a GET method, while the Private API uses a POST method. + _request_public - is for the public API, requires no nonce, key or hash or data. + """ + + # Create base URL + path = self._endpoint + path + + # Add each parameter into the URL + for parameter in postdata: + path = path + postdata[parameter] + "/" + + # Request + response_data = requests.get(path) + return response_data + def _request(self, path, postdata): + # Create URL + path = self._endpoint + path + + # Post data nonce = int(time() * 1000000) postdata["nonce"] = nonce params = json.dumps(postdata, separators=(",", ":")) signedMessage = self._get_signed_request(params) + + # Header headers = {} headers["Content-type"] = "application/json" headers["Accept"] = "text/plain" headers["key"] = self._api_key headers["sign"] = signedMessage - headers["User-Agent"] = ( - "py-coinspot-api/%s (https://github.com/geekpete/py-coinspot-api)" - % __version__ - ) - if self._debug: - logging.warning(self.timestamp + " " + str(headers)) - conn = http.client.HTTPSConnection(self._endpoint) - if self._debug: - conn.set_debuglevel(1) - response_data = '{"status":"invalid","error": "Did not make request"}' - try: - conn.request("POST", path, params, headers) - response = conn.getresponse() - if self._debug: - logging.warning(self.timestamp + " " + str(response)) - logging.warning(self.timestamp + " " + str(response.msg)) - # print response.status, response.reason - response_data = response.read() - if self._debug: - logging.warning(self.timestamp + " " + str(response_data)) - conn.close() - except IOError as error: - if self._debug: - error_text = "Attempting to make request I/O error({0}): {1}".format( - error.errno, error.strerror - ) - logging.warning(self.timestamp + " " + error_text) - response_data = '{"status":"invalid","error": "' + error_text + '"}' - except: - exit("Unexpected error: {0}".format(sys.exc_info()[0])) + # Request + response_data = requests.post(path, data=params, headers=headers) return response_data - def sendcoin(self, cointype, address, amount): + + def latestprices(self): """ - Send coins + Latest Prices + + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **prices** - array of objects with one set of properties for each coin with latest buy and sell prices, non aud markets are symbolised by (e.g.) 'btc_usdt' + + """ + request_data = {} + return self._request_public("/pubapi/v2/latest/", request_data) + + def coinprices(self, cointype): + """ + Latest Coin Prices :param cointype: - the coin shortname in uppercase, example value 'BTC', 'LTC', 'DOGE' - :param address: - the address to send the coins to - :param amount: - the amount of coins to send + coin short name, example value 'BTC', 'LTC', 'DOGE' :return: - **status** - ok, error + - **message** - ok, description of error if error occurred + - **prices** - object with set of properties for coin with latest buy, ask and last prices """ - request_data = {"cointype": cointype, "address": address, "amount": amount} - return self._request("/api/my/coin/send", request_data) + request_data = {"cointype":cointype} + return self._request_public("/pubapi/v2/latest/", request_data) - def coindeposit(self, cointype): + def coinmarketprices(self, cointype, markettype): """ - Deposit coins + Latest Coin / Market Prices :param cointype: - the coin shortname in uppercase, example value 'BTC', 'LTC', 'DOGE' + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + market coin short name, example value 'USDT' (only for available markets) :return: - **status** - ok, error - - **address** - your deposit address for the coin + - **message** - ok, description of error if error occurred + - **prices** - object with set of properties for coin with latest buy, ask and last prices """ - request_data = {"cointype": cointype} - return self._request("/api/my/coin/deposit", request_data) + request_data = {"cointype":cointype, "markettype":markettype} + return self._request_public("/pubapi/v2/latest/", request_data) - def quotebuy(self, cointype, amount): + def buyprice(self, cointype): """ - Quick buy quote + Latest Buy Price - Fetches a quote on rate per coin and estimated timeframe to buy an amount of coins + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **rate** - latest buy price for that coin + - **market** - market coin is trading in + + """ + request_data = {"cointype":cointype} + return self._request_public("/pubapi/v2/buyprice/", request_data) + + def buymarketprice(self, cointype, markettype): + """ + Latest Buy Price / Market :param cointype: - the coin shortname in uppercase, example value 'BTC', 'LTC', 'DOGE' - :param amount: - the amount of coins to sell + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + coin market you wish to use to buy it, example value: USDT' (only for available markets) :return: - **status** - ok, error - - **quote** - the rate per coin - - **timeframe** - estimate of hours to wait for trade to complete (0 = immediate trade) + - **message** - ok, description of error if error occurred + - **rate** - latest buy price for that coin + - **market** - market coin is trading in """ - request_data = {"cointype": cointype, "amount": amount} - return self._request("/api/quote/buy", request_data) + request_data = {"cointype":cointype, "markettype":markettype} + return self._request_public("/pubapi/v2/buyprice/", request_data) - def quotesell(self, cointype, amount): + def sellprice(self, cointype): """ - Quick sell quote + Latest Sell Price - Fetches a quote on rate per coin and estimated timeframe to sell an amount of coins + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **rate** - latest sell price for that coin + - **market** - market coin is trading in + + """ + request_data = {"cointype":cointype} + return self._request_public("/pubapi/v2/sellprice/", request_data) + + def sellmarketprice(self, cointype, markettype): + """ + Latest Sell Price / Market :param cointype: - the coin shortname in uppercase, example value 'BTC', 'LTC', 'DOGE' - :param amount: - the amount of coins to sell + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + coin market you wish to sell it for, example value: 'USDT' (note: only for available markets) :return: - **status** - ok, error - - **quote** - the rate per coin - - **timeframe** - estimate of hours to wait for trade to complete (0 = immediate trade) + - **message** - ok, description of error if error occurred + - **rate** - latest sell price for that coin + - **market** - market coin is trading in """ - request_data = {"cointype": cointype, "amount": amount} - return self._request("/api/quote/sell", request_data) + request_data = {"cointype":cointype, "markettype":markettype} + return self._request_public("/pubapi/v2/sellprice/", request_data) - def spot(self): + def openorders(self, cointype): """ - Fetch the latest spot prices + Open Orders By Coin + :param cointype: + the coin short name, example value 'BTC', 'LTC', 'DOGE' :return: - **status** - ok, error - - **spot** - a list of the current spot price for each coin type + - **message** - ok, description of error if error occurred + - **buyorders** - list of top 100 open AUD buy orders for the given coin + - **sellorders** - list of top 100 open AUD sell orders for the given coin """ - return self._request("/api/spot", {}) + request_data = {"cointype":cointype} + return self._request_public("/pubapi/v2/orders/open/", request_data) - def balances(self): + def openmarketorders(self, cointype, markettype): """ - List my balances + Open Orders By Coin / Market + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + coin market, example values 'USDT' (note: only for available markets) :return: - **status** - ok, error - - **balances** - object containing one property for each coin with your balance for that coin. + - **message** - ok, description of error if error occurred + - **buyorders** - list of top 20 open buy order rates for the given coin / market + - **sellorders** - list of top 20 open sell order rates for the given coin / market """ - return self._request("/api/my/balances", {}) + request_data = {"cointype":cointype, "markettype":markettype} + return self._request_public("/pubapi/v2/orders/open/", request_data) - def orderhistory(self, cointype): + def completedorders(self, cointype): """ - Lists the last 1000 completed orders + Completed Orders By Coin :param cointype: - the coin shortname in uppercase, example value 'BTC', 'LTC', 'DOGE' + coin short name, example value 'BTC', 'LTC', 'DOGE' :return: - **status** - ok, error - - **orders** - list of the last 1000 completed orders + - **message** - ok, description of error if error occurred + - **buyorders** - list of top 100 completed AUD buy orders for the given coin + - **sellorders** - list of top 100 completed AUD sell orders for the given coin """ - request_data = {"cointype": cointype} - return self._request("/api/orders/history", request_data) + request_data = {"cointype":cointype} + return self._request_public("/pubapi/v2/orders/completed/", request_data) - def orders(self, cointype): + def completedmarketorders(self, cointype, markettype): """ - Lists all open orders + Completed Orders By Coin / Market :param cointype: - the coin shortname in uppercase, example value 'BTC', 'LTC', 'DOGE' + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + coin market, example values 'USDT' (note: only for available markets) :return: - **status** - ok, error - - **buyorders** - array containing all the open buy orders - - **sellorders** - array containing all the open sell orders + - **message** - ok, description of error if error occurred + - **buyorders** - list of top 100 completed buy orders for the given coin / market + - **sellorders** - list of top 100 completed sell orders for the given coin / market + + """ + request_data = {"cointype":cointype, "markettype":markettype} + return self._request_public("/pubapi/v2/orders/completed/", request_data) + + def statuscheck(self): + """ + Full Access Status Check + + :return: + - **status** - ok """ - request_data = {"cointype": cointype} - return self._request("/api/orders", request_data) + request_data = {} + return self._request("/api/v2/status/", request_data) - def myorders(self): + def depositaddress(self, cointype): """ - List my buy and sell orders + My Coin Deposit Address + :param cointype: + short name, example value 'BTC', 'LTC', 'DOGE' :return: - **status** - ok, error - - **buyorders** - array containing all your buy orders - - **sellorders** - array containing all your sell orders + - **message** - ok, description of error if error occurred + - **networks** - list of available networks (fields below) """ - return self._request("/api/my/orders", {}) + request_data = {"cointype":cointype} + return self._request("/api/v2/my/coin/deposit/", request_data) - def buy(self, cointype, amount, rate): + def buynowquote(self, cointype, amount, amounttype): """ - Place buy orders + Buy Now Quote :param cointype: - the coin shortname in uppercase, example value 'BTC', 'LTC', 'DOGE' + coin short name, example value 'BTC', 'LTC', 'DOGE' :param amount: - the amount of coins you want to buy, max precision 8 decimal places + amount to buy + :param amounttype: + 'coin' or 'aud' - whether the amount above is coin amount or AUD amount + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **rate** - rate per specified coin + + """ + request_data = {"cointype":cointype, "amount":amount, "amounttype":amounttype} + return self._request("/api/v2/quote/buy/now/", request_data) + + def sellnowquote(self, cointype, amount, amounttype): + """ + Sell Now Quote + + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param amount: + amount of coins to sell + :param amounttype: + 'coin' or 'aud' - whether the amount below is coin amount or AUD amount + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **rate** - rate per specified coin inclusive of fee + + """ + request_data = {"cointype":cointype, "amount":amount, "amounttype":amounttype} + return self._request("/api/v2/quote/sell/now/", request_data) + + def swapnowquote(self, cointypesell, cointypebuy, amount): + """ + Swap Now Quote + + :param cointypesell: + coin short name you would like to swap, example value 'BTC', 'LTC', 'DOGE' + :param cointypebuy: + coin short name you wuld like to swap it for, example value 'BTC', 'LTC', 'DOGE' + :param amount: + amount of coins to swap + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **rate** - rate per coin swapped exclusive of fee + + """ + request_data = {"cointypesell":cointypesell, "cointypebuy":cointypebuy, "amount":amount} + return self._request("/api/v2/quote/swap/now/", request_data) + + def buymarket(self, cointype, amount, rate, markettype="AUD"): + """ + Place Markey Buy Order + + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param amount: + mount of coins you want to buy, max precision 8 decimal places :param rate: - the rate in AUD you are willing to pay, max precision 6 decimal places + rate in market currency (e.g. AUD or USDT) you are willing to pay, max precision 8 decimal places + :param markettype: + (optional, available markets only, default 'AUD') market coin short name to use to buy the coin, example value 'USDT' :return: - **status** - ok, error + - **message** - ok, description of error if error occurred + - **coin** - coin short name, example value 'BTC', 'LTC', 'DOGE' + - **market** - market used to place buy order for the coin + - **amount** - coin amount that was placed + - **rate** - rate that order was placed at + - **id** - id of buy order created which can be used to cancel the order if desired """ - request_data = {"cointype": cointype, "amount": amount, "rate": rate} - return self._request("/api/my/buy", request_data) + # Required parameters + request_data = {"cointype":cointype, "amount":amount, "rate":rate, "markettype":markettype} + + return self._request("/api/v2/my/buy/", request_data) - def sell(self, cointype, amount, rate): + def buynow(self, cointype, amounttype, amount, **kwargs): """ - Place sell orders + Place Buy Now Order :param cointype: - the coin shortname in uppercase, example value 'BTC', 'LTC', 'DOGE' + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param amounttype: + 'coin' or 'aud' - whether the amount below is coin amount or AUD amount :param amount: - the amount of coins you want to sell, max precision 8 decimal places + amount to buy, max precision for coin is 8 decimal places and 2 decimal places for AUD :param rate: - the rate in AUD you are willing to sell for, max precision 6 decimal places + (optional) rate in AUD received from using Buy Now Quote or otherwise + :param threshold: + (optional) 0 to 1000 - buy request will terminate if not within percentage threshold for current rate to vary from submitted rate, max precision for percentage is 8 decimal places + :param direction: + (optional) UP, DOWN, or BOTH (default is UP) - direction the price has moved for the percentage threshold to apply + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **coin** - coin short name, example value 'BTC', 'LTC', 'DOGE' + - **market** - market used to place buy order for the coin + - **amount** - amount that was bought + - **total** - total amount in market currency + + """ + # Required parameter + request_data = {"cointype":cointype, "amounttype":amounttype, "amount":amount} + + # Optional parameter + for key, value in kwargs.items(): + if key == "rate" or key == "threshold" or key == "direction": + request_data[key] = value + + return self._request("/api/v2/my/buy/now/", request_data) + + def sellmarket(self, cointype, amount, rate, **kwargs): + """ + Place Market Sell Order + + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param amount: + amount of coins you want to sell, max precision 8 decimal places + :param rate: + rate in AUD you are willing to sell for, max precision 8 decimal places + :param markettype: + OPTIONAL use markettype='market', example: sellmarket('BTC', 10, 10, markettype='USDT') (optional, available markets only, default 'AUD') market coin short name to use to sell the coin into, example value 'USDT' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **coin** - coin short name + - **market** - market used to place sell order for the coin + - **amount** - coin amount that was placed in order + - **rate** - rate that order was placed at + - **id** - id of sell order created which can be used to cancel the order if desired + + """ + # Required parameters + request_data = {"cointype":cointype, "amount":amount, "rate":rate} + + # Optional parameters + for key, value in kwargs.items(): + if key == "markettype": + request_data[key] = value + + return self._request("/api/v2/my/sell/", request_data) + + def sellnow(self, cointype, amounttype, amount, **kwargs): + """ + Place Sell Now Order + + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param amounttype: + 'coin' or 'aud' - whether the amount below is coin amount or AUD amount + :param amount: + amount of coins you want to sell, max precision 8 decimal places + :param rate: + (optional) rate in AUD received from using Sell Now Quote or otherwise + :param threshold: + (optional) 0 to 1000 - sell request will terminate if not within percentage threshold for current rate to vary from submitted rate, max precision for percentage is 8 decimal places + :param direction: + (optional) UP, DOWN, or BOTH (default is DOWN) - direction the price has moved for the percentage threshold to apply + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **coin** - coin short name, example value 'BTC', 'LTC', 'DOGE' + - **market** - market used to place sell order for the coin + - **amount** - amount that was sold + - **rate** - rate that order was placed at + - **total** - total amount in market currency + + """ + # Required parameters + request_data = {"cointype":cointype, "amounttype":amounttype, "amount":amount} + + # Optional parameters + for key, value in kwargs.items(): + if key == "rate" or key == "threshold" or key == "direction": + request_data[key] = value + + return self._request("/api/v2/my/sell/now/", request_data) + + def swapnow(self, cointypesell, cointypebuy, amount, **kwargs): + """ + Place Swap Now Order + + :param cointypesell: + coin short name you would like to swap, example value 'BTC', 'LTC', 'DOGE' + :param cointypebuy: + coin short name you wuld like to swap it for, example value 'BTC', 'LTC', 'DOGE' + :param amount: + amount of (cointypesell) to swap, max precision for coin is 8 decimal places + :param rate: + (optional) rate received from using Swap Now Quote or otherwise + :param threshold: + (optional) 0 to 1000 - Swap request will terminate if not within percentage threshold for current rate to vary from submitted rate, max precision for percentage is 8 decimal places + :param direction: + (optional) UP, DOWN, or BOTH (default is DOWN) - direction the price has moved for the percentage threshold to apply + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **coin** - coin short name, example value 'BTC', 'LTC', 'DOGE' + - **market** - coin swapped and and coin it was swapped for + - **amount** - coin amount that was swapped + - **rate** - rate that order was placed at + - **total** - total amount in swapped coin currency + + """ + # Required parameters + request_data = {"cointypesell":cointypesell, "cointypebuy":cointypebuy, "amount":amount} + + # Optional parameters + for key, value in kwargs.items(): + if key == "rate" or key == "threshold" or key == "direction": + request_data[key] = value + + return self._request("/api/v2/my/swap/now/", request_data) + + def cancelbuy(self, id): + """ + Cancel My Buy Order + + :param id: + id of the buy order to cancel + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + + """ + request_data = {"id":id} + return self._request("/api/v2/my/buy/cancel/", request_data) + + def cancelsell(self, id): + """ + Cancel My Sell Order + + :param id: + id of the sell order to cancel + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + + """ + request_data = {"id":id} + return self._request("/api/v2/my/sell/cancel/", request_data) + + def withdrawdetails(self, cointype): + """ + Get Coin Withdrawal Details + + + :param cointype: + coin short name you would like to withdraw, example value 'BTC', 'LTC', 'DOGE' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **networks** - list of available send networks + + """ + request_data = {"cointype":cointype} + return self._request("/api/v2/my/coin/withdraw/senddetails/", request_data) + + def withdraw(self, cointype, amount, address, **kwargs): + """ + Coin Withdrawal + + :param cointype: + coin short name you would like to withdraw, example values 'BTC', 'LTC', 'DOGE' + :param amount: + the amount (in coin currency) of coin you would like to withdraw + :param address: + the destination address for the coin amount' + :param emailconfirm: + (optional, default is 'NO') if 'YES' an email confirmation will be sent and withdraw will not complete until confirmation link within email is clicked, values: 'YES', 'NO' + :param network: + (optional) - network you would like to send using e.g. 'BNB', 'ETH' - omit for 'default' network + :param paymentid: + (optional) - the appropriate payment id/memo for the withdrawal where permitted + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + + """ + # Required parameters + request_data = {"cointype": cointype, "amount": amount, "address": address} + + # Optional parameters + for key, value in kwargs.items(): + if key == "emailconfirm" or key == "network" or key == "paymentid": + request_data[key] = value + + return self._request("/api/v2/my/coin/withdraw/send/", request_data) + + def rostatuscheck(self): + """ + Read Only Status Check + + :return: + - **status** - ok + + """ + request_data = {} + return self._request("/api/v2/ro/status/", request_data) + + def marketorders(self, cointype, markettype='AUD'): + """ + Open Market Orders + + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + (optional, available markets only)) market coin short name, example values 'AUD', 'USDT' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **buyorders** - list of top 20 open buy order rates for the given coin + - **sellorders** - list of top 20 open sell orders rates for the given coin + + """ + # Required parameter + request_data = {"cointype":cointype, "markettype":markettype} + + return self._request("/api/v2/ro/orders/market/open/", request_data) + + def completedmarket(self, cointype, **kwargs): + """ + Completed Market Orders + + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + (optional, available markets only)) market coin short name, example values 'AUD', 'USDT' + :param startdate: + (optional, note: date is UTC date or UNIX EPOCH time) format 'YYYY-MM-DD' or e.g. 1614824116 + :param enddate: + (optional, note: date is UTC date or UNIX EPOCH time) format 'YYYY-MM-DD' or e.g. 1614824116 + :param limit: + (optional, default is 200 records, max is 500 records) + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **buyorders** - list of top 100 completed buy orders for the given coin + - **sellorders** - list of top 100 completed sell orders for the given coin + + """ + # Required parameter + request_data = {"cointype":cointype} + + # Optional parameters + for key, value in kwargs.items(): + if key == "markettype" or key == "startdate" or key == "enddate" or key == "limit": + request_data[key] = value + + return self._request("/api/v2/ro/orders/market/completed/", request_data) + + def my_balances(self): + """ + My Coin Balances + + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **balances** - array containing one object for each coin with your balance, AUD value and rate for that coin + + """ + request_data = {} + return self._request("/api/v2/ro/my/balances/", request_data) + + def my_coinbalance(self, cointype): + """ + My Coin Balance + + :param cointype: + coin short name, example value 'BTC', 'LTC', 'DOGE' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **balance** - object containing one property with your balance, AUD value and rate for that coin + + """ + request_data = {"cointype":cointype} + return self._request("/api/v2/ro/my/balance/", request_data) + + def my_marketorders(self, **kwargs): + """ + My Open Market Orders + + :param cointype: + (optional) coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + (optional) market coin short name, example value 'USDT', 'AUD' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **buyorders** - array containing your open buy orders + - **sellorders** - array containing your open sell orders + + """ + # Required Parameters + request_data = {} + + # Optional parameters + for key, value in kwargs.items(): + if key == "cointype" or key == "markettype": + request_data[key] = value + + return self._request("/api/v2/ro/my/orders/market/open/", request_data) + + def my_limitorders(self, **kwargs): + """ + My Open Limit Orders + + :param cointype: + (optional) coin short name, example value 'BTC', 'LTC', 'DOGE' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **buyorders** - array containing your open buy orders + - **sellorders** - array containing your open sell orders + + """ + # Required Parameters + request_data = {} + + # Optional parameters + for key, value in kwargs.items(): + if key == "cointype": + request_data[key] = value + + return self._request("/api/v2/ro/my/orders/limit/open/", request_data) + + def my_orderhistory(self, **kwargs): + """ + My Order History + + :param cointype: + (optional) coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + (optional, available markets only)) market coin short name, example values 'AUD', 'USDT' + :param startdate: + (optional, note: date is UTC date or UNIX EPOCH time) format 'YYYY-MM-DD' or e.g. 1614824116 + :param enddate: + (optional, note: date is UTC date or UNIX EPOCH time) format 'YYYY-MM-DD' or e.g. 1614824116 + :param limit: + (optional, default is 200 records, max is 500 records). Must be in int format not string. + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **buyorders** - array containing your buy order history + - **sellorders** - array containing your sell order history + + """ + # Required Parameters + request_data = {} + + # Optional parameters + for key, value in kwargs.items(): + if key == "cointype" or key == "markettype" or key == "startdate" or key == "enddate" or key == "limit": + request_data[key] = value + + return self._request("/api/v2/ro/my/orders/completed/", request_data) + + def my_markethistory(self, **kwargs): + """ + My Market Order History + + :param cointype: + (optional) coin short name, example value 'BTC', 'LTC', 'DOGE' + :param markettype: + (optional, available markets only)) market coin short name, example values 'AUD', 'USDT' + :param startdate: + (optional, note: date is UTC date or UNIX EPOCH time) format 'YYYY-MM-DD' or e.g. 1614824116 + :param enddate: + ((optional, note: date is UTC date or UNIX EPOCH time) format 'YYYY-MM-DD' or e.g. 1614824116 + :param limit: + (optional, default is 200 records, max is 500 records) + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **buyorders** - array containing your buy order history + - **sellorders** - array containing your sell order history + + """ + # Required parameters + request_data = {} + + # Optional parameters + for key, value in kwargs.items(): + if key == "cointype" or key == "markettype" or key == "startdate" or key == "enddate" or key == "limit": + request_data[key] = value + + return self._request("/api/v2/ro/my/orders/market/completed/", request_data) + + def my_transferhistory(self, **kwargs): + """ + My Send & Receive History + + :param startdate: + (optional) format 'YYYY-MM-DD' + :param enddate: + (optional) format 'YYYY-MM-DD' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **sendtransactions** - array containing your coin send transaction history + - **receivetransactions** - array containing your coin receive transaction history + + """ + # Required parameter + request_data = {} + + # Optional parameters + for key, value in kwargs.items(): + if key == "startdate" or key == "enddate": + request_data[key] = value + + return self._request("/api/v2/ro/my/sendreceive/", request_data) + + def my_deposithistory(self, **kwargs): + """ + My Deposit History + + :param startdate: + (optional) format 'YYYY-MM-DD' + :param enddate: + (optional) format 'YYYY-MM-DD' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **deposits** - array containing your AUD deposit history + + """ + # Required parameter + request_data = {} + + # Optional parameters + for key, value in kwargs.items(): + if key == "startdate" or key == "enddate": + request_data[key] = value + + return self._request("/api/v2/ro/my/deposits/", request_data) + + def my_withdrawhistory(self, **kwargs): + """ + My Withdrawal History + + :param startdate: + (optional) format 'YYYY-MM-DD' + :param enddate: + (optional) format 'YYYY-MM-DD' + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **withdrawals** - array containing your AUD withdrawal history + + """ + # Required parameter + request_data = {} + + # Optional parameters + for key, value in kwargs.items(): + if key == "startdate" or key == "enddate": + request_data[key] = value + + return self._request("/api/v2/ro/my/withdrawals/", request_data) + + def my_affiliatepayments(self): + """ + My Affiliate Payments + + :return: + - **status** - ok, error + - **message** - ok, description of error if error occurred + - **payments** - array containing one object for each completed affiliate payment + + """ + request_data = {} + return self._request("/api/v2/ro/my/affiliatepayments/", request_data) + + def my_referralpayment(self): + """ + My Referral Payments + :return: - **status** - ok, error + - **message** - ok, description of error if error occurred + - **payments** - array containing one object for each completed referral payment """ - request_data = {"cointype": cointype, "amount": amount, "rate": rate} - self._request("/api/my/sell", request_data) + request_data = {} + return self._request("/api/v2/ro/my/referralpayments/", request_data) \ No newline at end of file