Coder Social home page Coder Social logo

meta-five's Introduction

Meta Five

This is Laravel 8.x package wrapper library for Metatrader 5 Web API

Documentation

Packagist

https://packagist.org/packages/aleedhillon/meta-five.

Installing

To install the package, in terminal:

composer require aleedhillon/meta-five

Configure

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

AleeDhillon\MetaFive\MetaFiveProvider::class,

Copy the package config to your local config with the publish command:

php artisan vendor:publish --tag=meta-five-config

and then you can configure connection information to MT5 with this .env value

MT5_SERVER_IP=
MT5_SERVER_PORT=
MT5_SERVER_WEB_LOGIN=
MT5_SERVER_WEB_PASSWORD=

Usage

Create Deposit

You can withdraw money by giving negetive number to the same trade method.

use AleeDhillon\MetaFive\Entities\Trade;
use AleeDhillon\MetaFive\Facades\Client;

$trade = new Trade();
$trade->setLogin(6000189);
$trade->setAmount(100);
$trade->setComment("Deposit");
$trade->setType(Trade::DEAL_BALANCE);
$result = Client::trade($trade);

The result variable will return Trade class with ticket information, you can grab ticket number by calling $result->getTicket()

Create User

use AleeDhillon\MetaFive\Entities\User;
use AleeDhillon\MetaFive\Facades\Client;

$user = new User();
$user->setName("John Doe");
$user->setEmail("[email protected]");
$user->setGroup("demo\demoforex");
$user->setLeverage("50");
$user->setPhone("0123456789");
$user->setAddress("Lahore");
$user->setCity("Lahore");
$user->setState("Punjab");
$user->setCountry("Pakistan");
$user->setZipCode(1470);
$user->setMainPassword("secret");
$user->setInvestorPassword("secret");
$user->setPhonePassword("secret");

$result = Client::createUser($user);

Get Trading Account Information

use AleeDhillon\MetaFive\Facades\Client;

$user = Client::getTradingAccounts($login);

$balance = $user->Balance;
$equity = $user->Equity;
$freeMargin = $user->MarginFree;

Get Trading History By Login Number

use AleeDhillon\MetaFive\Facades\Client;

// Get Closed Order Total and pagination
$total = Client::getOrderHistoryTotal($exampleLogin, $timestampfrom, $timestampto);
$trades = Client::getOrderHistoryPagination($exampleLogin, $timestampfrom, $timestampto, 0, $total);
foreach ($trades as $trade) {
    // see class MTOrder
    echo "LOGIN : ".$trade->Login.PHP_EOL;
    echo "TICKET : ".$trade->Order.PHP_EOL;
}

Open Order

use AleeDhillon\MetaFive\Facades\Client;
Client::dealerSend([
    'Login' => 8113,
    'Symbol' => 'XAUUSD',
    'Volume' => 100,
    'Type' => 0
});

The result variable will return User class with login information, you can grab login number by calling $result->getLogin()

Todo

  • Deposit or Withdrawal
  • Create Account
  • Open Order
  • Get Trading Account Information
  • Change Password
  • Create Group
  • Delete Group
  • Get Accounts
  • Remove Account
  • Get Trades
  • Get Group

This is work in progress, I will may be improve this package or rewrite the entire one with Laravel 9 and PHP 8 Support. In this revisioin I haven't touched much to the core in next I intend to rewrite the core.

Credits

Thanx to Tarikh Agustia who wrote the following two packges from which I have rewritten this current package with improvements like the Laravel singleton pattern for speed and reducing API calls to MT5.

Contributing

Thank you for considering contributing to the MetaFive! you can fork this repository and make pull request.

Security Vulnerabilities

If you discover a security vulnerability within MetaFive, please send an e-mail to Ali A. Dhillon via [email protected]. All security vulnerabilities will be promptly addressed.

License

The MetaFive packge is open-source software licensed under the MIT license.

meta-five's People

Contributors

aleedhillon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.