btplotting icon indicating copy to clipboard operation
btplotting copied to clipboard

The last candle is missing

Open helloboy110 opened this issue 2 years ago • 6 comments

The last candle is missing

helloboy110 avatar Apr 25 '23 15:04 helloboy110

can you provide more details?

happydasch avatar Jun 30 '23 04:06 happydasch

run demos/blackly_single.py image image bokeh plot: image

helloboy110 avatar Jul 01 '23 09:07 helloboy110

The last candle is not complete so it will not be generated. Will look into changing this behaviour.

happydasch avatar Jul 09 '23 06:07 happydasch

+1. The first candlestick is not displayed, and the time of all other candlesticks is reduced by one period (1 minute) when timeframe is 1min. My code as follow:

feed = SimpleLivingData(exchange=exchange, symbol=symbol, timeframe=bt.TimeFrame.Minutes, compression=1, backfill_start=True, backfill_from=data_start)

cerebro.adddata(feed, name=symbol)
cerebro.addanalyzer(BacktraderPlottingLive, barup='red',bardown='green', port=8065,lookback=99, scheme=Tradimo(hovertool_timeformat='%F %R:%S')) 

data_start as follow: 2023-07-26_230435 The first candlestick displayed is actually the second data in the dataframe.But time is reduced by 1 minute. image The last displayed candlestick is actually the last data entry in the dataframe, but the time has been reduced by 1 minute. image

zgpnuaa avatar Jul 26 '23 15:07 zgpnuaa

It does not draw the first candlestick whether it is in live trading or backtesting. Instead, it starts drawing from the second candlestick. The overall time remains unchanged, meaning that the chart starts from the second candlestick but with time starting from the first candlestick's time. This results in all candlesticks having incorrect timestamps, as there is a shift of one period in time. For example, when plotting 30-minute candlesticks, the OHLC data displayed at 10:00 actually corresponds to 10:30 OHLC data and so on.

2023/06/19 10:00:00, 1_prenext: open:271.758-high:271.758-low:271.168-close:271.258 2023/06/19 10:30:00, 2_prenext: open:271.228-high:271.768-low:268.408-close:268.878 2023/06/19 11:00:00, 3_prenext: open:268.898-high:270.458-low:268.898-close:269.238 2023/06/19 11:30:00, 4_prenext: open:269.238-high:269.238-low:266.868-close:268.158 image image

zgpnuaa avatar Aug 03 '23 09:08 zgpnuaa

same question, expecting a nice fix ! @happydasch

qsyao avatar Oct 18 '23 16:10 qsyao

@zgpnuaa @qsyao @happydasch It seems that change this line to if c_start and c_start >= t_end can fix the missing first candle error

Balzac1799 avatar May 25 '24 14:05 Balzac1799