{ "cells": [ { "cell_type": "code", "execution_count": 5, "id": "f4500c8d-0e58-4d3f-8dd3-06a4896f397f", "metadata": {}, "outputs": [], "source": [ "# import shelve\n", "# import pickle\n", "# import zlib\n", "# import lzma\n", "# import pytz\n", "from datetime import datetime, timedelta\n", "from aiomql import MetaTrader, TimeFrame, AccountInfo, TimeFrame, CopyTicks, Account, Symbol\n", "from MetaTrader5 import SymbolInfo\n", "import pandas as pd\n", "from pandas import DataFrame\n", "import pytz" ] }, { "cell_type": "code", "execution_count": 2, "id": "f2ef126c-6edc-4651-8a81-06bb97eed6f9", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "True\n" ] } ], "source": [ "res = await Account().sign_in()\n", "print(res)" ] }, { "cell_type": "code", "execution_count": 19, "id": "2c598a85-1e90-49b0-abf1-87329597feae", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tz = pytz.timezone('Etc/UTC')\n", "sym = Symbol(name='EURUSD')\n", "start = datetime(day=22, month=8, year=2024, tzinfo=tz)\n", "end = datetime(day=26, month=8, year=2024, hour=12, tzinfo=tz)\n", "# rates = await sym.mt5.copy_rates_from(symbol='EURUSD', date_from=end, count=5, timeframe=TimeFrame.H12)\n", "rates = await sym.mt5.copy_rates_from_pos(symbol='EURUSD', start_pos=0, count=5, timeframe=TimeFrame.H12)\n", "df = DataFrame(rates)\n", "df['time'] = pd.to_datetime(df['time'], unit='s')\n", "df.index[-1]" ] }, { "cell_type": "code", "execution_count": 30, "id": "0a7d319c-5760-4058-994f-27e8d10df108", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | time | \n", "open | \n", "high | \n", "low | \n", "close | \n", "tick_volume | \n", "spread | \n", "real_volume | \n", "
|---|---|---|---|---|---|---|---|---|
| 2 | \n", "2024-08-25 12:00:00 | \n", "1.11869 | \n", "1.11947 | \n", "1.11849 | \n", "1.11894 | \n", "4570 | \n", "1 | \n", "0 | \n", "
| 3 | \n", "2024-08-26 00:00:00 | \n", "1.11894 | \n", "1.12016 | \n", "1.11628 | \n", "1.11652 | \n", "43583 | \n", "0 | \n", "0 | \n", "
| 4 | \n", "2024-08-26 12:00:00 | \n", "1.11652 | \n", "1.11790 | \n", "1.11501 | \n", "1.11618 | \n", "45034 | \n", "0 | \n", "0 | \n", "