PHPackages                             michalbrauner/forex-calculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. michalbrauner/forex-calculator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

michalbrauner/forex-calculator
==============================

Library in order to make calculations related to Forex. It provides basic calculators that can be used to improve your money management.

v1.0.4(9y ago)0151MITPHPPHP &gt;= 7.0.0

Since Dec 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/michalbrauner/forex-calculator)[ Packagist](https://packagist.org/packages/michalbrauner/forex-calculator)[ RSS](/packages/michalbrauner-forex-calculator/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

[![Build Status](https://camo.githubusercontent.com/f77b5ae875aa8ae4419485a860e40a768b939992ffbcbc18f13c04fb52b06e58/68747470733a2f2f696d672e736869656c64732e696f2f736869707061626c652f3538343564346536333037623166306630303466623534642f6d61737465722e737667)](https://app.shippable.com/projects/5845d4e6307b1f0f004fb54d/status/dashboard)

About
-----

[](#about)

Forex-calculator is a library to make calculations related to Forex. It provides basic calculators that can be used to improve your money management. Library requires **PHP 7**.

Installation
------------

[](#installation)

```
composer install michalbrauner/forex-calculator:^v1.0

```

Usage
-----

[](#usage)

### Currency converter

[](#currency-converter)

```
$currencyConverter = new \ForexCalculator\Services\CurrencyConverter(
  new \ForexCalculator\DataProviders\YahooDataProvider(new \GuzzleHttp\Client())
);

# Convert 100 eur to usd

$convertedValue = $currencyConverter->convertToCurrency('eur', 'usd', 100);
```

### Profit, loss and RRR calculator

[](#profit-loss-and-rrr-calculator)

```
# Create calculator factory

$tradeAttributesCalculatorFactory = new \ForexCalculator\Services\TradeAttributesByTradeSizeCalculatorFactory(
    new \ForexCalculator\DataProviders\YahooDataProvider(new \GuzzleHttp\Client()),
    new \ForexCalculator\PrecisionProviders\MoneyPrecisionProvider(),
    new \ForexCalculator\PrecisionProviders\RiskRewardRatioPrecisionProvider()
);

# Calculator settings

$symbol = 'eurusd';
$outputCurrency = 'usd';
$extendedPoint = true;

$tradeAttributesCalculator = $tradeAttributesCalculatorFactory->create('eurusd', 'usd', $extendedPoint);

# Factory to create prices to trade

$priceNumberFactory = new \ForexCalculator\DataObjects\FloatNumberFactory(
    new \ForexCalculator\PrecisionProviders\PricePrecisionProvider($symbol, $extendedPoint)
);

$trade = new \ForexCalculator\DataObjects\Trade(
    $priceNumberFactory->create('1.03953'),
    $priceNumberFactory->create('1.03936'),
    $priceNumberFactory->create('1.04016')
);

# Loss and profit for trade and size 20000 units

$loss = $tradeAttributesCalculator->getLoss($trade, 20000);
$profit = $tradeAttributesCalculator->getProfit($trade, 20000);

$riskRewardRatio = $tradeAttributesCalculator->getRiskRewardRatio($trade);
```

### Number of units by maximal risk calculator

[](#number-of-units-by-maximal-risk-calculator)

```
...

$numberOfUnitsCalculator = new \ForexCalculator\Services\NumberOfUnitsByMaximalLossCalculator(
    $symbol,
    $outputCurrency,
    $extendedPoint,
    $tradeAttributesCalculatorFactory
);

$moneyNumberFactory = new \ForexCalculator\DataObjects\FloatNumberFactory(
    new \ForexCalculator\PrecisionProviders\MoneyPrecisionProvider()
);

# Number of units to trade to risk 180 usd per trade

$numberOfUnits = $numberOfUnitsCalculator->getNumberOfUnits($trade, $moneyNumberFactory->create('180'));
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

5

Last Release

3461d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1190316?v=4)[Michal Brauner](/maintainers/michalbrauner)[@michalbrauner](https://github.com/michalbrauner)

---

Top Contributors

[![michalbrauner](https://avatars.githubusercontent.com/u/1190316?v=4)](https://github.com/michalbrauner "michalbrauner (43 commits)")

---

Tags

utilscalculatorforexmoney management

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michalbrauner-forex-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/michalbrauner-forex-calculator/health.svg)](https://phpackages.com/packages/michalbrauner-forex-calculator)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k34](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)[roundcube/roundcubemail

The Roundcube Webmail suite

7.0k1.4k3](/packages/roundcube-roundcubemail)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[nfse-nacional/nfse-php

This is my package nfse

1533.1k](/packages/nfse-nacional-nfse-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
