Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aleedhillon committed Feb 20, 2022
0 parents commit a572556
Show file tree
Hide file tree
Showing 70 changed files with 19,471 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/art export-ignore
/docs export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.php_cs.dist.php export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/testbench.yaml export-ignore
/UPGRADING.md export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.idea
.php_cs
.php_cs.cache
.phpunit.result.cache
build
composer.lock
coverage
docs
phpunit.xml
phpstan.neon
testbench.yaml
vendor
node_modules
.php-cs-fixer.cache
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) aleedhillon <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "aleedhillon/meta-five",
"description": "Metatrader 5 Web API Wrapper for Laravel",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Ali A. Dhillon",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"AleeDhillon\\MetaFive\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"AleeDhillon\\MetaFive\\MetaFiveProvider"
]
}
},
"require-dev": {
"orchestra/testbench": "^6.0"
}
}
8 changes: 8 additions & 0 deletions config/meta-five.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'server' => env('MT5_SERVER_IP', '127.0.0.1'),
'port' => env('MT5_SERVER_PORT', 443),
'login' => env('MT5_SERVER_WEB_LOGIN', 1),
'password' => env('MT5_SERVER_WEB_PASSWORD', null)
];
159 changes: 159 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
## Laravel MT5

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

- [Official MT5 Web Api Documentation](https://support.metaquotes.net/en/docs/mt5/api/webapi).

## Documentation

### 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:

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

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

```dotenv
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.

```php
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

```php
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

```php
use AleeDhillon\MetaFive\Facades\Client;

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

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

### Get Trading History By Login Number

```php
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

```php
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

- [x] Deposit or Withdrawal
- [x] Create Account
- [x] Open Order
- [x] 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](https://github.com/tarikhagustia) who wrote the following two packges from which I have rewritten this current package with improvements like the Laravel singleton pattern for speed.

- [https://github.com/tarikhagustia/php-mt5](https://github.com/tarikhagustia/php-mt5)
- [https://github.com/tarikhagustia/laravel-mt5](https://github.com/tarikhagustia/laravel-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]]([email protected]). All security vulnerabilities will be promptly addressed.

## License

The Laravel framework is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).
Binary file added src/.DS_Store
Binary file not shown.
Loading

0 comments on commit a572556

Please sign in to comment.