Git Product home page Git Product logo

gdax's People

Contributors

mrteye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gdax's Issues

getProductHistoricRates issue

I am calling getProductHistoricRates() but this code returns Invalid JSON or null returned.

`$gdax = new Api('https://api-public.sandbox.gdax.com');
$date_1 = '2017-06-15T14:37:47.501Z';
$date_1Str = strtotime($date_1);
$date_2Str = $date_1Str + (60*5); // add 5 min

$date_1 = date(DATE_ISO8601, $date_1Str);
$date_2 = date(DATE_ISO8601, $date_2Str);

$paramArr = [
'start' => $date_1,
'end' => $date_2,
'granularity' => 60
];

$productId = 'ETH-BTC';
$productHistoricRates = $gdax->getProductHistoricRates($productId, $param = $paramArr
);`

Api does not properly reuse or destroy cURL handles when making private requests

I was running into issues with placing orders and other things and realized that I'm ending up with many, many open connections to GDAX -- the curl handle itself is staying open after private requests. This only seems to occur for private (requiring API auth) requests.

<?php

// Demo - requires lsof to show us our open conns from PHP

require 'vendor/autoload.php'; // gives us our mrteye\Gdax stuff

$apiConfig = (object) array(
  'key' => 'GDAX_API_KEY_HERE',
  'secret' => 'GDAX_API_SECRET_HERE',
  'pass' => 'GDAX_API_PASS_HERE',

  'api_url' => 'https://api-public.sandbox.gdax.com',
  'time_url' => 'https://api-public.sandbox.gdax.com/time'
);

use mrteye\Gdax\Api as Api;
use mrteye\Gdax\Auth as Auth;
use mrteye\Gdax\Exception as Exception;

$products = false;

$apiAuth = new Auth(
        $apiConfig->key,
        $apiConfig->secret,
        $apiConfig->pass,
        $apiConfig->time_url
);

// Get the GDAX API and start making calls.
$gdaxPrivate = new Api($apiConfig->api_url, $apiAuth);

echo "[INFO] Api has been instantiated.\n";
echo "[INFO] ". exec("lsof -i|grep php|grep ESTABLISHED|wc -l") . " open connections to GDAX.\n";

while (true) {

  // A private request.

  echo "[INFO] Executing cancelAllOrders (a _privateRequest)\n";
  $gdaxPrivate->cancelAllOrders($param = [
      'product_id' => 'BTC-USD'
  ]);
  echo "[INFO] ". exec("lsof -i|grep php|grep ESTABLISHED|wc -l") . " open connections to GDAX.\n";

  // A public request.

  echo "[INFO] Executing getProducts (a _publicRequest)\n";
  $gdaxPrivate->getProducts();
  echo "[INFO] ". exec("lsof -i|grep php|grep ESTABLISHED|wc -l") . " open connections to GDAX.\n";

}
$ php example.php
[INFO] Api has been instantiated.
[INFO] 0 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 2 open connections to GDAX.
[INFO] Executing getProducts (a _publicRequest)
[INFO] 2 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 3 open connections to GDAX.
[INFO] Executing getProducts (a _publicRequest)
[INFO] 3 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 4 open connections to GDAX.
[INFO] Executing getProducts (a _publicRequest)
[INFO] 4 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 5 open connections to GDAX.
[INFO] Executing getProducts (a _publicRequest)
[INFO] 5 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 6 open connections to GDAX.
[INFO] Executing getProducts (a _publicRequest)
[INFO] 6 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 7 open connections to GDAX.
[INFO] Executing getProducts (a _publicRequest)
[INFO] 7 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 8 open connections to GDAX.
[INFO] Executing getProducts (a _publicRequest)
[INFO] 8 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 9 open connections to GDAX.
[INFO] Executing getProducts (a _publicRequest)
[INFO] 9 open connections to GDAX.
[INFO] Executing cancelAllOrders (a _privateRequest)
[INFO] 10 open connections to GDAX.

Oddly, we are left with 2 open connections after the first private API call.

Over time, the number of open connections to GDAX increase manyfold -- I've had it hit near a thousand -- before things stop working due to having too many open connections.

Problem using Examples

testGDAX.zip
I have installed using composer as per instructions.
Then copy and pasted example #1
The very first thing I get is Exception about the GDX\Exception not found. I've attached my code. I'm sure "m just missing something obvious. Thank you for your help

C:\ProjectFiles\btcgdax\public>php testGDAX.php
PHP Fatal error: Uncaught Error: Class 'mrteye\Gdax\Exception' not found in C:\ProjectFiles\btcgdax\vendor\mrteye\gdax\src\Api.php:99
Stack trace:
#0 C:\ProjectFiles\btcgdax\vendor\mrteye\gdax\src\Api.php(58): mrteye\Gdax\Api->_call('GET', 'products', '')
#1 C:\ProjectFiles\btcgdax\vendor\mrteye\gdax\src\Api.php(656): mrteye\Gdax\Api->_publicRequest('GET', 'products')
#2 C:\ProjectFiles\btcgdax\public\testGDAX.php(20): mrteye\Gdax\Api->getProducts()
#3 {main}
thrown in C:\ProjectFiles\btcgdax\vendor\mrteye\gdax\src\Api.php on line 99

Fatal error: Uncaught Error: Class 'mrteye\Gdax\Exception' not found in C:\ProjectFiles\btcgdax\vendor\mrteye\gdax\src\Api.php:99
Stack trace:
#0 C:\ProjectFiles\btcgdax\vendor\mrteye\gdax\src\Api.php(58): mrteye\Gdax\Api->_call('GET', 'products', '')
#1 C:\ProjectFiles\btcgdax\vendor\mrteye\gdax\src\Api.php(656): mrteye\Gdax\Api->_publicRequest('GET', 'products')
#2 C:\ProjectFiles\btcgdax\public\testGDAX.php(20): mrteye\Gdax\Api->getProducts()
#3 {main}
thrown in C:\ProjectFiles\btcgdax\vendor\mrteye\gdax\src\Api.php on line 99

Exception call is using namespace

In your code you have throw new Exception which itself causes an error, need to change to throw new \Exception (add the slash) on all the places you use it. otherwise it is looking for an Exception class within the mrteye\Gdax namespace

enable cookies

`<?php
require_once DIR ."/app/config.php";

use mrteye\Gdax\Api as Api;
use mrteye\Gdax\Auth as Auth;

// Get the GDAX API and start making calls.
$gdax = new Api('https://api-public.sandbox.gdax.com');
$products = false;

try {
// Example usage of public calls.
$products = $gdax->getProducts();

} catch (\Exception $e) {
// echo $e->getMessage();
echo '

'. print_r($gdax->getError(), true) .'
';
}

if ($products) {
echo 'Products:

'. print_r($products, true) .'
';
} else {
echo 'Something went wrong.';
}
?>`

output

[response_headers] => Array

  | (
  | [0] => HTTP/1.1 403 Forbidden
  | [1] => Date: Fri, 02 Feb 2018 07:18:11 GMT
  | [2] => Content-Type: text/html; charset=UTF-8
  | [3] => Transfer-Encoding: chunked
  | [4] => Connection: close
  | [5] => Set-Cookie: __cfduid=d5ad71640c2fa26b4e3a3a25245e4d5a31517555891; expires=Sat, 02-Feb-19 07:18:11 GMT; path=/; domain=.gdax.com; HttpOnly
  | [6] => CF-Chl-Bypass: 1
  | [7] => Cache-Control: max-age=2
  | [8] => Expires: Fri, 02 Feb 2018 07:18:13 GMT
  | [9] => X-Frame-Options: SAMEORIGIN
  | [10] => Strict-Transport-Security: max-age=15552000; includeSubDomains; preload
  | [11] => X-Content-Type-Options: nosniff
  | [12] => Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
  | [13] => Server: cloudflare
  | [14] => CF-RAY: 3e6b60001e4269e9-LHR
  | )

Please enable cookies.

One more step

Please complete the security check to access api-public.sandbox.gdax.com

Why do I have to complete a CAPTCHA?

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

What can I do to prevent this in the future?

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

Cloudflare Ray ID: 3e6b60001e4269e9
•
Your IP: 182.72.146.186
•
Performance & security by Cloudflare

Pagination

Hello, sorry I have not found any other way how to contact you ;-)
Thanks you for the API, I am using it for a few days successfully. But now I need to use pagination and I have not found a proper way how to call the requests and set before/after parameters. Could you please give me some sample code for example how to get all open orders if there is more than 100 of them?
Thank you very much.

example has syntax error

From example #1:

$productOrderBook = $gdax->getProductOrderBook('BTC-USD', $param);
    'level' => 1
]);

should be:

$productOrderBook = $gdax->getProductOrderBook('BTC-USD', $param = [
    'level' => 1
]);

Problem using Examples #1

I am new to this and just getting started. I am on a Mac, enabled Apache, PHP and installed MySQL. Installed composer (version 1.7-dev). Ran composer require mrteye/gdax without errors.

Added dir mrteyeGDAX (with its contents) to the working dir. Updated config.php file name and added api credentials.

Created index.php inside mrteyeGDAX dir and pasted Examples #1 code. I am getting the following errors

Fatal error: Uncaught Error: Class 'mrteye\Gdax\Api' not found in /Users/josh/Sites/bot/mrteyeGDAX/index.php:6 Stack trace: #0 {main} thrown in /Users/josh/Sites/bot/mrteyeGDAX/index.php on line 6

What am I doing wrong? Thanks

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.