sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.96k stars 2.19k forks source link

"Create_test_order" not succeeding OR not doing anything. #1232

Closed LoicRcp closed 2 years ago

LoicRcp commented 2 years ago

Describe the bug The "create_test_order" when used with a "Market_order" does add or remove assets from the test wallet.

To Reproduce Code snippet to reproduce the behavior:

from binance import Client

# Test Net Credentials
api_key = "TESTNET API KEY"
api_secret = "TESTNET API SECRET"

# Client
client = Client(api_key, api_secret, testnet=True)

# Set the USDT quantity you want to use to buy ETH
USDTQuantityToSpend = 200

# Take the market price to set a quantity to buy
to_buy_quantity = round(USDTQuantityToSpend / float(client.get_symbol_ticker(symbol="ETHUSDT")['price']), 4)

# Store the wallet state before firing the order
beforeBalance = client.get_account()['balances']

# The order itself
order = client.create_test_order(
                symbol='ETHUSDT',
                side=Client.SIDE_BUY,
                type=Client.ORDER_TYPE_MARKET,
                quantity=to_buy_quantity
            )

# Store the wallet state after the firing of the order
afterBalance = client.get_account()['balances']

# Print the state of the wallet before and after
print(f"BeforeBalance:\n\n{beforeBalance}\n\nAfterBalance:\n\n{afterBalance}")

Expected behavior The assets should not stay the same. The order seem to be successful but there is no way to see if it succeded

Environment (please complete the following information):

Logs or Additional context I don't see any similar issues on the net, but i tried every code i found and it never worked. I'm worried that i'm missing something.

LoicRcp commented 2 years ago

I found the solution, if anyone encounter this issue.

The purpose of create_test_order is NOT to make an order on the testnet side. The purpose is to CHECK if the order is correct.

To make an order on the "real" or the "testnet" side, you need to use create_order.

Apologies for making a dumb "bug report".