Method that allows creating new orders for stock exchange trading

@param $pair
@param $type
@param $rate
@param $amount
@return mixed
965627
public function trade($pair, $type, $rate, $amount)
    {
        return $this->tradeRequest('Trade', [
            'pair' => $pair,
            'type' => $type,
            'rate' => $rate,
            'amount' => $amount,
        ]);
    }
1219960
public static function prepWhere($pairs=array(),$type='WHERE'){
		if(!count($pairs)) return array('',null);

		$values = array();
		$str = ' '.strtoupper($type).' ';
		$fieldcnt = 0;
		foreach($pairs as $field => $value){
			//set defaults
			$op = '=';
			$bool = 'AND';
			//handle advanced settings
			switch((is_array($value) ? count($value) : false)){
				case 3:
					$bool 	= array_shift($value);
					$op 	= array_shift($value);
					$value 	= array_shift($value);
					break;
				case 2:
					$op 	= array_shift($value);
					$value 	= array_shift($value);
					break;
				case 1:
					$op 	= array_shift($value);
					$value 	= null;
					break;
				default:
					//nothing
					break;
			}
			//format properly
			$bool = ($fieldcnt++==0)?'':' '.strtoupper($bool).' ';
			$op = strtoupper($op);
			//handle op and add to values if needed
			switch($op){
				case Db::IS_NULL:
				case Db::IS_NOT_NULL:
					//no action needed
					break;
				case Db::IN:
					if(is_array($value)){
						$op .= '('.rtrim(str_repeat('?,',count($value)),',').') ';
						foreach($value as $v) $values[] = $v;
					} else {
						$op .= '('.$value.')';
					}
					break;
				case Db::BETWEEN:
					if(is_array($value) && (count($value) == 2)){
						$op .= ' ? AND ?';
						$values[] = $value[0];
						$values[] = $value[1];
					}
					break;
				default:
					$op .= ' ?';
					$values[] = (string)$value;
					break;
			}
			//concat
			$str .= sprintf('%s%s %s',$bool,self::escape($field),$op);
		}
		return array_merge(array($str),$values);
	}
579781
public function make($name, $description, $amount, $currency, array $otherAttributes = [])
    {
        $this->name = $name;
        $this->description = $description;
        $this->amount = $amount;
        $this->currency = $currency;

        $this->_setAttributes($otherAttributes);
        $this->setCreatable(true);

        return $this;
    }
74195
public static function create($quantity, $productCode, $description, $amount, $vat, $currency = "EUR") {
        $item = new LineItem;
        $item->quantity = $quantity;
        $item->productCode = $productCode;
        $item->description = $description;
        $item->amount = $amount;
        $item->vat = $vat;
        $item->currency = $currency;
        return $item;
    }
488214
public function orderBy($column, $type = Order::ASC)
    {
        if (null !== $return = $this->validateMethodCall()) {
            return $return;
        }

        $this->orderBy[] = [$column, $type];

        return $this;
    }
148591
public static LimitOrder createOrder(
      CurrencyPair currencyPair,
      BitcoindeOrder bitcoindeOrder,
      Order.OrderType orderType,
      String orderId,
      Date timeStamp) {

    return new LimitOrder(
        orderType,
        bitcoindeOrder.getAmount(),
        currencyPair,
        orderId,
        timeStamp,
        bitcoindeOrder.getPrice());
  }
372728
public function createSeries( $data, $title = null, $type = null )
	{
        return new Series( $data, $title, $this->jsWriter );
	}
658008
public function _build($payment, $type)
        {
            $order    = $payment->getOrder();
            $billing  = $order->getBillingAddress();
            $shipping = $order->getShippingAddress();

            # Should be only used in the developement environment
            # without it we get duplicate order id.
            $token = $this->getConfigData('order_token');
            $token = (empty($token)) ? "" : "-" . $token;


            $transaction = array(
                'type'       => $type,
                'order_id'   => $order->getIncrementId() . $token,
                'crypt_type' => self::CRYPT_TYPE,
            );


            switch($type) {
                case self::TRANSACTION_PREAUTH :
                    $transaction = $transaction + array(
                        'cust_id'    => $billing->getCustomerId(),
                        'amount'     => sprintf("%01.2f", $payment->getAmount()),
                        'pan'        => $this->_cleanCC($payment->getCcNumber()),
                        'expdate'    => $this->_formatExpirationDate($payment->getCcExpYear(), $payment->getCcExpMonth()),
                        'cvd_value'  => $payment->getCcCid(),
                        'cvd_indicator' => 1
                    );

                    break;
                case self::TRANSACTION_COMPLETION :
                    $transaction = $transaction + array(
                        'comp_amount' => sprintf("%01.2f", $payment->getAmount()),
                        'txn_number'  => $payment->getCcTransId(),
                    );

                    break;
                case self::TRANSACTION_VOID :
                    $transaction = $transaction + array(
                        'comp_amount' => sprintf("%01.2f", $payment->getAmount()),
                        'txn_number'  => $payment->getCcTransId(),
                    );
                    break;

            }

            return new mpgTransaction($transaction);
        }
527252
public OkCoinTradeResult futuresTrade(
      String symbol,
      String type,
      String price,
      String amount,
      FuturesContract contract,
      int matchPrice,
      int leverRate)
      throws IOException {

    OkCoinTradeResult tradeResult =
        okCoin.futuresTrade(
            apikey,
            symbol,
            contract.getName(),
            type,
            price,
            amount,
            matchPrice,
            leverRate,
            signatureCreator());
    return returnOrThrow(tradeResult);
  }
884690
public function addPrice($amount, $currency, $type = null, $resolution = null)
    {
        $this->prices[] = array(
            'amount' => $amount,
            'currency' => $currency,
            'type' => $type,
            'resolution' => $resolution,
        );

        return $this;
    }
476803
public function withdraw($amount, $type = 'withdraw', $meta = [], $shouldAccept = true)
    {
        $accepted = $shouldAccept ? $this->canWithdraw($amount) : true;

        if ($accepted) {
            $this->wallet->balance -= $amount;
            $this->wallet->save();
        } elseif (! $this->wallet->exists) {
            $this->wallet->save();
        }

        $this->wallet->transactions()
            ->create([
                'amount' => $amount,
                'hash' => uniqid('lwch_'),
                'type' => $type,
                'accepted' => $accepted,
                'meta' => $meta
            ]);
    }
1008012
public function addOrderBy(string $sql, ?string $type, array $params = [])
    {
        $this->orderBy[] = [
            'sql'    => $sql,
            'type'   => $type,
            'params' => $params,
        ];

        return $this;
    }
44708
public function toWords($amount, $currency, $options = null)
    {
        $dictionary = new EnglishDictionary();
        $numberToTripletsConverter = new NumberToTripletsConverter();
        $tripletTransformer = new EnglishTripletTransformer($dictionary);
        $exponentInflector = new EnglishExponentGetter();

        $numberTransformer = (new NumberTransformerBuilder())
            ->withDictionary($dictionary)
            ->withWordsSeparatedBy(' ')
            ->transformNumbersBySplittingIntoTriplets($numberToTripletsConverter, $tripletTransformer)
            ->useRegularExponents($exponentInflector)
            ->build();

        $decimal = (int) ($amount / 100);
        $fraction = $amount % 100;

        if ($fraction === 0) {
            $fraction = null;
        }

        $currency = strtoupper($currency);

        if (!array_key_exists($currency, EnglishDictionary::$currencyNames)) {
            throw new NumberToWordsException(
                sprintf('Currency "%s" is not available for "%s" language', $currency, get_class($this))
            );
        }

        $currencyNames = EnglishDictionary::$currencyNames[$currency];

        $return = trim($numberTransformer->toWords($decimal));
        $level = ($decimal === 1) ? 0 : 1;

        if ($level > 0) {
            if (count($currencyNames[0]) > 1) {
                $return .= ' ' . $currencyNames[0][$level];
            } else {
                $return .= ' ' . $currencyNames[0][0] . 's';
            }
        } else {
            $return .= ' ' . $currencyNames[0][0];
        }

        if (null !== $fraction) {
            $return .= ' ' . trim($numberTransformer->toWords($fraction));

            $level = $fraction === 1 ? 0 : 1;

            if ($level > 0) {
                if (count($currencyNames[1]) > 1) {
                    $return .= ' ' . $currencyNames[1][$level];
                } else {
                    $return .= ' ' . $currencyNames[1][0] . 's';
                }
            } else {
                $return .= ' ' . $currencyNames[1][0];
            }
        }

        return $return;
    }
