Python get open orders
37 Python code examples are found related to "
get open orders".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: HuobiDMService.py From Futures-Python-demo with Apache License 2.0 | 6 votes |
def get_contract_open_orders(self, symbol=None, page_index=None, page_size=None): """ 参数名称 是否必须 类型 描述 symbol false string "BTC","ETH"... page_index false int 第几页,不填第一页 page_size false int 不填默认20,不得多于50 """ params = {} if symbol: params["symbol"] = symbol if page_index: params["page_index"] = page_index if page_size: params["page_size"] = page_size request_path = '/api/v1/contract_openorders' return api_key_post(self.__url, request_path, params, self.__access_key, self.__secret_key) # 获取合约历史委托
Example 2
Source File: service.py From huobi with MIT License | 6 votes |
def get_open_orders(self, symbol, page_index=None, page_size=20, _async=False): """ :param symbol: :param page_index: 页码,不填默认第1页 :param page_size: 不填默认20,不得多于50 20 :param _async: :return: """ params = {'symbol': symbol, 'page_size': page_size} if page_index is not None: params['page_index'] = page_index path = '/api/v1/contract_openorders' return api_key_post(params, path, _async=_async, url=self.url)
Example 3
Source File: openorders.py From coinbase-exchange-order-book with BSD 2-Clause "Simplified" License | 6 votes |
def get_open_orders(self): open_orders = requests.get(exchange_api_url + 'orders', auth=exchange_auth).json() try: self.open_bid_order_id = [order['id'] for order in open_orders if order['side'] == 'buy'][0] self.open_bid_price = [Decimal(order['price']) for order in open_orders if order['side'] == 'buy'][0] except IndexError: self.open_bid_order_id = None self.open_bid_price = None self.open_bid_status = None self.open_bid_cancelled = False self.open_bid_rejections = Decimal('0.0') try: self.open_ask_order_id = [order['id'] for order in open_orders if order['side'] == 'sell'][0] self.open_ask_price = [Decimal(order['price']) for order in open_orders if order['side'] == 'sell'][0] except IndexError: self.open_ask_order_id = None self.open_ask_price = None self.open_ask_status = None self.open_ask_cancelled = False self.open_ask_rejections = Decimal('0.0')
Example 4
Source File: bittrex.py From python-bittrex with MIT License | 6 votes |
def get_open_orders(self, market=None): """ Get all orders that you currently have opened. A specific market can be requested. Endpoint: 1.1 /market/getopenorders 2.0 /key/market/getopenorders :param market: String literal for the market (ie. BTC-LTC) :type market: str :return: Open orders info in JSON :rtype : dict """ return self._api_query(path_dict={ API_V1_1: '/market/getopenorders', API_V2_0: '/key/market/getopenorders' }, options={'market': market, 'marketname': market} if market else None, protection=PROTECTION_PRV)
Example 5
Source File: huobi.py From aioquant with MIT License | 6 votes |
def get_open_orders(self, symbol, limit=500): """Get all open order information. Args: symbol: Symbol name, e.g. `ethusdt`. limit: The number of orders to return, [1, 500]. Returns: success: Success results, otherwise it's None. error: Error information, otherwise it's None. """ uri = "/v1/order/openOrders" account_id = await self._get_account_id() params = { "account-id": account_id, "symbol": symbol, "size": limit } success, error = await self.request("GET", uri, params=params, auth=True) return success, error
Example 6
Source File: http.py From python-binance-chain with MIT License | 6 votes |
def get_open_orders( self, address: str, symbol: Optional[str] = None, offset: Optional[int] = 0, limit: Optional[int] = 500, total: Optional[int] = 0 ): data = { 'address': address } if symbol is not None: data['symbol'] = symbol if offset is not None: data['offset'] = offset if limit is not None: data['limit'] = limit if total is not None: data['total'] = total return await self._get("orders/open", data=data)
Example 7
Source File: api.py From stocklook with MIT License | 6 votes |
def get_open_orders(self, market=None): """ Get all orders that you currently have opened. A specific market can be requested. Endpoint: 1.1 /market/getopenorders 2.0 /key/market/getopenorders :param market: String literal for the market (ie. BTC-LTC) :type market: str :return: Open orders info in JSON :rtype : dict """ return self._api_query(path_dict={ API_V1_1: '/market/getopenorders', API_V2_0: '/key/market/getopenorders' }, options={'market': market, 'marketname': market} if market else None, protection=PROTECTION_PRV)
Example 8
Source File: rex.py From archon with MIT License | 6 votes |
def get_open_orders(self, market=None): """ Get all orders that you currently have opened. A specific market can be requested. Endpoint: 1.1 /market/getopenorders 2.0 /key/market/getopenorders :param market: String literal for the market (ie. BTC-LTC) :type market: str :return: Open orders info in JSON :rtype : dict """ #print ("market " + market) result = self._api_query(path_dict={ API_V1_1: '/market/getopenorders', API_V2_0: '/key/market/getopenorders' }, options={'market': market, 'marketname': market} if market else None, protection=PROTECTION_PRV) #print (result) return result
Example 9
Source File: Robinhood.py From RobinhoodShell with MIT License | 6 votes |
def get_open_orders(self): """ Returns all currently open (cancellable) orders. If not orders are currently open, `None` is returned. TODO: Is there a way to get these from the API endpoint without stepping through order history? """ open_orders = [] orders = self.order_history() for order in orders['results']: if(order['cancel'] is not None): open_orders.append(order) return open_orders ############################## # CANCEL ORDER ##############################
Example 10
Source File: robinhood.py From pyrh with MIT License | 6 votes |
def get_open_orders(self): """Returns all currently open (cancellable) orders. If not orders are currently open, `None` is returned. TODO: Is there a way to get these from the API endpoint without stepping through order history? """ open_orders = [] orders = self.order_history() for order in orders["results"]: if order["cancel"] is not None: open_orders.append(order) return open_orders ############################## # CANCEL ORDER # ############################## # TODO: Fix function complexity
Example 11
Source File: okex.py From thenextquant with MIT License | 6 votes |
def get_open_orders(self, symbol, limit=100): """ Get order details by order ID. Args: symbol: Trading pair, e.g. BTCUSDT. limit: order count to return, max is 100, default is 100. Returns: success: Success results, otherwise it's None. error: Error information, otherwise it's None. """ uri = "/api/spot/v3/orders_pending" params = { "instrument_id": symbol, "limit": limit } result, error = await self.request("GET", uri, params=params, auth=True) return result, error
Example 12
Source File: exchange.py From catalyst with Apache License 2.0 | 6 votes |
def get_open_orders(self, asset): """Retrieve all of the current open orders. Parameters ---------- asset : Asset If passed and not None, return only the open orders for the given asset instead of all open orders. Returns ------- open_orders : dict[list[Order]] or list[Order] If no asset is passed this will return a dict mapping Assets to a list containing all the open orders for the asset. If an asset is passed then this will return a list of the open orders for this asset. """ pass
Example 13
Source File: trade.py From huobi_Python with Apache License 2.0 | 5 votes |
def get_open_orders(self, symbol: 'str', account_id: 'int', side: 'OrderSide' = None, size: 'int' = None, from_id=None, direct=None) -> list: """ The request of get open orders. :param symbol: The symbol, like "btcusdt". (mandatory) :param account_id: The order side, buy or sell. If no side defined, will return all open orders of the account. (mandatory) :param side: The order side, buy or sell. If no side defined, will return all open orders of the account. (optional) :param size: The number of orders to return. Range is [1, 500]. (optional) :param direct: 1:prev order by ID asc from from_id, 2:next order by ID desc from from_id :param from_id: start ID for search :return: The orders information. """ check_symbol(symbol) check_range(size, 1, 500, "size") check_should_not_none(account_id, "account_id") params = { "symbol" : symbol, "account-id" : account_id, "side" : side, "size" : size, "from" : from_id, "direct" : direct } from huobi.service.trade.get_open_orders import GetOpenOrdersService return GetOpenOrdersService(params).request(**self.__kwargs)
Example 14
Source File: hitbtc.py From cryptotik with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_open_orders(self, pair=None): '''get open orders for <pair> or all open orders if called without an argument.''' if pair: return self.private_api(self.url + "order", params={'symbol': pair.upper()}) return self.private_api(self.url + "order")
Example 15
Source File: okex_api_spot.py From archon with MIT License | 5 votes |
def get_all_open_orders(self, symbol = '', page_from = '', page_to = '', limit = ''): params = {} if symbol != '': params.update({'instrument_id': str(symbol.replace('/', '-').replace('_', '-'))}) if page_from != '': params.update({'from': str(page_from)}) if page_to != '': params.update({'to': str(page_to)}) if limit != '': params.update({'limit': str(limit)}) return self.__get('/api/spot/v3/orders_pending', params)
Example 16
Source File: algorithm.py From zipline-chinese with Apache License 2.0 | 5 votes |
def get_open_orders(self, sid=None): if sid is None: return { key: [order.to_api_obj() for order in orders] for key, orders in iteritems(self.blotter.open_orders) if orders } if sid in self.blotter.open_orders: orders = self.blotter.open_orders[sid] return [order.to_api_obj() for order in orders] return []
Example 17
Source File: api_base.py From InplusTrader_Linux with MIT License | 5 votes |
def get_open_orders(): """ 获取当日未成交订单数据 :return: List[:class:`~Order` object] """ return ExecutionContext.account.get_open_orders()
Example 18
Source File: api.py From friartuck with MIT License | 5 votes |
def get_open_orders(self, security=None): open_orders = {} order_data = self.rh_session.order_history() # log.info("order_data: %s" % order_data) if order_data and "results" in order_data: for result in order_data["results"]: status = self._order_status_map[result["state"]] if status not in [0, 4]: # not open order continue instrument = self.rh_session.get_url_content_json(result["instrument"]) symbol = instrument["symbol"] if security and security.symbol != symbol: # not for the the security desired continue order = self._build_order_object(result, symbol) if symbol not in open_orders: open_orders[symbol] = [] open_orders[symbol].append(order) if security: if security.symbol in open_orders: return open_orders[security.symbol] return [] return open_orders
Example 19
Source File: api_base.py From Rqalpha-myquant-learning with Apache License 2.0 | 5 votes |
def get_open_orders(): """ 获取当日未成交订单数据 :return: List[:class:`~Order` object] """ return Environment.get_instance().broker.get_open_orders()
Example 20
Source File: lib_bittrex.py From algotrading with MIT License | 5 votes |
def get_open_orders(self, market): """ Get all orders that you currently have opened. A specific market can be requested /market/getopenorders :param market: String literal for the market (ie. BTC-LTC) :type market: str :return: Open orders info in JSON :rtype : dict """ return self.api_query('getopenorders', {'market': market})
Example 21
Source File: vnpy_broker.py From rqalpha-mod-vnpy with Apache License 2.0 | 5 votes |
def get_open_orders(self, order_book_id=None): if order_book_id is not None: return [order for order in self._gateway.open_orders if order.order_book_id == order_book_id] else: return self._gateway.open_orders
Example 22
Source File: client.py From python-binance with MIT License | 5 votes |
def get_open_orders(self, **params): """Get all open orders on a symbol. https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#current-open-orders-user_data :param symbol: optional :type symbol: str :param recvWindow: the number of milliseconds the request is valid for :type recvWindow: int :returns: API response .. code-block:: python [ { "symbol": "LTCBTC", "orderId": 1, "clientOrderId": "myOrder1", "price": "0.1", "origQty": "1.0", "executedQty": "0.0", "status": "NEW", "timeInForce": "GTC", "type": "LIMIT", "side": "BUY", "stopPrice": "0.0", "icebergQty": "0.0", "time": 1499827319559 } ] :raises: BinanceRequestException, BinanceAPIException """ return self._get('openOrders', True, data=params) # User Stream Endpoints
Example 23
Source File: hitbtc.py From cryptojp with MIT License | 5 votes |
def get_open_orders(self, symbol="BTCUSD"): OPEN_ORDERS_RESOURCE = "/api/2/order" params = {"symbol": symbol} json = self.session.get('https://' + HITBTC_REST_URL + OPEN_ORDERS_RESOURCE).json() return json
Example 24
Source File: binance.py From thenextquant with MIT License | 5 votes |
def get_open_orders(self, symbol): """ 获取当前还未完全成交的订单信息 @param symbol 交易对 """ params = { "symbol": symbol, "timestamp": tools.get_cur_timestamp_ms() } success, error = await self.request("GET", "/api/v3/openOrders", params=params, auth=True) return success, error
Example 25
Source File: client.py From vnpy_crypto with MIT License | 5 votes |
def get_open_orders(self, **params): """Get all open orders on a symbol. https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#current-open-orders-user_data :param symbol: required :type symbol: str :param recvWindow: the number of milliseconds the request is valid for :type recvWindow: int :returns: API response .. code-block:: python [ { "symbol": "LTCBTC", "orderId": 1, "clientOrderId": "myOrder1", "price": "0.1", "origQty": "1.0", "executedQty": "0.0", "status": "NEW", "timeInForce": "GTC", "type": "LIMIT", "side": "BUY", "stopPrice": "0.0", "icebergQty": "0.0", "time": 1499827319559 } ] :raises: BinanceResponseException, BinanceAPIException """ return self._get('openOrders', True, data=params) # User Stream Endpoints
Example 26
Source File: bittrex.py From exchange-simulator with MIT License | 5 votes |
def get_open_orders_api(self, market, *args, **kargs): if market: pair = self.__market_to_pair(market) else: pair = None orders = self.get_all_orders(pair) open_orders = filter(lambda o: o.status in [ 'new', 'partially_filled'], orders) return list(map(self.__order_to_dict, open_orders))
Example 27
Source File: client.py From python-idex with MIT License | 5 votes |
def get_open_orders(self, market, address, count=10, cursor=None): data = { 'market': market, 'address': address, 'count': count } if cursor: data['cursor'] = cursor return await self._post('returnOpenOrders', False, json=data)
Example 28
Source File: bbroker.py From backtrader with GNU General Public License v3.0 | 5 votes |
def get_orders_open(self, safe=False): '''Returns an iterable with the orders which are still open (either not executed or partially executed The orders returned must not be touched. If order manipulation is needed, set the parameter ``safe`` to True ''' if safe: os = [x.clone() for x in self.pending] else: os = [x for x in self.pending] return os
Example 29
Source File: algorithm.py From pylivetrader with Apache License 2.0 | 5 votes |
def get_open_orders(self, asset=None): ''' If asset is unspecified or None, returns a dictionary keyed by asset ID. The dictionary contains a list of orders for each ID, oldest first. If an asset is specified, returns a list of open orders for that asset, oldest first. ''' return self.get_all_orders(asset=asset, status='open')
Example 30
Source File: bittrex_utils.py From mcafee2cash with MIT License | 5 votes |
def get_open_orders(self): orders = self.my_bittrex.get_open_orders()["result"] result = [] for order in orders: message = f'Order {order["OrderUuid"]}\n\n{order["Exchange"]}\nType: {order["OrderType"]}\nQuantity: {order["Quantity"]}\nPrice: {order["Limit"]}\nBTC total: {order["Limit"]*order["Quantity"]}\n\nOpen: {order["Closed"] == None}' result.append(message) return result
Example 31
Source File: ctp_broker.py From rqalpha-mod-ctp with Apache License 2.0 | 5 votes |
def get_open_orders(self, order_book_id=None): if order_book_id is not None: return [order for order in self._trade_gateway.open_orders if order.order_book_id == order_book_id] else: return self._trade_gateway.open_orders
Example 32
Source File: orders.py From robin_stocks with MIT License | 5 votes |
def get_all_open_crypto_orders(info=None): """Returns a list of all the crypto orders that have been processed for the account. :param info: Will filter the results to get a specific value. :type info: Optional[str] :returns: Returns a list of dictionaries of key/value pairs for each option order. If info parameter is provided, \ a list of strings is returned where the strings are the value of the key that matches info. """ url = urls.crypto_orders() data = helper.request_get(url, 'pagination') data = [item for item in data if item['cancel_url'] is not None] return(helper.filter(data, info))
Example 33
Source File: orders.py From robin_stocks with MIT License | 5 votes |
def get_all_open_stock_orders(info=None): """Returns a list of all the orders that are currently open. :param info: Will filter the results to get a specific value. :type info: Optional[str] :returns: Returns a list of dictionaries of key/value pairs for each order. If info parameter is provided, \ a list of strings is returned where the strings are the value of the key that matches info. """ url = urls.orders() data = helper.request_get(url, 'pagination') data = [item for item in data if item['cancel'] is not None] return(helper.filter(data, info))
Example 34
Source File: orders.py From robin_stocks with MIT License | 5 votes |
def get_all_open_option_orders(info=None): """Returns a list of all the orders that are currently open. :param info: Will filter the results to get a specific value. :type info: Optional[str] :returns: Returns a list of dictionaries of key/value pairs for each order. If info parameter is provided, \ a list of strings is returned where the strings are the value of the key that matches info. """ url = urls.option_orders() data = helper.request_get(url, 'pagination') data = [item for item in data if item['cancel_url'] is not None] return(helper.filter(data, info))
Example 35
Source File: bittrex.py From Crypto-Trading-Bot with MIT License | 5 votes |
def get_open_orders(self, market=None): """ Get all orders that you currently have opened. A specific market can be requested /market/getopenorders :param market: String literal for the market (ie. BTC-LTC) :type market: str :return: Open orders info in JSON :rtype: dict """ if market is None: return self.api_query("getopenorders") else: return self.api_query("getopenorders", {"market": market})
Example 36
Source File: client.py From python-idex with MIT License | 4 votes |
def get_my_open_orders(self, market, count=10, cursor=None): """Get your open orders for a given market Output is similar to the output for get_order_book() except that orders are not sorted by type or price, but are rather displayed in the order of insertion. As is the case with get_order_book( there is a params property of the response value that contains details on the order which can help with verifying its authenticity. https://github.com/AuroraDAO/idex-api-docs#returnopenorders :param market: Name of market e.g. ETH_SAN :type market: string :param count: amount of results to return :type count: int :param cursor: For pagination. Provide the value returned in the idex-next-cursor HTTP header to request the next slice (or page) :type cursor: str .. code:: python orders = client.get_my_open_orders('ETH_SAN') :returns: API Response .. code-block:: python [ { orderNumber: 1412, orderHash: '0xf1bbc500af8d411b0096ac62bc9b60e97024ad8b9ea170340ff0ecfa03536417', price: '2.3', amount: '1.2', total: '2.76', type: 'sell', params: { tokenBuy: '0x0000000000000000000000000000000000000000', buySymbol: 'ETH', buyPrecision: 18, amountBuy: '2760000000000000000', tokenSell: '0xf59fad2879fb8380ffa6049a48abf9c9959b3b5c', sellSymbol: 'DVIP', sellPrecision: 8, amountSell: '120000000', expires: 190000, nonce: 166, user: '0xca82b7b95604f70b3ff5c6ede797a28b11b47d63' } }, { orderNumber: 1413, orderHash: '0x62748b55e1106f3f453d51f9b95282593ef5ce03c22f3235536cf63a1476d5e4', price: '2.98', amount: '1.2', total: '3.576', type: 'sell', params:{ tokenBuy: '0x0000000000000000000000000000000000000000', buySymbol: 'ETH', buyPrecision: 18, amountBuy: '3576000000000000000', tokenSell: '0xf59fad2879fb8380ffa6049a48abf9c9959b3b5c', sellSymbol: 'DVIP', sellPrecision: 8, amountSell: '120000000', expires: 190000, nonce: 168, user: '0xca82b7b95604f70b3ff5c6ede797a28b11b47d63' } } ] :raises: IdexWalletAddressNotFoundException, IdexResponseException, IdexAPIException """ return self.get_open_orders(market, self._wallet_address, count, cursor)
Example 37
Source File: client.py From python-binance with MIT License | 4 votes |
def get_open_margin_orders(self, **params): """Query margin accounts open orders If the symbol is not sent, orders for all symbols will be returned in an array. When all symbols are returned, the number of requests counted against the rate limiter is equal to the number of symbols currently trading on the exchange. https://github.com/binance-exchange/binance-official-api-docs/blob/master/margin-api.md#query-margin-accounts-open-order-user_data :param symbol: optional :type symbol: str :param recvWindow: the number of milliseconds the request is valid for :type recvWindow: int :returns: API response [ { "clientOrderId": "qhcZw71gAkCCTv0t0k8LUK", "cummulativeQuoteQty": "0.00000000", "executedQty": "0.00000000", "icebergQty": "0.00000000", "isWorking": true, "orderId": 211842552, "origQty": "0.30000000", "price": "0.00475010", "side": "SELL", "status": "NEW", "stopPrice": "0.00000000", "symbol": "BNBBTC", "time": 1562040170089, "timeInForce": "GTC", "type": "LIMIT", "updateTime": 1562040170089 } ] :raises: BinanceRequestException, BinanceAPIException """ return self._request_margin_api('get', 'margin/openOrders', signed=True, data=params)