Recalculate prices for all ARs
341065
def ajax_recalculate_prices(self):
        
        # When the option "Include and display pricing information" in
        # Bika Setup Accounting tab is not selected
        if not self.show_recalculate_prices():
            return {}

        # The sorted records from the request
        records = self.get_records()

        client = self.get_client()
        bika_setup = api.get_bika_setup()

        member_discount = float(bika_setup.getMemberDiscount())
        member_discount_applies = False
        if client:
            member_discount_applies = client.getMemberDiscountApplies()

        prices = {}
        for n, record in enumerate(records):
            ardiscount_amount = 0.00
            arservices_price = 0.00
            arprofiles_price = 0.00
            arprofiles_vat_amount = 0.00
            arservice_vat_amount = 0.00
            services_from_priced_profile = []

            profile_uids = record.get("Profiles_uid", "").split(",")
            profile_uids = filter(lambda x: x, profile_uids)
            profiles = map(self.get_object_by_uid, profile_uids)
            services = map(self.get_object_by_uid, record.get("Analyses", []))

            # ANALYSIS PROFILES PRICE
            for profile in profiles:
                use_profile_price = profile.getUseAnalysisProfilePrice()
                if not use_profile_price:
                    continue

                profile_price = float(profile.getAnalysisProfilePrice())
                arprofiles_price += profile_price
                arprofiles_vat_amount += profile.getVATAmount()
                profile_services = profile.getService()
                services_from_priced_profile.extend(profile_services)

            # ANALYSIS SERVICES PRICE
            for service in services:
                if service in services_from_priced_profile:
                    continue
                service_price = float(service.getPrice())
                # service_vat = float(service.getVAT())
                service_vat_amount = float(service.getVATAmount())
                arservice_vat_amount += service_vat_amount
                arservices_price += service_price

            base_price = arservices_price + arprofiles_price

            # Calculate the member discount if it applies
            if member_discount and member_discount_applies:
                logger.info("Member discount applies with {}%".format(
                    member_discount))
                ardiscount_amount = base_price * member_discount / 100

            subtotal = base_price - ardiscount_amount
            vat_amount = arprofiles_vat_amount + arservice_vat_amount
            total = subtotal + vat_amount

            prices[n] = {
                "discount": "{0:.2f}".format(ardiscount_amount),
                "subtotal": "{0:.2f}".format(subtotal),
                "vat": "{0:.2f}".format(vat_amount),
                "total": "{0:.2f}".format(total),
            }
            logger.info("Prices for AR {}: Discount={discount} "
                        "VAT={vat} Subtotal={subtotal} total={total}"
                        .format(n, **prices[n]))

        return prices
1174099
function updatePricesTo(ccy) {
    var yearly = price.yearly.value * fx[ccy].rate;
    var monthly = price.monthly.value * fx[ccy].rate;

    if (ccy !== 'GBP') {
      yearly = yearly | 0;
      monthly = monthly | 0;
    }

    var discount = price.discount.value * fx[ccy].rate | 0;
    price.yearly.el.html(fx[ccy].symbol + yearly);
    price.monthly.el.html(fx[ccy].symbol + monthly);
    price.discount.el.html(fx[ccy].symbol + discount);
  }
4127
def prices(self):
        
        # if accessing and stale - update first
        if self._needupdate or self.now != self.parent.now:
            self.update(self.root.now)
        return self._prices.loc[:self.now]
256938
def current_hold_price(self):
        
        
        def weights(x):
            n=len(x)
            res=1
            while res>0 or res<0:
                res=sum(x[:n]['amount'])
                n=n-1
            
            x=x[n+1:]     
            
            if sum(x['amount']) != 0:
                return np.average(
                    x['price'],
                    weights=x['amount'],
                    returned=True
                )
            else:
                return np.nan
        return self.history_table.set_index(
            'datetime',
            drop=False
        ).sort_index().groupby('code').apply(weights).dropna()
632076
@Indexable(type = IndexableType.REINDEX)
	@Override
	public CommercePriceList updateCommercePriceList(
		CommercePriceList commercePriceList) {
		return commercePriceListPersistence.update(commercePriceList);
	}
1291949
def get_prices(self) -> List[PriceModel]:
        
        # return self.security.prices.order_by(Price.date)
        from pricedb.dal import Price

        pricedb = PriceDbApplication()
        repo = pricedb.get_price_repository()
        query = (repo.query(Price)
            .filter(Price.namespace == self.security.namespace)
            .filter(Price.symbol == self.security.mnemonic)
            .orderby_desc(Price.date)
        )
        return query.all()
521350
def _calculate_order_value_amount(self, asset, value):
        
        # Make sure the asset exists, and that there is a last price for it.
        # FIXME: we should use BarData's can_trade logic here, but I haven't
        # yet found a good way to do that.
        normalized_date = normalize_date(self.datetime)

        if normalized_date < asset.start_date:
            raise CannotOrderDelistedAsset(
                msg="Cannot order {0}, as it started trading on"
                    " {1}.".format(asset.symbol, asset.start_date)
            )
        elif normalized_date > asset.end_date:
            raise CannotOrderDelistedAsset(
                msg="Cannot order {0}, as it stopped trading on"
                    " {1}.".format(asset.symbol, asset.end_date)
            )
        else:
            last_price = \
                self.trading_client.current_data.current(asset, "price")

            if np.isnan(last_price):
                raise CannotOrderDelistedAsset(
                    msg="Cannot order {0} on {1} as there is no last "
                        "price for the security.".format(asset.symbol,
                                                         self.datetime)
                )

        if tolerant_equals(last_price, 0):
            zero_message = "Price of 0 for {psid}; can't infer value".format(
                psid=asset
            )
            if self.logger:
                self.logger.debug(zero_message)
            # Don't place any order
            return 0

        value_multiplier = asset.price_multiplier

        return value / (last_price * value_multiplier)
1328626
def _hp_ars(x,params):
    """"""
    mO, sO2= params
    return -(x-mO)/sO2+1./x
502115
def convert(amount, from_code, to_code, decimals=2, qs=None):
    """"""
    if from_code == to_code:
        return amount

    if qs is None:
        qs = get_active_currencies_qs()

    from_, to = qs.get(code=from_code), qs.get(code=to_code)

    amount = D(amount) * (to.factor / from_.factor)
    return price_rounding(amount, decimals=decimals)
848529
function itemsInfo()
    {
        $basketInfo = array();
        // Build a price summary for the items based on VAT.
        foreach ( $this->items() as $item )
        {
            $vatValue = $item['vat_value'];
            $itemCount = abs( $item['item_count'] );
            $priceExVAT = $item['price_ex_vat'];
            $priceIncVAT = $item['price_inc_vat'];
            $totalPriceExVAT = $item['total_price_ex_vat'];
            $totalPriceIncVAT = $item['total_price_inc_vat'];

            if ( !isset( $basketInfo['price_info'][$vatValue]['price_ex_vat'] ) )
            {
                $basketInfo['price_info'][$vatValue]['price_ex_vat'] = ( $priceExVAT * $itemCount );
                $basketInfo['price_info'][$vatValue]['price_inc_vat'] = ( $priceIncVAT * $itemCount );
                $basketInfo['price_info'][$vatValue]['price_vat'] = ( $priceIncVAT - $priceExVAT ) * $itemCount;

                $basketInfo['price_info'][$vatValue]['total_price_ex_vat'] = $totalPriceExVAT;
                $basketInfo['price_info'][$vatValue]['total_price_inc_vat'] = $totalPriceIncVAT;
                $basketInfo['price_info'][$vatValue]['total_price_vat'] = $totalPriceIncVAT - $totalPriceExVAT;
            }
            else
            {
                $basketInfo['price_info'][$vatValue]['price_ex_vat'] += ( $priceExVAT * $itemCount );
                $basketInfo['price_info'][$vatValue]['price_inc_vat'] += ( $priceIncVAT * $itemCount );
                $basketInfo['price_info'][$vatValue]['price_vat'] += ( $priceIncVAT - $priceExVAT ) * $itemCount;

                $basketInfo['price_info'][$vatValue]['total_price_ex_vat'] += $totalPriceExVAT;
                $basketInfo['price_info'][$vatValue]['total_price_inc_vat'] += $totalPriceIncVAT;
                $basketInfo['price_info'][$vatValue]['total_price_vat'] += ( $totalPriceIncVAT - $totalPriceExVAT );
            }

            if ( !isset( $basketInfo['total_price_info']['total_price_ex_vat'] ) )
            {
                $basketInfo['total_price_info']['price_ex_vat'] = ( $priceExVAT * $itemCount );
                $basketInfo['total_price_info']['price_inc_vat'] = ( $priceIncVAT * $itemCount );
                $basketInfo['total_price_info']['price_vat'] = ( ( $priceIncVAT - $priceExVAT ) * $itemCount );

                $basketInfo['total_price_info']['total_price_ex_vat'] = $totalPriceExVAT;
                $basketInfo['total_price_info']['total_price_inc_vat'] = $totalPriceIncVAT;
                $basketInfo['total_price_info']['total_price_vat'] = ( $totalPriceIncVAT - $totalPriceExVAT );
            }
            else
            {
                $basketInfo['total_price_info']['price_ex_vat'] += ( $priceExVAT * $itemCount );
                $basketInfo['total_price_info']['price_inc_vat'] += ( $priceIncVAT * $itemCount );
                $basketInfo['total_price_info']['price_vat'] += ( ( $priceIncVAT - $priceExVAT ) * $itemCount );

                $basketInfo['total_price_info']['total_price_ex_vat'] += $totalPriceExVAT;
                $basketInfo['total_price_info']['total_price_inc_vat'] += $totalPriceIncVAT;
                $basketInfo['total_price_info']['total_price_vat'] += ( $totalPriceIncVAT - $totalPriceExVAT );
            }
        }

        // Add shipping cost to the total items price and add / update additional price information.
        $productCollectionID = $this->attribute( 'productcollection_id' );

        // Add additional calculated information to the basketInfo array, that can be used in the template.
        $shippingUpdateStatus = eZShippingManager::updatePriceInfo( $productCollectionID, $basketInfo );

        ksort( $basketInfo['price_info'] );
        return $basketInfo;
    }
364951
def get_stockprices(chart_range='1y'):
    '''
    
    '''

    all_symbols = list_symbols()

    @daily_cache(filename='iex_chart_{}'.format(chart_range))
    def get_stockprices_cached(all_symbols):
        return _get_stockprices(all_symbols, chart_range)

    return get_stockprices_cached(all_symbols)
101129
def currency_multiplier(src_currency, dest_currency):
    ''
    if src_currency == 'USD':
        return 1.0
    usd_mult = currency_rates()[src_currency]
    if dest_currency == 'USD':
        return usd_mult
    return usd_mult/currency_rates()[dest_currency]
1360316
public function getCalculatedPrice($spread_type, $spread_value, $stock_price, $product_price_charmer, $currency)
    {
        $price = $stock_price;

        switch($spread_type) {
            case 0;
                $price = $this->calculateProductsPriceByFlat($spread_value, $stock_price, $currency);
                break;
            case 1:
                $price = $this->calculateProductsPriceByPercent($spread_value, $stock_price, $currency);
                break;
        }

        $price = round($price, 2);

        if($product_price_charmer) {
            $price = $this->priceAdjuster($price);
        }

        return $price;
    }
723590
def prices(self):
        
        if self.root.stale:
            self.root.update(self.now, None)
        return self._prices.loc[:self.now]
124968
def deal_caps(x:Collection[str]) -> Collection[str]:
    ""
    res = []
    for t in x:
        if t == '': continue
        if t[0].isupper() and len(t) > 1 and t[1:].islower(): res.append(TK_MAJ)
        res.append(t.lower())
    return res
152013
def _calculate_order_value_amount(self, asset, value):
        
        if not self.executor.current_data.can_trade(asset):
            raise CannotOrderDelistedAsset(
                msg="Cannot order {0}, as it not tradable".format(asset.symbol)
            )

        last_price = \
            self.executor.current_data.current(asset, "price")

        if np.isnan(last_price):
            raise CannotOrderDelistedAsset(
                msg="Cannot order {0} on {1} as there is no last "
                    "price for the security.".format(asset.symbol,
                                                     self.datetime)
            )

        if tolerant_equals(last_price, 0):
            zero_message = "Price of 0 for {psid}; can't infer value".format(
                psid=asset
            )
            log.debug(zero_message)
            # Don't place any order
            return 0

        return value / last_price
318163
def calculateOptionPrice(self, reqId, contract, volatility, underPrice):
        """"""
        return _swigibpy.EClientSocketBase_calculateOptionPrice(self, reqId, contract, volatility, underPrice)