Files
Funding_Rate/algo.ipynb

3849 lines
114 KiB
Plaintext
Raw Permalink Normal View History

2026-04-25 23:43:28 +00:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 11,
2026-04-25 23:47:07 +00:00
"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-30 04:32:49 +00:00
"import modules.utils as utils\n",
"from decimal import Decimal, ROUND_DOWN\n",
2026-05-05 16:38:45 +00:00
"from typing import Any\n",
"from pydantic import BaseModel\n",
"import docker\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)\n",
" ALGO_CONFIG = structs.Algo_Config(**ALGO_CONFIG)"
2026-04-25 23:43:28 +00:00
]
},
{
"cell_type": "code",
"execution_count": 12,
2026-04-25 23:47:07 +00:00
"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",
"execution_count": 8,
2026-04-25 23:47:07 +00:00
"id": "d83c61e5",
2026-04-25 23:43:28 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
2026-04-25 23:43:28 +00:00
"source": [
2026-04-26 06:10:18 +00:00
"config_update = {\n",
" # 'Config': {\n",
" # 'Price_Worsener_Aster': 0,\n",
" # 'Price_Worsener_Extend': -1\n",
" # 'Min_Time_To_Funding_Minutes': 60\n",
" # 'Min_Fund_Rate_Pct_To_Trade': 0.0\n",
" # },\n",
" # 'Logging': {\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",
" 'Allow_Symbol_Change': True,\n",
" 'Flatten_Open_Positions': False,\n",
" # 'Flatten_Open_Positions_Opportunistic': False,\n",
" },\n",
2026-04-26 06:10:18 +00:00
"}\n",
"VAL_KEY.publish('fr_orchestrator_input', json.dumps(config_update))"
2026-04-25 23:43:28 +00:00
]
},
2026-04-27 17:57:58 +00:00
{
"cell_type": "code",
2026-05-07 00:25:49 +00:00
"execution_count": 19,
2026-05-05 16:38:45 +00:00
"id": "7e448690",
"metadata": {},
"outputs": [],
"source": [
"### ALGO FLOW ###\n",
"best_symbol_by_exchange: dict = json.loads(s=VAL_KEY.get(name='fr_engine_best_fund_rate_output')) # ty:ignore[invalid-argument-type]\n",
"Aster = structs.Perpetual_Exchange(**best_symbol_by_exchange['ASTER'])\n",
"Extend = structs.Perpetual_Exchange(**best_symbol_by_exchange['EXTEND'])\n",
" \n",
" # await get_aster_exch_info(symbol_override=Open_Symbols[0])\n",
" # await get_extend_exch_info(symbol_override=Open_Symbols[0])\n",
"\n",
"with open('algo_config.json', mode='r', encoding='utf-8') as file:\n",
" Config = json.load(file)\n",
" Config = structs.Algo_Config(**Config)\n",
"\n",
"Config.Config.Max_Target_Notional = float(min([Aster.mult, Extend.mult]) * Config.Config.Target_Open_Cash_Position)\n",
"# logging.info(f'Initial Algo Config: {ALGO_CONFIG}')\n",
"\n",
"VAL_KEY.set(name='fr_orchestrator_output', value=json.dumps(obj=Config.model_dump()))\n",
"VAL_KEY.set(name='fr_algo_working_symbol', value=json.dumps(obj={'ASTER': asdict(obj=Aster), 'EXTEND': asdict(obj=Extend)}))\n",
"\n",
"aster_ticker_dict: Any = VAL_KEY.get('fut_ticker_aster')\n",
"aster_ticker_dict: dict = json.loads(s=aster_ticker_dict) if aster_ticker_dict is not None else {}\n",
"if ( aster_ticker_dict.get('symbol', None) != Aster.symbol ) and not(Config.Overrides.Flatten_Open_Positions):\n",
" VAL_KEY.set(name='fr_algo_working_symbol', value=json.dumps(obj={'ASTER': asdict(obj=Aster), 'EXTEND': asdict(obj=Extend)}))\n",
"\n",
" # raise ValueError(f'ASTER Symbol mismatch: {ASTER_TICKER_DICT}; expected symbol: {ASTER.symbol}')\n",
"\n",
"extend_ticker_dict: Any = VAL_KEY.get('fut_ticker_extended')\n",
"extend_ticker_dict: dict = json.loads(s=extend_ticker_dict) if extend_ticker_dict is not None else {}\n",
"if ( extend_ticker_dict.get('symbol', None) != Extend.symbol) and not(Config.Overrides.Flatten_Open_Positions):\n",
" VAL_KEY.set(name='fr_algo_working_symbol', value=json.dumps(obj={'ASTER': asdict(obj=Aster), 'EXTEND': asdict(obj=Extend)}))\n",
" # raise ValueError(f'EXTEND Symbol mismatch: {EXTENDED_TICKER_DICT}; expected symbol: {EXTEND.symbol}')\n",
"\n",
"### Load Local Notional Updates from WS ###\n",
"aster_ws_pos_updates: Any = VAL_KEY.get(name='fr_aster_user_positions')\n",
"aster_ws_pos_updates: list = json.loads(s=aster_ws_pos_updates) if aster_ws_pos_updates is not None else []\n",
"extend_ws_pos_updates: Any = VAL_KEY.get('fr_extended_user_positions')\n",
"extend_ws_pos_updates: list = json.loads(extend_ws_pos_updates) if extend_ws_pos_updates is not None else [] \n",
"\n",
"### Load Local Order Updates from WS ###\n",
"aster_ws_order_updates: Any = VAL_KEY.get('fr_aster_user_orders')\n",
"aster_ws_order_updates: list = json.loads(aster_ws_order_updates) if aster_ws_order_updates is not None else [] \n",
"extend_ws_order_updates: Any = VAL_KEY.get('fr_extended_user_orders')\n",
"extend_ws_order_updates: list = json.loads(extend_ws_order_updates) if extend_ws_order_updates is not None else [] "
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "335235bd",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Aster = structs.Perpetual_Exchange(\n",
" mult = 150,\n",
" lh_asset = 'ETH',\n",
" rh_asset = 'USDT',\n",
" symbol = 'ETHUSDT',\n",
" symbol_asset_separator = '',\n",
")\n",
"\n",
"Extend = structs.Perpetual_Exchange(\n",
" mult = 50,\n",
" lh_asset = 'ETH',\n",
" rh_asset = 'USD',\n",
" symbol = 'ETH-USD',\n",
" symbol_asset_separator = '-',\n",
")\n",
"\n",
"VAL_KEY.set(name='fr_algo_working_symbol', value=json.dumps(obj={'ASTER': asdict(obj=Aster), 'EXTEND': asdict(obj=Extend)}))"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "e0498889",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with open('algo_config.json', mode='r', encoding='utf-8') as file:\n",
" Config = json.load(file)\n",
" Config = structs.Algo_Config(**Config)\n",
"\n",
"Config.Config.Max_Target_Notional = float(min([Aster.mult, Extend.mult]) * Config.Config.Target_Open_Cash_Position)\n",
"\n",
"VAL_KEY.set(name='fr_orchestrator_output', value=json.dumps(obj=Config.model_dump()))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "deaa8284",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'{\"ASTER\": {\"mult\": 150, \"lh_asset\": \"ETH\", \"rh_asset\": \"USDT\", \"symbol\": \"ETHUSDT\", \"symbol_asset_separator\": \"\", \"initial_funding_rate\": 0, \"fund_rate_at_same_time\": false, \"min_price\": 0, \"min_order_size\": 0, \"min_lot_size\": 0, \"min_notional\": 0, \"buy_ratio\": 0, \"buy_ratio_std\": 0, \"notional_obj\": {}, \"notional_position\": 0, \"unrealized_pnl\": 0, \"just_rejected_count\": 0, \"cancel_request_pending\": false}, \"EXTEND\": {\"mult\": 50, \"lh_asset\": \"ETH\", \"rh_asset\": \"USD\", \"symbol\": \"ETH-USD\", \"symbol_asset_separator\": \"-\", \"initial_funding_rate\": 0, \"fund_rate_at_same_time\": false, \"min_price\": 0, \"min_order_size\": 0, \"min_lot_size\": 0, \"min_notional\": 0, \"buy_ratio\": 0, \"buy_ratio_std\": 0, \"notional_obj\": {}, \"notional_position\": 0, \"unrealized_pnl\": 0, \"just_rejected_count\": 0, \"cancel_request_pending\": false}}'"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"VAL_KEY.get('fr_algo_working_symbol')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "52439504",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'{\"vk_name\":\"fr_orchestrator_output\",\"timestamp\":1778798391756,\"status\":\"HEALTHY\",\"checks\":{\"status\":{\"status\":\"HEALTHY\",\"method\":\"check_status\"},\"timestamp\":{\"status\":\"HEALTHY\",\"method\":\"check_timestamp\"},\"symbol\":{\"status\":\"HEALTHY\",\"method\":\"check_symbol\"}},\"data\":{\"Updated_Timestamp\":1778798391761,\"Config\":{\"Loop_Sleep_Sec\":0.0,\"Max_Order_Over_Notional_Ratio\":1.5,\"Max_Target_Notional\":0.0,\"Min_Time_To_Funding_Minutes\":57,\"Min_Fund_Rate_Pct_To_Trade\":0.0,\"Price_Worsener_Aster\":0,\"Price_Worsener_Extend\":-1,\"Switch_To_Taker_Seconds\":3,\"Target_Open_Cash_Position\":10},\"Logging\":{\"Log_Summary_Each_Loop\":false,\"Print_Summary_Each_Loop\":false},\"Overrides\":{\"Allow_Ordering_Aster\":true,\"Allow_Ordering_Extend\":true,\"Allow_Symbol_Change\":true,\"Flatten_Open_Positions\":false,\"Flatten_Open_Positions_Opportunistic\":false,\"Flip_Side_For_Testing\":false}}}'"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"VAL_KEY.get('fr_orchestrator_output')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "25625a2c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-1"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"VAL_KEY.ttl('fr_orchestrator_output')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "01a46d74",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with open('algo_config.json', mode='r', encoding='utf-8') as file:\n",
" Config = json.load(file)\n",
" Config = structs.Algo_Config(**Config)\n",
"\n",
"Config.Config.Max_Target_Notional = float(min([Aster.mult, Extend.mult]) * Config.Config.Target_Open_Cash_Position)\n",
"\n",
"VAL_KEY.set(name='fr_orchestrator_output', value=json.dumps(obj=Config.model_dump()))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "55810506",
"metadata": {},
"outputs": [],
"source": [
"vk_orchestrator = structs.VK_Orchestrator()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "c534dc57",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"VK_Orchestrator(vk_name='fr_algo_working_symbol', timestamp=1778798849459, status='HEALTHY', checks=VK_Checks(status=VK_Check(status='HEALTHY', method='check_status'), timestamp=VK_Check(status='HEALTHY', method='check_timestamp'), symbol=VK_Check(status='HEALTHY', method=None)), data=None)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vk_orchestrator"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "94710a67",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"getting\n"
]
}
],
"source": [
"await vk_orchestrator.get(VK_CON=VAL_KEY)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "c7a80698",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1778798867547"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vk_orchestrator.timestamp"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0381d934",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 6,
"id": "4d672e11",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'vk_name': 'fr_orchestrator_output',\n",
" 'status': 'HEALTHY',\n",
" 'checks': {'status': {'status': 'HEALTHY', 'method': 'check_status'},\n",
" 'timestamp': {'status': 'HEALTHY', 'method': 'check_timestamp'},\n",
" 'symbol': {'status': 'HEALTHY', 'method': 'check_symbol'}},\n",
" 'data': None}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"vk_orchestrator.model_dump()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "8d2b1adc",
"metadata": {},
"outputs": [
{
"ename": "ValidationError",
"evalue": "1 validation error for VK_Obj\nvk_name\n Field required [type=missing, input_value={'Updated_Timestamp': 177...de_For_Testing': False}}, input_type=dict]\n For further information visit https://errors.pydantic.dev/2.13/v/missing",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mValidationError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[8]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m vk_orchestrator.get(VK_CON=VAL_KEY)\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/Production/Funding_Rate/modules/structs.py:142\u001b[39m, in \u001b[36mVK_Obj.get\u001b[39m\u001b[34m(self, VK_CON)\u001b[39m\n\u001b[32m 140\u001b[39m vk_get: \u001b[38;5;28mstr\u001b[39m = VK_CON.get(\u001b[38;5;28mself\u001b[39m.vk_name) \u001b[38;5;66;03m# ty:ignore[invalid-assignment]\u001b[39;00m\n\u001b[32m 141\u001b[39m vk_dict: \u001b[38;5;28mdict\u001b[39m = json.loads(vk_get)\n\u001b[32m--> \u001b[39m\u001b[32m142\u001b[39m \u001b[38;5;28mself\u001b[39m = \u001b[30;43mself\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43m__class__\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43m*\u001b[39;49m\u001b[30;43m*\u001b[39;49m\u001b[30;43mvk_dict\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/miniconda3/envs/py_313/lib/python3.13/site-packages/pydantic/main.py:263\u001b[39m, in \u001b[36mBaseModel.__init__\u001b[39m\u001b[34m(self, **data)\u001b[39m\n\u001b[32m 261\u001b[39m \u001b[38;5;66;03m# `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks\u001b[39;00m\n\u001b[32m 262\u001b[39m __tracebackhide__ = \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m263\u001b[39m validated_self = \u001b[30;43mself\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43m__pydantic_validator__\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mvalidate_python\u001b[39;49m\u001b[30;43m(\u001b[39;49m\u001b[30;43mdata\u001b[39;49m\u001b[30;43m,\u001b[39;49m\u001b[30;43m \u001b[39;49m\u001b[30;43mself_instance\u001b[39;49m\u001b[30;43m=\u001b[39;49m\u001b[30;43mself\u001b[39;49m\u001b[30;43m)\u001b[39;49m\n\u001b[32m 264\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m validated_self:\n\u001b[32m 265\u001b[39m warnings.warn(\n\u001b[32m 266\u001b[39m \u001b[33m'\u001b[39m\u001b[33mA custom validator is returning a value other than `self`.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m'\u001b[39m\n\u001b[32m 267\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mReturning anything other than `self` from a top level model validator isn\u001b[39m\u001b[33m'\u001b[39m\u001b[33mt supported when validating via `__init__`.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 268\u001b[39m \u001b[33m'\u001b[39m\u001b[33mSee the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.\u001b[39m\u001b[33m'\u001b[39m,\n\u001b[32m 269\u001b[39m stacklevel=\u001b[32m2\u001b[39m,\n\u001b[32m 270\u001b[39m )\n",
"\u001b[31mValidationError\u001b[39m: 1 validation error for VK_Obj\nvk_name\n Field required [type=missing, input_value={'Updated_Timestamp': 177...de_For_Testing': False}}, input_type=dict]\n For further information visit https://errors.pydantic.dev/2.13/v/missing"
]
}
],
"source": [
"await vk_orchestrator.get(VK_CON=VAL_KEY)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d504d4d4",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ID: d3e6c192e9290d3dc0dfceea5ab6f065987d213aa814ef14a756b6569a0eabbf, Name: valkey-server, Status: running\n",
"ID: 1f9ea1879bb3f1aff41d6931b84dc1c945e84ec19c6b715d4a391e91e8fc82a7, Name: mysql_polymarket, Status: running\n"
]
}
],
"source": [
"### Docker ###\n",
"docker_client = docker.from_env()\n",
"container = docker_client.containers.get('algo_orchestrator')\n",
"\n",
"all_containers = docker_client.containers.list(all=True)\n",
"\n",
"for container in all_containers:\n",
" if container.status == 'running':\n",
" print(f\"ID: {container.id}, Name: {container.name}, Status: {container.status}\")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"docker_client."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bd57998f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"149.791"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"\n",
"r = requests.get('https://fapi.asterdex.com/fapi/v3/ping')\n",
"r.elapsed.microseconds/1000"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "100f2dee",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"24.368"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"r = requests.get('https://api.starknet.extended.exchange/api/v1/info/assets')\n",
"r.elapsed.microseconds/1000\n"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "9722a27c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"16.594"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"r = requests.get('https://data-api.binance.vision/api/v3/ping')\n",
"r.elapsed.microseconds/1000"
]
},
2026-05-05 16:38:45 +00:00
{
"cell_type": "code",
2026-05-07 00:25:49 +00:00
"execution_count": null,
"id": "ebea4788",
2026-05-07 00:25:49 +00:00
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 20,
"id": "49519685",
2026-05-07 00:25:49 +00:00
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'VAL_KEY' is not defined",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[20]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m VAL_KEY.get(\u001b[33m'fr_algo_working_symbol'\u001b[39m)\n",
"\u001b[31mNameError\u001b[39m: name 'VAL_KEY' is not defined"
]
2026-05-07 00:25:49 +00:00
}
],
"source": [
"VAL_KEY.get('fr_algo_working_symbol')"
2026-05-07 00:25:49 +00:00
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aee3840c",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
2026-05-07 00:25:49 +00:00
{
"cell_type": "code",
"execution_count": 14,
2026-05-05 16:38:45 +00:00
"id": "1d72da04",
2026-04-27 17:57:58 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2026-05-07 00:25:49 +00:00
"{'timestamp_arrival': 1778094603500,\n",
" 'timestamp_msg': 1778094603488,\n",
" 'timestamp_transaction': 1778094603450,\n",
" 'orderbook_update_id': 460270647968,\n",
" 'symbol': 'DOGEUSDT',\n",
" 'best_bid_px': '0.112900',\n",
" 'best_bid_qty': '11768',\n",
" 'best_ask_px': '0.112910',\n",
" 'best_ask_qty': '8626'}"
2026-04-27 17:57:58 +00:00
]
},
2026-05-07 00:25:49 +00:00
"execution_count": 14,
2026-04-27 17:57:58 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2026-05-05 16:38:45 +00:00
"aster_ticker_dict"
2026-04-27 17:57:58 +00:00
]
},
2026-05-04 18:04:45 +00:00
{
"cell_type": "code",
"execution_count": 50,
"id": "2ef09dc6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Decimal('1.00')"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"abs(Decimal('-1.00'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f45593f7",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 7,
2026-05-05 16:38:45 +00:00
"id": "0bcf9b05",
2026-05-04 18:04:45 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2026-05-05 16:38:45 +00:00
"0"
2026-05-04 18:04:45 +00:00
]
},
"execution_count": 7,
2026-05-04 18:04:45 +00:00
"metadata": {},
2026-05-05 16:38:45 +00:00
"output_type": "execute_result"
2026-05-04 18:04:45 +00:00
}
],
"source": [
2026-05-05 16:38:45 +00:00
"Aster.notional_position\n",
"Extend.notional_position"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5934a164",
"metadata": {},
"outputs": [],
"source": [
"@dataclass(kw_only=True)\n",
"class Signal:\n",
" signal: bool\n",
" exchange: str # ASTER | EXTEND\n",
" side: str # BUY | SELL\n",
" symbol: str # e.g. BTC-USD\n",
" expected_alpha: Decimal # e.g. BTC-USD\n",
" model_ratio: Decimal\n",
" current_ratio: Decimal\n",
"\n",
"@dataclass(kw_only=True)\n",
"class Target:\n",
" exchange: str # ASTER | EXTEND\n",
" side: str # BUY | SELL\n",
" symbol: str # e.g. BTC-USD\n",
" notional_tgt: Decimal\n",
" notional_tail: Decimal\n",
" base_tgt: Decimal\n",
" base_tail: Decimal"
2026-05-04 18:04:45 +00:00
]
},
2026-04-26 06:10:18 +00:00
{
"cell_type": "code",
"execution_count": 32,
2026-05-05 16:38:45 +00:00
"id": "27c193de",
"metadata": {},
"outputs": [],
"source": [
"def signal_alpha_over_taker(Aster: structs.Perpetual_Exchange, Extend: structs.Perpetual_Exchange, aster_ticker_dict: dict, extend_ticker_dict: dict) -> Signal:\n",
" aster_mid_px: Decimal = ( Decimal(str(aster_ticker_dict['best_ask_px'])) + Decimal(str(aster_ticker_dict['best_bid_px'])) ) / 2\n",
" extend_mid_px: Decimal = ( Decimal(str(extend_ticker_dict['best_ask_px'])) + Decimal(str(extend_ticker_dict['best_bid_px'])) ) / 2\n",
2026-05-05 16:38:45 +00:00
"\n",
" aster_buy_ratio: Decimal = (extend_mid_px / aster_mid_px) - 1\n",
" extend_buy_ratio: Decimal = aster_buy_ratio*-1\n",
2026-05-05 16:38:45 +00:00
"\n",
" extend_taker_fee: Decimal = Decimal(str(0.00025))\n",
2026-05-05 16:38:45 +00:00
"\n",
" aster_buy_ratio_min_taker = Decimal(str(aster_buy_ratio)) - extend_taker_fee\n",
" extend_buy_ratio_min_taker = Decimal(str(extend_buy_ratio)) - extend_taker_fee\n",
2026-05-05 16:38:45 +00:00
"\n",
" aster_buy_expected_alpha: Decimal = ( aster_buy_ratio_min_taker - Decimal(str(Aster.buy_ratio)) ).quantize(Decimal('0.0001'), rounding='ROUND_DOWN') # Decimal Price % Diff (x Qty = Alpha $)\n",
" extend_buy_expected_alpha: Decimal = ( extend_buy_ratio_min_taker - Decimal(str(Extend.buy_ratio)) ).quantize(Decimal('0.0001'), rounding='ROUND_DOWN') # Decimal Price % Diff (x Qty = Alpha $)\n",
" \n",
" if aster_buy_expected_alpha > 0:\n",
" signal: bool = True\n",
" exchange: str = 'ASTER'\n",
" side: str = 'BUY'\n",
" symbol: str = Extend.symbol # USING EXT SYMBOL AS DEFAULT\n",
" expected_alpha: Decimal = aster_buy_expected_alpha\n",
" model_ratio: Decimal = Decimal(str(Aster.buy_ratio))\n",
" current_ratio: Decimal = aster_buy_ratio_min_taker\n",
" elif extend_buy_expected_alpha > 0:\n",
" signal: bool = True\n",
" exchange: str = 'EXTEND'\n",
" side: str = 'BUY'\n",
" symbol: str = Extend.symbol\n",
" expected_alpha: Decimal = extend_buy_expected_alpha\n",
" model_ratio: Decimal = Decimal(str(Extend.buy_ratio))\n",
" current_ratio: Decimal = extend_buy_ratio_min_taker\n",
" else:\n",
" signal: bool = False\n",
" exchange: str = ''\n",
" side: str = ''\n",
" symbol: str = ''\n",
" expected_alpha: Decimal = Decimal('0.00')\n",
" model_ratio: Decimal = Decimal('0.00')\n",
" current_ratio: Decimal = Decimal('0.00')\n",
"\n",
" return Signal(\n",
" signal = signal,\n",
" exchange = exchange,\n",
" side = side,\n",
" symbol = symbol,\n",
" expected_alpha = expected_alpha,\n",
" model_ratio = model_ratio,\n",
" current_ratio = current_ratio,\n",
" )\n"
2026-05-05 16:38:45 +00:00
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "407919b8",
2026-04-26 06:10:18 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Signal(signal=True, exchange='ASTER', side='BUY', symbol='BTC-USD', expected_alpha=Decimal('0.0015'), mid_px=Decimal('0.0176660'))"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"signal_alpha_over_taker(Aster=Aster, Extend=Extend, aster_ticker_dict=aster_ticker_dict, extend_ticker_dict=extend_ticker_dict)"
2026-05-05 16:38:45 +00:00
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6e946c16",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 26,
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": [
"master_data = json.loads(s=VAL_KEY.get(name='fr_engine_best_fund_rate_master'))"
2026-05-05 16:38:45 +00:00
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "a5f57c5e",
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(master_data)"
]
2026-04-26 06:10:18 +00:00
},
2026-05-05 16:38:45 +00:00
{
"cell_type": "code",
"execution_count": 37,
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": [
"best_d = df.sort_values(by='max_leverage_ast', ascending=False).iloc[0].to_dict()"
]
2026-05-05 16:38:45 +00:00
},
{
"cell_type": "code",
"execution_count": 39,
"id": "59ef536d",
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": [
"Aster = structs.Perpetual_Exchange(\n",
" mult = int(best_d['max_leverage_ast']),\n",
" lh_asset = best_d['lh_asset_ast'],\n",
" rh_asset = best_d['rh_asset_ast'],\n",
" symbol_asset_separator = '',\n",
" initial_funding_rate=float(best_d['funding_rate_ast']),\n",
" min_price=float(best_d['min_price_ast']),\n",
" min_order_size=float(best_d['min_order_size_ast']),\n",
" min_lot_size=float(best_d['min_lot_size_ast']),\n",
" min_notional=float(best_d['min_notional_ast']),\n",
" buy_ratio=float(best_d['buy_ratio_ast']),\n",
" # buy_ratio_std=float(best_d['buy_ratio_std']),\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "011bf510",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'symbol_ast': 'HYPEUSDT',\n",
" 'max_leverage_ast': 300,\n",
" 'lh_asset_ast': 'HYPE',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': -0.00010404,\n",
" 'min_price_ast': '0.00100',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0001197311,\n",
" 'symbol_ext': 'HYPE-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'HYPE',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -2e-05,\n",
" 'min_price_ext': '0.001',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0001197311}"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"best_d"
]
2026-05-05 16:38:45 +00:00
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "199fe99c",
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timestamp('2026-05-06 12:40:45.883000')"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"pd.to_datetime(1778071245883, unit='ms')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "581a8d07",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timestamp('2026-05-06 12:40:46.880000')"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.to_datetime(1778071246880, unit='ms')"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "da1376d4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'ASTER': {'lh_asset': 'HYPE',\n",
" 'rh_asset': 'USDT',\n",
" 'symbol': 'HYPEUSDT',\n",
" 'symbol_asset_separator': '',\n",
" 'mult': 300,\n",
" 'initial_funding_rate': -0.00010273,\n",
" 'min_price': 0.001,\n",
" 'min_order_size': 0.01,\n",
" 'min_lot_size': 0.01,\n",
" 'min_notional': 5.0,\n",
" 'buy_ratio': -0.00011925787527911069,\n",
" 'notional_obj': {},\n",
" 'notional_position': 0,\n",
" 'unrealized_pnl': 0},\n",
" 'EXTEND': {'lh_asset': 'HYPE',\n",
" 'rh_asset': 'USD',\n",
" 'symbol': 'HYPE-USD',\n",
" 'symbol_asset_separator': '-',\n",
" 'mult': 50,\n",
" 'initial_funding_rate': -2e-05,\n",
" 'min_price': 0.001,\n",
" 'min_order_size': 0.1,\n",
" 'min_lot_size': 0.01,\n",
" 'min_notional': 0.0,\n",
" 'buy_ratio': 0.00011925787527911069,\n",
" 'notional_obj': {},\n",
" 'notional_position': 0,\n",
" 'unrealized_pnl': 0}}"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"best"
]
},
2026-05-05 16:38:45 +00:00
{
"cell_type": "code",
"execution_count": null,
"id": "0592f244",
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": []
},
2026-04-25 23:43:28 +00:00
{
"cell_type": "code",
"execution_count": 13,
2026-04-30 04:32:49 +00:00
"id": "cd600e0e",
2026-04-27 17:57:58 +00:00
"metadata": {},
"outputs": [],
"source": [
"from decimal import Decimal"
]
2026-04-27 17:57:58 +00:00
},
{
"cell_type": "code",
"execution_count": 33,
2026-04-30 04:32:49 +00:00
"id": "db52edf9",
2026-04-27 17:57:58 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"int(Decimal(0.56))"
]
2026-04-27 17:57:58 +00:00
},
{
"cell_type": "code",
"execution_count": 36,
"id": "7953fdfb",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Decimal('0.3136')"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Decimal(str(0.56))*Decimal(str(0.56))"
]
},
2026-05-07 06:13:43 +00:00
{
"cell_type": "code",
"execution_count": 97,
2026-05-07 06:13:43 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'{\"Updated_Timestamp\": 1778777617434, \"Config\": {\"Loop_Sleep_Sec\": 0.0, \"Max_Order_Over_Notional_Ratio\": 1.5, \"Max_Target_Notional\": 0.0, \"Min_Time_To_Funding_Minutes\": 57, \"Min_Fund_Rate_Pct_To_Trade\": 0.0, \"Price_Worsener_Aster\": 0, \"Price_Worsener_Extend\": -1, \"Switch_To_Taker_Seconds\": 3, \"Target_Open_Cash_Position\": 10}, \"Logging\": {\"Log_Summary_Each_Loop\": false, \"Print_Summary_Each_Loop\": false}, \"Overrides\": {\"Allow_Ordering_Aster\": true, \"Allow_Ordering_Extend\": true, \"Allow_Symbol_Change\": false, \"Flatten_Open_Positions\": false, \"Flatten_Open_Positions_Opportunistic\": false, \"Flip_Side_For_Testing\": false}}'"
2026-05-07 06:13:43 +00:00
]
},
"execution_count": 97,
2026-05-07 06:13:43 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"VAL_KEY.get(name='fr_orchestrator_output')"
2026-05-07 06:13:43 +00:00
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0bb60f52",
"metadata": {},
"outputs": [],
"source": []
},
2026-04-27 17:57:58 +00:00
{
"cell_type": "code",
2026-04-30 04:32:49 +00:00
"execution_count": null,
2026-04-27 17:57:58 +00:00
"metadata": {},
"outputs": [],
2026-04-30 04:32:49 +00:00
"source": []
2026-04-27 17:57:58 +00:00
},
{
"cell_type": "code",
2026-04-30 04:32:49 +00:00
"execution_count": 35,
2026-04-25 23:43:28 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2026-04-30 04:32:49 +00:00
"Timestamp('2026-04-27 15:20:58.950000')"
2026-04-25 23:43:28 +00:00
]
},
2026-04-30 04:32:49 +00:00
"execution_count": 35,
2026-04-25 23:43:28 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2026-04-30 04:32:49 +00:00
"import pandas as pd\n",
"pd.to_datetime(1777303258950, unit='ms')"
2026-04-25 23:43:28 +00:00
]
},
{
"cell_type": "code",
"execution_count": 87,
2026-04-30 04:32:49 +00:00
"id": "5f7535df",
2026-04-25 23:43:28 +00:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'symbol_ast': 'DOGEUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'DOGE',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '0.002440',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
2026-05-05 16:38:45 +00:00
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0014463806,\n",
" 'symbol_ext': 'DOGE-USD',\n",
2026-05-05 16:38:45 +00:00
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'DOGE',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 5.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0014463806,\n",
" 'buy_ratio_std': 0.000136533,\n",
2026-05-07 06:13:43 +00:00
" 'next_funding_at_same_time': False},\n",
" {'symbol_ast': 'HYPEUSDT',\n",
" 'max_leverage_ast': 300,\n",
" 'lh_asset_ast': 'HYPE',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ast': 'USDT',\n",
2026-05-07 06:13:43 +00:00
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.00100',\n",
2026-05-05 16:38:45 +00:00
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0004248737,\n",
2026-05-07 06:13:43 +00:00
" 'symbol_ext': 'HYPE-USD',\n",
2026-05-05 16:38:45 +00:00
" 'max_leverage_ext': 50,\n",
2026-05-07 06:13:43 +00:00
" 'lh_asset_ext': 'HYPE',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ext': 'USD',\n",
2026-05-07 06:13:43 +00:00
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.001',\n",
2026-05-05 16:38:45 +00:00
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0004248737,\n",
" 'buy_ratio_std': 0.0001416484,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'ENAUSDT',\n",
" 'max_leverage_ast': 25,\n",
" 'lh_asset_ast': 'ENA',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.0000100',\n",
2026-05-05 16:38:45 +00:00
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.001111125,\n",
" 'symbol_ext': 'ENA-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'ENA',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -9e-06,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.001111125,\n",
" 'buy_ratio_std': 0.0028568147,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'ASTERUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'ASTER',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.00010',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.000859134,\n",
" 'symbol_ext': 'ASTER-USD',\n",
2026-05-07 06:13:43 +00:00
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'ASTER',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
2026-05-07 06:13:43 +00:00
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.000859134,\n",
" 'buy_ratio_std': 0.0001278206,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'WLFIUSDT',\n",
" 'max_leverage_ast': 25,\n",
" 'lh_asset_ast': 'WLFI',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': -0.00015143,\n",
" 'min_price_ast': '0.0001000',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0012638022,\n",
" 'symbol_ext': 'WLFI-USD',\n",
" 'max_leverage_ext': 10,\n",
" 'lh_asset_ext': 'WLFI',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -6.9e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0012638022,\n",
" 'buy_ratio_std': 0.0006306163,\n",
2026-05-07 06:13:43 +00:00
" 'next_funding_at_same_time': True},\n",
2026-05-05 16:38:45 +00:00
" {'symbol_ast': 'BNBUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'BNB',\n",
" 'rh_asset_ast': 'USDT',\n",
2026-05-07 06:13:43 +00:00
" 'funding_rate_ast': 0.0,\n",
2026-05-05 16:38:45 +00:00
" 'min_price_ast': '0.010',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0008803089,\n",
2026-05-05 16:38:45 +00:00
" 'symbol_ext': 'BNB-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'BNB',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.01',\n",
" 'min_lot_size_ext': '0.001',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0008803089,\n",
" 'buy_ratio_std': 6.57424e-05,\n",
" 'next_funding_at_same_time': False},\n",
" {'symbol_ast': 'XRPUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'XRP',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '0.0143',\n",
" 'min_order_size_ast': '0.1',\n",
" 'min_lot_size_ast': '0.1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -7.0425e-05,\n",
" 'symbol_ext': 'XRP-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'XRP',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.1e-05,\n",
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 7.0425e-05,\n",
" 'buy_ratio_std': 9.95592e-05,\n",
2026-05-07 06:13:43 +00:00
" 'next_funding_at_same_time': False},\n",
" {'symbol_ast': 'SOLUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'SOL',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
2026-05-07 06:13:43 +00:00
" 'min_price_ast': '0.4200',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0003239916,\n",
" 'symbol_ext': 'SOL-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'SOL',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -1.1e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0003239916,\n",
" 'buy_ratio_std': 9.90782e-05,\n",
" 'next_funding_at_same_time': False},\n",
" {'symbol_ast': 'ETHUSDT',\n",
" 'max_leverage_ast': 150,\n",
" 'lh_asset_ast': 'ETH',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.401e-05,\n",
" 'min_price_ast': '0.01',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0002271154,\n",
" 'symbol_ext': 'ETH-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'ETH',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -9e-06,\n",
" 'min_price_ext': '0.1',\n",
" 'min_order_size_ext': '0.01',\n",
" 'min_lot_size_ext': '0.001',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0002271154,\n",
" 'buy_ratio_std': 9.43257e-05,\n",
" 'next_funding_at_same_time': False},\n",
" {'symbol_ast': 'TRUMPUSDT',\n",
" 'max_leverage_ast': 10,\n",
" 'lh_asset_ast': 'TRUMP',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.00100',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0013175231,\n",
" 'symbol_ext': 'TRUMP-USD',\n",
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'TRUMP',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.001',\n",
" 'min_order_size_ext': '1',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0013175231,\n",
" 'buy_ratio_std': 0.0022592656,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'BTCUSDT',\n",
" 'max_leverage_ast': 150,\n",
" 'lh_asset_ast': 'BTC',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5.311e-05,\n",
" 'min_price_ast': '1',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0002394865,\n",
" 'symbol_ext': 'BTC-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'BTC',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -6e-06,\n",
" 'min_price_ext': '1',\n",
" 'min_order_size_ext': '0.0001',\n",
" 'min_lot_size_ext': '0.00001',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0002394865,\n",
" 'buy_ratio_std': 8.17971e-05,\n",
" 'next_funding_at_same_time': False},\n",
" {'symbol_ast': 'AAVEUSDT',\n",
" 'max_leverage_ast': 10,\n",
" 'lh_asset_ast': 'AAVE',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '4.400',\n",
" 'min_order_size_ast': '0.1',\n",
" 'min_lot_size_ast': '0.1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0012056403,\n",
" 'symbol_ext': 'AAVE-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'AAVE',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0012056403,\n",
" 'buy_ratio_std': 0.000844961,\n",
" 'next_funding_at_same_time': False},\n",
" {'symbol_ast': 'ZORAUSDT',\n",
" 'max_leverage_ast': 5,\n",
" 'lh_asset_ast': 'ZORA',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.0000100',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0018283552,\n",
" 'symbol_ext': 'ZORA-USD',\n",
" 'max_leverage_ext': 5,\n",
" 'lh_asset_ext': 'ZORA',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.000001',\n",
" 'min_order_size_ext': '1000',\n",
" 'min_lot_size_ext': '100',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0018283552,\n",
" 'buy_ratio_std': 0.0009582043,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': '4USDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': '4',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.0000010',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0052916644,\n",
" 'symbol_ext': '4-USD',\n",
" 'max_leverage_ext': 5,\n",
" 'lh_asset_ext': '4',\n",
2026-05-07 06:13:43 +00:00
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 2.5e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0052916644,\n",
" 'buy_ratio_std': 0.0025950714,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'SUIUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'SUI',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '0.000100',\n",
2026-05-05 16:38:45 +00:00
" 'min_order_size_ast': '0.1',\n",
" 'min_lot_size_ast': '0.1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0001220495,\n",
" 'symbol_ext': 'SUI-USD',\n",
2026-05-05 16:38:45 +00:00
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'SUI',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1e-06,\n",
2026-05-05 16:38:45 +00:00
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0001220495,\n",
" 'buy_ratio_std': 0.000829533,\n",
2026-05-07 06:13:43 +00:00
" 'next_funding_at_same_time': False},\n",
" {'symbol_ast': 'XPTUSDT',\n",
" 'max_leverage_ast': 3,\n",
" 'lh_asset_ast': 'XPT',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0,\n",
" 'min_price_ast': '0.0100',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
2026-05-05 16:38:45 +00:00
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0001070091,\n",
" 'symbol_ext': 'XPT-USD',\n",
" 'max_leverage_ext': 5,\n",
" 'lh_asset_ext': 'XPT',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -5e-06,\n",
" 'min_price_ext': '0.1',\n",
" 'min_order_size_ext': '0.01',\n",
" 'min_lot_size_ext': '0.001',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0001070091,\n",
" 'buy_ratio_std': 0.0006482627,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'XMRUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'XMR',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.01',\n",
2026-05-07 06:13:43 +00:00
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
2026-05-05 16:38:45 +00:00
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0016754768,\n",
" 'symbol_ext': 'XMR-USD',\n",
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'XMR',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0016754768,\n",
" 'buy_ratio_std': 0.0011770111,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'LITUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'LIT',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
2026-05-05 16:38:45 +00:00
" 'min_price_ast': '0.0001000',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0005481326,\n",
" 'symbol_ext': 'LIT-USD',\n",
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'LIT',\n",
2026-05-05 16:38:45 +00:00
" 'rh_asset_ext': 'USD',\n",
2026-05-07 06:13:43 +00:00
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0005481326,\n",
" 'buy_ratio_std': 0.0010705148,\n",
" 'next_funding_at_same_time': True},\n",
2026-05-05 16:38:45 +00:00
" {'symbol_ast': 'ZECUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'ZEC',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.0100',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0005323778,\n",
2026-05-05 16:38:45 +00:00
" 'symbol_ext': 'ZEC-USD',\n",
" 'max_leverage_ext': 10,\n",
" 'lh_asset_ext': 'ZEC',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.001',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.1',\n",
2026-05-07 06:13:43 +00:00
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0005323778,\n",
" 'buy_ratio_std': 0.000636862,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'INITUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'INIT',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.0000100',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0059877289,\n",
" 'symbol_ext': 'INIT-USD',\n",
" 'max_leverage_ext': 5,\n",
" 'lh_asset_ext': 'INIT',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0059877289,\n",
" 'buy_ratio_std': 0.0024689927,\n",
" 'next_funding_at_same_time': True},\n",
" {'symbol_ast': 'CHIPUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'CHIP',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.0000100',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.001026001,\n",
" 'symbol_ext': 'CHIP-USD',\n",
" 'max_leverage_ext': 5,\n",
" 'lh_asset_ext': 'CHIP',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.000001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.001026001,\n",
" 'buy_ratio_std': 0.0022287374,\n",
2026-05-07 06:13:43 +00:00
" 'next_funding_at_same_time': True}]"
2026-05-04 18:04:45 +00:00
]
},
"execution_count": 87,
2026-05-04 18:04:45 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2026-05-05 16:38:45 +00:00
"json.loads(VAL_KEY.get('fr_engine_best_fund_rate_master'))"
2026-05-04 18:04:45 +00:00
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "b71bd50c",
"metadata": {},
"outputs": [],
"source": [
"min_lot = 10\n",
"order = 601"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "56f77b83",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"600"
2026-04-25 23:43:28 +00:00
]
},
2026-05-04 18:04:45 +00:00
"execution_count": 20,
2026-04-25 23:43:28 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2026-05-04 18:04:45 +00:00
"order - ( order % min_lot )"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "7a566db7",
"metadata": {},
"outputs": [],
"source": [
"c = 500\n",
"target = 400\n",
"order = 10"
2026-04-30 04:32:49 +00:00
]
},
2026-05-04 18:04:45 +00:00
{
"cell_type": "code",
"execution_count": 35,
"id": "c9d67074",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Should be selling, but its not - skipping\n"
]
}
],
"source": [
"if (target < c) and ((c + order) > c):\n",
" print('Should be selling, but its not - skipping')\n",
"else:\n",
" print('good')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4328f2e9",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import plotly.express as px\n",
"import numpy as np\n",
"from decimal import Decimal"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "d1b91123",
"metadata": {},
"outputs": [],
"source": [
"def calc_fr_minutes_remaining_factor(\n",
" min_start_procedure: int = 30,\n",
" min_to_end_procedure: int = 7,\n",
" factor_exp_pct: float = 0.50\n",
"):\n",
" factors = [np.float64(0.00)]\n",
" for x in range(min_start_procedure+1,61-min_to_end_procedure):\n",
" y = (x)**(np.log(x)*factor_exp_pct)\n",
" factors.append(y)\n",
"\n",
" pcts = list( factors / np.max(factors) )\n",
" for x in range(61-min_to_end_procedure, 61):\n",
" pcts.append(1)\n",
"\n",
" pcts.reverse()\n",
"\n",
" return pcts\n",
"\n",
"def get_fr_factor_by_minute(min_left: int, factor_pcts: list) -> Decimal:\n",
" return Decimal(str(factor_pcts[min(len(factor_pcts) - 1, min_left)])).quantize(Decimal('0.0001'))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "b145959f",
"metadata": {},
"outputs": [],
"source": [
"\n",
"pcts = calc_fr_minutes_remaining_factor()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Decimal('0.8590')"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_fr_factor_by_minute(9, pcts)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9cd9213a",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "716fbef8",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 216,
"id": "db91dfff",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "variable=0<br>index=%{x}<br>value=%{y}<extra></extra>",
"legendgroup": "0",
"line": {
"color": "#636efa",
"dash": "solid"
},
"marker": {
"symbol": "circle"
},
"mode": "lines",
"name": "0",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": {
"bdata": "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHg==",
"dtype": "i1"
},
"xaxis": "x",
"y": {
"bdata": "AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAADwPwAAAAAAAPA/AAAAAAAA8D8AAAAAAADwPxy3NpKwrO0/4gplc/R86z8UlYkfHm/pP1FhTy6Pgec/IzlJ9bey5T9RF5UrFwHkP4XT5I45a+I/NRnpibnv4D93gje4fRrfP3lOzYX8hNw/+S9ISHIc2j8O8etzet7XP1KS4X/IyNU/MVUvQyfZ0z+hHU1UeA3SPwaFT2uzY9A/F/5HjcuzzT9W8LAkY9zKP8i60aOaPcg/uwgamQbUxT8t6AL4YZzDP5cui/uMk8E/AAAAAAAAAAA=",
"dtype": "f8"
},
"yaxis": "y"
}
],
"layout": {
"legend": {
"title": {
"text": "variable"
},
"tracegroupgap": 0
},
"margin": {
"t": 60
},
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmap"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermap": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermap"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"sequentialminus": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
},
"xaxis": {
"anchor": "y",
"domain": [
0,
1
],
"title": {
"text": "index"
}
},
"yaxis": {
"anchor": "x",
"domain": [
0,
1
],
"title": {
"text": "value"
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"px.line(pd.DataFrame(pcts))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b3b5fb75",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 208,
"id": "d11dec9e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"np.float64(0.9273302894341415)"
]
},
"execution_count": 208,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": 201,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"41"
]
},
"execution_count": 201,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "c77b418e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
2026-05-04 18:04:45 +00:00
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 41,
"id": "9eb7e9b5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timestamp('2026-05-03 15:00:00')"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"pd.to_datetime(1777820400000, unit='ms')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "101dbef1",
"metadata": {},
"outputs": [],
"source": []
},
2026-04-30 04:32:49 +00:00
{
"cell_type": "code",
"execution_count": 5,
2026-04-30 04:32:49 +00:00
"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",
")"
2026-04-25 23:43:28 +00:00
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "fdeeb411",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"VAL_KEY.set(name='fr_algo_working_symbol', value=json.dumps(obj={'ASTER': asdict(obj=ASTER), 'EXTEND': asdict(obj=EXTEND)}))"
]
},
{
"cell_type": "code",
"execution_count": 4,
2026-04-30 04:32:49 +00:00
"id": "b417adad",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "the JSON object must be str, bytes or bytearray, not NoneType",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mTypeError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m best_symbol_by_exchange: dict = json.loads(s=VAL_KEY.get(name=\u001b[33m'fr_engine_best_fund_rate_output'\u001b[39m)) \u001b[38;5;66;03m# ty:ignore[invalid-argument-type]\u001b[39;00m\n\u001b[32m 2\u001b[39m best_symbol_by_exchange_aster = structs.Perpetual_Exchange(**best_symbol_by_exchange[\u001b[33m'ASTER'\u001b[39m])\n\u001b[32m 3\u001b[39m best_symbol_by_exchange_extend = structs.Perpetual_Exchange(**best_symbol_by_exchange[\u001b[33m'EXTEND'\u001b[39m])\n",
"\u001b[36mFile \u001b[39m\u001b[32m~/miniconda3/envs/py_313/lib/python3.13/json/__init__.py:345\u001b[39m, in \u001b[36mloads\u001b[39m\u001b[34m(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)\u001b[39m\n\u001b[32m 343\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 344\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(s, (\u001b[38;5;28mbytes\u001b[39m, \u001b[38;5;28mbytearray\u001b[39m)):\n\u001b[32m--> \u001b[39m\u001b[32m345\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m(\u001b[33mf\u001b[39m\u001b[33m'\u001b[39m\u001b[33mthe JSON object must be str, bytes or bytearray, \u001b[39m\u001b[33m'\u001b[39m\n\u001b[32m 346\u001b[39m \u001b[33mf\u001b[39m\u001b[33m'\u001b[39m\u001b[33mnot \u001b[39m\u001b[38;5;132;01m{\u001b[39;00ms.\u001b[34m__class__\u001b[39m.\u001b[34m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m)\n\u001b[32m 347\u001b[39m s = s.decode(detect_encoding(s), \u001b[33m'\u001b[39m\u001b[33msurrogatepass\u001b[39m\u001b[33m'\u001b[39m)\n\u001b[32m 349\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m (\u001b[38;5;28mcls\u001b[39m \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m object_hook \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m\n\u001b[32m 350\u001b[39m parse_int \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m parse_float \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m\n\u001b[32m 351\u001b[39m parse_constant \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m object_pairs_hook \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m kw):\n",
"\u001b[31mTypeError\u001b[39m: the JSON object must be str, bytes or bytearray, not NoneType"
]
}
],
2026-04-30 04:32:49 +00:00
"source": [
"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",
2026-05-07 00:25:49 +00:00
"execution_count": 36,
"id": "ba98754e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2026-05-07 00:25:49 +00:00
"Perpetual_Exchange(lh_asset='HYPE', rh_asset='USDT', symbol='HYPEUSDT', symbol_asset_separator='', mult=300, initial_funding_rate=5e-05, min_price=0.001, min_order_size=0.01, min_lot_size=0.01, min_notional=5.0, buy_ratio=-6.770327912997143e-05, notional_obj={}, notional_position=0, unrealized_pnl=0, buy_ratio_std=0.0003294334756256642, just_rejected_count=0)"
]
},
2026-05-07 00:25:49 +00:00
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"best_symbol_by_exchange_aster"
2026-04-30 04:32:49 +00:00
]
},
{
"cell_type": "code",
2026-05-07 00:25:49 +00:00
"execution_count": 37,
2026-04-30 04:32:49 +00:00
"id": "fa5a8e85",
2026-04-25 23:43:28 +00:00
"metadata": {},
2026-04-27 17:57:58 +00:00
"outputs": [
{
"data": {
"text/plain": [
2026-05-07 00:25:49 +00:00
"Perpetual_Exchange(lh_asset='HYPE', rh_asset='USD', symbol='HYPE-USD', symbol_asset_separator='-', mult=50, initial_funding_rate=1.3e-05, min_price=0.001, min_order_size=0.1, min_lot_size=0.01, min_notional=0.0, buy_ratio=6.770327912997143e-05, notional_obj={}, notional_position=0, unrealized_pnl=0, buy_ratio_std=0.0003294334756256642, just_rejected_count=0)"
2026-04-27 17:57:58 +00:00
]
},
2026-05-07 00:25:49 +00:00
"execution_count": 37,
2026-04-27 17:57:58 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
2026-04-30 04:32:49 +00:00
"best_symbol_by_exchange_extend"
2026-04-27 17:57:58 +00:00
]
},
2026-05-04 18:04:45 +00:00
{
"cell_type": "code",
2026-05-07 00:25:49 +00:00
"execution_count": 39,
2026-05-04 18:04:45 +00:00
"id": "d452385f",
"metadata": {},
2026-05-07 00:25:49 +00:00
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.005000%\n"
]
}
],
"source": [
"print(f'{best_symbol_by_exchange_aster.initial_funding_rate:.6%}')"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "ff024b08",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.001300%\n"
]
}
],
"source": [
"print(f'{best_symbol_by_exchange_extend.initial_funding_rate:.6%}')"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "9431d9ff",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.003700%\n"
]
}
],
"source": [
"print(f'{r:.6%}')"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.00114737"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"0.00114737"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "77124f29",
"metadata": {},
2026-05-04 18:04:45 +00:00
"outputs": [],
2026-05-07 00:25:49 +00:00
"source": [
"r = max([best_symbol_by_exchange_aster.initial_funding_rate, best_symbol_by_exchange_extend.initial_funding_rate]) - min([best_symbol_by_exchange_aster.initial_funding_rate, best_symbol_by_exchange_extend.initial_funding_rate])"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "36ab3e79",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0019584100000000003"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"0.0000195841000000000026465*100"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[{'symbol_ast': 'XMRUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'XMR',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 7.078e-05,\n",
" 'min_price_ast': '0.01',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0008651383,\n",
" 'symbol_ext': 'XMR-USD',\n",
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'XMR',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0008651383,\n",
" 'buy_ratio_std': 0.0015525267},\n",
" {'symbol_ast': 'ETHUSDT',\n",
" 'max_leverage_ast': 150,\n",
" 'lh_asset_ast': 'ETH',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 7.304e-05,\n",
" 'min_price_ast': '0.01',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0002131019,\n",
" 'symbol_ext': 'ETH-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'ETH',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -2.1e-05,\n",
" 'min_price_ext': '0.1',\n",
" 'min_order_size_ext': '0.01',\n",
" 'min_lot_size_ext': '0.001',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0002131019,\n",
" 'buy_ratio_std': 0.0001224161},\n",
" {'symbol_ast': 'CHIPUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'CHIP',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.0000100',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0007137488,\n",
" 'symbol_ext': 'CHIP-USD',\n",
" 'max_leverage_ext': 5,\n",
" 'lh_asset_ext': 'CHIP',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -0.000114,\n",
" 'min_price_ext': '0.000001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0007137488,\n",
" 'buy_ratio_std': 0.0019427015},\n",
" {'symbol_ast': 'HYPEUSDT',\n",
" 'max_leverage_ast': 300,\n",
" 'lh_asset_ast': 'HYPE',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.00100',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -3.96037e-05,\n",
" 'symbol_ext': 'HYPE-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'HYPE',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.001',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 3.96037e-05,\n",
" 'buy_ratio_std': 0.0003210041},\n",
" {'symbol_ast': 'BTCUSDT',\n",
" 'max_leverage_ast': 150,\n",
" 'lh_asset_ast': 'BTC',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': -4.842e-05,\n",
" 'min_price_ast': '1',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0001399255,\n",
" 'symbol_ext': 'BTC-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'BTC',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -1.3e-05,\n",
" 'min_price_ext': '1',\n",
" 'min_order_size_ext': '0.0001',\n",
" 'min_lot_size_ext': '0.00001',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0001399255,\n",
" 'buy_ratio_std': 0.0001040703},\n",
" {'symbol_ast': 'BNBUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'BNB',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.00024508,\n",
" 'min_price_ast': '0.010',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0009917987,\n",
" 'symbol_ext': 'BNB-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'BNB',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.01',\n",
" 'min_lot_size_ext': '0.001',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0009917987,\n",
" 'buy_ratio_std': 0.0002374105},\n",
" {'symbol_ast': 'DOGEUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'DOGE',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '0.002440',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0014628375,\n",
" 'symbol_ext': 'DOGE-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'DOGE',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0014628375,\n",
" 'buy_ratio_std': 0.000329719},\n",
" {'symbol_ast': 'SUIUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'SUI',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '0.000100',\n",
" 'min_order_size_ast': '0.1',\n",
" 'min_lot_size_ast': '0.1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0002565291,\n",
" 'symbol_ext': 'SUI-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'SUI',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0002565291,\n",
" 'buy_ratio_std': 0.0007973698},\n",
" {'symbol_ast': 'ASTERUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'ASTER',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 3.357e-05,\n",
" 'min_price_ast': '0.00010',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0008699898,\n",
" 'symbol_ext': 'ASTER-USD',\n",
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'ASTER',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0008699898,\n",
" 'buy_ratio_std': 0.0003556531},\n",
" {'symbol_ast': 'LITUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'LIT',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 2.658e-05,\n",
" 'min_price_ast': '0.0001000',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0004211414,\n",
" 'symbol_ext': 'LIT-USD',\n",
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'LIT',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0004211414,\n",
" 'buy_ratio_std': 0.0008731903},\n",
" {'symbol_ast': 'AAVEUSDT',\n",
" 'max_leverage_ast': 10,\n",
" 'lh_asset_ast': 'AAVE',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '4.400',\n",
" 'min_order_size_ast': '0.1',\n",
" 'min_lot_size_ast': '0.1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0006699361,\n",
" 'symbol_ext': 'AAVE-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'AAVE',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0006699361,\n",
" 'buy_ratio_std': 0.0009790403},\n",
" {'symbol_ast': 'SOLUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'SOL',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '0.4200',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -5.76552e-05,\n",
" 'symbol_ext': 'SOL-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'SOL',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 3e-06,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 5.76552e-05,\n",
" 'buy_ratio_std': 0.0002188433},\n",
" {'symbol_ast': 'XRPUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'XRP',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.236e-05,\n",
" 'min_price_ast': '0.0143',\n",
" 'min_order_size_ast': '0.1',\n",
" 'min_lot_size_ast': '0.1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0001058929,\n",
" 'symbol_ext': 'XRP-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'XRP',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -1e-06,\n",
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0001058929,\n",
" 'buy_ratio_std': 0.0001141525},\n",
" {'symbol_ast': 'ZECUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'ZEC',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.0100',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0002039566,\n",
" 'symbol_ext': 'ZEC-USD',\n",
" 'max_leverage_ext': 10,\n",
" 'lh_asset_ext': 'ZEC',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.001',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0002039566,\n",
" 'buy_ratio_std': 0.0013384919},\n",
" {'symbol_ast': '4USDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': '4',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.0000010',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0061657033,\n",
" 'symbol_ext': '4-USD',\n",
" 'max_leverage_ext': 5,\n",
" 'lh_asset_ext': '4',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0061657033,\n",
" 'buy_ratio_std': 0.0042234248}]"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"json.loads(s=VAL_KEY.get(name='fr_engine_best_fund_rate_master'))"
]
2026-05-04 18:04:45 +00:00
},
2026-04-27 17:57:58 +00:00
{
"cell_type": "code",
"execution_count": null,
"id": "09571e38",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Decimal('1.0')"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Decimal('1.0').quantize()"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "4c566e14",
"metadata": {},
"outputs": [],
"source": [
"price = float(0.9066)\n",
"min_price = float(0.0001)\n",
2026-04-30 04:32:49 +00:00
"\n",
"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",
2026-05-05 16:38:45 +00:00
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
2026-05-08 03:02:02 +00:00
"execution_count": 13,
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": [
2026-05-08 03:02:02 +00:00
"df = pd.DataFrame(json.loads(VAL_KEY.get('fr_engine_best_fund_rate_master'))) # ty:ignore[invalid-argument-type]"
2026-04-27 17:57:58 +00:00
]
2026-04-25 23:43:28 +00:00
},
2026-04-30 04:32:49 +00:00
{
"cell_type": "code",
"execution_count": null,
2026-05-08 03:02:02 +00:00
"id": "d1413506",
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": [
2026-05-08 03:02:02 +00:00
"\n",
"\n",
"col_extras = {\n",
" 'symbol_ast': {\n",
" 'editable': False, \n",
" 'sortable': True\n",
" }\n",
"}\n",
"cols = [ {'field': v, **col_extras.get(v, {})} for v in df.columns ]\n",
"rows = df.to_dict(orient='records')"
2026-05-05 16:38:45 +00:00
]
},
{
"cell_type": "code",
"execution_count": null,
2026-05-08 03:02:02 +00:00
"id": "fcad79c3",
2026-05-05 16:38:45 +00:00
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
2026-05-08 03:02:02 +00:00
"id": "d6f23c60",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2026-05-08 03:02:02 +00:00
"[{'symbol_ast': 'LITUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'LIT',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.00011009,\n",
" 'min_price_ast': '0.0001000',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0005956543,\n",
" 'symbol_ext': 'LIT-USD',\n",
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'LIT',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0005956543,\n",
" 'buy_ratio_std': 0.0007698555,\n",
" 'next_funding_at_same_time': True,\n",
" 'id': 0},\n",
" {'symbol_ast': 'HYPEUSDT',\n",
" 'max_leverage_ast': 300,\n",
" 'lh_asset_ast': 'HYPE',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.00100',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0002001154,\n",
" 'symbol_ext': 'HYPE-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'HYPE',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.001',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0002001154,\n",
" 'buy_ratio_std': 0.0002123501,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 1},\n",
" {'symbol_ast': 'SOLUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'SOL',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '0.4200',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0004271435,\n",
" 'symbol_ext': 'SOL-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'SOL',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -1.4e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.01',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0004271435,\n",
" 'buy_ratio_std': 9.37564e-05,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 2},\n",
" {'symbol_ast': 'BNBUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'BNB',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.00012242,\n",
" 'min_price_ast': '0.010',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0011992245,\n",
" 'symbol_ext': 'BNB-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'BNB',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.01',\n",
" 'min_order_size_ext': '0.01',\n",
" 'min_lot_size_ext': '0.001',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0011992245,\n",
" 'buy_ratio_std': 5.93637e-05,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 3},\n",
" {'symbol_ast': 'XRPUSDT',\n",
" 'max_leverage_ast': 100,\n",
" 'lh_asset_ast': 'XRP',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 4.038e-05,\n",
" 'min_price_ast': '0.0143',\n",
" 'min_order_size_ast': '0.1',\n",
" 'min_lot_size_ast': '0.1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0001086996,\n",
" 'symbol_ext': 'XRP-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'XRP',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0001086996,\n",
" 'buy_ratio_std': 8.12797e-05,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 4},\n",
" {'symbol_ast': 'DOGEUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'DOGE',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': -5.33e-06,\n",
" 'min_price_ast': '0.002440',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0010192971,\n",
" 'symbol_ext': 'DOGE-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'DOGE',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0010192971,\n",
" 'buy_ratio_std': 8.60126e-05,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 5},\n",
" {'symbol_ast': 'SUIUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'SUI',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 0.0001,\n",
" 'min_price_ast': '0.000100',\n",
" 'min_order_size_ast': '0.1',\n",
" 'min_lot_size_ast': '0.1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0002862497,\n",
" 'symbol_ext': 'SUI-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'SUI',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.0001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0002862497,\n",
" 'buy_ratio_std': 0.0005447464,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 6},\n",
" {'symbol_ast': 'BTCUSDT',\n",
" 'max_leverage_ast': 150,\n",
" 'lh_asset_ast': 'BTC',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': -5.216e-05,\n",
" 'min_price_ast': '1',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.000104008,\n",
" 'symbol_ext': 'BTC-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'BTC',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -8e-06,\n",
" 'min_price_ext': '1',\n",
" 'min_order_size_ext': '0.0001',\n",
" 'min_lot_size_ext': '0.00001',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.000104008,\n",
" 'buy_ratio_std': 0.0001018788,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 7},\n",
" {'symbol_ast': 'CHIPUSDT',\n",
" 'max_leverage_ast': 50,\n",
" 'lh_asset_ast': 'CHIP',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 1.25e-05,\n",
" 'min_price_ast': '0.0000100',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0007168459,\n",
" 'symbol_ext': 'CHIP-USD',\n",
" 'max_leverage_ext': 5,\n",
" 'lh_asset_ext': 'CHIP',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': -4.6e-05,\n",
" 'min_price_ext': '0.000001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0007168459,\n",
" 'buy_ratio_std': 0.0014437729,\n",
" 'next_funding_at_same_time': True,\n",
" 'id': 8},\n",
" {'symbol_ast': 'ASTERUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'ASTER',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.00010',\n",
" 'min_order_size_ast': '0.01',\n",
" 'min_lot_size_ast': '0.01',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -0.0001497055,\n",
" 'symbol_ext': 'ASTER-USD',\n",
" 'max_leverage_ext': 25,\n",
" 'lh_asset_ext': 'ASTER',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '10',\n",
" 'min_lot_size_ext': '1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 0.0001497055,\n",
" 'buy_ratio_std': 0.0001520848,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 9},\n",
" {'symbol_ast': 'ETHUSDT',\n",
" 'max_leverage_ast': 150,\n",
" 'lh_asset_ast': 'ETH',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': -2.051e-05,\n",
" 'min_price_ast': '0.01',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': -8.96077e-05,\n",
" 'symbol_ext': 'ETH-USD',\n",
" 'max_leverage_ext': 50,\n",
" 'lh_asset_ext': 'ETH',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 4e-06,\n",
" 'min_price_ext': '0.1',\n",
" 'min_order_size_ext': '0.01',\n",
" 'min_lot_size_ext': '0.001',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': 8.96077e-05,\n",
" 'buy_ratio_std': 8.24728e-05,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 10},\n",
" {'symbol_ast': 'ZECUSDT',\n",
" 'max_leverage_ast': 75,\n",
" 'lh_asset_ast': 'ZEC',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': -1.06e-06,\n",
" 'min_price_ast': '0.0100',\n",
" 'min_order_size_ast': '0.001',\n",
" 'min_lot_size_ast': '0.001',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.000456781,\n",
" 'symbol_ext': 'ZEC-USD',\n",
" 'max_leverage_ext': 10,\n",
" 'lh_asset_ext': 'ZEC',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.001',\n",
" 'min_order_size_ext': '0.1',\n",
" 'min_lot_size_ext': '0.1',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.000456781,\n",
" 'buy_ratio_std': 0.0008927931,\n",
" 'next_funding_at_same_time': True,\n",
" 'id': 11},\n",
" {'symbol_ast': 'WLFIUSDT',\n",
" 'max_leverage_ast': 25,\n",
" 'lh_asset_ast': 'WLFI',\n",
" 'rh_asset_ast': 'USDT',\n",
" 'funding_rate_ast': 5e-05,\n",
" 'min_price_ast': '0.0001000',\n",
" 'min_order_size_ast': '1',\n",
" 'min_lot_size_ast': '1',\n",
" 'min_notional_ast': '5',\n",
" 'buy_ratio_ast': 0.0008577801,\n",
" 'symbol_ext': 'WLFI-USD',\n",
" 'max_leverage_ext': 10,\n",
" 'lh_asset_ext': 'WLFI',\n",
" 'rh_asset_ext': 'USD',\n",
" 'funding_rate_ext': 1.3e-05,\n",
" 'min_price_ext': '0.00001',\n",
" 'min_order_size_ext': '100',\n",
" 'min_lot_size_ext': '10',\n",
" 'min_notional_ext': 0.0,\n",
" 'buy_ratio_ext': -0.0008577801,\n",
" 'buy_ratio_std': 0.0006254649,\n",
" 'next_funding_at_same_time': False,\n",
" 'id': 12}]"
2026-05-05 16:38:45 +00:00
]
},
2026-05-08 03:02:02 +00:00
"execution_count": 34,
2026-05-05 16:38:45 +00:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
2026-04-30 04:32:49 +00:00
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 40,
"id": "65c17db5",
"metadata": {},
"outputs": [],
"source": [
"aster_fund_rate_dict: Any = VAL_KEY.get('fund_rate_aster')\n",
"aster_fund_rate_dict: dict = json.loads(s=aster_fund_rate_dict) if aster_fund_rate_dict is not None else {}"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "5e618a1b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'timestamp_arrival': 1778258417127,\n",
" 'timestamp_msg': 1778258417000,\n",
" 'symbol': 'ENAUSDT',\n",
" 'mark_price': '0.12390998',\n",
" 'index_price': '0.12390482',\n",
" 'estimated_settle_price': '0.12432289',\n",
" 'funding_rate': '0.00005000',\n",
" 'next_funding_time_ts_ms': 1778270400000}"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"aster_fund_rate_dict"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "22e09652",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1778270400000"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"aster_fund_rate_dict['next_funding_time_ts_ms']"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1778270400000.0"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"aster_fund_rate_time"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Timestamp('2026-05-08 16:46:43.626771973')"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pd.to_datetime(datetime.now().timestamp()*1000, unit='ms')"
]
},
{
"cell_type": "code",
"execution_count": 63,
"id": "6d182c36",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.datetime(2026, 5, 8, 16, 44, 13, 71038, tzinfo=datetime.timezone.utc)"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"datetime.now(tz=UTC)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "798906fd",
"metadata": {},
"outputs": [],
"source": []
},
2026-04-30 04:32:49 +00:00
{
"cell_type": "code",
"execution_count": null,
"id": "c13e03c9",
2026-04-30 04:32:49 +00:00
"metadata": {},
"outputs": [],
"source": []
},
2026-04-25 23:43:28 +00:00
{
"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",
2026-04-27 17:57:58 +00:00
"version": "3.13.13"
2026-04-25 23:43:28 +00:00
}
},
"nbformat": 4,
"nbformat_minor": 5
}