All Projects → jvillarejo → arbolito

jvillarejo / arbolito

Licence: MIT license
A currency conversion api for the minimalist developer

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to arbolito

GoCurrency
Simple currency converter. Insert an amount, what currency to convert from and what currency to convert to.
Stars: ✭ 29 (-42%)
Mutual labels:  currencies, currency-conversion
Node Currency Swap
Currency Exchange Rates library for nodejs
Stars: ✭ 119 (+138%)
Mutual labels:  rate, currencies
Node Rate Limiter Flexible
Node.js rate limit requests by key with atomic increments in single process or distributed environment.
Stars: ✭ 1,950 (+3800%)
Mutual labels:  rate
FinanceMarketDataGrabber
Use Yahoo Finance or Google's 'hidden' Finance APIs to retrieve current stock and forex data as well as historic quotes
Stars: ✭ 42 (-16%)
Mutual labels:  yahoo-finance
MPNumericTextField
A class that extends UITextField to input numbers, percentages and currencies.
Stars: ✭ 18 (-64%)
Mutual labels:  currencies
Zztools
包括: StarView星星评价(支持半星, 整星, 任意星, 支持拖动, 支持自定义星星图片, 数量, 大小, 间距, 最低分值). 瀑布流(垂直, 浮动, 混合模式瀑布流)等.
Stars: ✭ 175 (+250%)
Mutual labels:  rate
Nager.Country
Worldwide Country Informations (ISO-3166-1 Alpha2, ISO-3166-1 Alpha3, ISO 639-1)
Stars: ✭ 68 (+36%)
Mutual labels:  currencies
Androidrate
AndroidRate is a library to help you promote your Android app by prompting users to rate the app after using it for a few days.
Stars: ✭ 117 (+134%)
Mutual labels:  rate
SwiftYFinance
The best Yahoo Finance library with the power of Swift
Stars: ✭ 30 (-40%)
Mutual labels:  yahoo-finance
latinum
Latinum is a framework for resource and currency calculations.
Stars: ✭ 109 (+118%)
Mutual labels:  currencies
flood-protection
Flood protection for realtime applications
Stars: ✭ 19 (-62%)
Mutual labels:  rate
BitBlocks old
BitBlocks Project_OLD
Stars: ✭ 12 (-76%)
Mutual labels:  currencies
Limitrr
Light NodeJS rate limiting and response delaying using Redis - including Express middleware.
Stars: ✭ 203 (+306%)
Mutual labels:  rate
yahoo-historical
Downloads historical EOD (end of day) prices from yahoo finance
Stars: ✭ 96 (+92%)
Mutual labels:  yahoo-finance
Ngx Bar Rating
Angular Bar Rating
Stars: ✭ 146 (+192%)
Mutual labels:  rate
Stocksera
Web application that provides alternative data to retail investors
Stars: ✭ 426 (+752%)
Mutual labels:  yahoo-finance
hdx-python-country
Utilities to map between country and region codes and names and to match administrative level names from different sources. Also utilities for foreign exchange enabling obtaining current and historic FX rates for different currencies
Stars: ✭ 16 (-68%)
Mutual labels:  currencies
vue-cute-rate
Simple to use and very cute rate component for Vue.js.
Stars: ✭ 43 (-14%)
Mutual labels:  rate
rate-limiter
The Rate Limiter Component provides a Token Bucket implementation to rate limit input and output in your application.
Stars: ✭ 156 (+212%)
Mutual labels:  rate
Stocky
Machine Learning Stock Trading Risk Analysis (Spring 2017)
Stars: ✭ 27 (-46%)
Mutual labels:  yahoo-finance

Arbolito

Arbolito is a minimalist Ruby API for currency conversions, it has no dependencies except the Ruby Standard Library.

It's like your Florida street best companion!

Florida Street

Features

  • Doesn't encapsulates the currencies in any object model, it just use BigDecimal class and Hash
  • You can add manually price rates
  • If the rate isn't found it fetches the rate using Yahoo Finance API as exchange or you can implement your own exchange.
  • You implement your own exchange and configure it
  • It stores in memory the rates fetched with a configurable expiration time
  • You can implement your own store and configure it
  • All the examples use the ISO 4217 code list for Currencies

Motivation

There were two reason why I've developed this gem.

First the argetine economy makes difficult to keep the prices updated with official exchanges rates like Yahoo Finance, so we had to manage our own prices rates. But also I wanted to know the rates of other currencies through Yahoo Finance. This gem lets you do both.

The second reason is that other gems implements their own money or currency model, and I didn't want to update all my models to manage those objects. That's why I tried to be agnostic on how you implement your currencies.

The API just receives a Big Decimal and a hash describing the conversion

Installation

Add this line to your application's Gemfile:

gem 'arbolito'

And then execute:

$ bundle

Or install it yourself as:

$ gem install arbolito

Usage

require 'arbolito'

# We can add multiple rates

Arbolito.add_currency_rate(BigDecimal.new(9), 'USD' => 'ARS')
Arbolito.add_currency_rate(BigDecimal.new(15), 'USD Blue' => 'ARS')
Arbolito.add_currency_rate(BigDecimal.new(12), 'USD Tarjeta' => 'ARS')
Arbolito.add_currency_rate(BigDecimal.new(6.5), 'USD Moreno' => 'ARS')

# It gives the stored rate
Arbolito.current_rate('USD' => 'ARS')
# => #<BigDecimal:7f061f0787e0,'0.15E2',9(27)>

# It stored rate backwards
Arbolito.current_rate('ARS' => 'USD')
# => #<BigDecimal:7f061f076af8,'0.6666666666 6666667E-1',18(36)>

# It can make the conversion for you
Arbolito.convert(BigDecimal.new(100), 'USD' => 'ARS')
# => #<BigDecimal:7f061f1bd010,'0.15E4',9(27)>

Arbolito.convert(BigDecimal.new(100), 'USD Tarjeta' => 'ARS')
=> #<BigDecimal:7f061f39c818,'0.12E4',9(27)>

# Now we ask for the Uruguayan pesos to USD rate
Arbolito.current_rate('UYU' => 'USD')
#<BigDecimal:7f061f142ba8,'0.34E-1',9(18)>

# Now we ask to convert USD to Chilean Pesos
Arbolito.convert(BigDecimal.new(100), 'USD' => 'CLP')
=> #<BigDecimal:7f061f35e680,'0.689695E5',18(36)>

# We can configure Arbolito expiration in seconds
Arbolito.set(:expiration_time, 5 * 60)

# We can implement our own Exchange and configure it in Arbolito 
Arbolito.set(:exchange, Exchange::FloridaStreet)

# We can implement our own Store and configure it in Arbolito 
Arbolito.set(:store, Store::Mongo)

Update: 2017-11-03

Yahoo discountinued their Yahoo Finance API so I've implemented another Exchange Alpha Vantage.

To use you need to get an API Key from them and the configure it like this.

api_key = ENV['API_KEY']
Arbolito.set(:exchange, Arbolito::Exchange::AlphaVantage.new(api_key))

Implementing Store and Exchange

Please take a look at the code to see how you can implement your own stores and exchanges.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jvillarjeo/arbolito. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

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].