From 1bbb4797ce74ed0a676cb595628685f3786ad4ca Mon Sep 17 00:00:00 2001 From: stevekeyharvey Date: Thu, 7 May 2026 06:13:43 +0000 Subject: [PATCH] nicegui initial --- algo.ipynb | 458 ++--- algo_config.json | 2 +- engine_best_funding_rate.ipynb | 1579 ++++++++--------- engine_best_funding_rate.py | 11 +- main.py | 21 +- modules/structs.py | 4 +- ng.py | 143 +- ng_modules/static/script.js | 223 --- nicegui_modules/static/script.js | 157 ++ .../static/styles.css | 0 10 files changed, 1221 insertions(+), 1377 deletions(-) delete mode 100644 ng_modules/static/script.js create mode 100644 nicegui_modules/static/script.js rename {ng_modules => nicegui_modules}/static/styles.css (100%) diff --git a/algo.ipynb b/algo.ipynb index 1b96ca9..e4bd3e9 100644 --- a/algo.ipynb +++ b/algo.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 17, + "execution_count": 7, "id": "d1eed397", "metadata": {}, "outputs": [], @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 8, "id": "c6151613", "metadata": {}, "outputs": [], @@ -32,7 +32,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 9, "id": "d83c61e5", "metadata": {}, "outputs": [ @@ -42,7 +42,7 @@ "1" ] }, - "execution_count": 16, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -638,6 +638,34 @@ "Decimal(str(0.56))*Decimal(str(0.56))" ] }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'{\"last_update_ts_ms\": 1778123362898, \"status\": \"WORKING\", \"expected_alpha\": -0.000225}'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "VAL_KEY.get(name='algo_status')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0bb60f52", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -668,139 +696,35 @@ }, { "cell_type": "code", - "execution_count": 170, + "execution_count": 7, "id": "5f7535df", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[{'symbol_ast': 'BTCUSDT',\n", - " 'max_leverage_ast': 150,\n", - " 'lh_asset_ast': 'BTC',\n", - " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': -7.975e-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", - " 'symbol_ext': 'BTC-USD',\n", - " 'max_leverage_ext': 50,\n", - " 'lh_asset_ext': 'BTC',\n", - " 'rh_asset_ext': 'USD',\n", - " 'funding_rate_ext': -3e-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", - " {'symbol_ast': 'ETHUSDT',\n", + "[{'symbol_ast': 'ETHUSDT',\n", " 'max_leverage_ast': 150,\n", " 'lh_asset_ast': 'ETH',\n", " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': -9.77e-06,\n", + " 'funding_rate_ast': 7.68e-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.0002467748,\n", " 'symbol_ext': 'ETH-USD',\n", " 'max_leverage_ext': 50,\n", " 'lh_asset_ext': 'ETH',\n", " 'rh_asset_ext': 'USD',\n", - " 'funding_rate_ext': -1.3e-05,\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", - " {'symbol_ast': 'SOLUSDT',\n", - " 'max_leverage_ast': 100,\n", - " 'lh_asset_ast': 'SOL',\n", - " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': 2.399e-05,\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", - " 'symbol_ext': 'SOL-USD',\n", - " 'max_leverage_ext': 50,\n", - " 'lh_asset_ext': 'SOL',\n", - " 'rh_asset_ext': 'USD',\n", - " 'funding_rate_ext': -1.2e-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", - " {'symbol_ast': 'DOGEUSDT',\n", - " 'max_leverage_ast': 75,\n", - " 'lh_asset_ast': 'DOGE',\n", - " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': 9.699e-05,\n", - " 'min_price_ast': '0.002440',\n", - " 'min_order_size_ast': '1',\n", - " 'min_lot_size_ast': '1',\n", - " 'min_notional_ast': '5',\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", - " {'symbol_ast': 'BNBUSDT',\n", - " 'max_leverage_ast': 100,\n", - " 'lh_asset_ast': 'BNB',\n", - " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': 0.00011803,\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", - " '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", - " {'symbol_ast': 'XRPUSDT',\n", - " 'max_leverage_ast': 100,\n", - " 'lh_asset_ast': 'XRP',\n", - " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': 5.373e-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", - " 'symbol_ext': 'XRP-USD',\n", - " 'max_leverage_ext': 50,\n", - " 'lh_asset_ext': 'XRP',\n", - " 'rh_asset_ext': 'USD',\n", - " 'funding_rate_ext': 6e-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", - " {'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", - " '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", + " 'min_notional_ext': 0.0,\n", + " 'buy_ratio_ext': 0.0002467748,\n", + " 'buy_ratio_std': 0.0001349023,\n", + " 'next_funding_at_same_time': False},\n", " {'symbol_ast': 'HYPEUSDT',\n", " 'max_leverage_ast': 300,\n", " 'lh_asset_ast': 'HYPE',\n", @@ -810,6 +734,7 @@ " 'min_order_size_ast': '0.01',\n", " 'min_lot_size_ast': '0.01',\n", " 'min_notional_ast': '5',\n", + " 'buy_ratio_ast': 6.31401e-05,\n", " 'symbol_ext': 'HYPE-USD',\n", " 'max_leverage_ext': 50,\n", " 'lh_asset_ext': 'HYPE',\n", @@ -818,97 +743,142 @@ " '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", - " {'symbol_ast': 'ENAUSDT',\n", - " 'max_leverage_ast': 25,\n", - " 'lh_asset_ast': 'ENA',\n", + " 'min_notional_ext': 0.0,\n", + " 'buy_ratio_ext': -6.31401e-05,\n", + " 'buy_ratio_std': 0.0003159488,\n", + " 'next_funding_at_same_time': False},\n", + " {'symbol_ast': 'LITUSDT',\n", + " 'max_leverage_ast': 50,\n", + " 'lh_asset_ast': 'LIT',\n", " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': 5e-05,\n", - " 'min_price_ast': '0.0000100',\n", + " 'funding_rate_ast': 4.51e-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", - " 'symbol_ext': 'ENA-USD',\n", - " 'max_leverage_ext': 50,\n", - " 'lh_asset_ext': 'ENA',\n", + " 'buy_ratio_ast': -0.0005306307,\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.00001',\n", - " 'min_order_size_ext': '100',\n", - " 'min_lot_size_ext': '10',\n", - " 'min_notional_ext': 0.0},\n", - " {'symbol_ast': 'AAVEUSDT',\n", - " 'max_leverage_ast': 10,\n", - " 'lh_asset_ast': 'AAVE',\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.0005306307,\n", + " 'buy_ratio_std': 0.0007812256,\n", + " 'next_funding_at_same_time': True},\n", + " {'symbol_ast': 'BNBUSDT',\n", + " 'max_leverage_ast': 100,\n", + " 'lh_asset_ast': 'BNB',\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", + " 'funding_rate_ast': 0.0,\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", - " 'symbol_ext': 'AAVE-USD',\n", + " 'buy_ratio_ast': -0.0008859719,\n", + " 'symbol_ext': 'BNB-USD',\n", " 'max_leverage_ext': 50,\n", - " 'lh_asset_ext': 'AAVE',\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.0008859719,\n", + " 'buy_ratio_std': 0.0002193807,\n", + " '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': 9.428e-05,\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.0001122271,\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.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", - " {'symbol_ast': 'TRUMPUSDT',\n", - " 'max_leverage_ast': 10,\n", - " 'lh_asset_ast': 'TRUMP',\n", + " 'min_notional_ext': 0.0,\n", + " 'buy_ratio_ext': 0.0001122271,\n", + " 'buy_ratio_std': 0.0002044953,\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': 5e-05,\n", - " 'min_price_ast': '0.00100',\n", - " 'min_order_size_ast': '0.01',\n", - " 'min_lot_size_ast': '0.01',\n", + " 'funding_rate_ast': 3.175e-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", - " 'symbol_ext': 'TRUMP-USD',\n", - " 'max_leverage_ext': 25,\n", - " 'lh_asset_ext': 'TRUMP',\n", + " 'buy_ratio_ast': -0.0001042321,\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.001',\n", - " 'min_order_size_ext': '1',\n", - " 'min_lot_size_ext': '1',\n", - " 'min_notional_ext': 0.0},\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", - " 'symbol_ext': 'INIT-USD',\n", - " 'max_leverage_ext': 5,\n", - " 'lh_asset_ext': 'INIT',\n", - " 'rh_asset_ext': 'USD',\n", - " 'funding_rate_ext': -1e-06,\n", - " 'min_price_ext': '0.00001',\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", - " {'symbol_ast': 'ZORAUSDT',\n", - " 'max_leverage_ast': 5,\n", - " 'lh_asset_ast': 'ZORA',\n", + " 'min_notional_ext': 0.0,\n", + " 'buy_ratio_ext': 0.0001042321,\n", + " 'buy_ratio_std': 0.0001123218,\n", + " 'next_funding_at_same_time': False},\n", + " {'symbol_ast': 'DOGEUSDT',\n", + " 'max_leverage_ast': 75,\n", + " 'lh_asset_ast': 'DOGE',\n", " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': 5e-05,\n", - " 'min_price_ast': '0.0000100',\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", - " 'symbol_ext': 'ZORA-USD',\n", - " 'max_leverage_ext': 5,\n", - " 'lh_asset_ext': 'ZORA',\n", + " 'buy_ratio_ast': 0.0013930884,\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.000001',\n", - " 'min_order_size_ext': '1000',\n", - " 'min_lot_size_ext': '100',\n", - " 'min_notional_ext': 0.0},\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.0013930884,\n", + " 'buy_ratio_std': 0.0003880879,\n", + " 'next_funding_at_same_time': False},\n", + " {'symbol_ast': 'BTCUSDT',\n", + " 'max_leverage_ast': 150,\n", + " 'lh_asset_ast': 'BTC',\n", + " 'rh_asset_ast': 'USDT',\n", + " 'funding_rate_ast': -4.728e-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.0001633518,\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.0001633518,\n", + " 'buy_ratio_std': 9.37709e-05,\n", + " 'next_funding_at_same_time': False},\n", " {'symbol_ast': 'WLFIUSDT',\n", " 'max_leverage_ast': 25,\n", " 'lh_asset_ast': 'WLFI',\n", @@ -918,33 +888,19 @@ " 'min_order_size_ast': '1',\n", " 'min_lot_size_ast': '1',\n", " 'min_notional_ast': '5',\n", + " 'buy_ratio_ast': -0.0014241811,\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", + " '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", - " {'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", - " '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", + " 'min_notional_ext': 0.0,\n", + " 'buy_ratio_ext': 0.0014241811,\n", + " 'buy_ratio_std': 0.0010500062,\n", + " 'next_funding_at_same_time': False},\n", " {'symbol_ast': 'ZECUSDT',\n", " 'max_leverage_ast': 75,\n", " 'lh_asset_ast': 'ZEC',\n", @@ -954,6 +910,7 @@ " 'min_order_size_ast': '0.001',\n", " 'min_lot_size_ast': '0.001',\n", " 'min_notional_ast': '5',\n", + " 'buy_ratio_ast': 0.0003491807,\n", " 'symbol_ext': 'ZEC-USD',\n", " 'max_leverage_ext': 10,\n", " 'lh_asset_ext': 'ZEC',\n", @@ -962,100 +919,13 @@ " '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", - " {'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", - " 'symbol_ext': '4-USD',\n", - " 'max_leverage_ext': 5,\n", - " 'lh_asset_ext': '4',\n", - " 'rh_asset_ext': 'USD',\n", - " 'funding_rate_ext': 0.000179,\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", - " {'symbol_ast': 'LITUSDT',\n", - " 'max_leverage_ast': 50,\n", - " 'lh_asset_ast': 'LIT',\n", - " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': 2.475e-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", - " '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", - " {'symbol_ast': 'XMRUSDT',\n", - " 'max_leverage_ast': 50,\n", - " 'lh_asset_ast': 'XMR',\n", - " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': 1.25e-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", - " '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", - " {'symbol_ast': 'XPTUSDT',\n", - " 'max_leverage_ast': 3,\n", - " 'lh_asset_ast': 'XPT',\n", - " '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", - " 'min_notional_ast': '5',\n", - " 'symbol_ext': 'XPT-USD',\n", - " 'max_leverage_ext': 5,\n", - " 'lh_asset_ext': 'XPT',\n", - " 'rh_asset_ext': 'USD',\n", - " 'funding_rate_ext': -3e-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", - " {'symbol_ast': 'CHIPUSDT',\n", - " 'max_leverage_ast': 50,\n", - " 'lh_asset_ast': 'CHIP',\n", - " 'rh_asset_ast': 'USDT',\n", - " 'funding_rate_ast': -2.45e-06,\n", - " 'min_price_ast': '0.0000100',\n", - " 'min_order_size_ast': '1',\n", - " 'min_lot_size_ast': '1',\n", - " 'min_notional_ast': '5',\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}]" + " 'min_notional_ext': 0.0,\n", + " 'buy_ratio_ext': -0.0003491807,\n", + " 'buy_ratio_std': 0.0012735632,\n", + " 'next_funding_at_same_time': True}]" ] }, - "execution_count": 170, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } diff --git a/algo_config.json b/algo_config.json index f9ff408..d967c42 100644 --- a/algo_config.json +++ b/algo_config.json @@ -1,5 +1,5 @@ { - "Updated_Timestamp": 1778095014766, + "Updated_Timestamp": 1778133411421, "Config": { "Loop_Sleep_Sec": 0.0, "Max_Order_Over_Notional_Ratio": 1.05, diff --git a/engine_best_funding_rate.ipynb b/engine_best_funding_rate.ipynb index 93c2fc7..a951b8f 100644 --- a/engine_best_funding_rate.ipynb +++ b/engine_best_funding_rate.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 155, + "execution_count": 1, "id": "0b5ca901", "metadata": {}, "outputs": [], @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 156, + "execution_count": 2, "id": "53647b40", "metadata": {}, "outputs": [], @@ -41,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": 157, + "execution_count": 3, "id": "1f3b65ee", "metadata": {}, "outputs": [], @@ -55,7 +55,7 @@ }, { "cell_type": "code", - "execution_count": 158, + "execution_count": 4, "id": "5176d5b1", "metadata": {}, "outputs": [], @@ -89,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 159, + "execution_count": 5, "id": "e33ec721", "metadata": {}, "outputs": [], @@ -116,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": 160, + "execution_count": 6, "id": "62815940", "metadata": {}, "outputs": [], @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 161, + "execution_count": 7, "id": "271a67c1", "metadata": {}, "outputs": [], @@ -147,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 162, + "execution_count": 8, "id": "1ce2fde4", "metadata": {}, "outputs": [], @@ -167,7 +167,7 @@ }, { "cell_type": "code", - "execution_count": 163, + "execution_count": 9, "id": "ff88b413", "metadata": {}, "outputs": [], @@ -187,7 +187,7 @@ }, { "cell_type": "code", - "execution_count": 164, + "execution_count": 10, "id": "f5ade993", "metadata": {}, "outputs": [], @@ -199,7 +199,7 @@ }, { "cell_type": "code", - "execution_count": 165, + "execution_count": 11, "id": "84bbc5a8", "metadata": {}, "outputs": [], @@ -218,7 +218,7 @@ }, { "cell_type": "code", - "execution_count": 166, + "execution_count": 12, "id": "7bd849e4", "metadata": {}, "outputs": [], @@ -233,7 +233,7 @@ }, { "cell_type": "code", - "execution_count": 167, + "execution_count": 14, "id": "86549660", "metadata": {}, "outputs": [], @@ -241,7 +241,7 @@ "import modules.aster_auth as aster_auth\n", "import modules.utils as utils\n", "\n", - "async def get_candles(symbol: str) -> pd.DataFrame:\n", + "async def get_candles(symbol: str, limit: int = 1440) -> pd.DataFrame:\n", " ### Candles for Midpoint Dispersion ###\n", " # Aster\n", " symbol_ast = utils.symbol_to_aster_fmt(symbol)\n", @@ -251,7 +251,7 @@ " \"params\": {\n", " 'symbol': symbol_ast,\n", " 'interval': '1m',\n", - " 'limit':'1440'\n", + " 'limit': str(limit)\n", " }\n", " }\n", " j = await aster_auth.post_authenticated_url(aster_candles)\n", @@ -266,7 +266,7 @@ " symbol_ext = utils.symbol_to_extend_fmt(symbol)\n", " ext_params = {\n", " 'interval':'1m',\n", - " 'limit':1440,\n", + " 'limit':limit,\n", " }\n", " r = json.loads(requests.get(f'https://api.starknet.extended.exchange/api/v1/info/candles/{symbol_ext}/trades', params=ext_params).text)\n", " df_candles_extended = pd.DataFrame(r['data'])\n", @@ -284,7 +284,7 @@ }, { "cell_type": "code", - "execution_count": 168, + "execution_count": 15, "id": "3da1ef8c", "metadata": {}, "outputs": [], @@ -292,7 +292,7 @@ "candles_ratios = []\n", "\n", "for index, row in df_best_fr_rate.iterrows():\n", - " df = await get_candles(symbol=row['symbol_ext'])\n", + " df = await get_candles(symbol=row['symbol_ext'], limit=60)\n", " buy_ratio_ext = float(df['med_ratio_aster_over_extend'].median())\n", " buy_ratio_std = float(df['med_ratio_aster_over_extend'].std())\n", " candles_ratios.append({'symbol_ext':row['symbol_ext'], 'buy_ratio_std': buy_ratio_std, 'buy_ratio_ext':buy_ratio_ext,'buy_ratio_ast':buy_ratio_ext*-1})\n", @@ -302,7 +302,7 @@ }, { "cell_type": "code", - "execution_count": 169, + "execution_count": 16, "id": "617bdb3a", "metadata": {}, "outputs": [ @@ -326,77 +326,72 @@ "type": "float" } ], - "ref": "234d26fb-bae0-44d4-b286-7995c40f5493", + "ref": "41f1a58f-087e-48a8-9829-27de7bd3bd44", "rows": [ [ "0", - "-0.001181480884319741", - "-0.003622563394859446" + "0.00047961685177977387", + "0.00010676916506513479" ], [ "1", - "0.00029906773980648005", - "-0.0005162089613875986" + "0.00039197315461914073", + "0.007192868347553283" ], [ "2", - "0.00013074942172808246", - "-0.00015921393804296802" + "0.0002912986303861276", + "0.0005358432541993086" ], [ "3", - "0.0010505163053042832", - "0.0007245691963582157" + "0.0009604511021952256", + "0.0004019230471949964" ], [ "4", - "0.00011580440645486689", - "-0.0014865637507147644" + "0.00030683403068354487", + "0.00012883830792365103" ], [ "5", - "0.00021061518497555998", - "-0.001820204267367842" + "-0.001055302332891861", + "-0.0023480538246184457" ], [ "6", - "0.00021041337278360217", - "0.00016516325752768957" + "7.095469542717225e-05", + "-0.0004262271790863581" ], [ "7", - "0.00476737157079099", - "0.005802562170308834" + "0.00013706284207826158", + "-1.975479362426036e-05" ], [ "8", - "-0.0007417494377083833", - "-0.0027350527894597354" + "0.00016960651288999706", + "-0.00033863867253636215" ], [ "9", - "-9.917334996478733e-05", - "-3.6865000368702106e-05" + "0.0013806103592610697", + "0.002941176470588225" ], [ "10", - "0.00021180831354239427", - "-7.02444506883726e-05" + "-0.0005592593208220142", + "-0.00045253363649400136" ], [ "11", - "9.690676685325528e-05", - "3.815149836938758e-05" - ], - [ - "12", - "1.3323150701682884e-05", - "-0.0004138239160925705" + "-0.0015596592214837668", + "0.006847133757961643" ] ], "shape": { "columns": 2, - "rows": 13 + "rows": 12 } }, "text/html": [ @@ -425,68 +420,63 @@ " \n", " \n", " 0\n", - " -0.001181\n", - " -0.003623\n", + " 0.000480\n", + " 0.000107\n", " \n", " \n", " 1\n", - " 0.000299\n", - " -0.000516\n", + " 0.000392\n", + " 0.007193\n", " \n", " \n", " 2\n", - " 0.000131\n", - " -0.000159\n", + " 0.000291\n", + " 0.000536\n", " \n", " \n", " 3\n", - " 0.001051\n", - " 0.000725\n", + " 0.000960\n", + " 0.000402\n", " \n", " \n", " 4\n", - " 0.000116\n", - " -0.001487\n", + " 0.000307\n", + " 0.000129\n", " \n", " \n", " 5\n", - " 0.000211\n", - " -0.001820\n", + " -0.001055\n", + " -0.002348\n", " \n", " \n", " 6\n", - " 0.000210\n", - " 0.000165\n", + " 0.000071\n", + " -0.000426\n", " \n", " \n", " 7\n", - " 0.004767\n", - " 0.005803\n", + " 0.000137\n", + " -0.000020\n", " \n", " \n", " 8\n", - " -0.000742\n", - " -0.002735\n", + " 0.000170\n", + " -0.000339\n", " \n", " \n", " 9\n", - " -0.000099\n", - " -0.000037\n", + " 0.001381\n", + " 0.002941\n", " \n", " \n", " 10\n", - " 0.000212\n", - " -0.000070\n", + " -0.000559\n", + " -0.000453\n", " \n", " \n", " 11\n", - " 0.000097\n", - " 0.000038\n", - " \n", - " \n", - " 12\n", - " 0.000013\n", - " -0.000414\n", + " -0.001560\n", + " 0.006847\n", " \n", " \n", "\n", @@ -494,22 +484,21 @@ ], "text/plain": [ " buy_ratio_ext current_ast_over_ext_ratio\n", - "0 -0.001181 -0.003623\n", - "1 0.000299 -0.000516\n", - "2 0.000131 -0.000159\n", - "3 0.001051 0.000725\n", - "4 0.000116 -0.001487\n", - "5 0.000211 -0.001820\n", - "6 0.000210 0.000165\n", - "7 0.004767 0.005803\n", - "8 -0.000742 -0.002735\n", - "9 -0.000099 -0.000037\n", - "10 0.000212 -0.000070\n", - "11 0.000097 0.000038\n", - "12 0.000013 -0.000414" + "0 0.000480 0.000107\n", + "1 0.000392 0.007193\n", + "2 0.000291 0.000536\n", + "3 0.000960 0.000402\n", + "4 0.000307 0.000129\n", + "5 -0.001055 -0.002348\n", + "6 0.000071 -0.000426\n", + "7 0.000137 -0.000020\n", + "8 0.000170 -0.000339\n", + "9 0.001381 0.002941\n", + "10 -0.000559 -0.000453\n", + "11 -0.001560 0.006847" ] }, - "execution_count": 169, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -520,7 +509,7 @@ }, { "cell_type": "code", - "execution_count": 170, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -708,52 +697,14 @@ "type": "float" } ], - "ref": "0a3330dc-ad46-4c8c-890a-4770d46c99d7", + "ref": "635ed245-b1bd-487c-9beb-66e32f50fc3f", "rows": [ [ "0", - "DOGE-USD", - "DOGEUSDT", - "6750571.4868", - "23217571.19", - "0.00001", - "0.002440", - "100", - "1", - "10", - "1", - "0.0", - "5", - "5.4e-05", - "-3.18e-05", - "50", - "75", - "DOGE", - "DOGE", - "USD", - "USDT", - "0.00324", - "5.4e-05", - "5.4e-05", - "False", - "1778047667600.0", - "0.11552", - "3.24", - "1778047363102", - "0.11594", - "-0.003622563394859446", - "2026-05-06 06:07:47.600000", - "2026-05-06 06:02:43.102000", - "0.0014333307540822734", - "-0.001181480884319741", - "0.001181480884319741" - ], - [ - "1", "LIT-USD", "LITUSDT", - "2522777.871", - "752345.21", + "1377302.6638", + "967935.86", "0.0001", "0.0001000", "10", @@ -763,301 +714,35 @@ "0.0", "5", "1.3e-05", - "7.328e-05", + "6.724e-05", "25", "50", "LIT", "LIT", "USD", "USDT", - "0.0020091324", - "6.0280000000000006e-05", - "6.0280000000000006e-05", + "0.0018078192", + "5.424e-05", + "5.424e-05", "True", - "1778047641000.0", - "0.9681", - "2.01", - "1778047669181", - "0.9686", - "-0.0005162089613875986", - "2026-05-06 06:07:21", - "2026-05-06 06:07:49.181000", - "0.002622391175397122", - "0.00029906773980648005", - "-0.00029906773980648005" + "1778133911550.0", + "0.9367", + "1.81", + "1778133698241", + "0.9366", + "0.00010676916506513479", + "2026-05-07 06:05:11.550000", + "2026-05-07 06:01:38.241000", + "0.0005347560260403073", + "0.00047961685177977387", + "-0.00047961685177977387" ], [ - "2", - "HYPE-USD", - "HYPEUSDT", - "58639909.104356", - "12556357.08", - "0.001", - "0.00100", - "0.1", - "0.01", - "0.01", - "0.01", - "0.0", - "5", - "-1.9e-05", - "-9.312e-05", - "50", - "300", - "HYPE", - "HYPE", - "USD", - "USDT", - "0.00162849", - "1.9e-05", - "-1.9e-05", - "False", - "1778047667153.0", - "43.959", - "1.63", - "1778047650011", - "43.966", - "-0.00015921393804296802", - "2026-05-06 06:07:47.153000", - "2026-05-06 06:07:30.011000", - "0.0018040102704939252", - "0.00013074942172808246", - "-0.00013074942172808246" - ], - [ - "3", - "BNB-USD", - "BNBUSDT", - "9050763.96402", - "14871971.35", - "0.01", - "0.010", - "0.01", - "0.01", - "0.001", - "0.01", - "0.0", - "5", - "1.3e-05", - "0.0001168", - "50", - "100", - "BNB", - "BNB", - "USD", - "USDT", - "0.0008667099999999999", - "1.3e-05", - "1.3e-05", - "False", - "1778047667495.0", - "635.32", - "0.87", - "1778047650009", - "634.86", - "0.0007245691963582157", - "2026-05-06 06:07:47.495000", - "2026-05-06 06:07:30.009000", - "0.0025526195877070383", - "0.0010505163053042832", - "-0.0010505163053042832" - ], - [ - "4", - "SOL-USD", - "SOLUSDT", - "22574115.81168", - "62436541.41", - "0.01", - "0.4200", - "0.1", - "0.01", - "0.01", - "0.01", - "0.0", - "5", - "1.3e-05", - "6.45e-06", - "50", - "100", - "SOL", - "SOL", - "USD", - "USDT", - "0.0008667099999999999", - "1.3e-05", - "1.3e-05", - "False", - "1778047667855.0", - "87.32", - "0.87", - "1778047602027", - "87.45", - "-0.0014865637507147644", - "2026-05-06 06:07:47.855000", - "2026-05-06 06:06:42.027000", - "0.0007759805411291462", - "0.00011580440645486689", - "-0.00011580440645486689" - ], - [ - "5", - "SUI-USD", - "SUIUSDT", - "5872094.79", - "285709.1", - "0.0001", - "0.000100", - "10", - "0.1", "1", - "0.1", - "0.0", - "5", - "1.3e-05", - "0.0001", - "50", - "75", - "SUI", - "SUI", - "USD", - "USDT", - "0.00078", - "1.3e-05", - "1.3e-05", - "False", - "1778047666700.0", - "0.9871", - "0.78", - "1778047576123", - "0.9889", - "-0.001820204267367842", - "2026-05-06 06:07:46.700000", - "2026-05-06 06:06:16.123000", - "0.004225649627470575", - "0.00021061518497555998", - "-0.00021061518497555998" - ], - [ - "6", - "ETH-USD", - "ETHUSDT", - "61213736.629642", - "404498738.24", - "0.1", - "0.01", - "0.01", - "0.001", - "0.001", - "0.001", - "0.0", - "5", - "-9e-06", - "-8.57e-05", - "50", - "150", - "ETH", - "ETH", - "USD", - "USDT", - "0.000675", - "9e-06", - "-9e-06", - "False", - "1778047668250.0", - "2361.69", - "0.68", - "1778047670911", - "2361.3", - "0.00016516325752768957", - "2026-05-06 06:07:48.250000", - "2026-05-06 06:07:50.911000", - "0.0006846669865609136", - "0.00021041337278360217", - "-0.00021041337278360217" - ], - [ - "7", - "4-USD", - "4USDT", - "320967.1974", - "313586.23", - "0.00001", - "0.0000010", - "100", - "1", - "10", - "1", - "0.0", - "5", - "-6.1e-05", - "1.25e-05", - "5", - "50", - "4", - "4", - "USD", - "USDT", - "0.0006681149999999999", - "7.35e-05", - "7.35e-05", - "True", - "1778047577183.0", - "0.013347", - "0.67", - "1778047526553", - "0.01327", - "0.005802562170308834", - "2026-05-06 06:06:17.183000", - "2026-05-06 06:05:26.553000", - "0.02444970583284721", - "0.00476737157079099", - "-0.00476737157079099" - ], - [ - "8", - "ASTER-USD", - "ASTERUSDT", - "322824.77694", - "41706939.66", - "0.00001", - "0.00010", - "10", - "0.01", - "1", - "0.01", - "0.0", - "5", - "1.3e-05", - "5e-05", - "25", - "75", - "ASTER", - "ASTER", - "USD", - "USDT", - "0.0004875", - "1.3e-05", - "1.3e-05", - "False", - "1778047668250.0", - "0.6782", - "0.49", - "1778047182945", - "0.68006", - "-0.0027350527894597354", - "2026-05-06 06:07:48.250000", - "2026-05-06 05:59:42.945000", - "0.0012757713355909424", - "-0.0007417494377083833", - "0.0007417494377083833" - ], - [ - "9", "CHIP-USD", "CHIPUSDT", - "452591.4998", - "237493.21", + "281710.81122", + "306719.89", "0.000001", "0.0000100", "100", @@ -1067,35 +752,187 @@ "0.0", "5", "-0.000114", - "-0.00016655", + "1.25e-05", "5", "50", "CHIP", "CHIP", "USD", "USDT", - "0.0004776795", - "5.2550000000000003e-05", - "5.2550000000000003e-05", + "0.001149885", + "0.0001265", + "0.0001265", "True", - "1778047577697.0", - "0.05425", - "0.48", - "1778047490911", - "0.054252", - "-3.6865000368702106e-05", - "2026-05-06 06:06:17.697000", - "2026-05-06 06:04:50.911000", - "0.04160502643730578", - "-9.917334996478733e-05", - "9.917334996478733e-05" + "1778133769370.0", + "0.05265", + "1.15", + "1778133309735", + "0.052274", + "0.007192868347553283", + "2026-05-07 06:02:49.370000", + "2026-05-07 05:55:09.735000", + "0.00117083954183346", + "0.00039197315461914073", + "-0.00039197315461914073" ], [ + "2", + "HYPE-USD", + "HYPEUSDT", + "43268056.41992", + "10387743.24", + "0.001", + "0.00100", + "0.1", + "0.01", + "0.01", + "0.01", + "0.0", + "5", + "1.3e-05", + "5e-05", + "50", + "300", + "HYPE", + "HYPE", + "USD", + "USDT", + "0.00111423", + "1.3e-05", + "1.3e-05", + "False", + "1778133936887.0", + "42.946", + "1.11", + "1778133930025", + "42.923", + "0.0005358432541993086", + "2026-05-07 06:05:36.887000", + "2026-05-07 06:05:30.025000", + "0.00013095977738623895", + "0.0002912986303861276", + "-0.0002912986303861276" + ], + [ + "3", + "BNB-USD", + "BNBUSDT", + "8459934.80766", + "35977829.28", + "0.01", + "0.010", + "0.01", + "0.01", + "0.001", + "0.01", + "0.0", + "5", + "1.3e-05", + "0.00013451", + "50", + "100", + "BNB", + "BNB", + "USD", + "USDT", + "0.0008667099999999999", + "1.3e-05", + "1.3e-05", + "False", + "1778133937113.0", + "647.15", + "0.87", + "1778133707748", + "646.89", + "0.0004019230471949964", + "2026-05-07 06:05:37.113000", + "2026-05-07 06:01:47.748000", + "7.192785854348182e-05", + "0.0009604511021952256", + "-0.0009604511021952256" + ], + [ + "4", + "ETH-USD", + "ETHUSDT", + "102649744.9418", + "577090390.39", + "0.1", + "0.01", + "0.01", + "0.001", + "0.001", + "0.001", + "0.0", + "5", + "-1.1e-05", + "3.834e-05", + "50", + "150", + "ETH", + "ETH", + "USD", + "USDT", + "0.000825", + "1.1e-05", + "-1.1e-05", + "False", + "1778133936351.0", + "2328.8", + "0.82", + "1778133918939", + "2328.5", + "0.00012883830792365103", + "2026-05-07 06:05:36.351000", + "2026-05-07 06:05:18.939000", + "6.286707183386635e-05", + "0.00030683403068354487", + "-0.00030683403068354487" + ], + [ + "5", + "DOGE-USD", + "DOGEUSDT", + "7132957.6312", + "41418540.74", + "0.00001", + "0.002440", + "100", + "1", "10", + "1", + "0.0", + "5", + "1.3e-05", + "0.0001", + "50", + "75", + "DOGE", + "DOGE", + "USD", + "USDT", + "0.00078", + "1.3e-05", + "1.3e-05", + "False", + "1778133935896.0", + "0.11047", + "0.78", + "1778133750010", + "0.11073", + "-0.0023480538246184457", + "2026-05-07 06:05:35.896000", + "2026-05-07 06:02:30.010000", + "8.110679725637555e-05", + "-0.001055302332891861", + "0.001055302332891861" + ], + [ + "6", "XRP-USD", "XRPUSDT", - "9026961.613246", - "16134762.15", + "10560948.5002", + "17769353.55", "0.0001", "0.0143", "10", @@ -1104,36 +941,36 @@ "0.1", "0.0", "5", - "-4e-06", - "4.078e-05", + "1e-05", + "-7.81e-06", "50", "100", "XRP", "XRP", "USD", "USDT", - "0.00026668", - "4e-06", - "-4e-06", + "0.0006667000000000001", + "1e-05", + "1e-05", "False", - "1778047665356.0", - "1.4235", - "0.27", - "1778047623101", - "1.4236", - "-7.02444506883726e-05", - "2026-05-06 06:07:45.356000", - "2026-05-06 06:07:03.101000", - "0.004378592970391728", - "0.00021180831354239427", - "-0.00021180831354239427" + "1778133935776.0", + "1.4071", + "0.67", + "1778133915802", + "1.4077", + "-0.0004262271790863581", + "2026-05-07 06:05:35.776000", + "2026-05-07 06:05:15.802000", + "7.272228317266807e-05", + "7.095469542717225e-05", + "-7.095469542717225e-05" ], [ - "11", + "7", "BTC-USD", "BTCUSDT", - "182885518.024236", - "979418882.68", + "233117079.15542", + "1009997302.83", "1", "1", "0.0001", @@ -1142,36 +979,112 @@ "0.001", "0.0", "5", - "-3e-06", - "-4.625e-05", + "6e-06", + "-5.428e-05", "50", "150", "BTC", "BTC", "USD", "USDT", - "0.000225", - "3e-06", - "-3e-06", + "0.00045", + "6e-06", + "6e-06", "False", - "1778047666657.0", - "81258.1", - "0.22", - "1778047671637", - "81255.0", - "3.815149836938758e-05", - "2026-05-06 06:07:46.657000", - "2026-05-06 06:07:51.637000", - "0.0009994776913570872", - "9.690676685325528e-05", - "-9.690676685325528e-05" + "1778133936703.0", + "80991.4", + "0.45", + "1778133936053", + "80993.0", + "-1.975479362426036e-05", + "2026-05-07 06:05:36.703000", + "2026-05-07 06:05:36.053000", + "8.226176895075401e-05", + "0.00013706284207826158", + "-0.00013706284207826158" ], [ - "12", + "8", + "SOL-USD", + "SOLUSDT", + "22137796.0018", + "99667918.6", + "0.01", + "0.4200", + "0.1", + "0.01", + "0.01", + "0.01", + "0.0", + "5", + "4e-06", + "0.0001", + "50", + "100", + "SOL", + "SOL", + "USD", + "USDT", + "0.00026668", + "4e-06", + "4e-06", + "False", + "1778133936390.0", + "88.56", + "0.27", + "1778133917319", + "88.59", + "-0.00033863867253636215", + "2026-05-07 06:05:36.390000", + "2026-05-07 06:05:17.319000", + "8.83996576899045e-05", + "0.00016960651288999706", + "-0.00016960651288999706" + ], + [ + "9", + "WLFI-USD", + "WLFIUSDT", + "271961.564", + "1499330.5", + "0.00001", + "0.0001000", + "100", + "1", + "10", + "1", + "0.0", + "5", + "-9e-06", + "5e-05", + "10", + "25", + "WLFI", + "WLFI", + "USD", + "USDT", + "0.00012861", + "9e-06", + "-9e-06", + "False", + "1778133909230.0", + "0.0682", + "0.13", + "1778133657113", + "0.068", + "0.002941176470588225", + "2026-05-07 06:05:09.230000", + "2026-05-07 06:00:57.113000", + "0.0008328634331733419", + "0.0013806103592610697", + "-0.0013806103592610697" + ], + [ + "10", "ZEC-USD", "ZECUSDT", - "6849535.1586", - "6584711.06", + "8617918.76849", + "13568944.82", "0.001", "0.0100", "0.1", @@ -1192,22 +1105,60 @@ "4.999999999999986e-07", "4.999999999999986e-07", "True", - "1778047666530.0", - "545.9", + "1778133935200.0", + "543.36", "0.01", - "1778047665513", - "546.126", - "-0.0004138239160925705", - "2026-05-06 06:07:46.530000", - "2026-05-06 06:07:45.513000", - "0.003199062977836445", - "1.3323150701682884e-05", - "-1.3323150701682884e-05" + "1778133929212", + "543.606", + "-0.00045253363649400136", + "2026-05-07 06:05:35.200000", + "2026-05-07 06:05:29.212000", + "0.00022684658450076162", + "-0.0005592593208220142", + "0.0005592593208220142" + ], + [ + "11", + "4-USD", + "4USDT", + "182196.3448", + "128695.28", + "0.00001", + "0.0000010", + "100", + "1", + "10", + "1", + "0.0", + "5", + "1.3e-05", + "1.25e-05", + "5", + "50", + "4", + "4", + "USD", + "USDT", + "4.544999999999987e-06", + "4.999999999999986e-07", + "4.999999999999986e-07", + "True", + "1778133901400.0", + "0.012646", + "0.0", + "1778133456831", + "0.01256", + "0.006847133757961643", + "2026-05-07 06:05:01.400000", + "2026-05-07 05:57:36.831000", + "0.004118432015643399", + "-0.0015596592214837668", + "0.0015596592214837668" ] ], "shape": { "columns": 35, - "rows": 13 + "rows": 12 } }, "text/html": [ @@ -1255,34 +1206,10 @@ " \n", " \n", " 0\n", - " DOGE-USD\n", - " DOGEUSDT\n", - " 6.750571e+06\n", - " 2.321757e+07\n", - " 0.00001\n", - " 0.002440\n", - " 100\n", - " 1\n", - " 10\n", - " 1\n", - " ...\n", - " 0.115520\n", - " 3.24\n", - " 1778047363102\n", - " 0.115940\n", - " -0.003623\n", - " 2026-05-06 06:07:47.600\n", - " 2026-05-06 06:02:43.102\n", - " 0.001433\n", - " -0.001181\n", - " 0.001181\n", - " \n", - " \n", - " 1\n", " LIT-USD\n", " LITUSDT\n", - " 2.522778e+06\n", - " 7.523452e+05\n", + " 1.377303e+06\n", + " 9.679359e+05\n", " 0.0001\n", " 0.0001000\n", " 10\n", @@ -1290,191 +1217,23 @@ " 1\n", " 1\n", " ...\n", - " 0.968100\n", - " 2.01\n", - " 1778047669181\n", - " 0.968600\n", - " -0.000516\n", - " 2026-05-06 06:07:21.000\n", - " 2026-05-06 06:07:49.181\n", - " 0.002622\n", - " 0.000299\n", - " -0.000299\n", + " 0.936700\n", + " 1.81\n", + " 1778133698241\n", + " 0.936600\n", + " 0.000107\n", + " 2026-05-07 06:05:11.550\n", + " 2026-05-07 06:01:38.241\n", + " 0.000535\n", + " 0.000480\n", + " -0.000480\n", " \n", " \n", - " 2\n", - " HYPE-USD\n", - " HYPEUSDT\n", - " 5.863991e+07\n", - " 1.255636e+07\n", - " 0.001\n", - " 0.00100\n", - " 0.1\n", - " 0.01\n", - " 0.01\n", - " 0.01\n", - " ...\n", - " 43.959000\n", - " 1.63\n", - " 1778047650011\n", - " 43.966000\n", - " -0.000159\n", - " 2026-05-06 06:07:47.153\n", - " 2026-05-06 06:07:30.011\n", - " 0.001804\n", - " 0.000131\n", - " -0.000131\n", - " \n", - " \n", - " 3\n", - " BNB-USD\n", - " BNBUSDT\n", - " 9.050764e+06\n", - " 1.487197e+07\n", - " 0.01\n", - " 0.010\n", - " 0.01\n", - " 0.01\n", - " 0.001\n", - " 0.01\n", - " ...\n", - " 635.320000\n", - " 0.87\n", - " 1778047650009\n", - " 634.860000\n", - " 0.000725\n", - " 2026-05-06 06:07:47.495\n", - " 2026-05-06 06:07:30.009\n", - " 0.002553\n", - " 0.001051\n", - " -0.001051\n", - " \n", - " \n", - " 4\n", - " SOL-USD\n", - " SOLUSDT\n", - " 2.257412e+07\n", - " 6.243654e+07\n", - " 0.01\n", - " 0.4200\n", - " 0.1\n", - " 0.01\n", - " 0.01\n", - " 0.01\n", - " ...\n", - " 87.320000\n", - " 0.87\n", - " 1778047602027\n", - " 87.450000\n", - " -0.001487\n", - " 2026-05-06 06:07:47.855\n", - " 2026-05-06 06:06:42.027\n", - " 0.000776\n", - " 0.000116\n", - " -0.000116\n", - " \n", - " \n", - " 5\n", - " SUI-USD\n", - " SUIUSDT\n", - " 5.872095e+06\n", - " 2.857091e+05\n", - " 0.0001\n", - " 0.000100\n", - " 10\n", - " 0.1\n", - " 1\n", - " 0.1\n", - " ...\n", - " 0.987100\n", - " 0.78\n", - " 1778047576123\n", - " 0.988900\n", - " -0.001820\n", - " 2026-05-06 06:07:46.700\n", - " 2026-05-06 06:06:16.123\n", - " 0.004226\n", - " 0.000211\n", - " -0.000211\n", - " \n", - " \n", - " 6\n", - " ETH-USD\n", - " ETHUSDT\n", - " 6.121374e+07\n", - " 4.044987e+08\n", - " 0.1\n", - " 0.01\n", - " 0.01\n", - " 0.001\n", - " 0.001\n", - " 0.001\n", - " ...\n", - " 2361.690000\n", - " 0.68\n", - " 1778047670911\n", - " 2361.300000\n", - " 0.000165\n", - " 2026-05-06 06:07:48.250\n", - " 2026-05-06 06:07:50.911\n", - " 0.000685\n", - " 0.000210\n", - " -0.000210\n", - " \n", - " \n", - " 7\n", - " 4-USD\n", - " 4USDT\n", - " 3.209672e+05\n", - " 3.135862e+05\n", - " 0.00001\n", - " 0.0000010\n", - " 100\n", - " 1\n", - " 10\n", - " 1\n", - " ...\n", - " 0.013347\n", - " 0.67\n", - " 1778047526553\n", - " 0.013270\n", - " 0.005803\n", - " 2026-05-06 06:06:17.183\n", - " 2026-05-06 06:05:26.553\n", - " 0.024450\n", - " 0.004767\n", - " -0.004767\n", - " \n", - " \n", - " 8\n", - " ASTER-USD\n", - " ASTERUSDT\n", - " 3.228248e+05\n", - " 4.170694e+07\n", - " 0.00001\n", - " 0.00010\n", - " 10\n", - " 0.01\n", - " 1\n", - " 0.01\n", - " ...\n", - " 0.678200\n", - " 0.49\n", - " 1778047182945\n", - " 0.680060\n", - " -0.002735\n", - " 2026-05-06 06:07:48.250\n", - " 2026-05-06 05:59:42.945\n", - " 0.001276\n", - " -0.000742\n", - " 0.000742\n", - " \n", - " \n", - " 9\n", + " 1\n", " CHIP-USD\n", " CHIPUSDT\n", - " 4.525915e+05\n", - " 2.374932e+05\n", + " 2.817108e+05\n", + " 3.067199e+05\n", " 0.000001\n", " 0.0000100\n", " 100\n", @@ -1482,23 +1241,119 @@ " 10\n", " 1\n", " ...\n", - " 0.054250\n", - " 0.48\n", - " 1778047490911\n", - " 0.054252\n", - " -0.000037\n", - " 2026-05-06 06:06:17.697\n", - " 2026-05-06 06:04:50.911\n", - " 0.041605\n", - " -0.000099\n", - " 0.000099\n", + " 0.052650\n", + " 1.15\n", + " 1778133309735\n", + " 0.052274\n", + " 0.007193\n", + " 2026-05-07 06:02:49.370\n", + " 2026-05-07 05:55:09.735\n", + " 0.001171\n", + " 0.000392\n", + " -0.000392\n", " \n", " \n", - " 10\n", + " 2\n", + " HYPE-USD\n", + " HYPEUSDT\n", + " 4.326806e+07\n", + " 1.038774e+07\n", + " 0.001\n", + " 0.00100\n", + " 0.1\n", + " 0.01\n", + " 0.01\n", + " 0.01\n", + " ...\n", + " 42.946000\n", + " 1.11\n", + " 1778133930025\n", + " 42.923000\n", + " 0.000536\n", + " 2026-05-07 06:05:36.887\n", + " 2026-05-07 06:05:30.025\n", + " 0.000131\n", + " 0.000291\n", + " -0.000291\n", + " \n", + " \n", + " 3\n", + " BNB-USD\n", + " BNBUSDT\n", + " 8.459935e+06\n", + " 3.597783e+07\n", + " 0.01\n", + " 0.010\n", + " 0.01\n", + " 0.01\n", + " 0.001\n", + " 0.01\n", + " ...\n", + " 647.150000\n", + " 0.87\n", + " 1778133707748\n", + " 646.890000\n", + " 0.000402\n", + " 2026-05-07 06:05:37.113\n", + " 2026-05-07 06:01:47.748\n", + " 0.000072\n", + " 0.000960\n", + " -0.000960\n", + " \n", + " \n", + " 4\n", + " ETH-USD\n", + " ETHUSDT\n", + " 1.026497e+08\n", + " 5.770904e+08\n", + " 0.1\n", + " 0.01\n", + " 0.01\n", + " 0.001\n", + " 0.001\n", + " 0.001\n", + " ...\n", + " 2328.800000\n", + " 0.82\n", + " 1778133918939\n", + " 2328.500000\n", + " 0.000129\n", + " 2026-05-07 06:05:36.351\n", + " 2026-05-07 06:05:18.939\n", + " 0.000063\n", + " 0.000307\n", + " -0.000307\n", + " \n", + " \n", + " 5\n", + " DOGE-USD\n", + " DOGEUSDT\n", + " 7.132958e+06\n", + " 4.141854e+07\n", + " 0.00001\n", + " 0.002440\n", + " 100\n", + " 1\n", + " 10\n", + " 1\n", + " ...\n", + " 0.110470\n", + " 0.78\n", + " 1778133750010\n", + " 0.110730\n", + " -0.002348\n", + " 2026-05-07 06:05:35.896\n", + " 2026-05-07 06:02:30.010\n", + " 0.000081\n", + " -0.001055\n", + " 0.001055\n", + " \n", + " \n", + " 6\n", " XRP-USD\n", " XRPUSDT\n", - " 9.026962e+06\n", - " 1.613476e+07\n", + " 1.056095e+07\n", + " 1.776935e+07\n", " 0.0001\n", " 0.0143\n", " 10\n", @@ -1506,23 +1361,23 @@ " 1\n", " 0.1\n", " ...\n", - " 1.423500\n", - " 0.27\n", - " 1778047623101\n", - " 1.423600\n", - " -0.000070\n", - " 2026-05-06 06:07:45.356\n", - " 2026-05-06 06:07:03.101\n", - " 0.004379\n", - " 0.000212\n", - " -0.000212\n", + " 1.407100\n", + " 0.67\n", + " 1778133915802\n", + " 1.407700\n", + " -0.000426\n", + " 2026-05-07 06:05:35.776\n", + " 2026-05-07 06:05:15.802\n", + " 0.000073\n", + " 0.000071\n", + " -0.000071\n", " \n", " \n", - " 11\n", + " 7\n", " BTC-USD\n", " BTCUSDT\n", - " 1.828855e+08\n", - " 9.794189e+08\n", + " 2.331171e+08\n", + " 1.009997e+09\n", " 1\n", " 1\n", " 0.0001\n", @@ -1530,23 +1385,71 @@ " 0.00001\n", " 0.001\n", " ...\n", - " 81258.100000\n", - " 0.22\n", - " 1778047671637\n", - " 81255.000000\n", - " 0.000038\n", - " 2026-05-06 06:07:46.657\n", - " 2026-05-06 06:07:51.637\n", - " 0.000999\n", - " 0.000097\n", - " -0.000097\n", + " 80991.400000\n", + " 0.45\n", + " 1778133936053\n", + " 80993.000000\n", + " -0.000020\n", + " 2026-05-07 06:05:36.703\n", + " 2026-05-07 06:05:36.053\n", + " 0.000082\n", + " 0.000137\n", + " -0.000137\n", " \n", " \n", - " 12\n", + " 8\n", + " SOL-USD\n", + " SOLUSDT\n", + " 2.213780e+07\n", + " 9.966792e+07\n", + " 0.01\n", + " 0.4200\n", + " 0.1\n", + " 0.01\n", + " 0.01\n", + " 0.01\n", + " ...\n", + " 88.560000\n", + " 0.27\n", + " 1778133917319\n", + " 88.590000\n", + " -0.000339\n", + " 2026-05-07 06:05:36.390\n", + " 2026-05-07 06:05:17.319\n", + " 0.000088\n", + " 0.000170\n", + " -0.000170\n", + " \n", + " \n", + " 9\n", + " WLFI-USD\n", + " WLFIUSDT\n", + " 2.719616e+05\n", + " 1.499330e+06\n", + " 0.00001\n", + " 0.0001000\n", + " 100\n", + " 1\n", + " 10\n", + " 1\n", + " ...\n", + " 0.068200\n", + " 0.13\n", + " 1778133657113\n", + " 0.068000\n", + " 0.002941\n", + " 2026-05-07 06:05:09.230\n", + " 2026-05-07 06:00:57.113\n", + " 0.000833\n", + " 0.001381\n", + " -0.001381\n", + " \n", + " \n", + " 10\n", " ZEC-USD\n", " ZECUSDT\n", - " 6.849535e+06\n", - " 6.584711e+06\n", + " 8.617919e+06\n", + " 1.356894e+07\n", " 0.001\n", " 0.0100\n", " 0.1\n", @@ -1554,117 +1457,135 @@ " 0.1\n", " 0.001\n", " ...\n", - " 545.900000\n", + " 543.360000\n", " 0.01\n", - " 1778047665513\n", - " 546.126000\n", - " -0.000414\n", - " 2026-05-06 06:07:46.530\n", - " 2026-05-06 06:07:45.513\n", - " 0.003199\n", - " 0.000013\n", - " -0.000013\n", + " 1778133929212\n", + " 543.606000\n", + " -0.000453\n", + " 2026-05-07 06:05:35.200\n", + " 2026-05-07 06:05:29.212\n", + " 0.000227\n", + " -0.000559\n", + " 0.000559\n", + " \n", + " \n", + " 11\n", + " 4-USD\n", + " 4USDT\n", + " 1.821963e+05\n", + " 1.286953e+05\n", + " 0.00001\n", + " 0.0000010\n", + " 100\n", + " 1\n", + " 10\n", + " 1\n", + " ...\n", + " 0.012646\n", + " 0.00\n", + " 1778133456831\n", + " 0.012560\n", + " 0.006847\n", + " 2026-05-07 06:05:01.400\n", + " 2026-05-07 05:57:36.831\n", + " 0.004118\n", + " -0.001560\n", + " 0.001560\n", " \n", " \n", "\n", - "

13 rows × 35 columns

\n", + "

12 rows × 35 columns

\n", "" ], "text/plain": [ " symbol_ext symbol_ast daily_volume_ext daily_volume_ast min_price_ext \\\n", - "0 DOGE-USD DOGEUSDT 6.750571e+06 2.321757e+07 0.00001 \n", - "1 LIT-USD LITUSDT 2.522778e+06 7.523452e+05 0.0001 \n", - "2 HYPE-USD HYPEUSDT 5.863991e+07 1.255636e+07 0.001 \n", - "3 BNB-USD BNBUSDT 9.050764e+06 1.487197e+07 0.01 \n", - "4 SOL-USD SOLUSDT 2.257412e+07 6.243654e+07 0.01 \n", - "5 SUI-USD SUIUSDT 5.872095e+06 2.857091e+05 0.0001 \n", - "6 ETH-USD ETHUSDT 6.121374e+07 4.044987e+08 0.1 \n", - "7 4-USD 4USDT 3.209672e+05 3.135862e+05 0.00001 \n", - "8 ASTER-USD ASTERUSDT 3.228248e+05 4.170694e+07 0.00001 \n", - "9 CHIP-USD CHIPUSDT 4.525915e+05 2.374932e+05 0.000001 \n", - "10 XRP-USD XRPUSDT 9.026962e+06 1.613476e+07 0.0001 \n", - "11 BTC-USD BTCUSDT 1.828855e+08 9.794189e+08 1 \n", - "12 ZEC-USD ZECUSDT 6.849535e+06 6.584711e+06 0.001 \n", + "0 LIT-USD LITUSDT 1.377303e+06 9.679359e+05 0.0001 \n", + "1 CHIP-USD CHIPUSDT 2.817108e+05 3.067199e+05 0.000001 \n", + "2 HYPE-USD HYPEUSDT 4.326806e+07 1.038774e+07 0.001 \n", + "3 BNB-USD BNBUSDT 8.459935e+06 3.597783e+07 0.01 \n", + "4 ETH-USD ETHUSDT 1.026497e+08 5.770904e+08 0.1 \n", + "5 DOGE-USD DOGEUSDT 7.132958e+06 4.141854e+07 0.00001 \n", + "6 XRP-USD XRPUSDT 1.056095e+07 1.776935e+07 0.0001 \n", + "7 BTC-USD BTCUSDT 2.331171e+08 1.009997e+09 1 \n", + "8 SOL-USD SOLUSDT 2.213780e+07 9.966792e+07 0.01 \n", + "9 WLFI-USD WLFIUSDT 2.719616e+05 1.499330e+06 0.00001 \n", + "10 ZEC-USD ZECUSDT 8.617919e+06 1.356894e+07 0.001 \n", + "11 4-USD 4USDT 1.821963e+05 1.286953e+05 0.00001 \n", "\n", " min_price_ast min_order_size_ext min_order_size_ast min_lot_size_ext \\\n", - "0 0.002440 100 1 10 \n", - "1 0.0001000 10 1 1 \n", + "0 0.0001000 10 1 1 \n", + "1 0.0000100 100 1 10 \n", "2 0.00100 0.1 0.01 0.01 \n", "3 0.010 0.01 0.01 0.001 \n", - "4 0.4200 0.1 0.01 0.01 \n", - "5 0.000100 10 0.1 1 \n", - "6 0.01 0.01 0.001 0.001 \n", - "7 0.0000010 100 1 10 \n", - "8 0.00010 10 0.01 1 \n", - "9 0.0000100 100 1 10 \n", - "10 0.0143 10 0.1 1 \n", - "11 1 0.0001 0.001 0.00001 \n", - "12 0.0100 0.1 0.001 0.1 \n", + "4 0.01 0.01 0.001 0.001 \n", + "5 0.002440 100 1 10 \n", + "6 0.0143 10 0.1 1 \n", + "7 1 0.0001 0.001 0.00001 \n", + "8 0.4200 0.1 0.01 0.01 \n", + "9 0.0001000 100 1 10 \n", + "10 0.0100 0.1 0.001 0.1 \n", + "11 0.0000010 100 1 10 \n", "\n", " min_lot_size_ast ... last_trade_px_ast hourly_dollars_per_1k \\\n", - "0 1 ... 0.115520 3.24 \n", - "1 1 ... 0.968100 2.01 \n", - "2 0.01 ... 43.959000 1.63 \n", - "3 0.01 ... 635.320000 0.87 \n", - "4 0.01 ... 87.320000 0.87 \n", - "5 0.1 ... 0.987100 0.78 \n", - "6 0.001 ... 2361.690000 0.68 \n", - "7 1 ... 0.013347 0.67 \n", - "8 0.01 ... 0.678200 0.49 \n", - "9 1 ... 0.054250 0.48 \n", - "10 0.1 ... 1.423500 0.27 \n", - "11 0.001 ... 81258.100000 0.22 \n", - "12 0.001 ... 545.900000 0.01 \n", + "0 1 ... 0.936700 1.81 \n", + "1 1 ... 0.052650 1.15 \n", + "2 0.01 ... 42.946000 1.11 \n", + "3 0.01 ... 647.150000 0.87 \n", + "4 0.001 ... 2328.800000 0.82 \n", + "5 1 ... 0.110470 0.78 \n", + "6 0.1 ... 1.407100 0.67 \n", + "7 0.001 ... 80991.400000 0.45 \n", + "8 0.01 ... 88.560000 0.27 \n", + "9 1 ... 0.068200 0.13 \n", + "10 0.001 ... 543.360000 0.01 \n", + "11 1 ... 0.012646 0.00 \n", "\n", " last_trade_ts_ext last_trade_px_ext current_ast_over_ext_ratio \\\n", - "0 1778047363102 0.115940 -0.003623 \n", - "1 1778047669181 0.968600 -0.000516 \n", - "2 1778047650011 43.966000 -0.000159 \n", - "3 1778047650009 634.860000 0.000725 \n", - "4 1778047602027 87.450000 -0.001487 \n", - "5 1778047576123 0.988900 -0.001820 \n", - "6 1778047670911 2361.300000 0.000165 \n", - "7 1778047526553 0.013270 0.005803 \n", - "8 1778047182945 0.680060 -0.002735 \n", - "9 1778047490911 0.054252 -0.000037 \n", - "10 1778047623101 1.423600 -0.000070 \n", - "11 1778047671637 81255.000000 0.000038 \n", - "12 1778047665513 546.126000 -0.000414 \n", + "0 1778133698241 0.936600 0.000107 \n", + "1 1778133309735 0.052274 0.007193 \n", + "2 1778133930025 42.923000 0.000536 \n", + "3 1778133707748 646.890000 0.000402 \n", + "4 1778133918939 2328.500000 0.000129 \n", + "5 1778133750010 0.110730 -0.002348 \n", + "6 1778133915802 1.407700 -0.000426 \n", + "7 1778133936053 80993.000000 -0.000020 \n", + "8 1778133917319 88.590000 -0.000339 \n", + "9 1778133657113 0.068000 0.002941 \n", + "10 1778133929212 543.606000 -0.000453 \n", + "11 1778133456831 0.012560 0.006847 \n", "\n", " last_trade_ts_dt_ast last_trade_ts_dt_ext buy_ratio_std \\\n", - "0 2026-05-06 06:07:47.600 2026-05-06 06:02:43.102 0.001433 \n", - "1 2026-05-06 06:07:21.000 2026-05-06 06:07:49.181 0.002622 \n", - "2 2026-05-06 06:07:47.153 2026-05-06 06:07:30.011 0.001804 \n", - "3 2026-05-06 06:07:47.495 2026-05-06 06:07:30.009 0.002553 \n", - "4 2026-05-06 06:07:47.855 2026-05-06 06:06:42.027 0.000776 \n", - "5 2026-05-06 06:07:46.700 2026-05-06 06:06:16.123 0.004226 \n", - "6 2026-05-06 06:07:48.250 2026-05-06 06:07:50.911 0.000685 \n", - "7 2026-05-06 06:06:17.183 2026-05-06 06:05:26.553 0.024450 \n", - "8 2026-05-06 06:07:48.250 2026-05-06 05:59:42.945 0.001276 \n", - "9 2026-05-06 06:06:17.697 2026-05-06 06:04:50.911 0.041605 \n", - "10 2026-05-06 06:07:45.356 2026-05-06 06:07:03.101 0.004379 \n", - "11 2026-05-06 06:07:46.657 2026-05-06 06:07:51.637 0.000999 \n", - "12 2026-05-06 06:07:46.530 2026-05-06 06:07:45.513 0.003199 \n", + "0 2026-05-07 06:05:11.550 2026-05-07 06:01:38.241 0.000535 \n", + "1 2026-05-07 06:02:49.370 2026-05-07 05:55:09.735 0.001171 \n", + "2 2026-05-07 06:05:36.887 2026-05-07 06:05:30.025 0.000131 \n", + "3 2026-05-07 06:05:37.113 2026-05-07 06:01:47.748 0.000072 \n", + "4 2026-05-07 06:05:36.351 2026-05-07 06:05:18.939 0.000063 \n", + "5 2026-05-07 06:05:35.896 2026-05-07 06:02:30.010 0.000081 \n", + "6 2026-05-07 06:05:35.776 2026-05-07 06:05:15.802 0.000073 \n", + "7 2026-05-07 06:05:36.703 2026-05-07 06:05:36.053 0.000082 \n", + "8 2026-05-07 06:05:36.390 2026-05-07 06:05:17.319 0.000088 \n", + "9 2026-05-07 06:05:09.230 2026-05-07 06:00:57.113 0.000833 \n", + "10 2026-05-07 06:05:35.200 2026-05-07 06:05:29.212 0.000227 \n", + "11 2026-05-07 06:05:01.400 2026-05-07 05:57:36.831 0.004118 \n", "\n", " buy_ratio_ext buy_ratio_ast \n", - "0 -0.001181 0.001181 \n", - "1 0.000299 -0.000299 \n", - "2 0.000131 -0.000131 \n", - "3 0.001051 -0.001051 \n", - "4 0.000116 -0.000116 \n", - "5 0.000211 -0.000211 \n", - "6 0.000210 -0.000210 \n", - "7 0.004767 -0.004767 \n", - "8 -0.000742 0.000742 \n", - "9 -0.000099 0.000099 \n", - "10 0.000212 -0.000212 \n", - "11 0.000097 -0.000097 \n", - "12 0.000013 -0.000013 \n", + "0 0.000480 -0.000480 \n", + "1 0.000392 -0.000392 \n", + "2 0.000291 -0.000291 \n", + "3 0.000960 -0.000960 \n", + "4 0.000307 -0.000307 \n", + "5 -0.001055 0.001055 \n", + "6 0.000071 -0.000071 \n", + "7 0.000137 -0.000137 \n", + "8 0.000170 -0.000170 \n", + "9 0.001381 -0.001381 \n", + "10 -0.000559 0.000559 \n", + "11 -0.001560 0.001560 \n", "\n", - "[13 rows x 35 columns]" + "[12 rows x 35 columns]" ] }, - "execution_count": 170, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -1675,7 +1596,7 @@ }, { "cell_type": "code", - "execution_count": 171, + "execution_count": 21, "id": "bbad7d21", "metadata": {}, "outputs": [], @@ -1724,17 +1645,17 @@ }, { "cell_type": "code", - "execution_count": 172, + "execution_count": 22, "id": "799ffa9c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "np.float64(0.00013075388140060262)" + "np.float64(-3.456754155017894e-05)" ] }, - "execution_count": 172, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -1745,17 +1666,17 @@ }, { "cell_type": "code", - "execution_count": 184, + "execution_count": 30, "id": "75ac86aa", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "np.float64(0.00015347678748833804)" + "np.float64(0.0002912986303861276)" ] }, - "execution_count": 184, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -1764,6 +1685,14 @@ "df_candles_comb.iloc[-60:]['med_ratio_aster_over_extend'].median()\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "b09eaab0", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/engine_best_funding_rate.py b/engine_best_funding_rate.py index e21c50c..0401888 100644 --- a/engine_best_funding_rate.py +++ b/engine_best_funding_rate.py @@ -32,6 +32,8 @@ LOOP_SLEEP_SEC: int = 5 REFRESH_MKT_INFO_EVERY_SEC: int = 90 REFRESH_MKT_VOLUME_EVERY_SEC: int = 30 +MINUTES_LOOKBACK: int = 60 + ### GLOBALS ### Mkt_Info_Last_Refresh_TS_ms: int = 0 Mkt_Volume_Last_Refresh_TS_ms: int = 0 @@ -116,7 +118,7 @@ def load_extend_current_fr(df_mkt_stats: pd.DataFrame) -> pd.DataFrame: return df -async def get_candles(symbol: str) -> pd.DataFrame: +async def get_candles(symbol: str, limit: int = MINUTES_LOOKBACK) -> pd.DataFrame: ### Candles for Midpoint Dispersion ### # Aster symbol_ast = utils.symbol_to_aster_fmt(symbol) @@ -126,7 +128,7 @@ async def get_candles(symbol: str) -> pd.DataFrame: "params": { 'symbol': symbol_ast, 'interval': '1m', - 'limit':'1440' + 'limit':str(limit) } } j = await aster_auth.post_authenticated_url(aster_candles) @@ -141,7 +143,7 @@ async def get_candles(symbol: str) -> pd.DataFrame: symbol_ext = utils.symbol_to_extend_fmt(symbol) ext_params = { 'interval':'1m', - 'limit':1440, + 'limit': limit, } r = json.loads(requests.get(f'https://api.starknet.extended.exchange/api/v1/info/candles/{symbol_ext}/trades', params=ext_params).text) df_candles_extended = pd.DataFrame(r['data']) @@ -157,7 +159,6 @@ async def get_candles(symbol: str) -> pd.DataFrame: return df_candles_comb - async def loop() -> None: global Mkt_Info_Last_Refresh_TS_ms try: @@ -264,7 +265,7 @@ async def loop() -> None: ].to_json(orient='records') VAL_KEY.set(name='fr_engine_best_fund_rate_master', value=str(master_data)) - print(df_best_fr_rate[['symbol_ext','max_leverage_ext','buy_ratio_ext','net_funding_rate','daily_volume_ast']].head(10)) + print(df_best_fr_rate[['symbol_ext','max_leverage_ext','buy_ratio_ext','net_funding_rate','daily_volume_ast','buy_ratio_ast']].head(10)) logging.info(f'BFR REFRESHED @ {datetime.now()}') time.sleep(LOOP_SLEEP_SEC) continue diff --git a/main.py b/main.py index 7e2078c..d8d54b5 100644 --- a/main.py +++ b/main.py @@ -61,7 +61,9 @@ Flags = structs.Flags() async def output_algo_status(status: str) -> None: global Algo_Status + Algo_Status.last_update_ts_ms = int(round(datetime.now().timestamp()*1000, 2)) Algo_Status.status = status + VAL_KEY.set('algo_status', json.dumps(Algo_Status.model_dump())) def create_exchange_objs_from_dict(exchanges_dict: dict) -> tuple[structs.Perpetual_Exchange, structs.Perpetual_Exchange]: @@ -497,7 +499,7 @@ async def post_extend_order( await kill_algo() ### OPEN ORDERS ### -async def handle_order_updates(exch: str, local_open_orders: list[dict], ws_open_orders: list[dict]) -> list[dict]: # exch = 'ASTER' | 'EXTEND' +async def handle_order_updates(exch: str, local_open_orders: list[dict], ws_open_orders: list[dict], ws_pos_updates: list[dict]) -> list[dict]: # exch = 'ASTER' | 'EXTEND' global Aster global Extend global Last_Aster_Fill_Time_Ts @@ -550,18 +552,18 @@ async def handle_order_updates(exch: str, local_open_orders: list[dict], ws_open logging.info(f'{exch} ORDER PARTIALLY FILLED: {order_id}') # await get_aster_collateral() if exch=='ASTER': - await get_aster_notional_position() + await get_aster_notional_position(resp=ws_pos_updates) Last_Aster_Fill_Time_Ts = datetime.now().timestamp()*1000 else: - await get_extend_notional() + await get_extend_notional(resp=ws_pos_updates) utils.send_tg_alert(f'FR_ALGO - {exch} PARTIALLY FILLED ({order_id})') elif order_update_status in ['FILLED']: logging.info(f'{exch} ORDER FILLED: {order_id}') local_open_orders.pop(idx) # await get_aster_collateral() if exch=='ASTER': - await aster_cancel_all_orders() - await get_aster_notional_position() + # await aster_cancel_all_orders() + await get_aster_notional_position(resp=ws_pos_updates) Last_Aster_Fill_Time_Ts = datetime.now().timestamp()*1000 else: await extend_cancel_all_orders() @@ -939,8 +941,8 @@ async def run_algo(): extend_ws_order_updates: list = json.loads(extend_ws_order_updates) if extend_ws_order_updates is not None else [] ### Update Local Open Orders w Changes from WS ### - Aster_Open_Orders = await handle_order_updates(exch='ASTER', local_open_orders=Aster_Open_Orders, ws_open_orders=aster_ws_order_updates) - Extend_Open_Orders = await handle_order_updates(exch='EXTEND', local_open_orders=Extend_Open_Orders, ws_open_orders=extend_ws_order_updates) + Aster_Open_Orders = await handle_order_updates(exch='ASTER', local_open_orders=Aster_Open_Orders, ws_open_orders=aster_ws_order_updates, ws_pos_updates=aster_ws_pos_updates) + Extend_Open_Orders = await handle_order_updates(exch='EXTEND', local_open_orders=Extend_Open_Orders, ws_open_orders=extend_ws_order_updates, ws_pos_updates=extend_ws_pos_updates) ### CHECK NO MORE THAN 1 OPEN ORDER ON EITHER EXCHANGE ### if len(Aster_Open_Orders) > 1 or len(Extend_Open_Orders) > 1: @@ -968,6 +970,8 @@ async def run_algo(): alpha_hurdle_adj=Decimal(str(Config.Config.Min_Fund_Rate_Pct_To_Trade)), ) Algo_Status.expected_alpha = float(signal.expected_alpha) + Algo_Status.model_ratio = float(signal.model_ratio) + Algo_Status.current_ratio = float(signal.current_ratio) if signal.signal: ### True signal, standard target alpha_target_notional = Decimal(str(Config.Config.Max_Target_Notional)) @@ -1267,7 +1271,10 @@ async def main(): last_update_ts_ms = int(round(datetime.now().timestamp()*1000, 2)), status = 'WORKING', expected_alpha = 0.00, + model_ratio = 0.00, + current_ratio = 0.00, ) + await output_algo_status('WORKING') async with engine.connect() as CON: ### ASTER SETUP ### diff --git a/modules/structs.py b/modules/structs.py index 37ab3d7..e1c84e8 100644 --- a/modules/structs.py +++ b/modules/structs.py @@ -93,8 +93,8 @@ class Algo_Status(BaseModel): last_update_ts_ms: int status: str # 'WORKING' | 'STOPPED' expected_alpha: float - - + model_ratio: float + current_ratio: float # @dataclass(kw_only=True) diff --git a/ng.py b/ng.py index 792ac16..e96ae00 100644 --- a/ng.py +++ b/ng.py @@ -7,7 +7,8 @@ import json # import re import valkey import asyncio -# import datetime as dt +from datetime import datetime +from dataclasses import dataclass, field # from random import random # from nicegui_modules import data # from nicegui_modules import ui_components @@ -15,12 +16,100 @@ import asyncio ALLOW_BODY_SCROLL: bool = True LOOKBACK: int = 60 LOOKBACK_RT_TV_MAX_POINTS: int = 3000 -REFRESH_INTERVAL_SEC: float = 10 -REFRESH_INTERVAL_RT_SEC: float = 1/30 +# REFRESH_INTERVAL_SEC: float = 10 +REFRESH_INTERVAL_RT_SEC: float = 1/10 ENGINE = create_engine('mysql+pymysql://root:pwd@localhost/fund_rate') VALKEY = valkey.Valkey(host='localhost', port=6379, db=0, decode_responses=True) + +CHARTS = [ + { + 'type': 'AREA', + 'autoscaleInfoProvider': False, + 'data': [], + 'options': { + 'color': '#94fcdf', + 'priceScaleId': 'right', + 'topColor': '#94fcdf', + 'bottomColor': 'rgba(112, 249, 210, 0.28)', + 'invertFilledArea': True + } + }, + { + 'type': 'AREA', + 'autoscaleInfoProvider': False, + 'data': [], + 'options': { + 'color': '#dd7525', + 'priceScaleId': 'right', + 'topColor': '#94fcdf', + 'bottomColor': 'rgba(249, 167, 112, 0.28)', + 'invertFilledArea': False + }, + }, + { + 'type': 'LINE', + 'autoscaleInfoProvider': [-0.1, 0.1], + 'data': [], + 'options': { + 'color': '#ea0707', + 'priceScaleId': 'left', + }, + }, + { + 'type': 'LINE', + 'autoscaleInfoProvider': False, + 'data': [], + 'options': { + 'color': '#009b12', + 'priceScaleId': 'left', + }, + }, + { + 'type': 'LINE', + 'autoscaleInfoProvider': False, + 'data': [], + 'options': { + 'color': '#ffffff', + 'priceScaleId': 'left', + }, + }, +] + +CHARTS_OPTIONS = { + 'crosshair': 'NORMAL', + 'autoSize': True, + 'toolbox': True, + 'timeScale': { + 'timeVisible': True, # // Shows HH:mm on x-axis + 'secondsVisible': True # // Optional: show seconds + }, + 'rightPriceScale': { + 'visible': True, + 'autoScale': True + }, + 'leftPriceScale': { + 'visible': True + }, + 'layout': { + 'background': { 'type': 'solid', 'color': '#222' }, + 'textColor': '#DDD', + }, + 'grid': { + 'vertLines': { + 'color': '#e1e1e1', # // Set vertical line color + 'visible': True, + 'style': 2, # // 0: Solid, 1: Dashed, 2: Dotted, 3: LargeDashed, 4: SparseDotted + }, + 'horzLines': { + 'color': '#e1e1e1', # // Set horizontal line color + 'visible': True, + 'style': 2, + }, + } +} + ### Utils ### def update_body_scroll(e=None, bool_override=False): if e is None: @@ -40,26 +129,40 @@ async def update_tv(): series_update_extend_tob = json.loads(VALKEY.get('fut_ticker_extended')) # ty:ignore[invalid-argument-type] series_update_algo_status = json.loads(VALKEY.get('algo_status')) # ty:ignore[invalid-argument-type] - timestamp_aster_tob = round( ( series_update_aster_tob['timestamp_arrival'] / 1000 ) , 2) - timestamp_extend_tob = round( ( series_update_extend_tob['timestamp_arrival'] / 1000 ) , 2) - timestamp_algo_status = round( ( series_update_algo_status['timestamp_arrival'] / 1000 ) , 2) + timestamp_aster_tob = round( ( series_update_aster_tob['timestamp_transaction'] / 1000 ) , 2) + timestamp_extend_tob = round( ( series_update_extend_tob['timestamp_msg'] / 1000 ) , 2) + timestamp_algo_status = round( ( series_update_algo_status['last_update_ts_ms'] / 1000 ) , 2) value_aster_tob = ( float(series_update_aster_tob['best_ask_px']) + float(series_update_aster_tob['best_bid_px']) ) / 2 value_extend_tob = ( float(series_update_extend_tob['best_ask_px']) + float(series_update_extend_tob['best_bid_px']) ) / 2 - value_algo_expected_alpha = float(series_update_algo_status['price']) + value_algo_model_ratio = float(series_update_algo_status['model_ratio'])*1_000 + value_algo_current_ratio = float(series_update_algo_status['current_ratio'])*1_000 + value_algo_expected_alpha = float(series_update_algo_status['expected_alpha'])*1_000 - data_dict = { - 'timestamp': timestamp_aster_tob, - 'timestamp_b': timestamp_extend_tob, - 'timestamp_c': timestamp_algo_status, - 'value': value_aster_tob, - 'value_b': value_extend_tob, - 'value_c': value_algo_expected_alpha, - 'target': series_update_algo_status['target_price'], - 'LOOKBACK_RT_TV_MAX_POINTS': LOOKBACK_RT_TV_MAX_POINTS, - } + data_list = [ + { + 'timestamp': timestamp_aster_tob, + 'value': value_aster_tob, + }, + { + 'timestamp': timestamp_extend_tob, + 'value': value_extend_tob, + }, + { + 'timestamp': timestamp_algo_status, + 'value': value_algo_model_ratio, + }, + { + 'timestamp': timestamp_algo_status, + 'value': value_algo_current_ratio, + }, + { + 'timestamp': timestamp_algo_status, + 'value': value_algo_expected_alpha, + }, + ] - ui.run_javascript(f'await update_tv(data_dict={data_dict});') + ui.run_javascript(f'await update_tv(data_list={data_list}, lookback_max_points={LOOKBACK_RT_TV_MAX_POINTS});') ### Pages ### @@ -75,12 +178,12 @@ async def rt_chart_page(): with ui.column(): ui.switch('▶️', value=True).bind_value_to(timer, 'active') with ui.column().style('position: absolute; right: 20px; font-family: monospace; align-self: center;'): - ui.label('Atwater Trading: Orderbook') + ui.label('Atwater Trading - Funding Rate') with ui.grid(columns=16).classes('w-full gap-0 auto-fit'): with ui.card().tight().classes('w-full col-span-full no-shadow border border-black-200').style('overflow: auto;'): ui.html('
', sanitize=False).classes('w-full') - ui.run_javascript('await create_tv();') + ui.run_javascript(f'await create_tv(charts_list={CHARTS}, create_chart_options={CHARTS_OPTIONS});') def root(): app.add_static_files(max_cache_age=0, url_path='/static', local_directory=os.path.join(os.path.dirname(__file__), 'nicegui_modules/static')) diff --git a/ng_modules/static/script.js b/ng_modules/static/script.js deleted file mode 100644 index aedf603..0000000 --- a/ng_modules/static/script.js +++ /dev/null @@ -1,223 +0,0 @@ -async function waitForVariable(variableName, timeout = 5000) { - const startTime = Date.now(); - while (typeof window[variableName] === 'undefined') { - if (Date.now() - startTime > timeout) { - throw new Error(`Variable '${variableName}' not defined within ${timeout}ms`); - } - await new Promise(resolve => setTimeout(resolve, 100)); - } - console.log(`Variable '${variableName}' is now defined.`); -} - -async function update_tv(data_dict) { - - window.data.push({ time: data_dict.timestamp, value: data_dict.value }); - window.data_b.push({ time: data_dict.timestamp_b, value: data_dict.value_b }); - window.data_c.push({ time: data_dict.timestamp_c, value: data_dict.value_c }); - window.data_tgt.push({ time: data_dict.timestamp_c, value: data_dict.target }); - window.lineSeries.update({ time: data_dict.timestamp, value: data_dict.value }); - window.lineSeries_b.update({ time: data_dict.timestamp_b, value: data_dict.value_b }); - window.lineSeries_c.update({ time: data_dict.timestamp_c, value: data_dict.value_c }); - window.lineSeries_tgt.update({ time: data_dict.timestamp_c, value: data_dict.target }); - - // midPriceLine.applyOptions({ - // price: data_dict.mid_px, - // color: '#c78228', - // lineWidth: 3, - // lineStyle: LightweightCharts.LineStyle.Dashed, - // axisLabelVisible: true, - // }); - - window.chart.timeScale().scrollToRealTime(); - // const currentRange = window.chart.timeScale().getVisibleLogicalRange(); - // window.chart.timeScale().fitContent(); - // window.chart.timeScale().setVisibleLogicalRange(currentRange); - - const MAX_DATA_POINTS = data_dict.LOOKBACK_RT_TV_MAX_POINTS; - if (window.lineSeries.data().length > MAX_DATA_POINTS) { - window.lineSeries.setData(lineSeries.data().slice(-MAX_DATA_POINTS)); - } - if (window.lineSeries_b.data().length > MAX_DATA_POINTS) { - window.lineSeries_b.setData(lineSeries_b.data().slice(-MAX_DATA_POINTS)); - } - if (window.lineSeries_c.data().length > MAX_DATA_POINTS) { - window.lineSeries_c.setData(lineSeries_c.data().slice(-MAX_DATA_POINTS)); - } - if (window.lineSeries_tgt.data().length > MAX_DATA_POINTS) { - window.lineSeries_tgt.setData(lineSeries_tgt.data().slice(-MAX_DATA_POINTS)); - } -}; - - -async function create_tv() { - window.chart = LightweightCharts.createChart(document.getElementById('tv'), - { - autoSize: true, - toolbox: true, - timeScale: { - timeVisible: true, // Shows HH:mm on x-axis - secondsVisible: true // Optional: show seconds - }, - rightPriceScale: { - visible: true, - autoScale: true - }, - leftPriceScale: { - visible: true - }, - - layout: { - background: { type: 'solid', color: '#222' }, - textColor: '#DDD', - }, - grid: { - vertLines: { - color: '#e1e1e1', // Set vertical line color - visible: true, - style: 2, // 0: Solid, 1: Dashed, 2: Dotted, 3: LargeDashed, 4: SparseDotted - }, - horzLines: { - color: '#e1e1e1', // Set horizontal line color - visible: true, - style: 2, - }, - }, - - crosshair: { mode: LightweightCharts.CrosshairMode.Normal }, - } - ); - window.lineSeries = chart.addSeries(LightweightCharts.LineSeries, { - color: '#94fcdf', - priceScaleId: 'right' - // topColor: '#94fcdf', - // bottomColor: 'rgba(112, 171, 249, 0.28)', - // invertFilledArea: false - }); - window.lineSeries_b = chart.addSeries(LightweightCharts.LineSeries, { - color: '#dd7525', - priceScaleId: 'right' - // topColor: '#94fcdf', - // bottomColor: 'rgba(112, 171, 249, 0.28)', - // invertFilledArea: false - }); - window.lineSeries_c = chart.addSeries(LightweightCharts.LineSeries, { - color: '#ea0707', - priceScaleId: 'left', - autoscaleInfoProvider: () => ({ - priceRange: { - minValue: 0.0, - maxValue: 1.0 - } - }) - // topColor: '#94fcdf', - // bottomColor: 'rgba(112, 171, 249, 0.28)', - // invertFilledArea: false - }); - window.lineSeries_tgt = chart.addSeries(LightweightCharts.LineSeries, { - color: '#ffffff', - priceScaleId: 'right', - lineStyle: LightweightCharts.LineStyle.Dashed - // topColor: '#94fcdf', - // bottomColor: 'rgba(112, 171, 249, 0.28)', - // invertFilledArea: false - }); - // window.midPriceLine_Config = { - // price: 0, - // color: '#c78228', - // lineWidth: 3, - // lineStyle: LightweightCharts.LineStyle.Dashed, - // axisLabelVisible: false, - // }; - // window.midPriceLine = window.lineSeries.createPriceLine(midPriceLine_Config); - window.data = []; - window.data_b = []; - window.data_c = []; - window.data_tgt = []; - window.lineSeries.setData(window.data); - window.lineSeries_b.setData(window.data_b); - window.lineSeries_c.setData(window.data_c); - window.lineSeries_tgt.setData(window.data_tgt); - - // Create and style the tooltip html element - const container = document.getElementById('tv'); - - window.toolTipWidth = 200; - - const toolTip = document.createElement('div'); - toolTip.style = `width: ${window.toolTipWidth}px; height: 100%; position: absolute; display: none; padding: 8px; box-sizing: border-box; font-size: 12px; text-align: left; z-index: 1000; top: 12px; left: 12px; pointer-events: none; border-radius: 4px 4px 0px 0px; border-bottom: none; box-shadow: 0 2px 5px 0 rgba(117, 134, 150, 0.45);font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;`; - toolTip.style.background = `rgba(${'0, 0, 0'}, 0.25)`; - toolTip.style.color = 'white'; - toolTip.style.borderColor = 'rgba( 239, 83, 80, 1)'; - container.appendChild(toolTip); - - // update tooltip - window.chart.subscribeCrosshairMove(async param => { - - if ( - param.point === undefined || - !param.time || - param.point.x < 0 || - param.point.x > container.clientWidth || - param.point.y < 0 || - param.point.y > container.clientHeight - ) { - toolTip.style.display = 'none'; - } else { - - // toolTip.style.height = '100%'; - toolTip.style.alignContent = 'center'; - - const dateStr = new Date(param.time*1000).toISOString(); - - let data = await param.seriesData.get(window.lineSeries); - if (data === undefined) { - data = {} - data.value = 0 - console.log('data is UNDEFINED, SETTING TO 0') - }; - - let data_b = await param.seriesData.get(window.lineSeries_b); - if (data_b === undefined) { - data_b = {} - data_b.value = 0 - console.log('data is UNDEFINED, SETTING TO 0') - }; - - const value_px = data.value - const value_px_b = window.data_b.value - const value_px_c = window.data_c.value - const value_px_tgt = window.data_tgt.value - - toolTip.style.display = 'block'; - //
- // Atwater Trading - //
- toolTip.innerHTML = ` -
- Chainlink: ${Math.round(100 * value_px) / 100} - Binance: ${Math.round(100 * value_px_b) / 100} -
-
- ${dateStr} -
- `; - - let left = param.point.x; // relative to timeScale - const timeScaleWidth = chart.timeScale().width(); - const priceScaleWidth = chart.priceScale('left').width(); - const halfTooltipWidth = toolTipWidth / 2; - left += priceScaleWidth - halfTooltipWidth; - left = Math.min(left, priceScaleWidth + timeScaleWidth - toolTipWidth); - left = Math.max(left, priceScaleWidth); - - toolTip.style.left = left + 'px'; - toolTip.style.top = 0 + 'px'; - } - }); - - - - window.chart.timeScale().fitContent(); - - console.log("TV Created!") -}; \ No newline at end of file diff --git a/nicegui_modules/static/script.js b/nicegui_modules/static/script.js new file mode 100644 index 0000000..87d514c --- /dev/null +++ b/nicegui_modules/static/script.js @@ -0,0 +1,157 @@ +async function waitForVariable(variableName, timeout = 5000) { + const startTime = Date.now(); + while (typeof window[variableName] === 'undefined') { + if (Date.now() - startTime > timeout) { + throw new Error(`Variable '${variableName}' not defined within ${timeout}ms`); + } + await new Promise(resolve => setTimeout(resolve, 100)); + } + console.log(`Variable '${variableName}' is now defined.`); +} + +async function update_tv(data_list, lookback_max_points) { + data_list.forEach(function (item, index) { + // console.log(item, index); + window.charts_arr[index].data.push({ time: item.timestamp, value: item.value }); + window.charts_arr[index].series.update({ time: item.timestamp, value: item.value }); + + if (window.charts_arr[index].series.data().length > lookback_max_points) { + window.charts_arr[index].series.setData(window.charts_arr[index].series.data().slice(-lookback_max_points)); + }; + }); + + // midPriceLine.applyOptions({ + // price: data_dict.mid_px, + // color: '#c78228', + // lineWidth: 3, + // lineStyle: LightweightCharts.LineStyle.Dashed, + // axisLabelVisible: true, + // }); + + window.chart.timeScale().scrollToRealTime(); + window.chart.timeScale().fitContent(); + const currentRange = window.chart.timeScale().getVisibleLogicalRange(); + window.chart.timeScale().setVisibleLogicalRange(currentRange); +}; + + +async function create_tv(charts_list, create_chart_options) { + if (create_chart_options.crosshair == 'NORMAL') { + create_chart_options.crosshair = { mode: LightweightCharts.CrosshairMode.Normal } + }; + window.chart = LightweightCharts.createChart(document.getElementById('tv'), create_chart_options); + window.charts_arr = []; + + charts_list.forEach(function (item, index) { + // console.log(item, index); + charts_dict = {}; + if ((Array.isArray(item.autoscaleInfoProvider) && item.autoscaleInfoProvider.length !== 0)) { + item.options.autoscaleInfoProvider = () => ({ + priceRange: { + minValue: item.autoscaleInfoProvider[0], + maxValue: item.autoscaleInfoProvider[1] + } + }) + }; + if (item.type == "AREA" ) { + charts_dict.series = chart.addSeries(LightweightCharts.AreaSeries, item.options); + } else { + charts_dict.series = chart.addSeries(LightweightCharts.LineSeries, item.options); + }; + charts_dict.data = []; + charts_dict.series.setData(charts_dict.data); + window.charts_arr.push(charts_dict); + }); + + window.chart.timeScale().fitContent(); + + console.log("TV Created!") + + // window.midPriceLine_Config = { + // price: 0, + // color: '#c78228', + // lineWidth: 3, + // lineStyle: LightweightCharts.LineStyle.Dashed, + // axisLabelVisible: false, + // }; + // window.midPriceLine = window.lineSeries.createPriceLine(midPriceLine_Config); + + + // Create and style the tooltip html element + // const container = document.getElementById('tv'); + + // window.toolTipWidth = 200; + + // const toolTip = document.createElement('div'); + // toolTip.style = `width: ${window.toolTipWidth}px; height: 100%; position: absolute; display: none; padding: 8px; box-sizing: border-box; font-size: 12px; text-align: left; z-index: 1000; top: 12px; left: 12px; pointer-events: none; border-radius: 4px 4px 0px 0px; border-bottom: none; box-shadow: 0 2px 5px 0 rgba(117, 134, 150, 0.45);font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;`; + // toolTip.style.background = `rgba(${'0, 0, 0'}, 0.25)`; + // toolTip.style.color = 'white'; + // toolTip.style.borderColor = 'rgba( 239, 83, 80, 1)'; + // container.appendChild(toolTip); + + // // update tooltip + // window.chart.subscribeCrosshairMove(async param => { + + // if ( + // param.point === undefined || + // !param.time || + // param.point.x < 0 || + // param.point.x > container.clientWidth || + // param.point.y < 0 || + // param.point.y > container.clientHeight + // ) { + // toolTip.style.display = 'none'; + // } else { + + // // toolTip.style.height = '100%'; + // toolTip.style.alignContent = 'center'; + + // const dateStr = new Date(param.time*1000).toISOString(); + + // let data = await param.seriesData.get(window.lineSeries); + // if (data === undefined) { + // data = {} + // data.value = 0 + // console.log('data is UNDEFINED, SETTING TO 0') + // }; + + // let data_b = await param.seriesData.get(window.lineSeries_b); + // if (data_b === undefined) { + // data_b = {} + // data_b.value = 0 + // console.log('data is UNDEFINED, SETTING TO 0') + // }; + + // const value_px = data.value + // const value_px_b = window.data_b.value + // const value_px_c = window.data_c.value + // // const value_px_tgt = window.data_tgt.value + + // toolTip.style.display = 'block'; + // //
+ // // Atwater Trading + // //
+ // toolTip.innerHTML = ` + //
+ // Chainlink: ${Math.round(100 * value_px) / 100} + // Binance: ${Math.round(100 * value_px_b) / 100} + //
+ //
+ // ${dateStr} + //
+ // `; + + // let left = param.point.x; // relative to timeScale + // const timeScaleWidth = chart.timeScale().width(); + // const priceScaleWidth = chart.priceScale('left').width(); + // const halfTooltipWidth = toolTipWidth / 2; + // left += priceScaleWidth - halfTooltipWidth; + // left = Math.min(left, priceScaleWidth + timeScaleWidth - toolTipWidth); + // left = Math.max(left, priceScaleWidth); + + // toolTip.style.left = left + 'px'; + // toolTip.style.top = 0 + 'px'; + // } + // }); + +}; \ No newline at end of file diff --git a/ng_modules/static/styles.css b/nicegui_modules/static/styles.css similarity index 100% rename from ng_modules/static/styles.css rename to nicegui_modules/static/styles.css