All Projects â†’ moltin â†’ Currency

moltin / Currency

Licence: other
Handles currency calculations, storage etc

Projects that are alternatives of or similar to Currency

Cryptocurrency Portfolio
Google Sheets automatic creation with Google Apps Script (GAS) for managing a cryptocurrency tracking spreadsheet with multi exchanges
Stars: ✭ 134 (+22.94%)
Mutual labels:  api, currency, exchange
currency-converter
💰 Easily convert between 32 currencies
Stars: ✭ 16 (-85.32%)
Mutual labels:  currency, exchange, currencies
stockholm
💵 Modern Python library for working with money and monetary amounts. Human friendly and flexible approach for development. 100% test coverage + built-in support for GraphQL and Protocol Buffers transports using current best-practices.
Stars: ✭ 26 (-76.15%)
Mutual labels:  currency, exchange, currencies
Cash Cli
💰💰 Convert currency rates directly from your terminal!
Stars: ✭ 168 (+54.13%)
Mutual labels:  currency, currencies, exchange
Currencyviewer
Short python framework that dynamically displays and converts the cryptocurrencies in your Kraken wallet into equivalents fiat money.
Stars: ✭ 13 (-88.07%)
Mutual labels:  api, currency, exchange
Uniswap Python
🦄 The unofficial Python client for the Uniswap exchange.
Stars: ✭ 191 (+75.23%)
Mutual labels:  api, currency, exchange
django-prices-openexchangerates
openexchangerates.org support for django-prices
Stars: ✭ 33 (-69.72%)
Mutual labels:  currency, exchange, currencies
uniswap-python
🦄 The unofficial Python client for the Uniswap exchange.
Stars: ✭ 533 (+388.99%)
Mutual labels:  currency, exchange
react-local-currency
💵 💴Shows the price of your services in the customer's currency 💶 💷
Stars: ✭ 21 (-80.73%)
Mutual labels:  currency, currencies
Cashify
💸 Lightweight currency conversion library, successor of money.js
Stars: ✭ 329 (+201.83%)
Mutual labels:  currency, exchange
Exchangesharp
ExchangeSharp is a powerful, fast and easy to use .NET/C# API for interfacing with many crypto currency exchanges. REST and web sockets are supported.
Stars: ✭ 489 (+348.62%)
Mutual labels:  api, exchange
money
Crystal shard for dealing with money and currency conversion
Stars: ✭ 26 (-76.15%)
Mutual labels:  currency, exchange
tellerbot
Telegram Bot for over-the-counter trading
Stars: ✭ 17 (-84.4%)
Mutual labels:  currency, exchange
Huobi python
Python SDK for Huobi Spot API
Stars: ✭ 391 (+258.72%)
Mutual labels:  api, exchange
Python Poloniex
Poloniex API wrapper for Python 2.7 & 3
Stars: ✭ 557 (+411.01%)
Mutual labels:  api, exchange
Ccxt
A JavaScript / Python / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
Stars: ✭ 22,501 (+20543.12%)
Mutual labels:  api, exchange
cotizacion
Portal to find current exchange rates in Paraguay
Stars: ✭ 11 (-89.91%)
Mutual labels:  exchange, currencies
Go Binance
A Go SDK for Binance API
Stars: ✭ 441 (+304.59%)
Mutual labels:  api, exchange
Exchange
Php script works with currenries.
Stars: ✭ 21 (-80.73%)
Mutual labels:  currencies, exchange
Huobi golang
Go SDK for Huobi Spot API
Stars: ✭ 76 (-30.28%)
Mutual labels:  api, exchange

Currency Package

Build Status

The Moltin currency composer package makes it easy to implement multi-currency pricing into your application and store the exchange data using one of the numerous data stores provided. You can also inject your own data store if you would like your data to be stored elsewhere.

Installation

Download and install composer from http://www.getcomposer.org/download

Add the following to your project composer.json file

{
    "require": {
        "moltin/currency": "~1.0.0"
    }
}

When you're done just run php composer.phar install and the package is ready to be used.

Usage

Below is a basic usage guide for this package.

Instantiating currency

Before you begin, you will need to know which storage, currencies and exchange method you are going to use. The exchange method defines where your exchange rates are retrieved from. The currencies method is used to retrieve your supported currencies for the current application.

In this example we're going to use the currencies file, exchange file and session for storage.

use Moltin\Currency\Currency as Currency;
use Moltin\Currency\Format\Runtime as RuntimeFormat;
use Moltin\Currency\Exchange\OpenExchangeRates as OpenExchange;

$currency = new Currency(new OpenExchange($app_id), new RuntimeFormat);

Setting the value

Now that you have Currency instantiated, you will now need to tell it what value you would like to convert. You can do this using the following method.

$currency->convert(9.33)->from('GBP');

Getting the value

The most basic action you can perform is retrieve the original value back from the method.

// Returns 9.33
$value = $currency->value();

Formatting as a currency

By default the currency is set to GBP so calling currency will format the value to a string with £ and correct decimal and thousand seperators.

// Returns £9.33
$value = $currency->format();

Rounding to common values

There are a number of common pricing formats built in to make "nice" prices easy to implement. These formats changes the default value and return the object to allow for chaining.

// Sets value to 10.00
$currency->zeros();

// Sets value to 9.99
$currency->nines();

// Sets value to 9.50
$currency->fifty();

// Returns £9.50
$value = $currency->fifty()->format();

Currency Exchange

The package makes it as easy as possible to quickly switch between currencies. Before each exchange the value is reset to default to ensure the correct price is assigned.

// Returns ~$14.47
$value = $currency->convert(9.33)->from('GBP')->to('USD')->format();

// Returns ~14.50
$value = $currency->convert(9.33)->from('GBP')->to('USD')->fifty()->value();

Resetting the value

After using exchange or any of the rounding functions to retrieve the default value you must call reset.

// Returns 10.00
$value = $currency->zeros()->value();

// Returns 9.33
$value = $currency->reset()->value();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].