💱 A crusty currency converter

Overview

💱 moneyman

Crates.io docs.rs Crates.io

A crusty currency converter

moneyman_cli

Example

$ moneyman convert 50 --from EUR --to PHP --on 2023-05-06 --fallback
50 EUR -> 3044.5833333333350 PHP on the date 2023-05-06

moneyman is also available as a library.

use std::path::PathBuf;

use chrono::NaiveDate;
use rust_decimal_macros::dec;
use rusty_money::{iso, Money};

fn main() {
    // Choose where to save the historical data files.
    let data_dir: PathBuf = dirs::home_dir()
        .and_then(|home_dir| Some(home_dir.join(".moneyman")))
        .expect("need a home directory");

    // Fetches the historical data from European Central Bank, and creates an
    // exchange store.
    let store = moneyman_core::ExchangeStore::sync(data_dir).expect("failed ze sync");

    let amount_in_usd = Money::from_decimal(dec!(6500), iso::USD);
    let date = NaiveDate::from_ymd_opt(2023, 5, 4).expect("ok date");

    // Converts 6,500.00 USD to EUR
    let actual = store.convert_on_date(amount_in_usd, iso::EUR, date);
    let expected = Money::from_decimal(dec!(5869.6044789597254831135994221), iso::EUR);

    // Shouldn't explode? :)
    assert_eq!(actual, expected);
}

Details

moneyman extends on rusty-money as it already provides a lot of the things like Money, Currency, ExchangeRate, and Exchange. However, it does not provide any data to actually convert currency. For historical data, moneyman uses the European Central Bank, and saves its data to its own local data store.

Caveat

One important thing to know is that ANY_OTHER_CURRENCY -> EUR is computed with 1/<RATE_OF_ONE_EUR_IN_THAT_OTHER_CURRENCY> since ECB only contains the EUR -> ANY_OTHER_CURRENCY rates, not vice versa. This [dividing] is most probably not the behavior observed by RealWordâ„¢ currency exchanges. So this only serves as an approximation at best.

You might also like...
Converter valores entre moedas com RUST.
Converter valores entre moedas com RUST.

Exchange Rust 🦀 Uma CLI escrita em Rust que converte um valor de uma moeda para outra consumindo a API CurrencyConverterApi (projeto de estudo). Util

Camera RAW to DNG file format converter

DNGLab - A camera RAW to DNG file format converter Command line tool to convert camera RAW files to Digital Negative Format (DNG). It is currently in

A fast wordlist to nthash converter

nthasher A fast wordlist to nthash converter Usage Pass it a UTF8 encoded wordlist, and write the output to a file. ./nthasher wordlist wordlist.n

elite - c converter

elite - c converter

elite - python3 converter

elite - python3 converter

elite - rust converter

elite - rust converter

elite - c++17 converter

elite - c++17 converter

An intel PT trace converter from `perf.data` to Fuchsia trace format.
An intel PT trace converter from `perf.data` to Fuchsia trace format.

Introduction Recent Intel processors feature the "Intel Processor Trace" feature, which can be used to capture the full execution trace of a program.

TI LDC1312/LDC1314/LDC1612/LDC1614 inductance-to-digital converter driver for Rust embedded-hal

ldc1x1x Rust embedded-hal 1.x driver for Texas Instruments (TI) I²C inductance-to-digital converters (LDC): LDC1312/LDC1314, LDC1612/LDC1614. Includes

🕛Handy epoch converter
🕛Handy epoch converter

epo Handy epoch converter. $ epo 1647165000 1647165000+300 "1647165000+300*2" "1647165000+300*3" los_angeles phoenix gmt | Epoch | America/

Markdown to HTML converter written in Rust. Inspired by Katsuki Yuri's Makudaun Tool.
Markdown to HTML converter written in Rust. Inspired by Katsuki Yuri's Makudaun Tool.

Makurust Makurust is a powerful tool written in Rust that allows you to effortlessly convert your Markdown files into static HTML pages. Inspired by T

PICNIC Is Config Notation Interpreter/Converter
PICNIC Is Config Notation Interpreter/Converter

PICNIC Is Config Notation Interpreter/Converter 🦀 PICNIC PICNIC's name is powered by AI, which immediately makes it worth your time: Human: Please co

Fahrenheit-celsius converter using actix

fahrenheit-celsius-converter Simple http Fahrenheit/Celsius/Kelvin converter using actix-web. Note This is a toy project, not yet finished. It's not r

Fastest GTF/GFF-to-BED converter chilling around
Fastest GTF/GFF-to-BED converter chilling around

gxf2bed The fastest G{F,T}F-to-BED converter around the block! translates chr27 gxf2bed gene 17266470 17285418 . + . gene_id "ENSG00000151743"; chr27

