PHP code example of algomateinc / cryptomarket

1. Go to this page and download the library: Download algomateinc/cryptomarket library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

algomateinc / cryptomarket example snippets


$kraken = new Kraken('mykey', 'mysecret');
$kraken->init();
// get currency pairs
$krakenPairs = $kraken->supportedCurrencyPairs();

foreach ($krakenPairs as $pair) {
  // get mkt data
  $tickerData = $kraken->ticker($pair);

  // buy anything less than 1000
  if ($tickerData->ask < 1000.0) {
    $kraken->buy($pair, 1.0, $tickerData->ask);
  }
}

class ConfigData {
  const ACCOUNTS_CONFIG = [
    'Kraken'=> [
      'key' => 'mykey',
    'secret' => 'mysecret'
    ];
}

$accountLoader =
new ConfigAccountLoader(ConfigData::ACCOUNTS_CONFIG);
$allExchanges = $accountLoader->getAccounts();

$kraken = $allExchanges[ExchangeName::Kraken]; // get one

foreach ($allExchanges as $exchange) { // all exchanges
  $btcusd = $exchange->ticker(CurrencyPair::BTCUSD);
  // do stuff with BTCUSD
}