<?php

// Step 1: Fetch market summary data
$response = wp_remote_get(‘https://nodes.bytedex.io/market/get-market-summary’);

if (is_wp_error($response)) {
echo ‘Failed to fetch market summary data’;
return;
}

$body = wp_remote_retrieve_body($response);
$data = json_decode($body, true);

if ($data[‘status’] !== ‘Success’) {
echo ‘Failed to fetch market summary data’;
return;
}

$markets = $data[‘data’];

// Step 2: Parse the data for gainers and losers
$gainers = [];
$losers = [];

foreach ($markets as $symbol => $market) {
$logoUrl = ‘https://bexc.io/assets/cryptocurrency-icons/color/’ . strtolower(str_replace(‘_’, ‘-‘, $symbol)) . ‘.svg’;
$market[‘Logo’] = $logoUrl;

if ($market[‘PercentChange’] > 0) {
$gainers[] = $market;
} else {
$losers[] = $market;
}
}

// Step 3: Sort the data based on percentage change
usort($gainers, function ($a, $b) {
return $b[‘PercentChange’] <=> $a[‘PercentChange’];
});

usort($losers, function ($a, $b) {
return $a[‘PercentChange’] <=> $b[‘PercentChange’];
});

// Step 4: Display the data on a WordPress page
?>

<h2>Top 10 Gainers</h2>

<table>
<thead>
<tr>
<th>Symbol</th>
<th>Logo</th>
<th>Last Price</th>
<th>24h Change</th>
<th>Volume (Base)</th>
<th>Volume (Quote)</th>
</tr>
</thead>
<tbody>
<?php foreach (array_slice($gainers, 0, 10) as $market): ?>
<tr>
<td><?php echo $market[‘Symbol’]; ?></td>
<td><img src=”<?php echo $market[‘Logo’]; ?>” alt=”<?php echo $market[‘Symbol’]; ?> logo” width=”20″ height=”20″></td>
<td><?php echo number_format($market[‘Last’], 8); ?></td>
<td style=”color: green;”><?php echo number_format($market[‘PercentChange’], 2); ?>%</td>
<td><?php echo number_format($market[‘BaseVolume’], 2); ?></td>
<td><?php echo number_format($market[‘QuoteVolume’], 2); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

<h2>Top 10 Losers</h2>

<table>
<thead>
<tr>
<th>Symbol</th>
<th>Logo</th>
<th>Last Price</th>
<th>24h Change</th>
<th>Volume (Base)</th>
<th>Volume (Quote)</th>
</tr>
</thead
<tbody>
<?php foreach (array_slice($losers, 0, 10) as $market): ?>
<tr>
<td><?php echo $market[‘Symbol’]; ?></td>
<td><img src=”<?php echo $market[‘Logo’]; ?>” alt=”<?php echo $market[‘Symbol’]; ?> logo” width=”20″ height=”20″></td>
<td><?php echo number_format($market[‘Last’], 8); ?></td>
<td style=”color: red;”><?php echo number_format($market[‘PercentChange’], 2); ?>%</td>
<td><?php echo number_format($market[‘BaseVolume’], 2); ?></td>
<td><?php echo number_format($market[‘QuoteVolume’], 2); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

<?php

// Step 1: Fetch market summary data
$response = wp_remote_get(‘https://nodes.bytedex.io/market/get-market-summary’);

if (is_wp_error($response)) {
echo ‘Failed to fetch market summary data’;
return;
}

$body = wp_remote_retrieve_body($response);
$data = json_decode($body, true);

if ($data[‘status’] !== ‘Success’) {
echo ‘Failed to fetch market summary data’;
return;
}

$markets = $data[‘data’];

// Step 2: Parse the data for gainers and losers
$gainers = [];
$losers = [];

foreach ($markets as $symbol => $market) {
$logoUrl = ‘https://bexc.io/assets/cryptocurrency-icons/color/’ . strtolower(str_replace(‘_’, ‘-‘, $symbol)) . ‘.svg’;
$market[‘Logo’] = $logoUrl;

if ($market[‘PercentChange’] > 0) {
$gainers[] = $market;
} else {
$losers[] = $market;
}
}

// Step 3: Sort the data based on percentage change
usort($gainers, function ($a, $b) {
return $b[‘PercentChange’] <=> $a[‘PercentChange’];
});

usort($losers, function ($a, $b) {
return $a[‘PercentChange’] <=> $b[‘PercentChange’];
});

// Step 4: Display the data on a WordPress page
?>

<h2>Top 10 Gainers</h2>

<table>
<thead>
<tr>
<th>Symbol</th>
<th>Logo</th>
<th>Last Price</th>
<th>24h Change</th>
<th>Volume (Base)</th>
<th>Volume (Quote)</th>
</tr>
</thead>
<tbody>
<?php foreach (array_slice($gainers, 0, 10) as $market): ?>
<tr>
<td><?php echo $market[‘Symbol’]; ?></td>
<td><img src=”<?php echo $market[‘Logo’]; ?>” alt=”<?php echo $market[‘Symbol’]; ?> logo” width=”20″ height=”20″></td>
<td><?php echo number_format($market[‘Last’], 8); ?></td>
<td style=”color: green;”><?php echo number_format($market[‘PercentChange’], 2); ?>%</td>
<td><?php echo number_format($market[‘BaseVolume’], 2); ?></td>
<td><?php echo number_format($market[‘QuoteVolume’], 2); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

<h2>Top 10 Losers</h2>

<table>
<thead>
<tr>
<th>Symbol</th>
<th>Logo</th>
<th>Last Price</th>
<th>24h Change</th>
<th>Volume (Base)</th>
<th>Volume (Quote)</th>
</tr>
</thead
<tbody>
<?php foreach (array_slice($losers, 0, 10) as $market): ?>
<tr>
<td><?php echo $market[‘Symbol’]; ?></td>
<td><img src=”<?php echo $market[‘Logo’]; ?>” alt=”<?php echo $market[‘Symbol’]; ?> logo” width=”20″ height=”20″></td>
<td><?php echo number_format($market[‘Last’], 8); ?></td>
<td style=”color: red;”><?php echo number_format($market[‘PercentChange’], 2); ?>%</td>
<td><?php echo number_format($market[‘BaseVolume’], 2); ?></td>
<td><?php echo number_format($market[‘QuoteVolume’], 2); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

<?php

// Step 1: Fetch market summary data
$response = wp_remote_get('https://nodes.bytedex.io/market/get-market-summary');

if (is_wp_error($response)) {
    echo 'Failed to fetch market summary data';
    return;
}

$body = wp_remote_retrieve_body($response);
$data = json_decode($body, true);

if ($data['status'] !== 'Success') {
    echo 'Failed to fetch market summary data';
    return;
}

$markets = $data['data'];

// Step 2: Parse the data for gainers and losers
$gainers = [];
$losers = [];

foreach ($markets as $symbol => $market) {
    $logoUrl = 'https://bexc.io/assets/cryptocurrency-icons/color/' . strtolower(str_replace('_', '-', $symbol)) . '.svg';
    $market['Logo'] = $logoUrl;

    if ($market['PercentChange'] > 0) {
        $gainers[] = $market;
    } else {
        $losers[] = $market;
    }
}

// Step 3: Sort the data based on percentage change
usort($gainers, function ($a, $b) {
    return $b['PercentChange'] <=> $a['PercentChange'];
});

usort($losers, function ($a, $b) {
    return $a['PercentChange'] <=> $b['PercentChange'];
});

// Step 4: Display the data on a WordPress page
?>

<h2>Top 10 Gainers</h2>

<table>
    <thead>
        <tr>
            <th>Symbol</th>
            <th>Logo</th>
            <th>Last Price</th>
            <th>24h Change</th>
            <th>Volume (Base)</th>
            <th>Volume (Quote)</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach (array_slice($gainers, 0, 10) as $market): ?>
            <tr>
                <td><?php echo $market['Symbol']; ?></td>
                <td><img src="<?php echo $market['Logo']; ?>" alt="<?php echo $market['Symbol']; ?> logo" width="20" height="20"></td>
                <td><?php echo number_format($market['Last'], 8); ?></td>
                <td style="color: green;"><?php echo number_format($market['PercentChange'], 2); ?>%</td>
                <td><?php echo number_format($market['BaseVolume'], 2); ?></td>
                <td><?php echo number_format($market['QuoteVolume'], 2); ?></td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>

<h2>Top 10 Losers</h2>

<table>
    <thead>
        <tr>
            <th>Symbol</th>
            <th>Logo</th>
            <th>Last Price</th>
            <th>24h Change</th>
            <th>Volume (Base)</th>
            <th>Volume (Quote)</th>
        </tr>
    </thead
<tbody>
    <?php foreach (array_slice($losers, 0, 10) as $market): ?>
        <tr>
            <td><?php echo $market['Symbol']; ?></td>
            <td><img src="<?php echo $market['Logo']; ?>" alt="<?php echo $market['Symbol']; ?> logo" width="20" height="20"></td>
            <td><?php echo number_format($market['Last'], 8); ?></td>
            <td style="color: red;"><?php echo number_format($market['PercentChange'], 2); ?>%</td>
            <td><?php echo number_format($market['BaseVolume'], 2); ?></td>
            <td><?php echo number_format($market['QuoteVolume'], 2); ?></td>
        </tr>
    <?php endforeach; ?>
</tbody>
</table>

Bu websitesindeki hiçbir veri bilgi yada materyal bir alım satım tavsiyesi olarak yorumlanamaz. Lütfen kripto varlıklar hakkında “Risk Bildirimi” metnini okuyunuz.

Ekosistem

Copyright: © 2023. All Rights Reserved.

Bytedex

There is something wrong with Feed URL