mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-07-27 20:27:43 +00:00
731 lines
18 KiB
Plaintext
731 lines
18 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "f4500c8d-0e58-4d3f-8dd3-06a4896f397f",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"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": 3,
|
|
"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": 21,
|
|
"id": "113d9327-bebc-4e99-8562-e6dbef29b108",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"0.58\n",
|
|
"OrderCheckResult(retcode=0, balance=65.76, equity=63.35, profit=-2.41, margin=1.74, margin_free=61.61, margin_level=3640.8045977011498, comment='Done', request=TradeRequest(action=1, magic=0, order=0, symbol='Volatility 25 (1s) Index', volume=0.005, price=464167.9, stoplimit=0.0, sl=0.0, tp=0.0, deviation=0, type=0, type_filling=0, type_time=0, expiration=0, comment='', position=0, position_by=0))\n"
|
|
]
|
|
},
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"OrderSendResult(retcode=10009, deal=3978355266, order=8068179971, volume=0.005, price=464076.06, bid=464042.01, ask=464076.06, comment='Request executed', request_id=943226517, retcode_external=0, request=TradeRequest(action=1, magic=0, order=0, symbol='Volatility 25 (1s) Index', volume=0.005, price=464167.9, stoplimit=0.0, sl=0.0, tp=0.0, deviation=0, type=0, type_filling=0, type_time=0, expiration=0, comment='', position=0, position_by=0))"
|
|
]
|
|
},
|
|
"execution_count": 21,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"sym = 'Volatility 25 (1s) Index'\n",
|
|
"# sym = 'EURUSD'\n",
|
|
"symb = Symbol(name=sym)\n",
|
|
"await symb.init()\n",
|
|
"op = symb.tick.ask + 100\n",
|
|
"cl = round((symb.trade_stops_level + symb.spread) * symb.point + symb.ask, symb.digits)\n",
|
|
"pr = await symb.mt5.order_calc_profit(action=0, symbol=sym, volume=symb.volume_min, price_open=op, price_close=cl)\n",
|
|
"rp = symb.volume_min * symb.trade_contract_size * (cl - op)\n",
|
|
"order = {'symbol': sym, 'price': op, 'volume': symb.volume_min, 'action': MetaTrader._TRADE_ACTION_A}\n",
|
|
"res = await symb.mt5.order_calc_margin(MetaTrader._ORDER_TYPE_BUY, sym, symb.volume_min, op)\n",
|
|
"print(res)\n",
|
|
"ocr = await symb.mt5.order_check(order)\n",
|
|
"print(ocr)\n",
|
|
"await symb.mt5.order_send(order)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 22,
|
|
"id": "f9189016-55fb-42d4-af77-e389767bc96c",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"(410, 7710.71, 0.01, 553.9999999999964)"
|
|
]
|
|
},
|
|
"execution_count": 22,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"symb.trade_stops_level, op, symb.point, abs(cl-op) / symb.point"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"id": "73109885-8291-42cd-90a6-8a04f5f25466",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"acc = Account()\n",
|
|
"await acc.refresh()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"id": "dbb5e4f3-286d-4a1f-b59c-60a5af1dc94a",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "AttributeError",
|
|
"evalue": "readonly attribute",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[1;32mIn[16], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# acc = await acc.mt5.account_info()\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[43macc\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmargin\u001b[49m \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m9\u001b[39m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m# acc._replace(margin=0)\u001b[39;00m\n",
|
|
"\u001b[1;31mAttributeError\u001b[0m: readonly attribute"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# acc = await acc.mt5.account_info()\n",
|
|
"acc.margin += 9\n",
|
|
"# acc._replace(margin=0)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2c598a85-1e90-49b0-abf1-87329597feae",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"sym = Symbol(name='Volatility 25 Index')\n",
|
|
"await sym.init()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "0a7d319c-5760-4058-994f-27e8d10df108",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"await sym.mt5.order_calc_margin(0, 'Volatility 25 Index', 1, sym.tick.ask)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4ec498ea-5e4e-4ff6-85da-051acc2eaf28",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"sy = await sym.mt5.symbol_info('Volatility 25 Index')\n",
|
|
"await sym.mt5.symbol_select('Volatility 25 Index', enable=True)\n",
|
|
"sy.trade_calc_mode"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9307e3df-a5f3-42cf-9d3d-e65e5254c0e5",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# margin\n",
|
|
"# worked for forex.\n",
|
|
"tcs = 1 * sym.trade_contract_size\n",
|
|
"lv = Account().leverage /0.125\n",
|
|
"tcs * sym.tick.ask / lv"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e8413f70-244f-47a2-97b3-2be6fcd87589",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "63050d62-443a-4d30-b2a6-4ec6d4f00362",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"symbols = {'Volatility 10 Index', 'Volatility 100 (1s) Index', 'Volatility 25 Index'}\n",
|
|
"timeframes = {TimeFrame.M5, TimeFrame.H1, TimeFrame.M1, TimeFrame.H4, TimeFrame.M30, TimeFrame.M15}\n",
|
|
"gd = GetData(st, et, timeframes, symbols, name='data')\n",
|
|
"await gd.fail()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "49d86767-d5cc-40a8-894e-c8f5b920f8cf",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"symbols = {'Volatility 10 Index', 'Volatility 100 (1s) Index', 'Volatility 25 Index'}\n",
|
|
"timeframes = {TimeFrame.M5, TimeFrame.H1, TimeFrame.M1, TimeFrame.H4, TimeFrame.M30, TimeFrame.M15}\n",
|
|
"async with MetaTester(st, et, timeframes, symbols, name='data') as mt:\n",
|
|
" # res = await mt.copy_ticks_range('Volatility 100 Index', st, et, CopyTicks.ALL)\n",
|
|
" # print(res)\n",
|
|
" await mt.get_and_save_data()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c4f8c64b-dcba-40cf-8342-53bb4b3fa6e6",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"df = pd.DataFrame(res)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "970126ba-a143-4b45-a82e-8cf6b885763c",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# df.set_index(list(range(secs)))\n",
|
|
"df.drop_duplicates(subset=['time'], keep='last', )"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "bf6d4786-4ee1-4bd4-81e2-fa43bdc527a4",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"df = df.set_index('time', drop=False, verify_integrity=True)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e788c43f-42d3-4c01-9bd9-5224e2175c1f",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"bg = int(st.timestamp())\n",
|
|
"en = int(secs) + bg\n",
|
|
"index = range(bg, en)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "fd9cffe6-c550-4f54-be8a-5e55b23b81a9",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"bf = len(df.index)\n",
|
|
"df = df.reindex(index=index, method='nearest')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "c0b60fb9-0c27-4435-900d-898ea6979e11",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"last = df.iloc[-1].time\n",
|
|
"print(datetime.fromtimestamp(last, tz=tz), et)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "60afd149-9600-4f0e-b3ff-1e8ad10247f3",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"acc = AccountInfo(balance=500)\n",
|
|
"data = MetaTester(start, end).load_data('data')\n",
|
|
"td = TestData(acc, data)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "be5704d5-4bff-4ec1-8cbe-2e96bfaf4f11",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"ticks = data['ticks']['Volatility 10 Index']"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "12b3d5cb-0d31-4b70-b583-1f2becb74a0f",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"ticks[-1]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "ee0c4ccb-0e7c-434e-a655-fe89b09e606c",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"y = TimeFrame.M5\n",
|
|
"y.time"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "7a28ce72-0409-4231-92f7-f4e61fc0be94",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"end.timestamp()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4aeeb64b-d3d2-4053-9808-2539e2755d09",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"len(ticks)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "29647ef4-01ad-46a0-afb2-f43a4988a529",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"type(ticks[0])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "bc593a4b-53d6-4203-a986-33b5267b9244",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"ticks.reshape(8, 86160)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "dc6440a3-4333-4363-b462-edee4facdd0f",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import numpy as np"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "0a246c6d-d35c-4878-a128-52ed1abb0108",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"res = np.reshape(ticks, (-1, 8))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "6e9de365-0f13-4d88-8302-f5e3418d489b",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"ticks.shape = (86160, 8)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "451b8e09-d17c-4662-a25d-39f00ff01788",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"res = np.hstack(ticks)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "395a1b7b-309d-4e38-b579-1b6b4854b19d",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"v = np.array((*ticks[0]))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "1bb16ff4-d92e-4474-a235-d8be87d094d6",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"r = next(iter(ticks))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "f2241c9c-68eb-4371-b3e3-202ebe25f7cd",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"v.shape"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "ee0d3713-8578-46e2-969c-aebc295fae98",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"ar = list(range(4))\n",
|
|
"t = np.array(ar)\n",
|
|
"t.shape = (1, 4)\n",
|
|
"t"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "8502f7da-793e-4bfe-b469-bc109f051507",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"mt.config.login"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4d818ddd-f78c-4a50-b4a7-dc266321091c",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"acc = Account()\n",
|
|
"await acc.sign_in()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4c4c32d9-9c45-4ee7-afee-e04d1f5dca4a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"mt5 = MetaTrader()\n",
|
|
"sym = await mt5.symbol_info('Volatility 100 (1s) Index')\n",
|
|
"print(sym._asdict)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 70,
|
|
"id": "e47bd638-42fa-40d9-b573-474a39884dbc",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
" time open high low close tick_volume spread \\\n",
|
|
"0 1724859360 6770.27 6775.26 6765.13 6765.13 60 144 \n",
|
|
"1 1724859420 6766.28 6769.70 6761.25 6761.35 60 144 \n",
|
|
"2 1724859480 6762.58 6777.91 6762.58 6776.98 58 144 \n",
|
|
"3 1724859540 6778.78 6784.64 6771.89 6782.54 60 144 \n",
|
|
"4 1724859600 6781.56 6787.20 6779.02 6784.20 60 144 \n",
|
|
".. ... ... ... ... ... ... ... \n",
|
|
"495 1724889060 6622.30 6626.43 6620.74 6620.76 60 144 \n",
|
|
"496 1724889120 6620.70 6623.06 6611.94 6623.06 60 144 \n",
|
|
"497 1724889180 6623.13 6625.32 6618.51 6623.52 60 144 \n",
|
|
"498 1724889240 6622.50 6627.44 6621.98 6626.63 60 144 \n",
|
|
"499 1724889300 6626.77 6626.77 6626.48 6626.48 2 144 \n",
|
|
"\n",
|
|
" real_volume \n",
|
|
"0 0 \n",
|
|
"1 0 \n",
|
|
"2 0 \n",
|
|
"3 0 \n",
|
|
"4 0 \n",
|
|
".. ... \n",
|
|
"495 0 \n",
|
|
"496 0 \n",
|
|
"497 0 \n",
|
|
"498 0 \n",
|
|
"499 0 \n",
|
|
"\n",
|
|
"[500 rows x 8 columns]"
|
|
]
|
|
},
|
|
"execution_count": 70,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"await symb.copy_rates_from_pos(timeframe=TimeFrame.M1)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 72,
|
|
"id": "a4bc7b28-6dac-4863-b257-64d2c5c62575",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"Empty DataFrame\n",
|
|
"Columns: [time, bid, ask, last, volume, time_msc, flags, volume_real]\n",
|
|
"Index: []"
|
|
]
|
|
},
|
|
"execution_count": 72,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"tz = pytz.timezone('Etc/UTC')\n",
|
|
"now = datetime.now(tz=tz)\n",
|
|
"# now.replace(tz=tz-tz)\n",
|
|
"await symb.copy_ticks_from(date_from=now)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "90c17d01-4ed0-468d-85c4-64988338b8a9",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"print(start)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9a9141a1-7049-48e5-a96f-0b637b817d40",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data = shelve.open('./data/01-08-24_17-08-24', writeback=True)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e2d4d4d7-5bfa-43e3-a455-012cf754a106",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data = dict(data)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "95931276-fb8c-4a97-b440-330efc5e4d93",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data = pickle.dumps(data)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "57c620ad-3fa5-41b9-a372-9a090e18ff85",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data = zlib.compress(data, level=9)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2d85bcdb-a86a-43f0-9b93-7d8c0ce7cf9e",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"_data = lzma.compress(data)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "eec34d71-7455-4064-9367-52156407335e",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"fh = lzma.open('./data/ldata.xz', 'w')\n",
|
|
"fh.write(_data)\n",
|
|
"fh.close()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "6f38b857-ed2d-4819-ba7f-4f70dc2fb3f9",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"rb = lzma.open('./data/ldata.xz')\n",
|
|
"rbb = rb.read()\n",
|
|
"rb.close()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "28220ba7-46af-409b-826d-2979ceb19f65",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"rbd = lzma.decompress(rbb)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "b3275fd6-70ff-4596-b4ba-9d9e4b6e52fe",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"rdata = pickle.loads(rbd)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "5bbcbc06-f353-4255-9792-89263793ba0f",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"data.keys()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "f9830b77-5e73-45c9-bc6a-40c19c3816c5",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"fh = open('./data/pdata', 'wb')\n",
|
|
"pickle.dump(rdata, fh)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "064b8628-1331-4fa3-abf3-66f88c75da33",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"fh.close()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "fe60fc41-8844-4e00-b254-bb95d28528f2",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"6 / (0 or 5)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "ceb79fa6-4713-43a5-9850-884cf6262f87",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|