added extend symbol change for ws

This commit is contained in:
2026-04-30 04:32:49 +00:00
parent dc3409ac40
commit 1ac0909c21
20 changed files with 28960 additions and 1221 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 4,
"id": "d1eed397",
"metadata": {},
"outputs": [],
@@ -11,6 +11,7 @@
"import json\n",
"from dataclasses import dataclass, asdict\n",
"import valkey\n",
"import modules.utils as utils\n",
"\n",
"with open('algo_config.json', 'r', encoding='utf-8') as file:\n",
" ALGO_CONFIG = json.load(file)\n",
@@ -19,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 5,
"id": "c6151613",
"metadata": {},
"outputs": [],
@@ -29,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 38,
"id": "d83c61e5",
"metadata": {},
"outputs": [
@@ -39,30 +40,31 @@
"1"
]
},
"execution_count": 4,
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"config_update = {\n",
" # 'Config': {\n",
" # 'Loop_Sleep_Sec': 0.00,\n",
" # 'Min_Time_To_Funding_Minutes': 60,\n",
" # 'Min_Fund_Rate_Pct_To_Trade': 0.001,\n",
" # 'Price_Worsener_Extend': 0.0,\n",
" # 'Price_Worsener_Aster': 0.0,\n",
" # 'Switch_To_Taker_Seconds': 1,\n",
" # },\n",
" 'Config': {\n",
" # 'Loop_Sleep_Sec': 0.00,\n",
" # 'Min_Time_To_Funding_Minutes': 60,\n",
" # 'Min_Fund_Rate_Pct_To_Trade': 0.0002,\n",
" # 'Price_Worsener_Extend': 0.0,\n",
" # 'Price_Worsener_Aster': 0.0,\n",
" # 'Switch_To_Taker_Seconds': 1,\n",
" },\n",
" 'Logging': {\n",
" 'Log_Summary_Each_Loop': False,\n",
" 'Print_Summary_Each_Loop': True,\n",
" # 'Log_Summary_Each_Loop': False,\n",
" 'Print_Summary_Each_Loop': False,\n",
" },\n",
" # 'Overrides': {\n",
" # 'Allow_Ordering_Aster': True,\n",
" # 'Allow_Ordering_Extend': True,\n",
" # 'Flip_Side_For_Testing': False,\n",
" # 'Flatten_Open_Positions': False,\n",
" # # 'Allow_Ordering_Aster': True,\n",
" # # 'Allow_Ordering_Extend': True,\n",
" # # 'Allow_Symbol_Change': False,\n",
" # # 'Flip_Side_For_Testing': False,\n",
" # # 'Flatten_Open_Positions': False,\n",
" # },\n",
"}\n",
"VAL_KEY.publish('fr_orchestrator_input', json.dumps(config_update))"
@@ -70,29 +72,30 @@
},
{
"cell_type": "code",
"execution_count": 93,
"id": "45fae761",
"execution_count": 52,
"id": "f5260342",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.0"
"1"
]
},
"execution_count": 93,
"execution_count": 52,
"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"
"order = {'order_id':'test_1'}\n",
"VAL_KEY.publish('fr_engine_orders_input', json.dumps(order))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "98c500cc",
"id": "940586bb",
"metadata": {},
"outputs": [],
"source": []
@@ -100,7 +103,15 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f2cf3325",
"id": "cd600e0e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "db52edf9",
"metadata": {},
"outputs": [],
"source": []
@@ -112,92 +123,6 @@
"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,
@@ -219,6 +144,118 @@
"pd.to_datetime(1777303258950, unit='ms')"
]
},
{
"cell_type": "code",
"execution_count": 57,
"id": "5f7535df",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'{\"ASTER\": {\"mult\": 150, \"lh_asset\": \"ETH\", \"rh_asset\": \"USD\", \"symbol_asset_separator\": \"\"}, \"EXTEND\": {\"mult\": 50, \"lh_asset\": \"ETH\", \"rh_asset\": \"USD\", \"symbol_asset_separator\": \"-\"}}'"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"VAL_KEY.get('fr_algo_working_symbol')"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "3acaa8cd",
"metadata": {},
"outputs": [],
"source": [
"ASTER = structs.Perpetual_Exchange(\n",
" mult = 150,\n",
" lh_asset = 'ETH',\n",
" rh_asset = 'USD',\n",
" symbol_asset_separator = '',\n",
")\n",
"EXTEND = structs.Perpetual_Exchange(\n",
" mult = 50,\n",
" lh_asset = 'ETH',\n",
" rh_asset = 'USD',\n",
" symbol_asset_separator = '-',\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "b417adad",
"metadata": {},
"outputs": [],
"source": [
"best_symbol_by_exchange: dict = json.loads(s=VAL_KEY.get(name='fr_algo_working_symbol')) # ty:ignore[invalid-argument-type]\n",
"best_symbol_by_exchange_aster = structs.Perpetual_Exchange(**asdict(ASTER))\n",
"best_symbol_by_exchange_extend = structs.Perpetual_Exchange(**asdict(EXTEND))"
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "fa5a8e85",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Perpetual_Exchange(mult=50, lh_asset='ETH', rh_asset='USD', symbol_asset_separator='-')"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"best_symbol_by_exchange_extend"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "fb81441a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"VAL_KEY.set('fr_algo_working_symbol', json.dumps({'ASTER': asdict(best_symbol_by_exchange_aster), 'EXTEND': asdict(best_symbol_by_exchange_extend)}))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "09571e38",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,