Comments
  • feat: Sync usnysced days

    feat: Sync usnysced days

    This is to prevent syncing everything all over again even if all that's missing are only a few days. This will also interpolate from the last known date, until the most recent one in the ECB history, if applicable. But this only does it from the last checkpoint. The latest date in the current data store will be assumed as the checkpoint. Meaning, if the data store were to be tampered by removing some data somewhere in between the bounds, this won't get fixed.

    opened by sekunho 0
Releases(v0.1.2)
  • v0.1.2(May 16, 2023)

  • v0.1.1(May 16, 2023)

  • v0.1.0(May 15, 2023)

    What's Changed

    • feat: Convert currency given a date by @sekunho in https://github.com/sekunho/moneyman/pull/1
    • feat: Add conversion involving non-EUR denominations by @sekunho in https://github.com/sekunho/moneyman/pull/2
    • improvement: Default to HOME for data dir by @sekunho in https://github.com/sekunho/moneyman/pull/3
    • improvement: Better error handling if no rate by @sekunho in https://github.com/sekunho/moneyman/pull/4
    • test: Test codebase by @sekunho in https://github.com/sekunho/moneyman/pull/5
    • docs: Update README example by @sekunho in https://github.com/sekunho/moneyman/pull/6
    • chore: Benchmark convert_on_date by @sekunho in https://github.com/sekunho/moneyman/pull/7
    • docs: Update some comments and example by @sekunho in https://github.com/sekunho/moneyman/pull/8
    • refactor: Simplify API and refactor errors by @sekunho in https://github.com/sekunho/moneyman/pull/9
    • refactor: Persistence by @sekunho in https://github.com/sekunho/moneyman/pull/10
    • feat: Add linear interpolation for missing dates by @sekunho in https://github.com/sekunho/moneyman/pull/11
    • refactor: Rename crates by @sekunho in https://github.com/sekunho/moneyman/pull/12
    • feat: Sync usnysced days by @sekunho in https://github.com/sekunho/moneyman/pull/13
    • feat: CLI by @sekunho in https://github.com/sekunho/moneyman/pull/14
    • docs: Update README by @sekunho in https://github.com/sekunho/moneyman/pull/15
    • chore: Upload binary by @sekunho in https://github.com/sekunho/moneyman/pull/16

    New Contributors

    • @sekunho made their first contribution in https://github.com/sekunho/moneyman/pull/1

    Full Changelog: https://github.com/sekunho/moneyman/commits/v0.1.0

    Source code(tar.gz)
    Source code(zip)
    moneyman-darwin-amd64(5.47 MB)
    moneyman-linux-amd64(7.16 MB)
Owner
SEKUN
λ PL is fun.
SEKUN
RBTC is cli to convert BTC to any currency and vice-versa.

RBTC RBTC is cli to convert BTC to any currency and vice-versa. Building for source For build the binary just: $ cargo build To run as debug, just run

Luca Lacerda 5 Nov 8, 2021
elite -> c++17 converter

elite -> c++17 converter

Ferhat Geçdoğan 1 Feb 10, 2022
Markdown to HTML converter written in Rust. Inspired by Katsuki Yuri's Makudaun Tool.

Makurust Makurust is a powerful tool written in Rust that allows you to effortlessly convert your Markdown files into static HTML pages. Inspired by T

Said (Fromgodd) 15 Apr 9, 2023
Fastest GTF/GFF-to-BED converter chilling around

gxf2bed The fastest G{F,T}F-to-BED converter around the block! translates chr27 gxf2bed gene 17266470 17285418 . + . gene_id "ENSG00000151743"; chr27

Alejandro Gonzales-Irribarren 11 Feb 20, 2024
Crusty - polite && scalable broad web crawler

Broad web crawling is an activity of going through practically boundless web by starting from a set of locations(urls) and following outgoing links. Usually it doesn't matter where you start from as long as it has outgoing links to external domains.

Sergey F. 72 Jan 2, 2023
Currency exchange rates in your terminal

Usage example Rates is a scriptable CLI tool that brings currency exchange rates right into your terminal and supports 30+ fiat and 10K+ crypto currencies.

Lunush 89 Nov 9, 2022
RBTC is cli to convert BTC to any currency and vice-versa.

RBTC RBTC is cli to convert BTC to any currency and vice-versa. Building for source For build the binary just: $ cargo build To run as debug, just run

Luca Lacerda 5 Nov 8, 2021
Briolette is an experimental framework for researching offline digital currency designs.

Briolette - experimental framework for offline-enabled digital currency Briolette is an experimental framework for researching offline digital currenc

Google 39 Apr 9, 2023
Artsy pixel image to vector graphics converter

inkdrop inkdrop is an artsy bitmap to vector converter. Command line interface The CLI binary is called inkdrop-cli and reads almost any image bitmap

Matthias Vogelgesang 62 Dec 26, 2022
A Simple Image to Ascii converter in Rust

Image to Ascii A Simple Image to Ascii converter in Rust Brief ?? In my way to learn Rust i decided to make this converter. Challenges ?? new to Rust

WasixXD 7 Sep 16, 2022