amandris / arbitrage-trading-bot

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

Cannot use object of type stdClass as array" In ItbitService.php line 148: #2

Open amandris opened 5 years ago

amandris commented 5 years ago

Hi Amandris,

I was successful in getting the "bin/console bot:trade" command to work, and while the "Ticker" now populates in the app, I'm receiving the following error once the command is inserted into the command line. Do you have any recommendations on how to resolve?

"app@XXXXXX:~/directory/app$ bin/console bot:trade 05/02/2019 07:29:59 bitstamp Ask:3,418.07 Bid:3,418.06 okcoin Ask:3,416.03 Bid:3,417.72 binance Ask:3,465.98 Bid:3,465.95

In ItbitService.php line 148:

Cannot use object of type stdClass as array"

Thank you in advance for your help on this!

Originally posted by @NH603 in https://github.com/amandris/arbitrage-trading-bot/issues/1#issuecomment-460528898

amandris commented 5 years ago

Itbit seems to work fine at this moment. QuadrigaCX and OkCoin are offline right now so avoid those exchanges. Which of the exchanges have you enable in config.yml? Did you set the api keys and secrets for those exchanges in the parameters.yml file? Remember to create your own api keys. Some of the exchanges force you to confirm your identity.

NH603 commented 5 years ago

Hi Amandris, thank you so much for your continued support! I appreciate it more than you know.

Please find a screenshot below of what I'm seeing on the main dashboard. You'll see I've enabled Binance, Bitstamp and Kraken, but with their API keys/secrets in the parameters.yml and with Binance enabled as "true" in config.yml. Unfortunately, the "Differences" chart in the app does not populate yet. When entering the bot/trade command, I'm also still receive the error of: "In ItbitService.php line 148: Cannot use object of type stdClass as array." Any recommendations to help officially solve the good puzzle? :)

image

Thanks again for all the support!

amandris commented 5 years ago

Perhaps the exchange Itbit is returning a non valid value. I suggest you to inspect the value the line $this->itbitHelper->wallet() in ItbitService.php [148] returns. It will help you to find the problem. Also, remember you should have a wallet created on your ItBit account. I you haven't done it, just go to https://exchange.itbit.com/accounts and click on the +NEW ACCOUNT button.

NH603 commented 5 years ago

Thank you very much for the continued support Gustavo! I’ve followed the guidance below and ensured I have a wallet created on Itbit, but I continue to receive the same error. I’ve noticed throughout that I’ve had to add a few bundle items (e.g. FOS, etc.) to the AppKernel.php in order for the build to work, and perhaps that’s where my mis-configuration sits? Do you mind taking a quick look at the AppKernel.php to see if that’s the trouble?

Thanks again for all your support, I feel so close, but yet so far!! :)

On Feb 6, 2019, at 1:47 AM, Gustavo Miguélez notifications@github.com wrote:

Perhaps the exchange Itbit is returning a non valid value. I suggest you to inspect the value the line $this->itbitHelper->wallet() in ItbitService.php [148] returns. It will help you to find the problem. Also, remember you should have a wallet created on your ItBit account. I you haven't done it, just go to https://exchange.itbit.com/accounts and click on the +NEW ACCOUNT button.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

amandris commented 5 years ago

I don't believe the problem is in the AppKernel.php file. I'm no able to replicate the error on my system so I'm gonna need some help from you. Could you inspect or dump the result of the $this->itbitHelper->wallet()call? The code expects an array from the ItBit API but it's getting something different. Maybe some kind of error message. Please let me know the result of that call. Thank you.

NH603 commented 5 years ago

After inspecting, it looks like that call is going through successfully, but the Dashboard in the UI is not populating. In fact, it looks like all the AJAX calls and POSTS are going through. Would this be related to the environment running in DEV right now and not prod? I can share direct debug URL with you if you'd like - if so, please feel free to share email and I can send over URL.

Thanks again Amandris.

amandris commented 5 years ago

If some exception is thrown on the bot:trade command execution, the data on the dashboard is no completely populated. That's why you get that result. Please share the data returned by the $this->itbitHelper->wallet() method when the exchange is Itbit. That's the key to solve this issue.

One quick fix you can also try is to temporarily disable Itbit exchange on the config.yml and try to trade with any other exchange pair.

NH603 commented 5 years ago

Thank you Amandris! Here's the data returned by $this->itbitHelper->wallet() :

-su: syntax error near unexpected token `('

As you review, please let me know if you have any recommendation on how to best fix?

NH603 commented 5 years ago

After disabling Itbit, I'm receiving an error with Kraken when attempting to run "bot:trade" command. I'm not sure if this is all interrelated with the issue we're receiving above with Itbit?

php bin/console bot:trade 11/02/2019 22:00:22 bitstamp Ask:3,596.22 Bid:3,595.11 kraken Ask:3,597.60 Bid:3,597.50 binance Ask:3,643.05 Bid:3,642.01

In KrakenService.php line 165:

Notice: Undefined index: result

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

NH603 commented 5 years ago

Could this perhaps be the result of a mismatch in server times? Today the code is hard coded with Madrid.

On Feb 11, 2019, at 1:16 AM, Gustavo Miguélez notifications@github.com wrote:

If some exception is thrown on the bot:trade command execution, the data on the dashboard is no completely populated. That's why you get that result. Please share the data returned by the $this->itbitHelper->wallet() method when the exchange is Itbit. That's the key to solve this issue.

One quick fix you can also try is to temporarily disable Itbit exchange on the config.yml and try to trade with any other exchange pair.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.