|
|
@@ -290,7 +290,7 @@ def update_data_for_plotly_and_table():
|
|
|
continue
|
|
|
|
|
|
# 3. 获取链上价格:用 in_amount_to_query_human 这么多的USDT去买目标币,能买到多少,以及价格 (USDT/TARGET)
|
|
|
- erc20_data, chain_swap_full_response = get_chain_price_vs_target_currency(
|
|
|
+ dex_data, chain_swap_full_response = get_chain_price_vs_target_currency(
|
|
|
CHAIN_ID,
|
|
|
IN_TOKEN_ADDRESS, # USDT
|
|
|
OUT_TOKEN_ADDRESS, # TARGET
|
|
|
@@ -300,8 +300,12 @@ def update_data_for_plotly_and_table():
|
|
|
USER_WALLET,
|
|
|
USER_EXCHANGE_WALLET
|
|
|
)
|
|
|
- dex_price = erc20_data.get("price_base_per_target") # USDT/TARGET
|
|
|
- erc20_err = erc20_data.get("error")
|
|
|
+ dex_price = dex_data.get("price_base_per_target") # USDT/TARGET
|
|
|
+ dex_err = dex_data.get("error")
|
|
|
+
|
|
|
+ if dex_err or cex_err:
|
|
|
+ time.sleep(REFRESH_INTERVAL_SECONDS)
|
|
|
+ continue
|
|
|
|
|
|
# 加入价差,考虑spread重新计算dex_price
|
|
|
global spread_ema, count
|
|
|
@@ -361,13 +365,13 @@ def update_data_for_plotly_and_table():
|
|
|
latest_values_for_table["cex_price"] = f"{cex_price:.18f}" if cex_price else "N/A"
|
|
|
latest_values_for_table["diff_dex_vs_cex_percentage"] = diff_erc20_vs_cex_pct
|
|
|
latest_values_for_table["profit_value_for_table"] = f"{actual_profit_usdt:.2f} {BASE_CURRENCY_SYMBOL}" if actual_profit_usdt is not None else "N/A" # 新增
|
|
|
- latest_values_for_table["dex_error"] = erc20_err
|
|
|
+ latest_values_for_table["dex_error"] = dex_err
|
|
|
latest_values_for_table["cex_error"] = cex_err
|
|
|
latest_values_for_table["last_updated"] = fetch_time_full
|
|
|
latest_values_for_table["in_amount_for_query_display"] = f"{in_amount_to_query_human:.2f} {BASE_CURRENCY_SYMBOL}" if in_amount_to_query_human > 0 else "N/A"
|
|
|
|
|
|
- if erc20_err or cex_err :
|
|
|
- logger.warning(f"{fetch_time_chart} Errors: erc20:{erc20_err}, CEX:{cex_err}")
|
|
|
+ if dex_err or cex_err :
|
|
|
+ logger.warning(f"{fetch_time_chart} Errors: erc20:{dex_err}, CEX:{cex_err}")
|
|
|
|
|
|
time.sleep(REFRESH_INTERVAL_SECONDS)
|
|
|
|