public static function Price() { if (Coin::force() || !file_exists('/tmp/aur_price_date') || file_get_contents('/tmp/aur_price_date') <= time()) { $timestamp = strtotime('+10 minutes', time()); file_put_contents('/tmp/aur_price_date', $timestamp); $price = Cryptsy::GetMarket('AUR'); Coin::where('code', 'AUR')->update(['price' => $price]); } else { $price = Coin::where('code', 'AUR')->pluck('price'); } return $price; }
public static function GetMarket($currencyCode) { $result = Cryptsy::api_query("getmarkets"); if ($currencyCode == 'BTC') { $btcRate = "0.00"; } elseif ($result['success'] == 1) { foreach ($result['return'] as $coin) { if ($coin['primary_currency_code'] == $currencyCode) { $btcRate = $coin['last_trade']; break; } } } return $btcRate; }
<?php require_once "cryptsy_lib.php"; require_once "config.php"; $cryptsy = new Cryptsy($config['public_key'], $config['private_key']); $markets = array(); while (1) { $data = $cryptsy->get_marketdata(); $markets = $data["markets"]; foreach ($markets as $market) { $count = 0; $b_c = 0; $s_c = 0; $total_btc = 0; if (sizeof($market["recenttrades"]) == 0) { continue; } $trades = array_reverse($market["recenttrades"]); foreach ($trades as $trade) { if ($count == 0) { $buy_price = $trade["price"] * $config["profit_percent"]; $sell_price = $trade["price"] * $config["stop_lost_percent"]; $count++; } if ($trade["price"] >= $buy_price) { $b_c++; $buy_price = $trade["price"]; } else { if ($trade["price"] <= $sell_price) { $s_c++; $sell_price = $trade["price"];