cassandre-tech / cassandre-trading-bot

Create your Java crypto trading bot in minutes. Our Spring boot starter takes care of exchange connections, accounts, orders, trades, and positions so you can focus on building your strategies.
https://trading-bot.cassandre.tech
GNU General Public License v3.0
582 stars 162 forks source link

[Kucoin Sandbox] Sample application startup fails due to http error 403 thrown during Exchange initialization #686

Closed lucarosellini closed 2 years ago

lucarosellini commented 3 years ago

Release number 5.0.1

Describe the bug I get an http error 403 with response body {"code":"400007","msg":"Access denied, require more permission."} from Kucoin Sandbox while calling the endpoint https://openapi-sandbox.kucoin.com/api/v1/base-fee at Exchange initialization during the sample application startup. The Kucoin Sandbox account used is brand new.

To Reproduce

Expected behavior The application should start up correctly and the sample strategy should start to run.

Screenshots

Additional context Attaching the full application startup log with logging level for 'si.mazi.rescu' set to TRACE (API Information hidden).

cassandre-app-startup.log

straumat commented 3 years ago

Hi @lucarosellini there is a problem with Kucoin Sandbox server. I send them a message to ask them to fix it but no reply yet. For information I have a bot running 5.0.1 with Kucoin classic and it works perfectly. Kucoin sandbox is quite often down :(

lucarosellini commented 3 years ago

Thanks a lot for the info @straumat, I'll keep trying from time to time to check whether or not kucoin fixed the issue.

straumat commented 3 years ago

@lucarosellini I will keep you updated if they give a reply to my email

straumat commented 3 years ago

@lucarosellini for information, I run a strategy with positions (short and long) with 5.0.1 for 3 weeks with Kucoin and there was no problem.

straumat commented 3 years ago

@lucarosellini I'm on holiday so i will see that later but if you have time, they asked me to connect to to them throw Instagram: Sorry for the late reply, please contact us through telegram to offer you with more convenient service: @KuCoin_API_Team01

straumat commented 3 years ago

They have a problem with the sandbox API and it will last some time... 😥 Screenshot_20210809-113733_Telegram.jpg

331520 commented 3 years ago

HI @straumat!

The issue still exists for me. On 5.0.3 and 5.0.1, it doesn't matter. I try to connect to https://sandbox.kucoin.com/ but after executing mvn spring-boot:run always get an error


Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tech.cassandre.trading.bot.configuration.ExchangeAutoConfiguration': Invocation of init method failed; nested exception is tech.cassandre.trading.bot.util.exception.ConfigurationException: Unknown configuration error: si.mazi.resc

Could you please advise anything in this case? Thanks in advance, Alex

straumat commented 3 years ago

@331520 Yes. Kucoin did not update the sandbox yet. But it works perfectly in kucoin production... For the moment, I test with drymode set to true and I run in production with sandbox to false

331520 commented 3 years ago

Thank you @straumat

sebasira commented 2 years ago

Any news on this?

straumat commented 2 years ago

@sebasira nope : Screenshot (9) (

straumat commented 2 years ago

2 December - Still got the error. If you know an exchange who have a sandbox, I would be glad to change the default account in cassandre.

lucarosellini commented 2 years ago

@straumat thanks for the update. Bybit does have a very nice testnet, but unfortunately it's not yet supported by XChange.

straumat commented 2 years ago

@lucarosellini thx ! I will keep an eye on Xchange support for Bybit

straumat commented 2 years ago

I had a chat two days ago with Kucoin API support team, they say they will update the sandbox within two weeks. Hope it will work. kucoin_conversation

straumat commented 2 years ago

Testing today, I get a new error: 401. After logging to my sandbox account I created a new API access:

cassandre.trading.bot.exchange.driver-class-name=kucoin
cassandre.trading.bot.exchange.username=kucoin.cassandre.test@gmail.com
cassandre.trading.bot.exchange.passphrase=cassandre
cassandre.trading.bot.exchange.key=61d0c8a041a5330001d0d59c
cassandre.trading.bot.exchange.secret=79edb229-a9c8-449d-a476-04689eaf376b

When I try to connect, I get this new error (with 5.0.6):

java.lang.NullPointerException
    at java.base/java.math.BigDecimal.<init>(BigDecimal.java:834)
    at org.knowm.xchange.kucoin.KucoinAdapters.adaptCurrencyMetaData(KucoinAdapters.java:172)
    at org.knowm.xchange.kucoin.KucoinAdapters.adaptMetadata(KucoinAdapters.java:115)
    at org.knowm.xchange.kucoin.KucoinExchange.remoteInit(KucoinExchange.java:102)
    at org.knowm.xchange.BaseExchange.applySpecification(BaseExchange.java:113)
    at org.knowm.xchange.kucoin.KucoinExchange.applySpecification(KucoinExchange.java:53)
    at org.knowm.xchange.ExchangeFactory.createExchange(ExchangeFactory.java:130)
    at tech.cassandre.trading.bot.configuration.ExchangeAutoConfiguration.configure(ExchangeAutoConfiguration.java:150)

I need some time to go check in the XChange library.

straumat commented 2 years ago

The error comes from the fact that, for USDN, kucoin returns null values for getWithdrawalMinFee and getWithdrawalMinSize.

I created a pull request for XChange: https://github.com/knowm/XChange/pull/4376

straumat commented 2 years ago

The problem is now solved.

In src/main/resources/application.properties, change those parameters:

cassandre.trading.bot.exchange.driver-class-name=kucoin
cassandre.trading.bot.exchange.username=kucoin.cassandre.test@gmail.com
cassandre.trading.bot.exchange.passphrase=cassandre
cassandre.trading.bot.exchange.key=61d0c8a041a5330001d0d59c
cassandre.trading.bot.exchange.secret=79edb229-a9c8-449d-a476-04689eaf376b
#
# Modes
cassandre.trading.bot.exchange.modes.sandbox=true
cassandre.trading.bot.exchange.modes.dry=false

If Xchange did not close my pull request, you have to download my XChange release and build it with: mvn clean install -Dgpg.skip -Dmaven.test.skip=true.

Then in your pom.xml, set this release:

<dependency>
   <groupId>org.knowm.xchange</groupId>
   <artifactId>xchange-kucoin</artifactId>
   <version>5.0.13-SNAPSHOT</version>
</dependency>

Yout bot should start now on the sandbox !