Giter Club home page Giter Club logo

Comments (13)

tb100 avatar tb100 commented on June 14, 2024 1

from coinbase-pro-sdk.

tb100 avatar tb100 commented on June 14, 2024 1

from coinbase-pro-sdk.

MockingMagician avatar MockingMagician commented on June 14, 2024

Hi @tb100,

Are you the Terry Trusty who is talking to me via email?

Can you provide this issue with your piece of code not working.

From the description it seems to be an import defect, are you using Composer to install the library as I recommended last time?

from coinbase-pro-sdk.

tb100 avatar tb100 commented on June 14, 2024

from coinbase-pro-sdk.

tb100 avatar tb100 commented on June 14, 2024

from coinbase-pro-sdk.

tb100 avatar tb100 commented on June 14, 2024

from coinbase-pro-sdk.

MockingMagician avatar MockingMagician commented on June 14, 2024

Just for a better understanding, you're code indented a bit and highlighted, I'll take a look on it tonight :

<?php

$api = CoinbaseFacade::createDefaultCoinbaseApi('https://api.pro.coinbase.com', $_API_KEY, $_API_SECRET, $_API_PASS);

/* Start to develop here. Best regards https://php-download.com/ */include 'db_connection.php';$db = OpenCon();
$getaccounts= "N";
$getcurrencies = "Y";
$placeorder = "Y";
$placelimits ="Y";
$sellorders = "Y";

//get account informationif($getaccounts= "Y"){ echo 'getting accounts';$accts = $api->accounts()->list();$output='';file_put_contents('file.txt', $output);$i=0;foreach($accts as $myaccounts){$output = print_r($myaccounts, true);file_put_contents('file.txt', $output,FILE_APPEND);}$sql='TRUNCATE TABLE account';$result = mysqli_query($db,$sql);$fh = fopen('file.txt','r');while ($line = fgets($fh)) {  // <... Do your work with the line ...>   $item = 'id';if (substr($line,5,strlen($item)) == $item){   $strpos = strripos($line,"=>")+2;    $item= substr($line,$strpos) ;  $sqli="INSERT INTO ACCOUNT(id,currency,balance,holdFunds,availableFunds,isTradingEnabled,profileId) VALUES (";     $sqli=$sqli."'".$item."',";  }    $item = 'currency';if (substr($line,5,strlen($item)) == $item){   $strpos = strripos($line,"=>")+2;    $item= substr($line,$strpos) ;  $sqli=$sqli."'".$item."',";  }   $item = 'balance';if (substr($line,5,strlen($item)) == $item){   $strpos = strripos($line,"=>")+2;    $item= substr($line,$strpos) ;  $sqli=$sqli.$item.",";  } $item = 'holdFunds';if (substr($line,5,strlen($item)) == $item){   $strpos = strripos($line,"=>")+2;    $item= substr($line,$strpos) ; $sqli=$sqli.$item.",";  }

$item = 'availableFunds';
if (substr($line,5,strlen($item)) == $item){
    $strpos = strripos($line,"=>")+2;
    $item= substr($line,$strpos);
    $sqli=$sqli.$item.",";
}

$item = 'isTradingEnabled';

if (substr($line,5,strlen($item)) == $item){ 
    $strpos = strripos($line,"=>")+2; 
    $item= substr($line,$strpos) ; $sqli=$sqli.$item.",";  
}

$item = 'profileId';
if (substr($line,5,strlen($item)) == $item){ 
    $strpos = strripos($line,"=>")+2; 
    $item= substr($line,$strpos); 
    $sqli=$sqli."'".$item."')"; $profileId= 'YES';  
}

if (isset($profileId)){  $result = mysqli_query($db,$sqli);  unset($profileId);}

//die;





}
fclose($fh);
}//end of get accounts

//this command fails
$currencylist =$api->products()->get24hrStats('19d88d23-744c-498b-96bc-63541f326a40');

foreach($currencylist as $listitems){ echo '<pre>';$output = print_r($listitems);echo '</pre>';echo '<br>';}





echo 'about to place an order';

//Place a market order
//$orderToPlace = CoinbaseFacade::createMarketOrderToPlace('buy', 'ANKR-USD', 10.00);
//$placedOrder = $api->orders()->placeOrder($orderToPlace);

