Files
Funding_Rate/algo.ipynb

146 lines
3.2 KiB
Plaintext
Raw Permalink Normal View History

2026-04-25 23:43:28 +00:00
{
"cells": [
{
"cell_type": "code",
2026-04-25 23:47:07 +00:00
"execution_count": 1,
"id": "d1eed397",
2026-04-25 23:43:28 +00:00
"metadata": {},
"outputs": [],
"source": [
2026-04-25 23:47:07 +00:00
"import modules.structs as structs\n",
2026-04-25 23:43:28 +00:00
"import json\n",
"from dataclasses import dataclass, asdict\n",
2026-04-25 23:47:07 +00:00
"import valkey\n",
2026-04-25 23:43:28 +00:00
"\n",
2026-04-25 23:47:07 +00:00
"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))"
2026-04-25 23:43:28 +00:00
]
},
{
"cell_type": "code",
2026-04-25 23:47:07 +00:00
"execution_count": 2,
"id": "c6151613",
2026-04-25 23:43:28 +00:00
"metadata": {},
"outputs": [],
"source": [
2026-04-25 23:47:07 +00:00
"VAL_KEY = valkey.Valkey(host='localhost', port=6379, db=0, decode_responses=True)"
2026-04-25 23:43:28 +00:00
]
},
{
"cell_type": "code",
2026-04-25 23:47:07 +00:00
"execution_count": 3,
"id": "d83c61e5",
2026-04-25 23:43:28 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2026-04-25 23:47:07 +00:00
"1"
2026-04-25 23:43:28 +00:00
]
},
2026-04-25 23:47:07 +00:00
"execution_count": 3,
2026-04-25 23:43:28 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2026-04-25 23:47:07 +00:00
"config_update = {'Min_Time_To_Funding_Minutes': 7}\n",
"VAL_KEY.publish('fr_orchestrator_input', json.dumps(config_update))"
2026-04-25 23:43:28 +00:00
]
},
{
"cell_type": "code",
2026-04-25 23:47:07 +00:00
"execution_count": 11,
"id": "45fae761",
2026-04-25 23:43:28 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2026-04-25 23:47:07 +00:00
"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)"
2026-04-25 23:43:28 +00:00
]
},
2026-04-25 23:47:07 +00:00
"execution_count": 11,
2026-04-25 23:43:28 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2026-04-25 23:47:07 +00:00
"json.loads(VAL_KEY.get('fr_orchestrator_output'), object_hook=lambda d: structs.Algo_Config(**d))"
2026-04-25 23:43:28 +00:00
]
},
{
"cell_type": "code",
2026-04-25 23:47:07 +00:00
"execution_count": 16,
2026-04-25 23:43:28 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2026-04-25 23:47:07 +00:00
"{'Config_Updated_Timestamp': 1777098091913,\n",
" 'Allow_Ordering_Aster': True,\n",
" 'Allow_Ordering_Extend': True,\n",
" 'Loop_Sleep_Sec': 1,\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}"
2026-04-25 23:43:28 +00:00
]
},
2026-04-25 23:47:07 +00:00
"execution_count": 16,
2026-04-25 23:43:28 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2026-04-25 23:47:07 +00:00
"asdict(ALGO_CONFIG)"
2026-04-25 23:43:28 +00:00
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d2e26271",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "a0df43de",
"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.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}