public function buypice() { //OKCoin 实时价格 require_once $_SERVER['DOCUMENT_ROOT'] . '/API/OKCoin/OKCoin.php'; $API_KEY = "**********"; $SECRET_KEY = "**********"; //OKCoin DEMO 入口 $client = new \OKCoin(new \OKCoin_ApiKeyAuthentication($API_KEY, $SECRET_KEY)); //获取OKCoin行情(盘口数据) $params = array('symbol' => 'btc_cny'); $result = $client->tickerApi($params); $array = get_object_vars($result); $array1 = get_object_vars($array['ticker']); $last = $array1['last']; //比特币中国实时价格 //火币网实时价格 echo json_encode($last); }
public function salepice() { // OKCoin 实时价格 require_once $_SERVER['DOCUMENT_ROOT'] . '/API/OKCoin/OKCoin.php'; $API_KEY = "18d95fb4-0cba-4993-b7b1-d48eb993f8cb"; $SECRET_KEY = "2DF5FBBD3F8937D556581FFAE296467D"; // OKCoin DEMO 入口 $client = new \OKCoin(new \OKCoin_ApiKeyAuthentication($API_KEY, $SECRET_KEY)); // 获取OKCoin行情(盘口数据) $params = array('symbol' => 'btc_cny'); $result = $client->tickerApi($params); $array = get_object_vars($result); $array1 = get_object_vars($array['ticker']); $last = $array1['last']; // 比特币中国实时价格 // 火币网实时价格 echo json_encode($last); }
<?php require_once dirname(__FILE__) . '/OKCoin/OKCoin.php'; const API_KEY = "OKCoin提供的api_key"; const SECRET_KEY = "OKCoin提供的secret_key"; try { //OKCoin DEMO 入口 $client = new OKCoin(new OKCoin_ApiKeyAuthentication(API_KEY, SECRET_KEY)); //获取OKCoin行情(盘口数据) $params = array('symbol' => 'ltc_usd'); $result = $client->tickerApi($params); print_r($result); //获取OKCoin市场深度 $params = array('symbol' => 'btc_usd', 'size' => 5); $result = $client->depthApi($params); print_r($result); //获取OKCoin历史交易信息 //$params = array('symbol' => 'btc_usd'); //$result = $client -> tradesApi($params); //获取比特币或莱特币的K线数据 //$params = array('symbol' => 'btc_usd', 'type' => '1day', 'size' => 5); //$result = $client -> klineDataApi($params); //获取用户信息 //$params = array('api_key' => API_KEY); //$result = $client -> userinfoApi($params); //下单交易 //$params = array('api_key' => API_KEY, 'symbol' => 'btc_usd', 'type' => 'buy', 'price' => 1, 'amount' => 1); //$result = $client -> tradeApi($params); //var_dump($result); //批量下单 //$params = array('api_key' => API_KEY, 'symbol' => 'btc_usd', 'type' => 'buy', 'orders_data' => "[;price:3,amount:5,type:'sell'var_dump($result);,;price:3,amount:3,type:'buy'var_dump($result);,;price:3,amount:3var_dump($result);]");
<?php require_once 'phplot.php'; //OKCoin DEMO 入口 $client = new OKCoin(new OKCoin_ApiKeyAuthentication(API_KEY, SECRET_KEY)); //获取OKCoin行情(盘口数据) // $params = array('symbol' => 'btc_usd'); // $result = $client -> tickerApi($params); // print_r($result); $btcffrjson = file_get_contents('https://api.bitfinex.com/v1/lendbook/BTC?limit_bids=0&limit_asks=1'); $btcffrarray = json_decode($btcffrjson, true); if (isset($btcffrarray)) { $btcffr = $btcffrarray['asks'][0]['rate']; } else { $btcffr = "N/A"; } echo "<br>"; print_r("Bitfinex BTC yield (APY):" . $btcffr . "%"); $getokcindex = array('symbol' => 'btc_usd', 'type' => '1day', 'contract_type' => 'this_week', 'size' => 5); $okcindex = $client->getFutureIndexFutureApi($getokcindex); $theokcindex = $okcindex->future_index; $getokcweekly = array('symbol' => 'btc_usd', 'contract_type' => 'this_week'); $okcweekly = $client->tickerFutureApi($getokcweekly); $theokcweekly = $okcweekly->ticker->last; $weeklyspread = $theokcweekly - $theokcindex; $weeklyspreadperc = $weeklyspread / $theokcindex * 100; $weeklyspreadperc2 = round($weeklyspreadperc, 2); $dayofweek = date('w', strtotime(getdate())); if ($dayofweek == 6) { $okcwdays = 7; $okcbdays = 14;