//$orderToPlace = CoinbaseFacade::createMarketOrderToPlace('buy', 'MKR-USD', 50.00);//$placedOrder = $api->orders()->placeOrder($orderToPlace);

//$placedOrderId =$api->orders()->getOrderById($placedOrder->getId()); //echo $placedOrderID; /* public static function createLimitOrderToPlace(        string $side,        string $productId,        float $price,        float $size,        ?string $timeInForce = null,        ?string $cancelAfter = null,        bool $postOnly = false,        ?string $selfTradePrevention = null,        ?string $stop = null,        ?float $stopPrice = null,        ?string $clientOrderId = null    ): LimitOrderToPlace {        return new LimitOrderToPlace(            $side,            $productId,            $price,            $size,            $timeInForce,            $cancelAfter,            $postOnly,            $selfTradePrevention,            $stop,            $stopPrice,            $clientOrderId        );    }     */  
//$orderToPlace = CoinbaseFacade::createLimitOrderToPlace('sell','ANKR-USD',.13,5,'' ,'' ,'' ,'' ,'' ,.13,'');/*

$limitOrder = CoinbaseFacade::createLimitOrderToPlace(    sell,    'ANKR-USD',    .13, // Price    5, // Sice    'TIME_IN_FORCE_GOOD_TILL_CANCELED', // The TIF flag    'CANCEL_AFTER_DAY', // A cancel after time    true, // Define if post-only or taker allowed, post_only is disabled by default   'SELF_TRADE_PREVENTION_DECREASE_AND_CANCEL', // The self trade prevention flag,    'Entry', // Direction flag for stop   .13, // Stop price    '132fb6ae-456b-4654-b4e0-d681ac05cea1' // A custom id that you defined (UUID format only));
*/

//$placedOrder = $api->orders()->placeOrder($limitOrder);

$db = CloseCon($db);
//hEADER("refresh:3");

from coinbase-pro-sdk.

MockingMagician avatar MockingMagician commented on June 14, 2024

In a quick read, I've already spotted that :

$limitOrder = CoinbaseFacade::createLimitOrderToPlace( sell, 'ANKR-USD', .13, // Price 5, // Sice 'TIME_IN_FORCE_GOOD_TILL_CANCELED', // The TIF flag 'CANCEL_AFTER_DAY', // A cancel after time true, // Define if post-only or taker allowed, post_only is disabled by default 'SELF_TRADE_PREVENTION_DECREASE_AND_CANCEL', // The self trade prevention flag, 'Entry', // Direction flag for stop .13, // Stop price '132fb6ae-456b-4654-b4e0-d681ac05cea1' // A custom id that you defined (UUID format only));

sell should be a string

from coinbase-pro-sdk.

MockingMagician avatar MockingMagician commented on June 14, 2024

Also, I've spotted that line too:

/* Start to develop here. Best regards https://php-download.com/ */include 'db_connection.php';$db = OpenCon();

Are you sure you are using composer for library import ??? Cause when I see this kind of lines, I have serious doubts about it.

from coinbase-pro-sdk.

tb100 avatar tb100 commented on June 14, 2024

from coinbase-pro-sdk.

MockingMagician avatar MockingMagician commented on June 14, 2024

composer could not find pcntl.dll

Hi @tb100 ,

This error is due to missing dependencies on your machine, you can install if you ignore dev dependencies that are not required on production, use command as is composer require --no-dev mocking-magician/coinbase-pro-sdk

from coinbase-pro-sdk.

MockingMagician avatar MockingMagician commented on June 14, 2024

$productinfo = $api->products()->get24hrStats('19d88d23-744c-498b-96bc-63541f326a40');

Hi @tb100 ,

You've spotted a lack in documentation, it is not a uuid like 19d88d23-744c-498b-96bc-63541f326a40 to pass as parameter but the product id like BTC-USD

I'm going to modify the doc quickly so that it reflects better the reality

from coinbase-pro-sdk.

MockingMagician avatar MockingMagician commented on June 14, 2024

Hi @tb100 , documentation is now updated 👏 Commit 1012842

from coinbase-pro-sdk.

Related Issues (13)

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.