您好,登錄后才能下訂單哦!
這篇文章主要介紹“PHP SDK怎么使用”,在日常操作中,相信很多人在PHP SDK怎么使用問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”PHP SDK怎么使用”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
對應平臺接口,在大于或等于三個參數(shù)以上的,使用數(shù)組傳入,否則使用同名參數(shù)傳入
幣安的 timestamp 參數(shù)已內置,不需要額外傳入
火幣的 AccessKeyId,SignatureMethod,SignatureVersion,Timestamp 已內置,不需要額外傳入
<?php use EasyExchange\Factory; // 配置 $config = [ 'binance' => [ 'response_type' => 'array', //'base_uri' => 'https://api.binance.com', // 正式網(wǎng) 'base_uri' => 'https://testnet.binance.vision', // 測試網(wǎng) 'app_key' => 'your app key', 'secret' => 'your secret', ], ]; $app = Factory::binance($config['binance']);
市場行情相關
$app = Factory::binance($config['binance']); // 深度信息 $app->market->depth('LTCBTC'); // 近期成交列表 $app->market->trades('ETHBTC', 10); // 查詢歷史成交 $app->market->historicalTrades('ETHBTC', 10); // 近期成交 $app->market->aggTrades('ETHBTC'); // 24hr 價格變動情況 $app->market->hr24('ETHBTC'); // K線數(shù)據(jù) $params = [ 'symbol' => 'ETHBTC', 'interval' => 'DAY', 'startTime' => '時間戳', 'endTime' => '時間戳', 'limit' => 10, ]; // 詳見幣安文檔 $app->market->kline($params); // 當前平均價格 $app->market->avgPrice('ETHBTC'); // 獲取交易對最新價格 $app->market->price('ETHBTC'); // 返回當前最優(yōu)的掛單(最高買單,最低賣單) $app->market->bookTicker('ETHBTC');
錢包相關
// 獲取所有幣信息 $app->market->getAll(); // 查詢每日資產(chǎn)快照 $params = []; // 具體值詳見對應api文檔,下同 $app->market->accountSnapshot($params); // 關閉站內劃轉 $app->market->disableFastWithdrawSwitch($params); // 開啟站內劃轉 $app->market->enableFastWithdrawSwitch($params);
現(xiàn)貨交易相關
// 測試下單 $params = [ 'symbol' => 'LTCUSDT', 'side' => 'SELL', //BUY or SELL 'type' => 'LIMIT', 'timeInForce' => 'GTC', 'quantity' => 0.1, 'price' => 180, 'recvWindow' => 10000, ]; $app->spot->orderTest($params); // 下單 $params = [ 'symbol' => 'LTCUSDT', 'side' => 'SELL', //BUY or SELL 'type' => 'LIMIT', 'timeInForce' => 'GTC', 'quantity' => 0.1, 'price' => 180, 'recvWindow' => 10000, ]; $app->spot->order($params); // 獲取交易對的所有當前掛單 $app->spot->openOrders('ETHBTC'); // 撤銷訂單 $params = [ 'symbol' => 'LTCUSDT', 'orderId' => 3946, 'recvWindow' => 10000, ]; $app->spot->cancelOrder($params); // 撤銷單一交易對的所有掛單 $app->spot->cancelOrders('ETHBTC'); // 查詢訂單 $params = []; // 具體值詳見對應api文檔,下同 $app->spot->get($params); // 獲取所有帳戶訂單; 有效,已取消或已完成 $app->spot->allOrders($params); // 獲取賬戶指定交易對的成交歷史 $params = []; // 具體值詳見對應api文檔,下同 $app->spot->myTrades($params); // OCO下單 $params = []; // 具體值詳見對應api文檔,下同 $app->spot->oco($params); // 取消 OCO 訂單 $params = []; // 具體值詳見對應api文檔,下同 $app->spot->cancelOcoOrder($params); // 查詢 OCO $params = []; // 具體值詳見對應api文檔,下同 $app->spot->getOcoOrder($params); // 查詢所有 OCO $params = []; // 具體值詳見對應api文檔,下同 $app->spot->allOrderList($params); // 查詢 OCO 掛單 $app->spot->openOrderList($params);
杠桿交易相關
$app->margin;
合約交易相關
$app->future;
<?php use EasyExchange\Factory; // 配置 $config = [ 'huobi' => [ 'response_type' => 'array', 'base_uri' => 'https://api.huobi.pro', 'app_key' => 'your app key', 'secret' => 'your secret', ], ]; $app = Factory::houbi($config['houbi']);
$app = Factory::huobi($config['huobi']); $app->basic->systemTime(); $app->basic->exchangeInfo(); $app->basic->systemStatus(); $app->basic->currencys(); $app->basic->symbols(); $params = [ 'account-id' => 360000, 'symbol' => 'btcusdt', 'type' => 'buy-limit', 'amount' => 0.001, 'price' => 10000, ]; $app->spot->order($params); $app->spot->cancelOrder('204533841408061'); $params = [ 'account-id' => 360000, 'symbol' => 'btcusdt', // 'side' => 'both', ]; $app->spot->openOrders($params); $app->market->trades('btcusdt'); $app->market->depth('btcusdt', 'step0', 5); $app->market->marketStatus(); $app->market->exchangeInfo(); $app->wallet->accounts(); $app->wallet->account(360218); $app->wallet->assetValuation(); $params = [ 'account-id' => 3600000, ]; $app->wallet->history($params); $app->wallet->depositAddress('btc'); $params = [ 'currency' => 'xrp', ]; $app->wallet->withdrawAddress($params);
<?php use EasyExchange\Factory; // 配置 $config = [ 'okex' => [ 'response_type' => 'array', 'base_uri' => 'https://www.okexcn.com', 'app_key' => 'your app key', 'secret' => 'your secret', ], ]; $app = Factory::okex($config['okex']);
$app = Factory::okex($config['okex']); $app->basic->systemTime(); $app->basic->exchangeInfo('SPOT'); $app->market->depth('BTC-USD-SWAP', 5);
到此,關于“PHP SDK怎么使用”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。