如图,看左边的时间,我是5分钟K线,14:10:00打印了两次,然后对比后发现一个是2483,一个是2482?为什么会发生变化?
这是获取K线和打印的部分代码
klines = api.get_kline_serial(SYMBOL, duration_seconds=60*5, data_length=data_length)
target_pos = TargetPosTask(api, SYMBOL)
quote = api.get_quote(SYMBOL)
while True:
api.wait_update()
”’
风控
”’
position = api.get_position(SYMBOL)
handle_pos_size = position[‘pos_long_his’]+position[‘pos_long_today’]
if handle_pos_size > 0:
if quote.last_price <= move_line:
# target_pos.set_target_volume(0)
logging.info(f'[sell]:trade->ping last_price is {quote.last_price}’)
”’
信号
”’
if api.is_changing(klines.iloc[-1], “datetime”):
klines[‘datetime’] = klines[‘datetime’].apply(lambda x: datetime.datetime.fromtimestamp(x / 1e9) if is_timestamp(x) else x)
logging.info(f’klines \r\n{klines}’)