Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api error code -4164 #77

Open
brtechcrypto opened this issue Jul 31, 2024 · 5 comments
Open

Api error code -4164 #77

brtechcrypto opened this issue Jul 31, 2024 · 5 comments

Comments

@brtechcrypto
Copy link

I am running the bot for futures in binance and after some time I get the next error:

python3.9 main.py --account binanceaccount1 --exchange binance --pair BTCUSDT --strategy Rci
2024-07-30 21:03:50,238 - INFO - Bot Mode : Trade
2024-07-30 21:03:50,238 - INFO - pair: BTCUSDT
2024-07-30 21:03:50,238 - INFO - timeframes: ['5m']
2024-07-30 21:03:51,393 - INFO - Starting Bot
2024-07-30 21:03:51,394 - INFO - Strategy : Rci
2024-07-30 21:03:52,523 - INFO - Websocket connected
2024-07-30 21:03:52,833 - INFO - Pair Launched: 2019-09-25T08:00:00+00:00
2024-07-30 21:03:53,127 - INFO - Current Leverage: 7.0
2024-07-30 21:03:53,179 - INFO - fetching OHLCV data - 2024-07-30 16:43:53.176590+00:00
2024-07-30 21:03:54,522 - INFO - Initial Buffer Fill - Last Candle: 2024-07-31 01:03:53+00:00
2024-07-30 21:03:54,565 - INFO - Asset: BTC Rounding: 3 - Quote: USDT Rounding: 2
2024-07-30 21:03:54,565 - INFO - Position Size: 0.000 Entry Price: 0.00
2024-07-30 21:03:54,565 - INFO - Balance : 65.3243244
2024-07-30 21:40:00,612 - INFO - pos_size: 0.0
2024-07-30 21:40:02,034 - INFO - APIError(code=-4164): Order's notional must be no smaller than 100 (unless you choose reduce only).
2024-07-30 21:40:02,035 - ERROR - Fatal error. APIError(code=-4164): Order's notional must be no smaller than 100 (unless you choose reduce only).
2024-07-30 21:40:02,041 - ERROR - Traceback (most recent call last):
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/__init__.py", line 448, in retry_binance_futures
    ret, res = func()
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures.py", line 638, in <lambda>
    retry(lambda: self.client.futures_create_order(symbol=self.pair, type=ord_type, newClientOrderId=ord_id,
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures_api.py", line 444, in futures_create_order
    return self._request_futures_api('post', 'order', True, data=params)
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures_api.py", line 259, in _request_futures_api
    return self._request(method, uri, signed, True, **kwargs)
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures_api.py", line 234, in _request
    return self._handle_response()
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures_api.py", line 268, in _handle_response
    raise BinanceAPIException(self.response)
src.exchange.binance_futures.exceptions.BinanceAPIException: APIError(code=-4164): Order's notional must be no smaller than 100 (unless you choose reduce only).

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures.py", line 1760, in __update_ohlcv
    self.strategy(t, open, close, high, low, volume)
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/strategies/Rci.py", line 58, in strategy
    self.exchange.entry("Short", False, lot)
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures.py", line 743, in entry
    self.order(id, long, ord_qty, limit=limit, stop=stop, post_only=post_only, reduce_only=reduce_only,
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures.py", line 1216, in order
    self.__new_order(ord_id, side, ord_qty, limit, stop, post_only, reduce_only,
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/exchange/binance_futures/binance_futures.py", line 638, in __new_order
    retry(lambda: self.client.futures_create_order(symbol=self.pair, type=ord_type, newClientOrderId=ord_id,
  File "/Users/billy/trading/repos/alpharptr/alpha-rptr/src/__init__.py", line 475, in retry_binance_futures
    raise FatalError(error)
src.FatalError: APIError(code=-4164): Order's notional must be no smaller than 100 (unless you choose reduce only).

what can it be wrong?
I am testing in this moment.

Thanks in advance for any explanation and help.

@praveenbm5
Copy link
Contributor

You seem to be placing an order with notional value less than 100 USDT.

APIError(code=-4164): Order's notional must be no smaller than 100 (unless you choose reduce only).

Please check the size and value in USDT of the order you are sending.

@brtechcrypto
Copy link
Author

You seem to be placing an order with notional value less than 100 USDT.

APIError(code=-4164): Order's notional must be no smaller than 100 (unless you choose reduce only).

Please check the size and value in USDT of the order you are sending.

Hi @praveenbm5 thanks for your answer, where exactly should change the size and value in USDT?

@praveenbm5
Copy link
Contributor

look into Rci->strategy function

self.exchange.entry("Long", True, lot)

this call places an order for maximum quantity allowed at the set leverage for your account on exchange for the balance in your account.

Ex. if the leverage is set to 20 (default on Binance Futures) and you have 50 USDT balance on your futures account, then this call will place an order for 20*50 = 1000 USDT worth of BTC.

@brtechcrypto
Copy link
Author

Okay, so, this error:
APIError(code=-4164): Order's notional must be no smaller than 100 (unless you choose reduce only).

was telling me that my balance which was 65 USDT and the leverage (I assume this was 1x because I didn't specify it) was less than 100 USDT, right?

Now I could find the leverage is an option that can be provided to the main.py script but I don't see where I can limit the amount of invest. For just an example, of my 65 USDT I would like to invest only 40 USDT with a leverage of 20x. How can I do it?

really appreciated your help :)

@praveenbm5
Copy link
Contributor

praveenbm5 commented Aug 1, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants