GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ccxt/python/ccxt/bitbns.py at master · ccxt/ccxt Expand file tree/ Copy pathbitbns.pyMore file actions 1261 lines (1223 loc) · 51.9 KB / Copy pathbitbns.pyFile metadata and controls1261 lines (1223 loc) · 51.9 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 # -*- coding: utf-8 -*- # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN: # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code from ccxt.base.exchange import Exchange from ccxt.abstract.bitbns import ImplicitAPI import hashlib from ccxt.base.types import Balances, Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Status, Str, Strings, Ticker, Tickers, Trade, Transaction from ccxt.base.errors import ExchangeError from ccxt.base.errors import ArgumentsRequired from ccxt.base.errors import BadRequest from ccxt.base.errors import BadSymbol from ccxt.base.errors import InsufficientFunds from ccxt.base.errors import OrderNotFound from ccxt.base.decimal_to_precision import TICK_SIZE from ccxt.base.precise import Precise class bitbns(Exchange, ImplicitAPI): def describe(self) -> dict: return self.deep_extend(super(bitbns, self).describe(), { 'id': 'bitbns', 'name': 'Bitbns', 'countries': ['IN'], # India 'rateLimit': 1000, 'certified': False, 'version': 'v2', # new metainfo interface 'has': { 'CORS': None, 'spot': True, 'margin': None, # has but unimplemented 'swap': False, 'future': False, 'option': None, # coming soon 'cancelAllOrders': False, 'cancelOrder': True, 'createOrder': True, 'createStopOrder': True, 'createTriggerOrder': True, 'fechCurrencies': False, 'fetchBalance': True, 'fetchDepositAddress': True, 'fetchDepositAddresses': False, 'fetchDepositAddressesByNetwork': False, 'fetchDeposits': True, 'fetchFundingHistory': False, 'fetchFundingRate': False, 'fetchFundingRateHistory': False, 'fetchFundingRates': False, 'fetchIndexOHLCV': False, 'fetchMarginMode': False, 'fetchMarkets': True, 'fetchMarkOHLCV': False, 'fetchMyTrades': True, 'fetchOHLCV': False, 'fetchOpenOrders': True, 'fetchOrder': True, 'fetchOrderBook': True, 'fetchPositionMode': False, 'fetchPremiumIndexOHLCV': False, 'fetchStatus': True, 'fetchTicker': 'emulated', 'fetchTickers': True, 'fetchTrades': True, 'fetchTradingFee': False, 'fetchTradingFees': False, 'fetchTransfer': False, 'fetchTransfers': False, 'fetchWithdrawal': False, 'fetchWithdrawals': True, 'transfer': False, 'withdraw': False, }, 'hostname': 'bitbns.com', 'urls': { 'logo': 'https://github.com/user-attachments/assets/a5b9a562-cdd8-4bea-9fa7-fd24c1dad3d9', 'api': { 'www': 'https://{hostname}', 'v1': 'https://api.{hostname}/api/trade/v1', 'v2': 'https://api.{hostname}/api/trade/v2', }, 'www': 'https://bitbns.com', 'referral': 'https://ref.bitbns.com/1090961', 'doc': [ 'https://bitbns.com/trade/#/api-trading/', ], 'fees': 'https://bitbns.com/fees', }, 'api': { 'www': { 'get': { 'order/fetchMarkets': {'cost': 1}, 'order/fetchTickers': {'cost': 1}, 'order/fetchOrderbook': {'cost': 1}, 'order/getTickerWithVolume': {'cost': 1}, 'exchangeData/ohlc': {'cost': 1}, 'exchangeData/orderBook': {'cost': 1}, 'exchangeData/tradedetails': {'cost': 1}, }, }, 'v1': { 'get': { 'platform/status': {'cost': 1}, 'tickers': {'cost': 1}, 'orderbook/sell/{symbol}': {'cost': 1}, 'orderbook/buy/{symbol}': {'cost': 1}, }, 'post': { 'currentCoinBalance/EVERYTHING': {'cost': 1}, 'getApiUsageStatus/USAGE': {'cost': 1}, 'getOrderSocketToken/USAGE': {'cost': 1}, 'currentCoinBalance/{symbol}': {'cost': 1}, 'orderStatus/{symbol}': {'cost': 1}, 'depositHistory/{symbol}': {'cost': 1}, 'withdrawHistory/{symbol}': {'cost': 1}, 'withdrawHistoryAll/{symbol}': {'cost': 1}, 'depositHistoryAll/{symbol}': {'cost': 1}, 'userHistoryNew': {'cost': 1}, 'listOpenOrders/{symbol}': {'cost': 1}, 'listOpenOrdersOther/{symbol}': {'cost': 1}, 'listOpenStopOrders/{symbol}': {'cost': 1}, 'getCoinAddress/{symbol}': {'cost': 1}, 'placeSellOrder/{symbol}': {'cost': 1}, 'placeSellOrderOther/{symbol}': {'cost': 1}, 'placeBuyOrder/{symbol}': {'cost': 1}, 'placeBuyOrderOther/{symbol}': {'cost': 1}, 'buyStopLoss/{symbol}': {'cost': 1}, 'sellStopLoss/{symbol}': {'cost': 1}, 'cancelOrder/{symbol}': {'cost': 1}, 'cancelOrderOther/{symbol}': {'cost': 1}, 'cancelStopLossOrder/{symbol}': {'cost': 1}, 'listExecutedOrders/{symbol}': {'cost': 1}, 'placeMarketOrder/{symbol}': {'cost': 1}, 'placeMarketOrderQnty/{symbol}': {'cost': 1}, }, }, 'v2': { 'post': { 'orders': {'cost': 1}, 'cancel': {'cost': 1}, 'getordersnew': {'cost': 1}, 'marginOrders': {'cost': 1}, }, }, }, 'fees': { 'trading': { 'feeSide': 'quote', 'tierBased': False, 'percentage': True, 'taker': self.parse_number('0.0025'), 'maker': self.parse_number('0.0025'), }, }, 'precisionMode': TICK_SIZE, 'features': { 'spot': { 'sandbox': False, 'createOrder': { 'marginMode': False, 'triggerPrice': True, 'triggerPriceType': None, 'triggerDirection': False, 'stopLossPrice': False, # todo with triggerPrice 'takeProfitPrice': False, # todo with triggerPrice 'attachedStopLossTakeProfit': None, 'timeInForce': { 'IOC': False, 'FOK': False, 'PO': False, 'GTD': False, }, 'hedged': False, 'trailing': False, # todo recheck 'leverage': False, 'marketBuyRequiresPrice': False, 'marketBuyByCost': False, 'selfTradePrevention': False, 'iceberg': False, }, 'createOrders': None, 'fetchMyTrades': { 'marginMode': False, 'limit': None, 'daysBack': None, 'untilDays': None, 'symbolRequired': True, }, 'fetchOrder': { 'marginMode': False, 'trigger': False, 'trailing': False, 'symbolRequired': True, }, 'fetchOpenOrders': { 'marginMode': False, 'limit': None, 'trigger': True, 'trailing': False, 'symbolRequired': True, }, 'fetchOrders': None, 'fetchClosedOrders': None, # todo: implement fetchOHLCV 'fetchOHLCV': { 'limit': 100, }, }, # todo: implement swap methods 'swap': { 'linear': None, 'inverse': None, }, 'future': { 'linear': None, 'inverse': None, }, }, 'exceptions': { 'exact': { '400': BadRequest, # {"msg":"Invalid Request","status":-1,"code":400} '409': BadSymbol, # {"data":"","status":0,"error":"coin name not supplied or not yet supported","code":409} '416': InsufficientFunds, # {"data":"Oops ! Not sufficient currency to sell","status":0,"error":null,"code":416} '417': OrderNotFound, # {"data":[],"status":0,"error":"Nothing to show","code":417} }, 'broad': {}, }, }) def fetch_status(self, params: dict = {}) -> Status: """ the latest known information on the availability of the exchange API :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: a `status structure <https://docs.ccxt.com/?id=exchange-status-structure>` """ response = self.v1GetPlatformStatus(params) # # { # "data":{ # "BTC":{"status":1}, # "ETH":{"status":1}, # "XRP":{"status":1}, # }, # "status":1, # "error":null, # "code":200 # } # statusRaw = self.safe_string(response, 'status') return { 'status': self.safe_string({'1': 'ok'}, statusRaw, statusRaw), 'updated': None, 'eta': None, 'url': None, 'info': response, } def fetch_markets(self, params: dict = {}) -> list[Market]: """ retrieves data on all markets for bitbns :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict[]: an array of objects representing market data """ response = self.wwwGetOrderFetchMarkets(params) # # [ # { # "id":"BTC", # "symbol":"BTC/INR", # "base":"BTC", # "quote":"INR", # "baseId":"BTC", # "quoteId":"", # "active":true, # "limits":{ # "amount":{"min":"0.00017376","max":20}, # "price":{"min":2762353.2359999996,"max":6445490.883999999}, # "cost":{"min":800,"max":128909817.67999998} # }, # "precision":{ # "amount":8, # "price":2 # }, # "info":{} # }, # ] # result = [] rawMarkets = self.to_array(response) for i in range(0, len(rawMarkets)): market = rawMarkets[i] id = self.safe_string(market, 'id') baseId = self.safe_string(market, 'base') quoteId = self.safe_string(market, 'quote') base = self.safe_currency_code(baseId) quote = self.safe_currency_code(quoteId) if (baseId is None) or (base is None) or (quote is None): continue marketPrecision = self.safe_dict(market, 'precision', {}) marketLimits = self.safe_dict(market, 'limits', {}) amountLimits = self.safe_dict(marketLimits, 'amount', {}) priceLimits = self.safe_dict(marketLimits, 'price', {}) costLimits = self.safe_dict(marketLimits, 'cost', {}) usdt = (quoteId == 'USDT') # INR markets don't need a _INR prefix uppercaseId = baseId if usdt: uppercaseId = (baseId + '_' + quoteId) result.append({ 'id': id, 'uppercaseId': uppercaseId, 'symbol': base + '/' + quote, 'base': base, 'quote': quote, 'settle': None, 'baseId': baseId, 'quoteId': quoteId, 'settleId': None, 'type': 'spot', 'spot': True, 'margin': False, 'swap': False, 'future': False, 'option': False, 'active': self.safe_bool(market, 'active'), 'contract': False, 'linear': None, 'inverse': None, 'contractSize': None, 'expiry': None, 'expiryDatetime': None, 'strike': None, 'optionType': None, 'precision': { 'amount': self.parse_number(self.parse_precision(self.safe_string(marketPrecision, 'amount'))), 'price': self.parse_number(self.parse_precision(self.safe_string(marketPrecision, 'price'))), }, 'limits': { 'leverage': { 'min': None, 'max': None, }, 'amount': { 'min': self.safe_number(amountLimits, 'min'), 'max': self.safe_number(amountLimits, 'max'), }, 'price': { 'min': self.safe_number(priceLimits, 'min'), 'max': self.safe_number(priceLimits, 'max'), }, 'cost': { 'min': self.safe_number(costLimits, 'min'), 'max': self.safe_number(costLimits, 'max'), }, }, 'created': None, 'info': market, }) return result def fetch_order_book(self, symbol: str, limit: Int = None, params: dict = {}) -> OrderBook: """ fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data :param str symbol: unified symbol of the market to fetch the order book for :param int [limit]: the maximum amount of order book entries to return :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: an `order book structure <https://docs.ccxt.com/?id=order-book-structure>` """ if self.markets is None: self.load_markets() market = self.market(symbol) request = { 'symbol': market['id'], } if limit is not None: request['limit'] = limit # default 100, max 5000, see https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#order-book response = self.wwwGetOrderFetchOrderbook(self.extend(request, params)) # # { # "bids":[ # [49352.04,0.843948], # [49352.03,0.742048], # [49349.78,0.686239], # ], # "asks":[ # [49443.59,0.065137], # [49444.63,0.098211], # [49449.01,0.066309], # ], # "timestamp":1619172786577, # "datetime":"2021-04-23T10:13:06.577Z", # "nonce":"" # } # timestamp = self.safe_integer(response, 'timestamp') return self.parse_order_book(response, market['symbol'], timestamp) def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker: # # { # "symbol":"BTC/INR", # "info":{ # "highest_buy_bid":4368494.31, # "lowest_sell_bid":4374835.09, # "last_traded_price":4374835.09, # "yes_price":4531016.27, # "volume":{"max":"4569119.23","min":"4254552.13","volume":62.17722344} # }, # "timestamp":1619100020845, # "datetime":1619100020845, # "high":"4569119.23", # "low":"4254552.13", # "bid":4368494.31, # "bidVolume":"", # "ask":4374835.09, # "askVolume":"", # "vwap":"", # "open":4531016.27, # "close":4374835.09, # "last":4374835.09, # "baseVolume":62.17722344, # "quoteVolume":"", # "previousClose":"", # "change":-156181.1799999997, # "percentage":-3.446934874943623, # "average":4452925.68 # } # timestamp = self.safe_integer(ticker, 'timestamp') marketId = self.safe_string(ticker, 'symbol') symbol = self.safe_symbol(marketId, market) last = self.safe_string(ticker, 'last') return self.safe_ticker({ 'symbol': symbol, 'timestamp': timestamp, 'datetime': self.iso8601(timestamp), 'high': self.safe_string(ticker, 'high'), 'low': self.safe_string(ticker, 'low'), 'bid': self.safe_string(ticker, 'bid'), 'bidVolume': self.safe_string(ticker, 'bidVolume'), 'ask': self.safe_string(ticker, 'ask'), 'askVolume': self.safe_string(ticker, 'askVolume'), 'vwap': self.safe_string(ticker, 'vwap'), 'open': self.safe_string(ticker, 'open'), 'close': last, 'last': last, 'previousClose': self.safe_string(ticker, 'previousClose'), # previous day close 'change': self.safe_string(ticker, 'change'), 'percentage': self.safe_string(ticker, 'percentage'), 'average': self.safe_string(ticker, 'average'), 'baseVolume': self.safe_string(ticker, 'baseVolume'), 'quoteVolume': self.safe_string(ticker, 'quoteVolume'), 'info': ticker, }, market) def fetch_tickers(self, symbols: Strings = None, params: dict = {}) -> Tickers: """ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>` """ if self.markets is None: self.load_markets() response = self.wwwGetOrderFetchTickers(params) # # { # "BTC/INR":{ # "symbol":"BTC/INR", # "info":{ # "highest_buy_bid":4368494.31, # "lowest_sell_bid":4374835.09, # "last_traded_price":4374835.09, # "yes_price":4531016.27, # "volume":{"max":"4569119.23","min":"4254552.13","volume":62.17722344} # }, # "timestamp":1619100020845, # "datetime":1619100020845, # "high":"4569119.23", # "low":"4254552.13", # "bid":4368494.31, # "bidVolume":"", # "ask":4374835.09, # "askVolume":"", # "vwap":"", # "open":4531016.27, # "close":4374835.09, # "last":4374835.09, # "baseVolume":62.17722344, # "quoteVolume":"", # "previousClose":"", # "change":-156181.1799999997, # "percentage":-3.446934874943623, # "average":4452925.68 # } # } # return self.parse_tickers(response, symbols) def parse_balance(self, response: dict) -> Balances: timestamp = None result = { 'info': response, 'timestamp': timestamp, 'datetime': self.iso8601(timestamp), } data = self.safe_dict(response, 'data', {}) keys = list(data.keys()) for i in range(0, len(keys)): key = keys[i] parts = key.split('availableorder') numParts = len(parts) if numParts > 1: usedCurrencyId = self.safe_string(parts, 1, '') currencyId = self.safe_string(parts, 1) # note that "Money" stands for INR - the only fiat in bitbns account = self.account() account['free'] = self.safe_string(data, key) account['used'] = self.safe_string(data, 'inorder' + usedCurrencyId) if currencyId == 'Money': currencyId = 'INR' code = self.safe_currency_code(currencyId) if code is not None: result[code] = account return self.safe_balance(result) def fetch_balance(self, params: dict = {}) -> Balances: """ query for balance and get the amount of funds available for trading or funds locked in orders :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: a `balance structure <https://docs.ccxt.com/?id=balance-structure>` """ if self.markets is None: self.load_markets() response = self.v1PostCurrentCoinBalanceEVERYTHING(params) # # { # "data":{ # "availableorderMoney":12.34, // INR # "availableorderBTC":0, # "availableorderXRP":0, # "inorderMoney":0, // INR # "inorderBTC":0, # "inorderXRP":0, # "inorderNEO":0, # }, # "status":1, # "error":null, # "code":200 # } # # note that "Money" stands for INR - the only fiat in bitbns return self.parse_balance(response) def parse_status(self, status: Str) -> Str: statuses = { '-1': 'cancelled', '0': 'open', '1': 'open', '2': 'done', # 'PARTIALLY_FILLED': 'open', # 'FILLED': 'closed', # 'CANCELED': 'canceled', # 'PENDING_CANCEL': 'canceling', // currently unused # 'REJECTED': 'rejected', # 'EXPIRED': 'expired', } return self.safe_string(statuses, status, status) def parse_order(self, order: dict, market: Market = None) -> Order: # # createOrder # # { # "data": "Successfully placed bid to purchase currency", # "status": 1, # "error": null, # "id": 5424475, # "code": 200 # } # # fetchOpenOrders, fetchOrder # # { # "entry_id": 5424475, # "btc": 0.01, # "rate": 2000, # "time": "2021-04-25T17:05:42.000Z", # "type": 0, # "status": 0 # "t_rate": 0.45, // only stop orders # "trail": 0 // only stop orders # } # # cancelOrder # # { # "data": "Successfully cancelled the order", # "status": 1, # "error": null, # "code": 200 # } # id = self.safe_string_2(order, 'id', 'entry_id') datetime = self.safe_string(order, 'time') triggerPrice = self.safe_string(order, 't_rate') side = self.safe_string(order, 'type') if side == '0': side = 'buy' elif side == '1': side = 'sell' data = self.safe_string(order, 'data') status = self.safe_string(order, 'status') if data == 'Successfully cancelled the order': status = 'cancelled' else: status = self.parse_status(status) return self.safe_order({ 'info': order, 'id': id, 'clientOrderId': None, 'timestamp': self.parse8601(datetime), 'datetime': datetime, 'lastTradeTimestamp': None, 'symbol': self.safe_string(market, 'symbol'), 'timeInForce': None, 'postOnly': None, 'side': side, 'price': self.safe_string(order, 'rate'), 'triggerPrice': triggerPrice, 'amount': self.safe_string(order, 'btc'), 'cost': None, 'average': None, 'filled': None, 'remaining': None, 'status': status, 'fee': { 'cost': None, 'currency': None, 'rate': None, }, 'trades': None, }, market) def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params: dict = {}) -> Order: """ create a trade order https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/place-orders https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/market-orders-quantity # market orders :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or 'limit' :param str side: 'buy' or 'sell' :param float amount: how much of currency you want to trade in units of base currency :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders :param dict [params]: extra parameters specific to the exchange API endpoint :param float [params.triggerPrice]: the price at which a trigger order is triggered at EXCHANGE SPECIFIC PARAMETERS :param float [params.target_rate]: *requires params.trail_rate when set, type must be 'limit'* a bracket order is placed when set :param float [params.trail_rate]: *requires params.target_rate when set, type must be 'limit'* a bracket order is placed when set :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` """ if self.markets is None: self.load_markets() market = self.market(symbol) triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPrice', 't_rate']) targetRate = self.safe_string(params, 'target_rate') trailRate = self.safe_string(params, 'trail_rate') paramsOmitted = self.omit(params, ['triggerPrice', 'stopPrice', 'trail_rate', 'target_rate', 't_rate']) self.check_required_argument('createOrder', side, 'side') request = { 'side': side.upper(), 'symbol': market['uppercaseId'], 'quantity': self.amount_to_precision(symbol, amount), # 'target_rate': this.priceToPrecision (symbol, targetRate), # 't_rate': this.priceToPrecision (symbol, stopPrice), # 'trail_rate': this.priceToPrecision (symbol, trailRate), } if type == 'limit': request['rate'] = self.price_to_precision(symbol, price) else: request['market'] = market['quoteId'] if triggerPrice is not None: request['t_rate'] = self.price_to_precision(symbol, triggerPrice) if targetRate is not None: request['target_rate'] = self.price_to_precision(symbol, targetRate) if trailRate is not None: request['trail_rate'] = self.price_to_precision(symbol, trailRate) response = None if type == 'limit': response = self.v2PostOrders(self.extend(request, paramsOmitted)) else: response = self.v1PostPlaceMarketOrderQntySymbol(self.extend(request, paramsOmitted)) # # { # "data":"Successfully placed bid to purchase currency", # "status":1, # "error":null, # "id":5424475, # "code":200 # } # parsed = {} if (response is None) else response return self.parse_order(parsed, market) def cancel_order(self, id: str, symbol: Str = None, params: dict = {}) -> Order: """ cancels an open order https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/cancel-orders https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/cancel-stop-loss-orders :param str id: order id :param str symbol: unified symbol of the market the order was made in :param dict [params]: extra parameters specific to the exchange API endpoint :param boolean [params.trigger]: True if cancelling a trigger order :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>` """ if symbol is None: raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument') if self.markets is None: self.load_markets() market = self.market(symbol) isTrigger = self.safe_bool_2(params, 'trigger', 'stop') paramsOmitted = self.omit(params, ['trigger', 'stop']) request = { 'entry_id': id, 'symbol': market['uppercaseId'], } response = None tail = 'StopLossOrder' if (isTrigger is True) else 'Order' quoteSide = 'usdtcancel' if (market['quoteId'] == 'USDT') else 'cancel' quoteSide += tail request['side'] = quoteSide response = self.v2PostCancel(self.extend(request, paramsOmitted)) parsed = {} if (response is None) else response return self.parse_order(parsed, market) def fetch_order(self, id: str, symbol: Str = None, params: dict = {}) -> Order: """ fetches information on an order made by the user https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/order-status :param str id: order id :param str symbol: unified symbol of the market the order was made in :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: An `order structure <https://docs.ccxt.com/?id=order-structure>` """ if symbol is None: raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument') if self.markets is None: self.load_markets() market = self.market(symbol) request = { 'symbol': market['id'], 'entry_id': id, } trigger = self.safe_bool_2(params, 'trigger', 'stop') if trigger is True: raise BadRequest(self.id + ' fetchOrder cannot fetch stop orders') response = self.v1PostOrderStatusSymbol(self.extend(request, params)) # # { # "data":[ # { # "entry_id":5424475, # "btc":0.01, # "rate":2000, # "time":"2021-04-25T17:05:42.000Z", # "type":0, # "status":0, # "total":0.01, # "avg_cost":null, # "side":"BUY", # "amount":0.01, # "remaining":0.01, # "filled":0, # "cost":null, # "fee":0.05 # } # ], # "status":1, # "error":null, # "code":200 # } # data = self.safe_list(response, 'data', []) first = self.safe_dict(data, 0, {}) return self.parse_order(first, market) def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params: dict = {}) -> list[Order]: """ fetch all unfilled currently open orders https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/order-status-limit https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/order-status-limit/order-status-stop-limit :param str symbol: unified market symbol :param int [since]: the earliest time in ms to fetch open orders for :param int [limit]: the maximum number of open orders structures to retrieve :param dict [params]: extra parameters specific to the exchange API endpoint :param boolean [params.trigger]: True if fetching trigger orders :returns Order[]: a list of `order structures <https://docs.ccxt.com/?id=order-structure>` """ if symbol is None: raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires a symbol argument') if self.markets is None: self.load_markets() market = self.market(symbol) isTrigger = self.safe_bool_2(params, 'trigger', 'stop') paramsOmitted = self.omit(params, ['trigger', 'stop']) quoteSide = 'listOpen' if market['quoteId'] == 'USDT': quoteSide = 'usdtListOpen' request = { 'symbol': market['uppercaseId'], 'page': 0, 'side': (quoteSide + 'StopOrders') if (isTrigger is True) else (quoteSide + 'Orders'), } response = self.v2PostGetordersnew(self.extend(request, paramsOmitted)) # # { # "data":[ # { # "entry_id":5424475, # "btc":0.01, # "rate":2000, # "time":"2021-04-25T17:05:42.000Z", # "type":0, # "status":0 # "t_rate":0.45, // only stop orders # "type":1, // only stop orders # "trail":0 // only stop orders # } # ], # "status":1, # "error":null, # "code":200 # } # data = self.safe_list(response, 'data', []) return self.parse_orders(data, market, since, limit) def parse_trade(self, trade: dict, market: Market = None) -> Trade: # # fetchMyTrades # # { # "type": "BTC Sell order executed", # "typeI": 6, # "crypto": 5000, # "amount": 35.4, # "rate": 709800, # "date": "2020-05-22T15:05:34.000Z", # "unit": "INR", # "factor": 100000000, # "fee": 0.09, # "delh_btc": -5000, # "delh_inr": 0, # "del_btc": 0, # "del_inr": 35.4, # "id": "2938823" # } # # fetchTrades # # { # "tradeId":"1909151", # "price":"61904.6300", # "quote_volume":1618.05, # "base_volume":0.02607254, # "timestamp":1634548602000, # "type":"buy" # } # marketResolved = self.safe_market(None, market) orderId = self.safe_string_2(trade, 'id', 'tradeId') timestamp = self.parse8601(self.safe_string(trade, 'date')) timestamp = self.safe_integer(trade, 'timestamp', timestamp) priceString = self.safe_string_2(trade, 'rate', 'price') amountString = self.safe_string(trade, 'amount') side = self.safe_string_lower(trade, 'type') if side is not None: if side.find('buy') >= 0: side = 'buy' elif side.find('sell') >= 0: side = 'sell' factor = self.safe_string(trade, 'factor') costString = None if factor is not None: amountString = Precise.string_div(amountString, factor) else: amountString = self.safe_string(trade, 'base_volume') costString = self.safe_string(trade, 'quote_volume') symbol = marketResolved['symbol'] fee = None feeCostString = self.safe_string(trade, 'fee') if feeCostString is not None: feeCurrencyCode = marketResolved['quote'] fee = { 'cost': feeCostString, 'currency': feeCurrencyCode, } return self.safe_trade({ 'info': trade, 'timestamp': timestamp, 'datetime': self.iso8601(timestamp), 'symbol': symbol, 'id': orderId, 'order': orderId, 'type': None, 'side': side, 'takerOrMaker': None, 'price': priceString, 'amount': amountString, 'cost': costString, 'fee': fee, }, marketResolved) def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params: dict = {}) -> list[Trade]: """ fetch all trades made by the user :param str symbol: unified market symbol :param int [since]: the earliest time in ms to fetch trades for :param int [limit]: the maximum number of trades structures to retrieve :param dict [params]: extra parameters specific to the exchange API endpoint :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>` """ if symbol is None: raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument') if self.markets is None: self.load_markets() market = self.market(symbol) request = { 'symbol': market['id'], 'page': 0, } if since is not None: request['since'] = self.iso8601(since) response = self.v1PostListExecutedOrdersSymbol(self.extend(request, params)) # # { # "data": [ # { # "type": "BTC Sell order executed", # "typeI": 6, # "crypto": 5000, # "amount": 35.4, # "rate": 709800, # "date": "2020-05-22T15:05:34.000Z", # "unit": "INR", # "factor": 100000000, # "fee": 0.09, # "delh_btc": -5000, # "delh_inr": 0, # "del_btc": 0, # "del_inr": 35.4, # "id": "2938823" # }, # { # "type": "BTC Sell order executed", # "typeI": 6, # "crypto": 195000, # "amount": 1380.58, # "rate": 709765.5, # "date": "2020-05-22T15:05:34.000Z", # "unit": "INR", # "factor": 100000000, # "fee": 3.47, # "delh_btc": -195000, # "delh_inr": 0, # "del_btc": 0, # "del_inr": 1380.58, # "id": "2938823" # } # ], # "status": 1, # "error": null, # "code": 200 # } # data = self.safe_list(response, 'data', []) return self.parse_trades(data, market, since, limit) def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params: dict = {}) -> list[Trade]: """ get the list of most recent trades for a particular symbol :param str symbol: unified symbol of the market to fetch trades for :param int [since]: timestamp in ms of the earliest trade to fetch :param int [limit]: the maximum amount of trades to fetch :param dict [params]: extra parameters specific to the exchange API endpoint :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>` """ if symbol is None: |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |