amandris / arbitrage-trading-bot

Bot to automate trading orders between Bitcoin exchanges to make some profit.
MIT License
42 stars 34 forks source link

Bitstamp error #4

Closed sanitariu closed 5 years ago

sanitariu commented 5 years ago

Anyone can help with this error:

In BitstampService.php line 147:

[Symfony\Component\Debug\Exception\ContextErrorException] Warning: Illegal string offset 'datetime'

This is the line in code:

    $timestamp = new \DateTime('now', new \DateTimeZone('Europe/Madrid'));

I am using php 7.3.3

amandris commented 5 years ago

I think the line where the error pops in is this one:

$timestamp = new \DateTime($order['datetime'], new \DateTimeZone('Europe/Madrid'));

When do you get the error? Placing new buying/selling order or retrieving the open orders?

Because it seems like there is no $order['datetime'] index on the data array retrieved from bitstamp. Try to inspect or dump variable $order. It'll help you to fix the issue.

sanitariu commented 5 years ago

Hello, On one terminal i run: dri@dri ~/miner/test/arbitrage-trading-bot $ bin/console server:run 192.168.1.166:8000

[OK] Server listening on http://192.168.1.166:8000

// Quit the server with CONTROL-C.

PHP 7.3.4 Development Server started at Mon Apr 29 18:55:33 2019 Listening on http://192.168.1.166:8000 Document root is /home/dri/miner/test/arbitrage-trading-bot/web Press Ctrl-C to quit.

Which runs fine no errors/warnings

And on the other terminal i run:

dri@dri ~/miner/test/arbitrage-trading-bot $ bin/console bot:trade 29/04/2019 17:56:58 bitstamp Ask:5,145.08 Bid:5,142.38 kraken Ask:5,144.20 Bid:5,143.00 okcoin Ask:5,143.36 Bid:5,145.58 cexio Ask:5,224.90 Bid:5,222.60

In BitstampService.php line 147:

Warning: Illegal string offset 'datetime'

bot:trade [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--]

Program exited. This is first run no orders at all. Seems like the problem is retrieving orders.

sanitariu commented 5 years ago

Any help how to fix this datetime issue ? Maybe order is empty because actually there are no orders yet. I do not know what to print and where in the code.

sanitariu commented 5 years ago

Problem solved. Wrong api