Comments (13)
from coinbase-pro-sdk.
from coinbase-pro-sdk.
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.
from coinbase-pro-sdk.
from coinbase-pro-sdk.
from coinbase-pro-sdk.
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.
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.
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.
from coinbase-pro-sdk.
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.
$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.
Hi @tb100 , documentation is now updated
from coinbase-pro-sdk.
Related Issues (13)
- [Question] What about websockets to get real-time market data? HOT 3
- Change how the API responses to the server? HOT 4
- OrderBook level issue HOT 7
- getCurrencies() is returning an object HOT 2
- Need better install instructions. HOT 7
- Support Symfony 5.x HOT 2
- OrderData.php post_only must be of the type bool, null given HOT 4
- Unable to get currencies from API HOT 2
- Error while calling it from queue HOT 2
- local.ERROR: NotFound HOT 7
- MockingMagician\CoinbaseProSdk\Functional\Error\ApiError cURL error 3: (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for /products HOT 1
- Products Api Not working its shows error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coinbase-pro-sdk.