Shortcut for ``instrument.order("BUY", ...)`` and accepts all of its
        `optional parameters <#qtpylib.instrument.Instrument.order>`_

        :Parameters:
            quantity : int
                Order quantity
498643
def buy_market(self, quantity, **kwargs):
        
        kwargs['limit_price'] = 0
        kwargs['order_type'] = "MARKET"
        self.parent.order("BUY", self, quantity=quantity, **kwargs)
543749
def increment(key, amount = 1, options = {})
      value = Utils.to_int(load(key, options)) + amount
      store(key, value.to_s, options)
      value
    end
928023
def first_available(self, *quantities):
        
        for i, q in enumerate(quantities):
            if self.has_quantity(q):
                if i:
                    warnings.warn('{} not available; using {} instead'.format(quantities[0], q))
                return q
1354154
def create_order_with_token(request):
    
    # Get the request data
    try:
        address = request.data['address']
        shipping_option = request.data.get('shipping_option', None)
        email = request.data['email']
        transaction_id = request.data['transaction_id']
    except KeyError:
        return Response(data={"message": "Missing parameters from request data"},
                        status=status.HTTP_400_BAD_REQUEST)

    # Create the order
    order = create_order(
        email,
        request,
        addresses=address,
        shipping_option=shipping_option,
    )

    order.payment_date = timezone.now()
    order.transaction_id = transaction_id
    order.save()
    # Once the order has been successfully taken, we can empty the basket
    destroy_basket(request)

    return Response(data={"order_id": order.id}, status=status.HTTP_201_CREATED)
140859
def order_by(self, **kwargs):
        
        if kwargs:
            col, order = kwargs.popitem()
            self.order_clause = "order by {col} {order} ".format(
                col=col, order=order)
        return self
192907
def repay_loan(self, order_id, amount):
        
        params = {'order-id': order_id, 'amount': amount}
        path = f'/v1/margin/orders/{order_id}/repay'

        def _wrapper(_func):
            @wraps(_func)
            def handle():
                _func(api_key_post(params, path))

            return handle

        return _wrapper
869752
public void enterOrder(Order order, String instrument) {
    books
        .get(instrument)
        .enter(order.id(), order.level().side(), order.level().price(), order.size());
  }
445223
def place_order(self, amount, price, side, ord_type, symbol='btcusd', exchange='bitfinex'):
        
        payload = {

            "request": "/v1/order/new",
            "nonce": self._nonce,
            "symbol": symbol,
            "amount": amount,
            "price": price,
            "exchange": exchange,
            "side": side,
            "type": ord_type

        }

        signed_payload = self._sign_payload(payload)
        r = requests.post(self.URL + "/order/new", headers=signed_payload, verify=True)
        json_resp = r.json()

        try:
            json_resp['order_id']
        except:
            return json_resp['message']

        return json_resp
1008361
def order_param(ts, axis=2):
    """"""
    return np.abs(np.exp(1.0j * ts).mean(axis=axis))
894854
def _quantityToReal(self, quantity):
        
        if not quantity:
            return 1.0

        try:
            return float(quantity.replace(',', '.'))
        except ValueError:
            pass

        try:
            return float(self.ptc.numbers[quantity])
        except KeyError:
            pass

        return 0.0
977273
def quantity(*args):
    
    if len(args) == 1:
        if isinstance(args[0], str):
            # use copy constructor to create quantity from string
            return Quantity(from_string(args[0]))
        elif isinstance(args[0], dict):
            if hasattr(args[0]["value"], "__len__"):
                return QuantVec(from_dict_v(args[0]))
            else:
                return Quantity(from_dict(args[0]))
        elif isinstance(args[0], Quantity) or isinstance(args[0], QuantVec):
            return args[0]
        else:
            raise TypeError("Invalid argument type for")
    else:
        if hasattr(args[0], "__len__"):
            return QuantVec(*args)
        else:
            return Quantity(*args)
797289
def add_order(opts={})
      required_opts = %w{ pair type ordertype volume }
      leftover = required_opts - opts.keys.map(&:to_s)
      if leftover.length > 0
        raise ArgumentError.new("Required options, not given. Input must include #{leftover}")
      end
      post_private 'AddOrder', opts
    end
629361
def get_orders(self, instrument=None, count=50):
        
        url = "{0}/{1}/accounts/{2}/orders".format(
            self.domain,
            self.API_VERSION,
            self.account_id
        )
        params = {"instrument": instrument, "count": count}
        try:
            return self._Client__call(uri=url, params=params, method="get")
        except RequestException:
            return False
        except AssertionError:
            return False
991232
def from_dict(data, ctx):
        

        data = data.copy()

        if data.get('price') is not None:
            data['price'] = ctx.convert_decimal_number(
                data.get('price')
            )

        if data.get('bucketWidth') is not None:
            data['bucketWidth'] = ctx.convert_decimal_number(
                data.get('bucketWidth')
            )

        if data.get('buckets') is not None:
            data['buckets'] = [
                ctx.instrument.OrderBookBucket.from_dict(d, ctx)
                for d in data.get('buckets')
            ]

        return OrderBook(**data)
340740
def buy_market_order(self, amount):
        
        amount = str(amount)
        self._log("buy {} {} at market price".format(amount, self.major))
        return self._rest_client.post(
            endpoint='/buy',
            payload={'book': self.name, 'amount': amount}
        )
1119340
def createStopOrder(self, quantity, parentId=0, stop=0., trail=None,
            transmit=True, group=None, stop_limit=False, rth=False, tif="DAY",
            account=None):

        
        if trail:
            if trail == "percent":
                order = self.createOrder(quantity,
                            trailingPercent = stop,
                            transmit  = transmit,
                            orderType = dataTypes["ORDER_TYPE_TRAIL_STOP"],
                            ocaGroup  = group,
                            parentId  = parentId,
                            rth       = rth,
                            tif       = tif,
                            account   = account
                        )
            else:
                order = self.createOrder(quantity,
                            trailStopPrice = stop,
                            stop      = stop,
                            transmit  = transmit,
                            orderType = dataTypes["ORDER_TYPE_TRAIL_STOP"],
                            ocaGroup  = group,
                            parentId  = parentId,
                            rth       = rth,
                            tif       = tif,
                            account   = account
                        )

        else:
            order = self.createOrder(quantity,
                        stop      = stop,
                        price     = stop if stop_limit else 0.,
                        transmit  = transmit,
                        orderType = dataTypes["ORDER_TYPE_STOP_LIMIT"] if stop_limit else dataTypes["ORDER_TYPE_STOP"],
                        ocaGroup  = group,
                        parentId  = parentId,
                        rth       = rth,
                        tif       = tif,
                        account   = account
                    )
        return order
620354
def order(*ordering)
      @order = ordering.map do |c|
        if c.kind_of?(String)
          {:column => c, :ascending => true}
        else
          c.symbolize_keys!
        end
      end
      self
    end