GithubHelp home page GithubHelp logo

Comments (15)

cjdsellers avatar cjdsellers commented on May 20, 2024 1

I've fixed the CCXT configuration in the client factories. I don't have testnet credentials however when I changed to sandbox mode I received similar errors to the above which seemed to suggest it was directing calls to the sandbox API.

Fixes are on the latest develop branch and will make it into the next release.

from nautilus_trader.

BlackWingedKing avatar BlackWingedKing commented on May 20, 2024 1

@cjdsellers
Thank you for your quick action. I have tested on the sandbox API and it's working

from nautilus_trader.

thematz1 avatar thematz1 commented on May 20, 2024 1

Hi @cjdsellers

I am using the BinanceCCXTExecutionClient. I found adding a wallet currency balance check the other day helped execute more trades because the Insufficient Funds warning and _queue.put max 10,000 took longer to appear. Your suspicions on the async await piling up is a good one, I hadn't thought of that. My train of that was that the repeated insufficient funds may be causing binance to throttle me or penalize me? The simple buy in the EMACross example, with a wallet check, and time in force Fill or Kill, was not enough because it does not account for the total value of orders sent to queue. The orders in queue execute and have the insufficient funds return. Perhaps if i placed the wallet check elsewhere than the buy/sell function the need to calculate the total value of order in queue would be negated.

I haven't looked further since I decided to build out a strategy that is slower pace (which seems to work fine). With a balance check I am able to trade using multiple strategies with different base currencies. This was my original plan. Backtests were breaking on me when running these multiple strategies in one engine without a wallet balance check. With a wallet check there are no issues anymore. I was trading oen pair about every 600ms and it never earns enough to beat commissions, so I've taken a new route :P

Side note:
I cythonized the ema_cross_stop_entry_trail and added a rough wallet check (copy paste rather than code a function). I'll be cleaning it up in time, I usually work iteratively. If I were less new at github i'd post make a pull request (that's the right one?). I know you mentioned the risk engine and some other modules are being worked on to incorporate some of this stuff.

In the coming weeks I also plan to write a class that loads XGBoost model weights to make market price direction predictions. Without any tuning and the use of soft margins the accuracy for such models is quite good. The code block is very small and the calls to predict take about 29 seconds to execute and return a prediction.

If anyone feels like helping a GitHub newbie like me to contribute, please message me privately. :-)

Your responses are always prompt and helpful.

Thanks as always.

from nautilus_trader.

thematz1 avatar thematz1 commented on May 20, 2024 1

Unfortunately I do not have a screenshot. I'm sure you know so the rest of this message may be useless. It is a yellow WRN log that says _queue.put full and indicates that its reached 10,000 items on the queue. I would have just reproduced the error but I've already over written the strategy file with some new code. Sorry.

from nautilus_trader.

BlackWingedKing avatar BlackWingedKing commented on May 20, 2024

@cjdsellers
May I know if the binance testnet api is supported?

from nautilus_trader.

cjdsellers avatar cjdsellers commented on May 20, 2024

I haven't specifically tested on the Binance testnet. There is a chance it could work as is through CCXT if you set sandbox_mode: True in the config.

Otherwise if you could report your findings, I can make the necessary fixes to get it going.

Thanks for your interest!

from nautilus_trader.

BlackWingedKing avatar BlackWingedKing commented on May 20, 2024

@cjdsellers Thank you for your quick reply
I have tried setting sandbox_mode: True in the config of binance_ema_cross example, But I get the error

2021-05-02T10:00:19.542071Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:20.042060Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_orders
2021-05-02T10:00:20.538084Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances

I have generated testnet api keys from here and have set the environment variables in my conda environment. I'm currently running the develop branch (as I'm in windows)

full output of the run


