saving for japan

This commit is contained in:
2026-04-25 23:47:07 +00:00
parent dac490ca5b
commit 73c4eb1bf8
6 changed files with 240 additions and 159 deletions

View File

@@ -2,152 +2,101 @@
"cells": [
{
"cell_type": "code",
"execution_count": 28,
"id": "ac27075d",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"from dataclasses import dataclass, asdict\n",
"\n",
"@dataclass(kw_only=True)\n",
"class Algo_Config:\n",
" Allow_Ordering_Aster: bool\n",
" Allow_Ordering_Extend: bool\n",
" Loop_Sleep_Sec: int\n",
" Min_Time_To_Funding_Minutes: int\n",
" Price_Worsener_Aster: float\n",
" Price_Worsener_Extend: float\n",
" Target_Open_Cash_Position: int"
]
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 1,
"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: Algo_Config(**d))"
" ALGO_CONFIG = json.load(file, object_hook=lambda d: structs.Algo_Config(**d))"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "286bf2d2",
"execution_count": 2,
"id": "c6151613",
"metadata": {},
"outputs": [],
"source": [
"VAL_KEY = valkey.Valkey(host='localhost', port=6379, db=0, decode_responses=True)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d83c61e5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Algo_Config(Allow_Ordering_Aster=True, Allow_Ordering_Extend=True, Loop_Sleep_Sec=1, Min_Time_To_Funding_Minutes=7, Price_Worsener_Aster=0.0, Price_Worsener_Extend=0.0, Target_Open_Cash_Position=10)"
"1"
]
},
"execution_count": 30,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ALGO_CONFIG"
"config_update = {'Min_Time_To_Funding_Minutes': 7}\n",
"VAL_KEY.publish('fr_orchestrator_input', json.dumps(config_update))"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "0cbed6d4",
"metadata": {},
"outputs": [],
"source": [
"d = asdict(ALGO_CONFIG)"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "daa47980",
"metadata": {},
"outputs": [],
"source": [
"d_update = {'Allow_Ordering_Aster': False}"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "aba7797b",
"execution_count": 11,
"id": "45fae761",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Allow_Ordering_Aster': True,\n",
"Algo_Config(Config_Updated_Timestamp=1777151524162, Allow_Ordering_Aster=True, Allow_Ordering_Extend=True, Loop_Sleep_Sec=1, Max_Target_Notional=0.0, Min_Time_To_Funding_Minutes=60, Price_Worsener_Aster=0.0, Price_Worsener_Extend=0.0, Target_Open_Cash_Position=10)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"json.loads(VAL_KEY.get('fr_orchestrator_output'), object_hook=lambda d: structs.Algo_Config(**d))"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Config_Updated_Timestamp': 1777098091913,\n",
" 'Allow_Ordering_Aster': True,\n",
" 'Allow_Ordering_Extend': True,\n",
" 'Loop_Sleep_Sec': 1,\n",
" 'Min_Time_To_Funding_Minutes': 7,\n",
" 'Max_Target_Notional': 0.0,\n",
" 'Min_Time_To_Funding_Minutes': 60,\n",
" 'Price_Worsener_Aster': 0.0,\n",
" 'Price_Worsener_Extend': 0.0,\n",
" 'Target_Open_Cash_Position': 10}"
]
},
"execution_count": 42,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"d"
"asdict(ALGO_CONFIG)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "3250cb84",
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "expected ':' (3324129842.py, line 1)",
"output_type": "error",
"traceback": [
" \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[43]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[31m \u001b[39m\u001b[31mif d.get(d_update)\u001b[39m\n ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m expected ':'\n"
]
}
],
"source": [
"if d.get(d_update)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e283b819",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['Allow_Ordering_Aster'])"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(d_update.keys())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6f067c02",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,