2017 © Pedro Peláez
 

library forex-calculator

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

image

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.

  • Saturday, January 7, 2017
  • by michalbrauner
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

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., (*2)

Installation

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

Usage

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

# 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

...

$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'));

The Versions

07/01 2017

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

utils calculator forex money management

07/01 2017

v1.0.4

1.0.4.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

utils calculator forex money management

28/12 2016

v1.0.3

1.0.3.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

utils calculator forex money management

28/12 2016

v1.0.2

1.0.2.0

  Sources   Download

The Requires

 

The Development Requires

28/12 2016

v1.0.1

1.0.1.0

  Sources   Download

The Requires

 

The Development Requires

28/12 2016

v1.0.0

1.0.0.0

  Sources   Download

The Requires

 

The Development Requires