PHP Classes

PHP Crypto Currency Exchange: Simulate the selling and buying of cryptocurrency

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-11-14 (11 months ago) RSS 2.0 feedNot enough user ratingsTotal: 52 All time: 10,662 This week: 78Up
Version License PHP version Categories
corretora 1.0.0MIT/X Consortium ...5PHP 5, Web services, Finances, Applic...
Description 

Author

This package can simulate the selling and buying of cryptocurrency.

It implements a Web application that allows users to have virtual current wallets in different cryptocurrencies using fictitious money.

The package can adjust the currency exchange rates.

It can also display a chart to show the fluctuation of the exchange rates.

Innovation Award
PHP Programming Innovation award nominee
November 2023
Number 4
Virtual currencies have become very popular among people who like finances since currencies like Bitcoin started to become used to exchange real money with virtual currency money.

Usually, the exchange process between currencies is done by broker companies.

This package implements a simulation of a cryptocurrency broker system.

With more development work, it can evolve into a real cryptocurrency broker system that actual broker companies can use.

Manuel Lemos
Picture of Rodrigo Faustino
  Performance   Level  
Name: Rodrigo Faustino <contact>
Classes: 27 packages by
Country: Brazil Brazil
Age: 41
All time rank: 2506173 in Brazil Brazil
Week rank: 1 Up
Innovation award
Innovation award
Nominee: 17x

Winner: 2x

Example

<?php
use App\Api\API;
require
'vendor/autoload.php';

$db = new Database();
$api = new API($db);
$method = $_SERVER['REQUEST_METHOD'];
$url = $_SERVER['REQUEST_URI'];
$path = parse_url($url, PHP_URL_PATH);
$parts = explode('/', $path);
switch (
$method) {
    case
'GET':
        if (
preg_match('/\/quote\/([a-z]+)$/', $url, $matches)) {
           
$api->get_quote($matches[1]);
        } elseif (
preg_match('/\/carteira\/([a-z0-9\-]+)$/', $url, $matches)) {
           
$api->getCarteira($matches[1]);
        }
         elseif (
preg_match('/\/money\/([a-z0-9\-]+)$/', $url, $matches)) {
           
$api->getMoney($matches[1]);
        }
        break;
    case
'POST':
       
$data = json_decode(file_get_contents('php://input'), true);
        if (
preg_match('/\/update\/([a-z]+)$/', $url, $matches)) {
           
$api->get_quote($matches[1]);
        } elseif (
preg_match('/\/carteira$/', $url)) {
           
$api->createCarteira($data);
        }
        elseif (
preg_match('/\/money$/', $url)) {
           
$api->initializeMoney($data);
        }
        elseif (
preg_match('/\/moneycompra\/([a-z0-9\-]+)$/', $url, $matches)) {
           
$api->updateMoney($matches[1], $data);
        }
        break;
    case
'PUT':
       
$data = json_decode(file_get_contents('php://input'), true);
        if (
preg_match('/\/carteira\/([a-z0-9\-]+)$/', $url, $matches)) {
           
$api->updateCarteira($matches[1], $data);
        }
        break;
    case
'DELETE':
        if (
preg_match('/\/carteira\/([a-z0-9\-]+)$/', $url, $matches)) {
           
$api->deleteCarteira($matches[1]);
        }
        break;
    default:
       
http_response_code(405);
        echo
json_encode(["error" => "Método não permitido"]);
        break;
}


Details

Simulador de Corretora de Criptomoedas

Este é um simulador interativo de uma corretora de criptomoedas. Ele permite aos usuários comprar e vender criptomoedas com dinheiro fictício, aprendendo assim como funciona uma bolsa de valores de criptomoedas sem o risco de perder dinheiro real.

Características

  • Carteira Virtual: Cada usuário recebe uma chave criptográfica única para gerenciar sua carteira. Essa chave é armazenada em um banco de dados MySQL.
  • Dinheiro Fictício: Os usuários iniciam com uma quantidade fictícia de dinheiro que podem usar para comprar e vender criptomoedas.
  • Simulação de Taxas de Câmbio: As taxas de câmbio das criptomoedas são ajustadas aleatoriamente a cada 5 segundos para simular o mercado em tempo real.
  • Gráfico Interativo: O simulador apresenta um gráfico que exibe a flutuação dos preços das criptomoedas. O gráfico é destruído e reconstruído a cada atualização para garantir a precisão dos dados.

Tecnologias Utilizadas

  • HTML
  • CSS
  • JavaScript
  • PHP
  • MySQL

Licença

Este projeto está licenciado sob a licença MIT - veja o arquivo LICENSE.md para detalhes.


  Files folder image Files (21)  
File Role Description
Files folder imagebackend (3 directories)
Files folder imagecss (6 files)
Files folder imageimg (1 file)
Files folder imagejs (5 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file cotacoes.php Example Example script
Accessible without login Plain text file index.html Data Application page
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (21)  /  backend  
File Role Description
Files folder imageapi (1 file)
Files folder imageconfig (1 file)
Files folder imageModel (3 files)

  Files folder image Files (21)  /  backend  /  api  
File Role Description
  Plain text file Api.php Class Class source

  Files folder image Files (21)  /  backend  /  config  
File Role Description
  Plain text file Database.php Class Class source

  Files folder image Files (21)  /  backend  /  Model  
File Role Description
  Plain text file CarteiraVirtual.php Class Class source
  Plain text file Cliente.php Class Class source
  Plain text file CryptoQuote.php Class Class source

  Files folder image Files (21)  /  css  
File Role Description
  Accessible without login Plain text file btc.txt Doc. Documentation
  Accessible without login Plain text file eth.txt Doc. Documentation
  Accessible without login Plain text file ltc.txt Doc. Documentation
  Accessible without login Plain text file style.css Data Auxiliary data
  Accessible without login Plain text file styleindex.css Data Auxiliary data
  Accessible without login Plain text file stylelogin.css Data Auxiliary data

  Files folder image Files (21)  /  img  
File Role Description
  Accessible without login Image file trade.png Data Auxiliary data

  Files folder image Files (21)  /  js  
File Role Description
  Accessible without login Plain text file chart.js Data Auxiliary data
  Accessible without login Plain text file chartjs-chart-financial.js Data Auxiliary data
  Accessible without login Plain text file jquery-3.6.0.min.js Data Auxiliary data
  Accessible without login Plain text file sha256.min.js Data Auxiliary data
  Accessible without login Plain text file sha256.min.js.map Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:52
This week:0
All time:10,662
This week:78Up