Determines the complete cash outlay (including commission) necessary
        given a quantity q.
        Second returning parameter is a commission itself.

        Args:
            * q (float): quantity
16363
def outlay(self, q):
        
        fee = self.commission(q, self._price * self.multiplier)
        outlay = q * self._price * self.multiplier
        return outlay + fee, outlay, fee
822150
def get_quantity_info(self, quantity, key=None, default=None):
        
        d = self._get_quantity_info_dict(quantity, default if key is None else dict())

        if key is None:
            return d

        return d.get(key, default)
97605
def get_quantity_of_splits_for_account(self, account_id: str) -> Decimal:
        
        splits = self.get_split_for_account(account_id)
        result = Decimal(0)
        for split in splits:
            result += split.quantity
        return result
619900
def buy(self, quantity, **kwargs):
        
        self.parent.order("BUY", self, quantity=quantity, **kwargs)
1068837
def getTotal(self):
        
        total = 0
        for lineitem in self.supplyorder_lineitems:
            total += Decimal(lineitem['Quantity']) * \
                     Decimal(lineitem['Price']) *  \
                     ((Decimal(lineitem['VAT']) /100) + 1)
        return total
1257871
def complete_offer(self, offer_id, complete_dict):
        
        return self._create_put_request(
            resource=OFFERS,
            billomat_id=offer_id,
            command=COMPLETE,
            send_data=complete_dict
        )
693873
def process_commission(self, commission):
        
        asset = commission['asset']
        cost = commission['cost']

        self.position_tracker.handle_commission(asset, cost)
        self._cash_flow(-cost)
498643
def buy_market(self, quantity, **kwargs):
        
        kwargs['limit_price'] = 0
        kwargs['order_type'] = "MARKET"
        self.parent.order("BUY", self, quantity=quantity, **kwargs)
473965
def fee(self, value=None, unit='satoshi'):
        
        convert = None
        if not value:
            # no fee was specified, use $0.02 as default.
            convert = get_current_price(self.crypto, "usd")
            self.fee_satoshi = int(0.02 / convert * 1e8)
            verbose = "Using default fee of:"

        elif value == 'optimal':
            self.fee_satoshi = get_optimal_fee(
                self.crypto, self.estimate_size(), verbose=self.verbose
            )
            verbose = "Using optimal fee of:"
        else:
            self.fee_satoshi = self.from_unit_to_satoshi(value, unit)
            verbose = "Using manually set fee of:"

        if self.verbose:
            if not convert:
                convert = get_current_price(self.crypto, "usd")
            fee_dollar = convert * self.fee_satoshi / 1e8
            print(verbose + " %s satoshis ($%.2f)" % (self.fee_satoshi, fee_dollar))
18363
def is_transfer_complete(self, relation_name):
    """"""
    phold = self.data_access.sql_writer.to_placeholder()
    return self.data_access.find_model(
      Relation,
      ("name = {0} and completed_at is not null".format(phold), [relation_name])) is not None
47942
def pay_order_query(self, out_trade_no):
        

        package = {
            'partner': self.pay_partner_id,
            'out_trade_no': out_trade_no,
        }

        _package = package.items()
        _package.sort()

        s = '&'.join(
            [
                "%s=%s" % (p[0], str(p[1]))
                for p in (_package + [('key', self.pay_partner_key)])
            ]
        )
        package['sign'] = md5(s).hexdigest().upper()

        package = '&'.join(["%s=%s" % (p[0], p[1]) for p in package.items()])

        params, sign, _ = self._pay_sign_dict(
            add_noncestr=False, package=package
        )

        params['app_signature'] = sign
        params['sign_method'] = 'sha1'

        return self.post(
            url="https://api.weixin.qq.com/pay/orderquery", data=params
        )
79579
def _withholdOffbids(self):
        
        limits = self.limits

        # Eliminate offers (but not bids) above 'price_cap'.
        if not limits.has_key('max_offer'):
            limits['max_offer'] = self.priceCap

        # Limit cleared offer prices after locational adjustments.
        if not self.limits.has_key('maxClearedOffer'):
            self.limits['maxClearedOffer'] = self.priceCap

        # Withhold invalid offers/bids.
        for offer in self.offers:
            if round(offer.quantity, 4) <= 0.0:
                logger.info("Withholding non-posistive quantity [%.2f] "
                            "offer." % offer.quantity)
                offer.withheld = True

        for bid in self.bids:
            if round(bid.quantity, 4) <= 0.0:
                logger.info("Withholding non-posistive quantity [%.2f] "
                            "bid." % bid.quantity)
                bid.withheld = True

        # Optionally, withhold offers/bids beyond price limits.
        if limits.has_key("maxOffer"):
            for offer in self.offers:
                if offer.price > limits["maxOffer"]:
                    logger.info("Offer price [%.2f] above limit [%.3f], "
                        "withholding." % (offer.price, limits["maxOffer"]))
                    offer.withheld = True

        if limits.has_key("minBid"):
            for bid in self.bids:
                if bid.price < limits["minBid"]:
                    logger.info("Bid price [%.2f] below limit [%.2f], "
                        "withholding." % (bid.price, limits["minBid"]))
                    bid.withheld = True
1330043
def check(self):
        
        for k in iter(self.__dict__.keys()):
            if k not in self.__allowed:
                raise TypeError("Parameter not allowed {}".format(k))

        for k in self.__requiered:
            if k not in self.__dict__:
                raise TypeError("Requiered parameter not found {}".format(k))

        if not isinstance(self.units, (int, float)):
            msg = "Unit must be either int or float, '{}'' found".format(
                type(self.units))
            raise TypeError(msg)

        if self.side not in self.__side:
            msg = "Side must be in {1}, '{0}' found".format(
                self.side, self.__side)
            raise TypeError(msg)

        if self.type not in self.__type:
            msg = "Type must be in {1}, '{0}' found".format(
                self.type, self.__type)
            raise TypeError(msg)

        if not self.type == "market" and (
           not hasattr(self, "expiry") or not hasattr(self, "price")):
            msg = "As type is {}, expiry and price must be provided".format(
                self.type)
            raise TypeError(msg)
        if hasattr(self, "expiry") and not isinstance(self.expiry, datetime):
            msg = "Expiry must be {1}, '{0}' found".format(
                type(self.expiry), datetime)
            raise TypeError(msg)

        if hasattr(self, "price"):
            try:
                Decimal(self.price)
            except InvalidOperation:
                msg = "Expiry must be int or float, '{0}' found".format(
                    type(self.price))
                raise TypeError(msg)

        return True
684810
def cum_percentile(series,q):
    
    total = series.sum()
    cum_sum = series.cumsum()
    return sum(cum_sum < total*q)
1025235
def validate_quantity(self, value):
        """"""
        if not isinstance(value, pq.quantity.Quantity):
            self._error('%s' % value, "Must be a Python quantity.")
902379
def all(self, data={}, **kwargs):
        "
        return super(Payment, self).all(data, **kwargs)
1066541
private static Money getBid(BiddableAdGroupCriterion biddableCriterion) {
    BiddingStrategyConfiguration biddingConfig =
        biddableCriterion.getBiddingStrategyConfiguration();
    Money cpcBidAmount = null;
    if (biddingConfig.getBids() != null) {
      for (Bids bid : biddingConfig.getBids()) {
        if (bid instanceof CpcBid) {
          CpcBid cpcBid = (CpcBid) bid;
          if (BidSource.CRITERION.equals(cpcBid.getCpcBidSource())) {
            cpcBidAmount = cpcBid.getBid();
            break;
          }
        }
      }
    }
    return cpcBidAmount;
  }