def place_order(self, symbol: str, side: str, order_type: str, amount: Decimal, price=None, client_order_id=None, options=None): if not price: raise ValueError( 'Gemini only supports limit orders, must specify price') ot = normalize_trading_options(self.ID, order_type) sym = symbol_std_to_exchange(symbol, self.ID) parameters = { 'type': ot, 'symbol': sym, 'side': side, 'amount': str(amount), 'price': str(price), 'options': [normalize_trading_options(self.ID, o) for o in options] if options else [] } if client_order_id: parameters['client_order_id'] = client_order_id data = self._post("/v1/order/new", parameters) return Gemini._order_status(data)
def place_order(self, symbol: str, side: str, order_type: str, amount: Decimal, price=None, client_order_id=None, options=None): ot = normalize_trading_options(self.ID, order_type) if ot == MARKET and price: raise ValueError('Cannot specify price on a market order') if ot == LIMIT and not price: raise ValueError('Must specify price on a limit order') body = { 'product_id': symbol, 'side': 'buy' if BUY else SELL, 'size': str(amount), 'type': ot } if price: body['price'] = str(price) if client_order_id: body['client_oid'] = client_order_id if options: _ = [ body.update(normalize_trading_options(self.ID, o)) for o in options ] resp = self._request('POST', '/orders', auth=True, body=body) return Coinbase._order_status(resp.json())
def place_order(self, symbol: str, side: str, order_type: str, amount: Decimal, price=None, options=None): if not price: raise ValueError('Poloniex only supports limit orders, must specify price') # Poloniex only supports limit orders, so check the order type _ = normalize_trading_options(self.ID, order_type) parameters = {} if options: parameters = { normalize_trading_options(self.ID, o): 1 for o in options } parameters['currencyPair'] = pair_std_to_exchange(symbol, self.ID) parameters['amount'] = str(amount) parameters['rate'] = str(price) endpoint = None if side == BUY: endpoint = 'buy' elif side == SELL: endpoint = 'sell' data = self._post(endpoint, parameters) order = self.order_status(data['orderNumber']) if 'error' not in order: if len(data['resultingTrades']) == 0: return order else: return Poloniex._trade_status(data['resultingTrades'], symbol, data['orderNumber'], amount) return data
def place_order(self, symbol: str, side: str, order_type: str, amount: Decimal, price=None, options=None): ot = normalize_trading_options(self.ID, order_type) parameters = { 'pair': symbol_std_to_exchange(symbol, self.ID + 'REST'), 'type': 'buy' if side == BUY else 'sell', 'volume': str(amount), 'ordertype': ot } if price is not None: parameters['price'] = str(price) if options: parameters['oflags'] = ','.join( [normalize_trading_options(self.ID, o) for o in options]) data = self._post_private('/private/AddOrder', parameters) if len(data['error']) != 0: return data else: if len(data['result']['txid']) == 1: return self.order_status(data['result']['txid'][0]) else: return [self.order_status(tx) for tx in data['result']['txid']]
def place_order(self, symbol: str, side: str, order_type: str, amount: Decimal, price=None, options=None): if not price: raise ValueError( 'Poloniex only supports limit orders, must specify price') # Poloniex only supports limit orders, so check the order type _ = normalize_trading_options(self.ID, order_type) parameters = { normalize_trading_options(self.ID, o): 1 for o in options } parameters['currencyPair'] = pair_std_to_exchange(symbol, self.ID) parameters['amount'] = str(amount) parameters['rate'] = str(price) endpoint = None if side == BUY: endpoint = 'buy' elif side == SELL: endpoint = 'sell' return self._post(endpoint, parameters)