v1 working switch symbols w volume filter

This commit is contained in:
2026-05-01 20:45:26 +00:00
parent 7d579faa82
commit b05f389e49
40 changed files with 12837 additions and 28654 deletions

View File

@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 1,
"id": "d1eed397",
"metadata": {},
"outputs": [],
@@ -12,6 +12,7 @@
"from dataclasses import dataclass, asdict\n",
"import valkey\n",
"import modules.utils as utils\n",
"from decimal import Decimal, ROUND_DOWN\n",
"\n",
"with open('algo_config.json', 'r', encoding='utf-8') as file:\n",
" ALGO_CONFIG = json.load(file)\n",
@@ -20,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"id": "c6151613",
"metadata": {},
"outputs": [],
@@ -30,7 +31,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": null,
"id": "d83c61e5",
"metadata": {},
"outputs": [
@@ -40,31 +41,25 @@
"1"
]
},
"execution_count": 38,
"execution_count": 7,
"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.0002,\n",
" # 'Price_Worsener_Extend': 0.0,\n",
" # 'Price_Worsener_Aster': 0.0,\n",
" # 'Switch_To_Taker_Seconds': 1,\n",
" },\n",
" # 'Config': {\n",
" # 'Price_Worsener_Aster': 0,\n",
" # 'Price_Worsener_Extend': -1\n",
" # },\n",
" 'Logging': {\n",
" # 'Log_Summary_Each_Loop': False,\n",
" 'Print_Summary_Each_Loop': False,\n",
" 'Log_Summary_Each_Loop': False,\n",
" 'Print_Summary_Each_Loop': True,\n",
" },\n",
" # 'Overrides': {\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",
" # 'Allow_Ordering_Aster': True,\n",
" # 'Allow_Ordering_Extend': True,\n",
" # 'Allow_Symbol_Change': True,\n",
" # },\n",
"}\n",
"VAL_KEY.publish('fr_orchestrator_input', json.dumps(config_update))"
@@ -94,27 +89,55 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "940586bb",
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"'{\"stream\":\"btcusdt@bookTicker\",\"data\":{\"event_type\":\"bookTicker\",\"update_id\":458028589204,\"symbol\":\"BTCUSDT\",\"best_bid_price\":\"76414.9\",\"best_bid_qty\":\"0.507\",\"best_ask_price\":\"76415.0\",\"best_ask_qty\":\"0.878\",\"transaction_time\":1777565596460,\"event_time\":1777565596488}}'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"VAL_KEY.get('test_key')"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "cd600e0e",
"metadata": {},
"outputs": [],
"source": []
"source": [
"from decimal import Decimal"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"id": "db52edf9",
"metadata": {},
"outputs": [],
"source": []
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"int(Decimal(0.56))"
]
},
{
"cell_type": "code",
@@ -146,17 +169,17 @@
},
{
"cell_type": "code",
"execution_count": 57,
"execution_count": 18,
"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\": \"-\"}}'"
"'{\"ASTER\": {\"lh_asset\": \"ZEC\", \"rh_asset\": \"USDT\", \"symbol_asset_separator\": \"\", \"mult\": 75, \"initial_funding_rate\": -8.836e-05, \"min_price\": 0.01, \"min_order_size\": 0.01}, \"EXTEND\": {\"lh_asset\": \"ZEC\", \"rh_asset\": \"USD\", \"symbol_asset_separator\": \"-\", \"mult\": 10, \"initial_funding_rate\": 1.3e-05, \"min_price\": 0.01, \"min_order_size\": 0.01}}'"
]
},
"execution_count": 57,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@@ -188,29 +211,50 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 3,
"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))"
"best_symbol_by_exchange: dict = json.loads(s=VAL_KEY.get(name='fr_engine_best_fund_rate_output')) # ty:ignore[invalid-argument-type]\n",
"best_symbol_by_exchange_aster = structs.Perpetual_Exchange(**best_symbol_by_exchange['ASTER'])\n",
"best_symbol_by_exchange_extend = structs.Perpetual_Exchange(**best_symbol_by_exchange['EXTEND'])"
]
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 4,
"id": "ba98754e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Perpetual_Exchange(lh_asset='ZEC', rh_asset='USDT', symbol_asset_separator='', mult=75, initial_funding_rate=-8.836e-05, min_price=0.01, min_order_size=0.001)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"best_symbol_by_exchange_aster"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "fa5a8e85",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Perpetual_Exchange(mult=50, lh_asset='ETH', rh_asset='USD', symbol_asset_separator='-')"
"Perpetual_Exchange(lh_asset='ZEC', rh_asset='USD', symbol_asset_separator='-', mult=10, initial_funding_rate=1.3e-05, min_price=0.001, min_order_size=0.1)"
]
},
"execution_count": 53,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -221,30 +265,203 @@
},
{
"cell_type": "code",
"execution_count": 54,
"id": "fb81441a",
"execution_count": null,
"id": "09571e38",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
"Decimal('1.0')"
]
},
"execution_count": 54,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Decimal('1.0').quantize()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.0"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = 1.0\n",
"x"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "70b57870",
"metadata": {},
"outputs": [],
"source": [
"f = ['b','a','z','e']"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['b', 'a', 'z', 'e']"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "9fd60c6e",
"metadata": {},
"outputs": [],
"source": [
"f.sort()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "cd8b41de",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['a', 'b', 'e', 'z']"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "4c566e14",
"metadata": {},
"outputs": [],
"source": [
"price = float(0.9066)\n",
"min_price = float(0.0001)\n",
"\n",
"VAL_KEY.set('fr_algo_working_symbol', json.dumps({'ASTER': asdict(best_symbol_by_exchange_aster), 'EXTEND': asdict(best_symbol_by_exchange_extend)}))"
"min_price = int(min_price) if min_price == int(min_price) else min_price\n",
"price: Decimal = Decimal(str(price)).quantize(Decimal(str(min_price)), rounding=ROUND_DOWN)"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "ad6444a5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"6"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(str(price))"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "74a227cc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Decimal('0.9066')"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"price"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "09571e38",
"id": "57fac02c",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "2331e29f",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Decimal('0.000100000000000000004792173602385929598312941379845142364501953125')"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Decimal(min_price)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1c139413",
"metadata": {},
"outputs": [],
"source": []
@@ -259,6 +476,15 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a938b2e0",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "39667bd8",
"metadata": {},
"outputs": [],
"source": []