Git Product home page Git Product logo

poloniex-php's Introduction

It is recommended that you read the official document first

Spot Document https://docs.poloniex.com/#cancelloanoffer

Future Document https://futures-docs.poloniex.com/#get-position-list

All interface methods are initialized the same as those provided by Poloniex. See details src/api

Most of the interface is now complete, and the user can continue to extend it based on my design, working with me to improve it.

中文文档

Other exchanges API

Exchanges It includes all of the following exchanges and is highly recommended.

Bitmex Support Websocket

Okex Support Websocket

Huobi Support Websocket

Binance Support Websocket

Kucoin

Mxc

Coinbase

ZB

Bitfinex

Bittrex

Kraken

Gate

Bigone

Crex24

Bybit

Coinbene

Bitget

Poloniex

If you don't find the exchange SDK you want, you can tell me and I'll join them.

Installation

composer require linwj/poloniex

Support for more request Settings

$poloniex=new PoloniexSpot();
//or
$poloniex=new PoloniexFuture();

//You can set special needs
$poloniex->setOptions([
    //Set the request timeout to 60 seconds by default
    'timeout'=>10,
    
    //If you are developing locally and need an agent, you can set this
    //'proxy'=>true,
    //More flexible Settings
    /* 'proxy'=>[
     'http'  => 'http://127.0.0.1:12333',
     'https' => 'http://127.0.0.1:12333',
     'no'    =>  ['.cn']
     ], */
    //Close the certificate
    //'verify'=>false,
]);

Spot API

Public API More

$poloniex=new PoloniexSpot();

try {
    $result=$poloniex->publics()->returnTicker();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->return24hVolume();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnOrderBook([
        'currencyPair'=>'BTC_ETH',
        'depth'=>'5',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnTradeHistory([
        'currencyPair'=>'BTC_ETH',
        'start'=>'1410158341',
        'end'=>'1410499372',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnChartData([
        'currencyPair'=>'USDT_BTC',
        'period'=>'1800',
        'start'=>'1410158341',
        'end'=>'1410499372',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

Private API More

$poloniex=new PoloniexSpot($key,$secret);

//account
try {
    $result=$poloniex->privates()->returnBalances();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->returnCompleteBalances();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->returnDepositAddresses();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->returnDepositsWithdrawals([
        'start'=>'1539954535',
        'end'=>'1540314535',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//order
try {
    $result=$poloniex->privates()->buy([
        'currencyPair'=>'USDT_BTC',
        'rate'=>'5000',
        'amount'=>'0.1',
        'clientOrderId'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->cancelOrder([
        'orderNumber'=>'123456',//(Optional) The identity number of the order to be canceled.
        //'clientOrderId'=>'123456',//(Optional) User specified 64-bit integer identifier.
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->cancelAllOrders([
        'currencyPair'=>'USDT_BTC',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->marginBuy([
        'currencyPair'=>'USDT_BTC',
        'rate'=>'5000',
        'amount'=>'0.1',
        'lendingRate'=>'0.03',
        'clientOrderId'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->getMarginPosition([
        'currencyPair'=>'USDT_BTC',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->closeMarginPosition([
        'currencyPair'=>'USDT_BTC',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->privates()->cancelLoanOffer([
        'orderNumber'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

More Test

More Api

Future API

Market API More

$poloniex=new PoloniexFuture();
try {
    $result=$poloniex->publics()->returnTicker();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->return24hVolume();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnOrderBook([
        'currencyPair'=>'BTC_ETH',
        'depth'=>'5',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnTradeHistory([
        'currencyPair'=>'BTC_ETH',
        'start'=>'1410158341',
        'end'=>'1410499372',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->publics()->returnChartData([
        'currencyPair'=>'USDT_BTC',
        'period'=>'1800',
        'start'=>'1410158341',
        'end'=>'1410499372',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

Trade API More

$poloniex=new PoloniexFuture($key,$secret,$passphrase);
//order
try {
    $result=$poloniex->trade()->postOrders([
        'clientOid'=>'123456',
        'side'=>'buy',
        'symbol'=>'BTCUSDTPERP',
        'type'=>'market',
        'size'=>'20',
        //'quantity'=>'',
        'leverage'=>'20',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->deleteOrder([
        'order-id'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->deleteOrders([
        'symbol'=>'BTCUSDTPERP',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->getOrder([
        'order-id'=>'123456',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->getOrders([
        'status'=>'active',
        'symbol'=>'BTCUSDTPERP',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

//position
try {
    $result=$poloniex->trade()->getPosition([
        'symbol'=>'BTCUSDTPERP',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->getPositions();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->trade()->postPositionMarginAutoDepositStatus([
        'symbol'=>'BTCUSDTPERP',
        'status'=>true
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

User API More

$poloniex=new PoloniexFuture($key,$secret,$passphrase);

try {
    $result=$poloniex->user()->getAccountOverview([
        //'currency'=>'USDT'
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

try {
    $result=$poloniex->user()->getTransactionHistory();
    print_r($result);
}catch (\Exception $e){
    print_r(json_decode($e->getMessage(),true));
}

More Test

More Api

poloniex-php's People

Contributors

zhouaini528 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.