1310371
protected function createOrder(string $side, string $pair, float $volume, float $price, bool $mapping = false)
    {
        $options = [
            'form_params' => [
                'side' => $side,
                'market' => $pair,
                'volume' => $volume,
                'price' => $price,
            ],
        ];

        $response = $this->sendRequest(Api::POST, $this->getApiUrn(['orders']), $options);

        if ($mapping) {
            $response = $this->deserializeItem($response, Order::class);
        }

        return $response;
    }
587667
public function toWords($amount, $currency, $options = null)
    {
        $dictionary = new PolishDictionary();
        $numberToTripletsConverter = new NumberToTripletsConverter();
        $tripletTransformer = new PolishTripletTransformer($dictionary);
        $nounGenderInflector = new PolishNounGenderInflector();
        $exponentInflector = new PolishExponentInflector($nounGenderInflector);

        $numberTransformer = (new NumberTransformerBuilder())
            ->withDictionary($dictionary)
            ->withWordsSeparatedBy(' ')
            ->transformNumbersBySplittingIntoTriplets($numberToTripletsConverter, $tripletTransformer)
            ->inflectExponentByNumbers($exponentInflector)
            ->build();

        $decimal = (int) ($amount / 100);
        $fraction = $amount % 100;

        if ($fraction === 0) {
            $fraction = null;
        }

        $currency = strtoupper($currency);

        if (!array_key_exists($currency, PolishDictionary::$currencyNames)) {
            throw new NumberToWordsException(
                sprintf('Currency "%s" is not available for "%s" language', $currency, get_class($this))
            );
        }

        $currencyNames = PolishDictionary::$currencyNames[$currency];

        $words = [];

        $words[] = $numberTransformer->toWords($decimal);
        $words[] = $nounGenderInflector->inflectNounByNumber(
            $decimal,
            $currencyNames[0][0],
            $currencyNames[0][1],
            $currencyNames[0][2]
        );

        if (null !== $fraction) {
            $words[] = $numberTransformer->toWords($fraction);
            $words[] = $nounGenderInflector->inflectNounByNumber(
                $fraction,
                $currencyNames[1][0],
                $currencyNames[1][1],
                $currencyNames[1][2]
            );
        }

        return implode(' ', $words);
    }
275567
protected function createRate(CurrencyPairContract $currencyPair, float $rate, \DateTimeInterface $date): ExchangeRate
    {
        return new ExchangeRate($currencyPair, $rate, $date, $this->getName());
    }
637879
private void addCurrencyInfo(TypeSpec.Builder type, NumberData data) {
    addCurrencyInfoMethod(type, "getCurrencySymbol", data.currencySymbols);
    addCurrencyInfoMethod(type, "getNarrowCurrencySymbol", data.narrowCurrencySymbols);
    addCurrencyInfoMethod(type, "getCurrencyDisplayName", data.currencyDisplayName);

    MethodSpec.Builder method = MethodSpec.methodBuilder("getCurrencyPluralName")
        .addModifiers(PROTECTED)
        .addParameter(Types.CLDR_CURRENCY_ENUM, "code")
        .addParameter(PluralCategory.class, "category")
        .returns(String.class);

    method.beginControlFlow("switch (code)");
    for (Map.Entry<String, Map<String, String>> currencyMap : data.currencyDisplayNames.entrySet()) {
      String code = currencyMap.getKey();
      Map<String, String> mapping = currencyMap.getValue();
      if (mapping.isEmpty()) {
        continue;
      }
      
      method.beginControlFlow("case $L:", code);
      method.beginControlFlow("switch (category)");
      for (Map.Entry<String, String> entry : mapping.entrySet()) {
        String[] parts = entry.getKey().split("-");
        PluralCategory category = PluralCategory.fromString(parts[2]);
        if (category == PluralCategory.OTHER) {
          method.addStatement("case $L:\ndefault: return $S", category, entry.getValue());
        } else {
          method.addStatement("case $L: return $S", category, entry.getValue());
        }
      }
      method.endControlFlow();
      method.endControlFlow();
    }
    
    method.addStatement("default: return $S", "");
    method.endControlFlow();
    
    type.addMethod(method.build());
    
    method = MethodSpec.methodBuilder("getCurrencyDigits")
        .addModifiers(PUBLIC)
        .addParameter(Types.CLDR_CURRENCY_ENUM, "code")
        .returns(int.class);
    method.addStatement("return _CurrencyUtil.getCurrencyDigits(code)");
    type.addMethod(method.build());
  }