DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.21k stars 2.04k forks source link

Buy and sell actions in sim mode don't get executed until 3-4 mins after signal #1546

Open zeldrinn opened 6 years ago

zeldrinn commented 6 years ago

System information

Describe the problem

All buy and sell actions when running the sim (with the possible exception of stop losses) get executed 3-4 minutes after the period in which the signal was sent (via s.signal = 'buy' or s.signal = 'sell'), at least when comparing entries/exits on the sim chart with logs outputted by the strategy code.

I'm using a 1-minute period, so this 3-4 minute lag means buys and sells aren't being executed until 3-4 periods after the initial signal. This happens with every strategy that I've tried (including rsi and macd). It also appears not to be exchange-specific, as it happens on both gdax and bitfinex.

Is this lag expected behavior for zenbot? If not, has anyone else experienced this? And if so, how have you gone about reducing lag between signal and execution? The 1-minute period isn't particularly useful when it takes 3-4 minutes to actually execute trades (I know it sometimes takes some time for an order to be filled, but this appears to be consistent behavior, so I would be surprised if natural order fulfillment lag were the sole cause). I wonder if there's just an issue with the simulator that perhaps doesn't occur in live trading.

I posted this on the zenbot subreddit but haven't gotten any responses yet, so hoping to get more input here.

zeldrinn commented 6 years ago

@DeviaVir can you acknowledge whether or not you've seen this issue before? At the very least it would be helpful to know whether others have seen this behavior. Thanks.

leozzo commented 6 years ago

Maybe you have markdown and markup price option > 0 ?

Inviato da iPhone

Il giorno 14 apr 2018, alle ore 05:56, Kavan McEachern notifications@github.com ha scritto:

@DeviaVir can you acknowledge whether or not you've seen this issue before? At the very least it would be helpful to know whether others have seen this behavior. Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

zeldrinn commented 6 years ago

Doesn't appear so. @leozzo how quickly do your trade actions typically get executed in sim mode? This is my full config:

{
  "asset_capital": 0,
  "avg_slippage_pct": 0.045,
  "buy_pct": 99,
  "buy_stop_pct": 0,
  "currency_capital": 1000,
  "days": 9,
  "end": 1523145600000,
  "markdown_buy_pct": 0,
  "markup_sell_pct": 0,
  "max_buy_loss_pct": 25,
  "max_sell_loss_pct": 25,
  "max_slippage_pct": 5,
  "min_periods": 52,
  "mode": "sim",
  "order_adjust_time": 5000,
  "order_poll_time": 5000,
  "order_type": "maker",
  "overbought_rsi": 82,
  "oversold_rsi": 30,
  "period": "2m",
  "period_length": "2m",
  "profit_stop_enable_pct": 0,
  "profit_stop_pct": 1,
  "rsi_divisor": 2,
  "rsi_drop": 0,
  "rsi_periods": 14,
  "rsi_recover": 3,
  "selector": {
    "exchange_id": "gdax",
    "product_id": "BTC-USD",
    "asset": "BTC",
    "currency": "USD",
    "normalized": "gdax.BTC-USD"
  },
  "sell_pct": 99,
  "sell_stop_pct": 0,
  "show_options": true,
  "start": 1522368000000,
  "stats": false,
  "strategy": "rsi",
  "verbose": false
}
ernstll commented 6 years ago

@zeldrinn

Ich have the same isue in Simulation mode. Sorry to say not on a container, on: Ubuntu 16.04 Node 9.6.1 NPM 5.8.0

Even with activated taker fees and markdown/up @0 trades take some minutes to write them in the books.

I didnt saw the behavior before.

Maybee helpful if i activate the "symmetrical = true" option.

I have an Node memory leak and the sim proceeds into the future until you stop it manualy. Afterwards the momory leak notices shows up could be completly normal as i am running 3m intervals for 60 days....

ernstll commented 6 years ago

Here is another report consisting of same delays, could be the same isue described: https://github.com/DeviaVir/zenbot/issues/1183