gazbert / bxbot

A simple Bitcoin trading bot written in Java.
MIT License
825 stars 280 forks source link

Invalid Price #54

Closed tacp17 closed 7 years ago

tacp17 commented 7 years ago

After the bot makes a buy I am getting this:

executeAlgoForWhenLastOrderWasBuy() - BTC/USD ^^^ Yay!!! Last BUY Order Id [776165985] filled at [2402.37]
144889 [main] 2017-06-16 01:33:17,496 INFO  ExampleScalpingStrategy executeAlgoForWhenLastOrderWasBuy() - BTC/USD Percentage profit (in decimal) to make for the sell order is: 0.01000000
144891 [main] 2017-06-16 01:33:17,498 INFO  ExampleScalpingStrategy executeAlgoForWhenLastOrderWasBuy() - BTC/USD Amount to add buy last order fill price: 24.0237000000
144893 [main] 2017-06-16 01:33:17,500 INFO  ExampleScalpingStrategy executeAlgoForWhenLastOrderWasBuy() - BTC/USD Placing new SELL order at ask price [2426.3937]
144894 [main] 2017-06-16 01:33:17,501 INFO  ExampleScalpingStrategy executeAlgoForWhenLastOrderWasBuy() - BTC/USD Sending new SELL order to exchange --->
145038 [main] 2017-06-16 01:33:17,645 ERROR AbstractExchangeAdapter sendNetworkRequest() - Failed to connect to Exchange due to unexpected IO error. ErrorStream Response: {"result":"error","reason":"InvalidPrice","message":"Invalid price for symbol BTCUSD: 2426.3937"}
java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.gemini.com/v1/order/new

I tried editing the price decimal places in the Gemini exchange adapter to only 2 decimal places but i get a build failure when i try to create a new bot. Thanks for any help and sorry if this isn't the right place for this.

askosyrskiy commented 7 years ago

had the same, just fix the unit test as well

Best Regards, Alexey Skosyrskiy

On Jun 15, 2017, 8:33 PM -0400, leville17 notifications@github.com, wrote:

After the bot makes a buy I am getting this:

executeAlgoForWhenLastOrderWasBuy() - BTC/USD ^^^ Yay!!! Last BUY Order Id [776165985] filled at [2402.37] 144889 [main] 2017-06-16 01:33:17,496 INFO ExampleScalpingStrategy executeAlgoForWhenLastOrderWasBuy() - BTC/USD Percentage profit (in decimal) to make for the sell order is: 0.01000000 144891 [main] 2017-06-16 01:33:17,498 INFO ExampleScalpingStrategy executeAlgoForWhenLastOrderWasBuy() - BTC/USD Amount to add buy last order fill price: 24.0237000000 144893 [main] 2017-06-16 01:33:17,500 INFO ExampleScalpingStrategy executeAlgoForWhenLastOrderWasBuy() - BTC/USD Placing new SELL order at ask price [2426.3937] 144894 [main] 2017-06-16 01:33:17,501 INFO ExampleScalpingStrategy executeAlgoForWhenLastOrderWasBuy() - BTC/USD Sending new SELL order to exchange ---> 145038 [main] 2017-06-16 01:33:17,645 ERROR AbstractExchangeAdapter sendNetworkRequest() - Failed to connect to Exchange due to unexpected IO error. ErrorStream Response: {"result":"error","reason":"InvalidPrice","message":"Invalid price for symbol BTCUSD: 2426.3937"} java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.gemini.com/v1/order/new

I tried editing the price decimal places in the Gemini exchange adapter to only 2 decimal places but i get a build failure when i try to create a new bot. Thanks for any help and sorry if this isn't the right place for this. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

askosyrskiy commented 7 years ago

image

tacp17 commented 7 years ago

Thank you!

gazbert commented 7 years ago

Bit late to the party, but I've got a fix going in.

I've only been trading on the ethbtc market due to the early US/UK trading restrictions. The market price currency (BTC) price value is limited to 5 decimal places and I was rounding in the trading strategy.

As you've discovered, when USD is the price currency, it needs rounding to 2 decimal places.

More details here: https://docs.gemini.com/rest-api/#symbols-and-minimums

gazbert commented 7 years ago

Released.