2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode:  NAUTILUS TRADER - Algorithmic Trading Platform
2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode:  by Nautech Systems Pty Ltd.
2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode:  Copyright (C) 2015-2021. All rights reserved.
2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode:
2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode:                             .......
2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode:                          .............
2021-05-02T10:00:16.040815Z [INF] TESTER-001.TradingNode:     .                  ......... .......
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:    .                  ......... .. .......
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:    .                 ......',,,,'..........
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:    ..               ......::,,''';,.........
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:    ..                ....'o:;oo;..:'..... ''
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:     ..               ......,;,,..,:'.........
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:     ..                .........';:'..... ...
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:      ..                 .......'..... .'. .'
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:       ..                   .....    .. .. ..
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:        ..                           .' ....
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:          ..                         .. .'.
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:           ....                     .....
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:              ....                ..'..
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:                  ..................
2021-05-02T10:00:16.041800Z [INF] TESTER-001.TradingNode:
2021-05-02T10:00:16.042800Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.042800Z [INF] TESTER-001.TradingNode:  SYSTEM SPECIFICATION
2021-05-02T10:00:16.042800Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.042800Z [INF] TESTER-001.TradingNode: CPU architecture: AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD
2021-05-02T10:00:16.042800Z [INF] TESTER-001.TradingNode: CPU(s): 16 @ 3000 MHz
2021-05-02T10:00:16.042800Z [INF] TESTER-001.TradingNode: OS: Windows-10-10.0.21370-SP0
2021-05-02T10:00:16.043828Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.043828Z [INF] TESTER-001.TradingNode:  MEMORY USAGE
2021-05-02T10:00:16.043828Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.043828Z [INF] TESTER-001.TradingNode: RAM-Total: 16,557 MB
2021-05-02T10:00:16.043828Z [INF] TESTER-001.TradingNode: RAM-Used:  10,277 MB (62.10%)
2021-05-02T10:00:16.044813Z [WRN] TESTER-001.TradingNode: RAM-Avail: 6,280 MB (37.90%)
2021-05-02T10:00:16.045803Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.045803Z [INF] TESTER-001.TradingNode:  IDENTIFIERS
2021-05-02T10:00:16.045803Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.045803Z [INF] TESTER-001.TradingNode: trader_id: TESTER-001
2021-05-02T10:00:16.045803Z [INF] TESTER-001.TradingNode: system_id: b644c29f-6e8d-2888-6c02-e9ed247bedfe
2021-05-02T10:00:16.046803Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.046803Z [INF] TESTER-001.TradingNode:  VERSIONING
2021-05-02T10:00:16.046803Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.046803Z [INF] TESTER-001.TradingNode: nautilus-trader 1.117.0
2021-05-02T10:00:16.046803Z [INF] TESTER-001.TradingNode: python 3.9.2
2021-05-02T10:00:16.046803Z [INF] TESTER-001.TradingNode: numpy 1.20.2
2021-05-02T10:00:16.047803Z [INF] TESTER-001.TradingNode: scipy 1.6.1
2021-05-02T10:00:16.047803Z [INF] TESTER-001.TradingNode: pandas 1.2.4
2021-05-02T10:00:16.047803Z [INF] TESTER-001.TradingNode: redis 3.5.3
2021-05-02T10:00:16.047803Z [INF] TESTER-001.TradingNode: msgpack 1.0.2
2021-05-02T10:00:16.047803Z [INF] TESTER-001.TradingNode: =================================================================
2021-05-02T10:00:16.047803Z [INF] TESTER-001.TradingNode: Building...
2021-05-02T10:00:16.048796Z [INF] TESTER-001.DataEngine: state=INITIALIZED...
2021-05-02T10:00:16.048796Z [INF] TESTER-001.DataEngine: Config: {'qsize': 10000}.
2021-05-02T10:00:16.048796Z [INF] TESTER-001.DataCache: Initialized.
2021-05-02T10:00:16.048796Z [INF] TESTER-001.DataEngine: use_previous_close=True
2021-05-02T10:00:16.049793Z [INF] TESTER-001.RedisExecutionDatabase: Initialized.
2021-05-02T10:00:16.049793Z [INF] TESTER-001.ExecEngine: state=INITIALIZED...
2021-05-02T10:00:16.050793Z [INF] TESTER-001.ExecEngine: Config: {'qsize': 10000}.
2021-05-02T10:00:16.050793Z [INF] TESTER-001.ExecCache: Initialized.
2021-05-02T10:00:16.050793Z [INF] TESTER-001.RiskEngine: state=INITIALIZED...
2021-05-02T10:00:18.072070Z [INF] TESTER-001.ExecCache: Cached 0 accounts from database.
2021-05-02T10:00:18.073076Z [INF] TESTER-001.ExecCache: Cached 0 orders from database.
2021-05-02T10:00:18.074062Z [INF] TESTER-001.ExecCache: Cached 0 positions from database.
2021-05-02T10:00:18.074062Z [INF] TESTER-001.ExecCache: Checking data integrity...
2021-05-02T10:00:18.074062Z [INF] TESTER-001.ExecCache: Integrity check passed in 0μs.
2021-05-02T10:00:18.074062Z [INF] TESTER-001.ExecEngine: Loaded cache in 2023270μs.
2021-05-02T10:00:18.075075Z [INF] TESTER-001.ExecEngine: Registered <nautilus_trader.live.risk_engine.LiveRiskEngine object at 0x0000020CBAFA1360>.
2021-05-02T10:00:18.075075Z [INF] TESTER-001.Trader: state=INITIALIZED...
2021-05-02T10:00:18.076067Z [INF] TESTER-001.Trader: Initializing strategies...
2021-05-02T10:00:18.077076Z [INF] TESTER-001.DataEngine: Registered EMACross(id=EMACross-001).
2021-05-02T10:00:18.078066Z [INF] TESTER-001.ExecEngine: Registered EMACross(id=EMACross-001).
2021-05-02T10:00:18.078066Z [INF] TESTER-001.EMACross-001: Set ClientOrderIdGenerator count to 0.
2021-05-02T10:00:18.078066Z [INF] TESTER-001.Trader: Initialized EMACross(id=EMACross-001).
2021-05-02T10:00:18.079064Z [INF] TESTER-001.EMACross-001: No user state to load.
2021-05-02T10:00:18.079064Z [INF] TESTER-001.TradingNode: state=INITIALIZED.
2021-05-02T10:00:18.079064Z [INF] TESTER-001.TradingNode: Initialized in 2.038s.
2021-05-02T10:00:18.353084Z [INF] TESTER-001.CCXTDataClient-BINANCE: Initialized.
2021-05-02T10:00:18.353084Z [INF] TESTER-001.DataEngine: Registered CCXTDataClient-BINANCE.
2021-05-02T10:00:18.361084Z [INF] TESTER-001.CCXTExecClient-BINANCE: Initialized.
2021-05-02T10:00:18.361084Z [INF] TESTER-001.ExecEngine: Registered CCXTExecutionClient-BINANCE.
2021-05-02T10:00:18.361084Z [INF] TESTER-001.RiskEngine: Registered CCXTExecutionClient-BINANCE.
2021-05-02T10:00:18.361084Z [INF] TESTER-001.TradingNode: state=STARTING...
2021-05-02T10:00:18.362072Z [INF] TESTER-001.DataEngine: state=STARTING...
2021-05-02T10:00:18.362072Z [INF] TESTER-001.CCXTDataClient-BINANCE: Connecting...
2021-05-02T10:00:18.362072Z [INF] TESTER-001.DataEngine: state=RUNNING.
2021-05-02T10:00:18.362072Z [INF] TESTER-001.ExecEngine: state=STARTING...
2021-05-02T10:00:18.362072Z [INF] TESTER-001.CCXTExecClient-BINANCE: Connecting...
2021-05-02T10:00:18.362072Z [INF] TESTER-001.CCXTExecClient-BINANCE: API credentials validated.
2021-05-02T10:00:18.362072Z [INF] TESTER-001.Portfolio: Initialized 0 working orders.
2021-05-02T10:00:18.362072Z [INF] TESTER-001.Portfolio: Initialized 0 open positions.
2021-05-02T10:00:18.362072Z [INF] TESTER-001.Portfolio: Initialized 0 closed positions.
2021-05-02T10:00:18.362072Z [INF] TESTER-001.ExecEngine: state=RUNNING.
2021-05-02T10:00:18.362072Z [INF] TESTER-001.RiskEngine: state=STARTING...
2021-05-02T10:00:18.362072Z [INF] TESTER-001.RiskEngine: state=RUNNING.
2021-05-02T10:00:18.362072Z [INF] TESTER-001.TradingNode: Waiting for engines to initialize (5.0s timeout)...
2021-05-02T10:00:18.956084Z [INF] TESTER-001.CCXTDataClient-BINANCE: Updated 1422 instruments.
2021-05-02T10:00:18.956084Z [INF] TESTER-001.CCXTDataClient-BINANCE: Connected.
2021-05-02T10:00:19.131083Z [INF] TESTER-001.CCXTExecClient-BINANCE: Updated 1422 instruments.
2021-05-02T10:00:19.299073Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _update_balances
2021-05-02T10:00:19.299073Z [INF] TESTER-001.CCXTExecClient-BINANCE: Connected.
2021-05-02T10:00:19.301072Z [INF] TESTER-001.ExecEngine: State reconciled.
2021-05-02T10:00:19.301072Z [INF] TESTER-001.Trader: state=STARTING...
2021-05-02T10:00:19.301072Z [INF] TESTER-001.EMACross-001: state=STARTING...
2021-05-02T10:00:19.301072Z [INF] TESTER-001.EMACross-001: Registered indicator ExponentialMovingAverage(10) for ETH/USDT.BINANCE-1-MINUTE-LAST bars.
2021-05-02T10:00:19.301072Z [INF] TESTER-001.EMACross-001: Registered indicator ExponentialMovingAverage(20) for ETH/USDT.BINANCE-1-MINUTE-LAST bars.
2021-05-02T10:00:19.301072Z [INF] TESTER-001.EMACross-001: [REQ]--> DataRequest(<Bar> {'BarType': BarType(ETH/USDT.BINANCE-1-MINUTE-LAST, internal_aggregation=True), 'FromDateTime': None, 'ToDateTime': None, 'Limit': 1000}).
2021-05-02T10:00:19.301072Z [INF] TESTER-001.EMACross-001: [CMD]--> Subscribe(<Bar> {'BarType': BarType(ETH/USDT.BINANCE-1-MINUTE-LAST, internal_aggregation=True)}).
2021-05-02T10:00:19.301072Z [INF] TESTER-001.EMACross-001: state=RUNNING.
2021-05-02T10:00:19.301072Z [INF] TESTER-001.Trader: state=RUNNING.
2021-05-02T10:00:19.301072Z [INF] TESTER-001.TradingNode: state=RUNNING.
2021-05-02T10:00:19.304064Z [INF] TESTER-001.CCXTDataClient-BINANCE: Subscribed to ETH/USDT <TradeTick> data.
2021-05-02T10:00:19.304064Z [INF] TESTER-001.DataEngine: Subscribed to ETH/USDT.BINANCE <TradeTick> data.
2021-05-02T10:00:19.304064Z [INF] TESTER-001.DataEngine: Subscribed to ETH/USDT.BINANCE-1-MINUTE-LAST <Bar> data.
2021-05-02T10:00:19.517084Z [INF] TESTER-001.EMACross-001: Received <Bar[999]> data for ETH/USDT.BINANCE-1-MINUTE-LAST.
2021-05-02T10:00:19.542071Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:20.042060Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_orders
2021-05-02T10:00:20.538084Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:21.025110Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:21.521069Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_orders
2021-05-02T10:00:22.035063Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:22.532065Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:23.054070Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_orders
2021-05-02T10:00:23.526083Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:24.024083Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:24.541073Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_orders
2021-05-02T10:00:25.029083Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:25.525084Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:26.026083Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_orders
2021-05-02T10:00:26.533068Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances
2021-05-02T10:00:27.039084Z [WRN] TESTER-001.CCXTExecClient-BINANCE: AuthenticationError: binance {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} in _watch_balances

from nautilus_trader.

BlackWingedKing avatar BlackWingedKing commented on May 20, 2024

@cjdsellers I'm getting this error with the latest develop branch (ccxt-binance_ema_cross example and testnet keys)

2021-05-03T13:02:22.968634Z [INF] TESTER-001.ExecEngine: state=INITIALIZED...
2021-05-03T13:02:22.968634Z [INF] TESTER-001.ExecEngine: Config: {'qsize': 10000}.
2021-05-03T13:02:22.969626Z [INF] TESTER-001.ExecCache: Initialized.
2021-05-03T13:02:22.969626Z [INF] TESTER-001.RiskEngine: state=INITIALIZED...
Traceback (most recent call last):
  File "nautilus_trader\examples\live\ccxt-binance_ema_cross.py", line 108, in <module>
    node = TradingNode(strategies=[strategy], config=config)
  File "nautilus_trader\nautilus_trader\live\node.py", line 209, in __init__
    self._exec_engine.load_cache()
  File "nautilus_trader\\execution\\engine.pyx", line 406, in nautilus_trader.execution.engine.ExecutionEngine.load_cache
    cpdef void load_cache(self) except *:
  File "nautilus_trader\\execution\\engine.pyx", line 412, in nautilus_trader.execution.engine.ExecutionEngine.load_cache
    self.cache.cache_accounts()
  File "nautilus_trader\\execution\\cache.pyx", line 103, in nautilus_trader.execution.cache.ExecutionCache.cache_accounts
    self._cached_accounts = self._database.load_accounts()
  File "nautilus_trader\\redis\\execution.pyx", line 136, in nautilus_trader.redis.execution.RedisExecutionDatabase.load_accounts
    account = self.load_account(account_id)
  File "nautilus_trader\\redis\\execution.pyx", line 218, in nautilus_trader.redis.execution.RedisExecutionDatabase.load_account
    cdef Account account = Account(self._event_serializer.deserialize(events[0]))
  File "nautilus_trader\\serialization\\serializers.pyx", line 622, in nautilus_trader.serialization.serializers.MsgPackEventSerializer.deserialize
    [Money(v, Currency.from_str_c(k)) for k, v in unpacked[BALANCES].items()],
TypeError: Argument 'currency' has incorrect type (expected nautilus_trader.model.currency.Currency, got NoneType)

could you please look into it?

Thank you.

from nautilus_trader.

cjdsellers avatar cjdsellers commented on May 20, 2024

A yes, it looks like with the way balances are pulled out of the database if they aren't in the built-in internal _CURRENCY_MAP the deserialization step fails.

    @staticmethod
    cdef Currency from_str_c(str code):
        return _CURRENCY_MAP.get(code)

    @staticmethod
    def from_str(str code):
        """
        Parse a currency from the given string (if found).

        Parameters
        ----------
        code : str
            The code of the currency to get.

        Returns
        -------
        Currency or None

        """
        return _CURRENCY_MAP.get(code)

What we need is access to the InstrumentProvider which will have all of the currencies.

I'll come up with a fix today.

from nautilus_trader.

BlackWingedKing avatar BlackWingedKing commented on May 20, 2024

@cjdsellers
I flushed redis and this issue doesn't happen anymore

import redis
r = redis.Redis()
r.flushdb()
r.flushall()

from nautilus_trader.

cjdsellers avatar cjdsellers commented on May 20, 2024

Interesting, however you have indeed uncovered a bug - if the currency code is not found in the internal currency map, then that method will return None and cause your previously reported error.

Edit: This issue has now been resolved in 1.118.0. The RedisExecutionDatabase will now cache and persist Currency objects.

from nautilus_trader.

thematz1 avatar thematz1 commented on May 20, 2024

I have been testing live on Binance. So far the only true issue is when executing many trades with a high frequency strategy. The queue blocks up and the exchange stops processing orders. I've tried setting the time in force to FOK (for sells) and compiling the strategy. This helped delay the inevitable queue fill (10000 items) but did not resolve the problem. I think the issue may be due to submitting sells or buys that result in insufficient funds, or simply a block from such high frequency trades from Binance since my account is new and has little dollars. I am trying to implement an account balance check before creating an order. Hopefully it limits the number of unprocessed orders, ensures orders get filled, and helps keep the queue in check.

The second reason for a balance check this is to use multiple assets in one wallet with the same base currency. When one strategy has a position that has used all of the base currency any orders from another strategy result in insufficient funds which waste the 160,000 daily trade limit and bottleneck the queue.

from nautilus_trader.

cjdsellers avatar cjdsellers commented on May 20, 2024

Hi @thematz1

Are you currently using the BitmexCCXTExecutionClient?

If so then the setting for the internal ccxt client is hard coded enableRateLimit: True. I believe currently the Binance rate limit for new order submissions is 100 orders per 10 seconds. I haven't tested this myself and so can't guarantee CCXT is throttling at this rate.

The ExecutionEngine message queue is capable of processing ~750,000 messages per/second on a single thread and so depending on how fast you are sending orders I'd say they are piling up on the call to create an order.

            # Submit order and await response
            await self._client.create_order(

nautilus_trader/adapters/ccxt/execution.pyx line 895.

There is currently some work on improving the wiring to the RiskEngine which will include internal configurable throttlers.

from nautilus_trader.

cjdsellers avatar cjdsellers commented on May 20, 2024

@thematz1 is there a chance you could provide a screenshot of the queue blocking logs? We did some work on good log outputs in this case, and it would be a great example. Many thanks!

from nautilus_trader.

cjdsellers avatar cjdsellers commented on May 20, 2024

Closing this issue in favor of more specific issues which may be opened by users.

from nautilus_trader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.