AminHP / gym-mtsim

A general-purpose, flexible, and easy-to-use simulator alongside an OpenAI Gym trading environment for MetaTrader 5 trading platform (Approved by OpenAI Gym)
MIT License
412 stars 101 forks source link

A question about calculate balance #45

Open ruifeng96150 opened 7 months ago

ruifeng96150 commented 7 months ago

In my opinion, balance mean to cash. So when open a new order, the balance should minus cash used in orders. But in _create_hedged_order function, not update balance. It's a bug or I have misunderstand?

ruifeng96150 commented 7 months ago
seq Id Symbol Type Volume Entry Time Entry Price Exit Time Exit Price Profit Margin Fee Closed
0 2 USDJPY Sell 2.0 2021-09-01 00:17:52+00:00 110.02500 2021-09-06 00:17:52+00:00 109.71200 552.355257 2000.000000 0.0100 False
1 1 GBPCAD Buy 1.0 2021-08-30 00:17:52+00:00 1.73389 2021-09-06 00:17:52+00:00 1.73626 165.225928 1375.480933 0.0003 False

And an other question. For the table above from Readme.md. How the profit and margin calcuate out? I calcuate it but not same.

AminHP commented 6 months ago

In my opinion, balance mean to cash. So when open a new order, the balance should minus cash used in orders. But in _create_hedged_order function, not update balance. It's a bug or I have misunderstand?

You are referring to equity. According to Metatrader, equity is calculated as balance+profit.

AminHP commented 6 months ago

And an other question. For the table above from Readme.md. How the profit and margin calcuate out? I calcuate it but not same.

The implementations can be found here and here. There references might also help as well.