mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-22 16:28:08 +00:00
testdata
This commit is contained in:
+23
-2
@@ -591,9 +591,30 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 2,
|
||||||
"id": "fe60fc41-8844-4e00-b254-bb95d28528f2",
|
"id": "fe60fc41-8844-4e00-b254-bb95d28528f2",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"1.2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"6 / (0 or 5)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "ceb79fa6-4713-43a5-9850-884cf6262f87",
|
||||||
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
}
|
}
|
||||||
@@ -614,7 +635,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.11.6"
|
"version": "3.11.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import pandas as pd
|
|||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
from MetaTrader5 import (Tick, SymbolInfo, AccountInfo, TradeOrder, TradePosition, TradeDeal,
|
from MetaTrader5 import (Tick, SymbolInfo, AccountInfo, TradeOrder, TradePosition, TradeDeal,
|
||||||
ORDER_TYPE_BUY, ORDER_TYPE_SELL)
|
ORDER_TYPE_BUY, ORDER_TYPE_SELL)
|
||||||
|
from ..meta_trader import MetaTrader
|
||||||
|
|
||||||
from ..constants import TimeFrame, CopyTicks
|
from ..constants import TimeFrame, CopyTicks
|
||||||
from .get_data import Data, GetData
|
from .get_data import Data, GetData
|
||||||
@@ -33,6 +34,8 @@ class TestData:
|
|||||||
self.open_orders: dict[int, TradeOrder] = {}
|
self.open_orders: dict[int, TradeOrder] = {}
|
||||||
self.positions: dict[str, dict[int, TradePosition]] = {}
|
self.positions: dict[str, dict[int, TradePosition]] = {}
|
||||||
self.open_positions: dict[int, TradePosition] = {}
|
self.open_positions: dict[int, TradePosition] = {}
|
||||||
|
self.mt = MetaTrader()
|
||||||
|
self.mt5 = MetaTrader5
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
self.cursor = next(self.iter)
|
self.cursor = next(self.iter)
|
||||||
@@ -104,10 +107,10 @@ class TestData:
|
|||||||
end = ticks[ticks.index >= end].iloc[-1].index
|
end = ticks[ticks.index >= end].iloc[-1].index
|
||||||
return ticks.loc[start:end].to_numpy()
|
return ticks.loc[start:end].to_numpy()
|
||||||
|
|
||||||
def order_calc_margin(self, action: Literal[0, 1], symbol: str, volume: float, price: float):
|
async def order_calc_margin(self, action: Literal[0, 1], symbol: str, volume: float, price: float, use_terminal=False):
|
||||||
symbol_info = self.get_symbol_info(symbol)
|
if use_terminal
|
||||||
margin_rate = symbol_info.margin_rate
|
sym = self.symbols[symbol]
|
||||||
margin = volume * price / margin_rate
|
margin = (volume * sym.trade_contract_size * price) / (self.account.leverage / (sym.margin_initial or 1))
|
||||||
return margin
|
return margin
|
||||||
|
|
||||||
def order_send(self, request: dict) -> dict:
|
def order_send(self, request: dict) -> dict:
|
||||||
|
|||||||
Reference in New Issue
Block a user