Adding Binance support #86

Closed
opened 2019-04-28 00:16:40 -07:00 by sanitariu · 6 comments
sanitariu commented 2019-04-28 00:16:40 -07:00 (Migrated from github.com)

I tried adding Binance support.
Everything seems fine except when trading.
This is the error I have:

arbitrader_1  | 2019-04-27 17:05:31.906  INFO 1 --- [   scheduling-1] c.r.arbitrader.service.TradingService    : ***** ENTRY *****
arbitrader_1  | 2019-04-27 17:05:33.552  INFO 1 --- [   scheduling-1] c.r.arbitrader.service.TradingService    : Updated account balances: Binance $49.11 + Quoine $49.97 = $99.08
arbitrader_1  | 2019-04-27 17:05:33.689  INFO 1 --- [   scheduling-1] c.r.arbitrader.service.TradingService    : Entry spread: 0.00724588
arbitrader_1  | 2019-04-27 17:05:33.823  INFO 1 --- [   scheduling-1] c.r.arbitrader.service.TradingService    : Exit spread target: -0.19975412
arbitrader_1  | 2019-04-27 17:05:33.958  INFO 1 --- [   scheduling-1] c.r.arbitrader.service.TradingService    : Long entry: Binance XRP/USD 99.58791 @ 0.29120000 (0E-8 slip) = $28.9999993920000
arbitrader_1  | 2019-04-27 17:05:34.095  INFO 1 --- [   scheduling-1] c.r.arbitrader.service.TradingService    : Short entry: Quoine XRP/USD 98.87 @ 0.29331 (0.00000 slip) = $28.9995597
arbitrader_1  | 2019-04-27 17:05:34.547 ERROR 1 --- [   scheduling-1] c.r.arbitrader.service.TradingService    : Exchange returned an error executing trade!
arbitrader_1  |
arbitrader_1  | org.knowm.xchange.exceptions.ExchangeException: Filter failure: LOT_SIZE
arbitrader_1  |  at org.knowm.xchange.binance.BinanceErrorAdapter.adapt(BinanceErrorAdapter.java:45)
arbitrader_1  |  at org.knowm.xchange.binance.service.BinanceTradeService.placeOrder(BinanceTradeService.java:187)
arbitrader_1  |  at org.knowm.xchange.binance.service.BinanceTradeService.placeLimitOrder(BinanceTradeService.java:131)
arbitrader_1  |  at com.r307.arbitrader.service.TradingService.executeOrderPair(TradingService.java:712)
arbitrader_1  |  at com.r307.arbitrader.service.TradingService.lambda$tick$13(TradingService.java:438)
arbitrader_1  |  at java.util.ArrayList.forEach(ArrayList.java:1257)
arbitrader_1  |  at com.r307.arbitrader.service.TradingService.tick(TradingService.java:306)
arbitrader_1  |  at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
arbitrader_1  |  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
arbitrader_1  |  at java.lang.reflect.Method.invoke(Method.java:498)
arbitrader_1  |  at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
arbitrader_1  |  at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
arbitrader_1  |  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
arbitrader_1  |  at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
arbitrader_1  |  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
arbitrader_1  |  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
arbitrader_1  |  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
arbitrader_1  |  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
arbitrader_1  |  at java.lang.Thread.run(Thread.java:748)

Seems like LOT_SIZE is not OK. I did put $29 for maximum trade value but bot seems to use values like $28.9995597 or so. Can we use value without decimal split like $29 or even $30 ?

I tried adding Binance support. Everything seems fine except when trading. This is the error I have: ``` arbitrader_1 | 2019-04-27 17:05:31.906 INFO 1 --- [ scheduling-1] c.r.arbitrader.service.TradingService : ***** ENTRY ***** arbitrader_1 | 2019-04-27 17:05:33.552 INFO 1 --- [ scheduling-1] c.r.arbitrader.service.TradingService : Updated account balances: Binance $49.11 + Quoine $49.97 = $99.08 arbitrader_1 | 2019-04-27 17:05:33.689 INFO 1 --- [ scheduling-1] c.r.arbitrader.service.TradingService : Entry spread: 0.00724588 arbitrader_1 | 2019-04-27 17:05:33.823 INFO 1 --- [ scheduling-1] c.r.arbitrader.service.TradingService : Exit spread target: -0.19975412 arbitrader_1 | 2019-04-27 17:05:33.958 INFO 1 --- [ scheduling-1] c.r.arbitrader.service.TradingService : Long entry: Binance XRP/USD 99.58791 @ 0.29120000 (0E-8 slip) = $28.9999993920000 arbitrader_1 | 2019-04-27 17:05:34.095 INFO 1 --- [ scheduling-1] c.r.arbitrader.service.TradingService : Short entry: Quoine XRP/USD 98.87 @ 0.29331 (0.00000 slip) = $28.9995597 arbitrader_1 | 2019-04-27 17:05:34.547 ERROR 1 --- [ scheduling-1] c.r.arbitrader.service.TradingService : Exchange returned an error executing trade! arbitrader_1 | arbitrader_1 | org.knowm.xchange.exceptions.ExchangeException: Filter failure: LOT_SIZE arbitrader_1 | at org.knowm.xchange.binance.BinanceErrorAdapter.adapt(BinanceErrorAdapter.java:45) arbitrader_1 | at org.knowm.xchange.binance.service.BinanceTradeService.placeOrder(BinanceTradeService.java:187) arbitrader_1 | at org.knowm.xchange.binance.service.BinanceTradeService.placeLimitOrder(BinanceTradeService.java:131) arbitrader_1 | at com.r307.arbitrader.service.TradingService.executeOrderPair(TradingService.java:712) arbitrader_1 | at com.r307.arbitrader.service.TradingService.lambda$tick$13(TradingService.java:438) arbitrader_1 | at java.util.ArrayList.forEach(ArrayList.java:1257) arbitrader_1 | at com.r307.arbitrader.service.TradingService.tick(TradingService.java:306) arbitrader_1 | at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source) arbitrader_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) arbitrader_1 | at java.lang.reflect.Method.invoke(Method.java:498) arbitrader_1 | at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) arbitrader_1 | at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) arbitrader_1 | at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) arbitrader_1 | at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) arbitrader_1 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) arbitrader_1 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) arbitrader_1 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) arbitrader_1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) arbitrader_1 | at java.lang.Thread.run(Thread.java:748) ``` Seems like LOT_SIZE is not OK. I did put $29 for maximum trade value but bot seems to use values like $28.9995597 or so. Can we use value without decimal split like $29 or even $30 ?
sanitariu commented 2019-04-28 00:25:05 -07:00 (Migrated from github.com)

Here i found more information. Maybe its specific for each exchange:
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#filters
Check for LOT_SIZE how to pass....

Here i found more information. Maybe its specific for each exchange: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#filters Check for LOT_SIZE how to pass....
scionaltera commented 2019-04-28 12:07:03 -07:00 (Migrated from github.com)

I edited your original post slightly to make the logs more readable. Hope you don't mind.

Thanks for working on this, and for the link to the LOT_SIZE documentation. I'll take a look and see if I can figure out what we need to do.

I edited your original post slightly to make the logs more readable. Hope you don't mind. Thanks for working on this, and for the link to the `LOT_SIZE` documentation. I'll take a look and see if I can figure out what we need to do.
scionaltera commented 2019-04-28 12:45:51 -07:00 (Migrated from github.com)

It looks like XChange provides a way for me to look up the lot size for each currency pair on each exchange. I'll experiment with that and try adjusting the trade volume if there is an applicable lot size. I'll have to rely on you to test since I don't have an account with Binance.

It looks like XChange provides a way for me to look up the lot size for each currency pair on each exchange. I'll experiment with that and try adjusting the trade volume if there is an applicable lot size. I'll have to rely on you to test since I don't have an account with Binance.
sanitariu commented 2019-04-29 01:14:05 -07:00 (Migrated from github.com)

Thanks for editing. It was my blind copy/paste from terminal :(
I have binance account and wil use it in trading even if it did make some errors.... so you can count on me for testing and bug reporting. Binance have high fees like 0.1 but its okay for me.

Thanks for editing. It was my blind copy/paste from terminal :( I have binance account and wil use it in trading even if it did make some errors.... so you can count on me for testing and bug reporting. Binance have high fees like 0.1 but its okay for me.
scionaltera commented 2019-05-03 21:47:43 -07:00 (Migrated from github.com)

I have pushed a branch with code that knows how to get an exchange's lot size if it has one and round orders to the correct volumes. I don't think any of the exchanges I use have this feature though, so if you could try it out I'd appreciate it. The branch is named stepped-lot-size. If you're using Docker there is a tag you can pull with that same name. Let me know how it works out.

I have pushed a branch with code that knows how to get an exchange's lot size if it has one and round orders to the correct volumes. I don't think any of the exchanges I use have this feature though, so if you could try it out I'd appreciate it. The branch is named `stepped-lot-size`. If you're using Docker there is a tag you can pull with that same name. Let me know how it works out.
scionaltera commented 2019-05-15 13:02:19 -07:00 (Migrated from github.com)

Closing for now. If it doesn't work, go ahead and open a new issue.

Closing for now. If it doesn't work, go ahead and open a new issue.
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
scion/arbitrader#86
No description provided.