Update open interest

This commit is contained in:
2025-08-14 23:53:45 +07:00
parent 580ce4d9c9
commit 2622da05e6
7 changed files with 44 additions and 34 deletions

View File

@@ -94,15 +94,15 @@ const BotList: React.FC<IBotList> = ({ list }) => {
</button>
)
}
function getToggleBotStatusBadge(status: string, identifier: string) {
function getToggleBotStatusBadge(status: BotStatus, identifier: string) {
const classes =
baseBadgeClass() + (status == 'Up' ? ' bg-error' : ' bg-success')
baseBadgeClass() + (status == BotStatus.Running ? ' bg-error' : ' bg-success')
return (
<button
className={classes}
onClick={() => toggleBotStatus(status, identifier)}
>
{status == 'Up' ? (
{status == BotStatus.Running ? (
<p className="text-accent-content flex">
<StopIcon width={15}></StopIcon>
</p>
@@ -165,11 +165,11 @@ const BotList: React.FC<IBotList> = ({ list }) => {
setShowTradesModal(true)
}
function toggleBotStatus(status: string, identifier: string) {
const isUp = status == 'Up'
function toggleBotStatus(status: BotStatus, identifier: string) {
const isUp = status == BotStatus.Running
const t = new Toast(isUp ? 'Stoping bot' : 'Restarting bot')
if (status == 'Up') {
if (status == BotStatus.Running) {
client
.bot_Stop(identifier)
.then(() => {
@@ -178,7 +178,7 @@ const BotList: React.FC<IBotList> = ({ list }) => {
.catch((err) => {
t.update('error', err)
})
} else if (status == 'Down' || status == 'None') {
} else if (status == BotStatus.Stopped || status == BotStatus.Saved) {
client
.bot_Restart(identifier)
.then(() => {
@@ -261,7 +261,7 @@ const BotList: React.FC<IBotList> = ({ list }) => {
{/* Action Badges - Only show for bot owners */}
{isBotOwner(bot.agentName) && (
<div className="flex flex-wrap gap-1">
{getToggleBotStatusBadge(bot.status, bot.identifier)}
{getToggleBotStatusBadge(bot.status as BotStatus, bot.identifier)}
{getUpdateBotBadge(bot)}
{getManualPositionBadge(bot.identifier)}
{getDeleteBadge(bot.identifier)}

View File

@@ -1,16 +1,11 @@
import React, {useEffect, useState} from 'react'
import useApiUrlStore from '../../app/store/apiStore'
import {
DataClient,
type PlatformSummaryViewModel,
type StrategiesStatisticsViewModel,
type TopStrategiesViewModel
} from '../../generated/ManagingApi'
import {DataClient, type PlatformSummaryViewModel, type TopStrategiesViewModel} from '../../generated/ManagingApi'
function PlatformSummary({ index }: { index: number }) {
const { apiUrl } = useApiUrlStore()
const [platformData, setPlatformData] = useState<PlatformSummaryViewModel | null>(null)
const [strategiesStats, setStrategiesStats] = useState<StrategiesStatisticsViewModel | null>(null)
const [topStrategies, setTopStrategies] = useState<TopStrategiesViewModel | null>(null)
const [isLoading, setIsLoading] = useState(true)
const [error, setError] = useState<string | null>(null)
@@ -23,14 +18,12 @@ function PlatformSummary({ index }: { index: number }) {
const client = new DataClient({}, apiUrl)
// Fetch all platform data in parallel
const [platform, strategies, top] = await Promise.all([
const [platform, top] = await Promise.all([
client.data_GetPlatformSummary(),
client.data_GetStrategiesStatistics(),
client.data_GetTopStrategies()
])
setPlatformData(platform)
setStrategiesStats(strategies)
setTopStrategies(top)
} catch (err) {
setError('Failed to fetch platform data')
@@ -112,10 +105,10 @@ function PlatformSummary({ index }: { index: number }) {
{/* Header */}
<div className="mb-8">
<h1 className="text-4xl font-bold text-white mb-2">
{formatNumber(strategiesStats?.totalStrategiesRunning || 0)} Strategies Deployed
{formatNumber(platformData?.totalActiveStrategies || 0)} Strategies Deployed
</h1>
<div className="text-lg">
{strategiesStats && formatChangeIndicator(strategiesStats.changeInLast24Hours || 0)}
{platformData && formatChangeIndicator(platformData.strategiesChange24h || 0)}
</div>
</div>