{ "cells": [ { "cell_type": "code", "execution_count": 76, "id": "d1eed397", "metadata": {}, "outputs": [], "source": [ "import modules.structs as structs\n", "import json\n", "from dataclasses import dataclass, asdict\n", "import valkey\n", "\n", "with open('algo_config.json', 'r', encoding='utf-8') as file:\n", " ALGO_CONFIG = json.load(file, object_hook=lambda d: structs.Algo_Config(**d))" ] }, { "cell_type": "code", "execution_count": 77, "id": "c6151613", "metadata": {}, "outputs": [], "source": [ "VAL_KEY = valkey.Valkey(host='localhost', port=6379, db=0, decode_responses=True)" ] }, { "cell_type": "code", "execution_count": null, "id": "d83c61e5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 131, "metadata": {}, "output_type": "execute_result" } ], "source": [ "config_update = {\n", " 'Min_Time_To_Funding_Minutes': 7,\n", " # 'Allow_Ordering_Aster': True,\n", " # 'Allow_Ordering_Extend': True,\n", " 'Loop_Sleep_Sec': 0.00,\n", "# 'Flip_Side_For_Testing': False,\n", "# 'Price_Worsener_Extend': 0.0,\n", " 'Log_Summary_Each_Loop': False,\n", " 'Print_Summary_Each_Loop': False,\n", "}\n", "VAL_KEY.publish('fr_orchestrator_input', json.dumps(config_update))" ] }, { "cell_type": "code", "execution_count": 93, "id": "45fae761", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5.0" ] }, "execution_count": 93, "metadata": {}, "output_type": "execute_result" } ], "source": [ "json.loads(VAL_KEY.get('fr_orchestrator_output'), object_hook=lambda d: structs.Algo_Config(**d)).Loop_Sleep_Sec" ] }, { "cell_type": "code", "execution_count": null, "id": "98c500cc", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "f2cf3325", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 31, "id": "a0df43de", "metadata": {}, "outputs": [], "source": [ "pos = json.loads(VAL_KEY.get('fr_aster_user_positions'))" ] }, { "cell_type": "code", "execution_count": 32, "id": "ca526c8a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'timestamp_arrival': 1777303258987,\n", " 'timestamp_msg': 1777303258979,\n", " 'timestamp_transaction': 1777303258950,\n", " 'event_reason_type': 'ORDER',\n", " 'symbol': 'ETHUSDT',\n", " 'position_amount': 0.226,\n", " 'entry_price': 2284.28,\n", " 'accumulated_realized_pre_fees': 8.24392002,\n", " 'unrealized_pnl': 0.0,\n", " 'margin_type': 'cross',\n", " 'isolated_wallet': 0.0,\n", " 'position_side': 'BOTH'}]" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pos" ] }, { "cell_type": "code", "execution_count": 33, "id": "f788b6df", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Timestamp('2026-04-27 15:20:58.987000')" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "pd.to_datetime(1777303258987, unit='ms')" ] }, { "cell_type": "code", "execution_count": 34, "id": "855f980b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Timestamp('2026-04-27 15:20:58.979000')" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "pd.to_datetime(1777303258979, unit='ms')" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Timestamp('2026-04-27 15:20:58.950000')" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "pd.to_datetime(1777303258950, unit='ms')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py_313", "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.13.13" } }, "nbformat": 4, "nbformat_minor": 5 }