mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Add test for NaT problematic
This commit is contained in:
parent
926b017981
commit
6191288ff9
|
@ -1,5 +1,4 @@
|
|||
from datetime import date, datetime
|
||||
from pandas import isnull
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
@ -357,8 +356,6 @@ class PairHistory(BaseModel):
|
|||
class Config:
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.strftime(DATETIME_PRINT_FORMAT)
|
||||
# needed for aslong NaT doesn't work with strftime
|
||||
if not isnull(v) else "",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import psutil
|
|||
from dateutil.relativedelta import relativedelta
|
||||
from dateutil.tz import tzlocal
|
||||
from numpy import NAN, inf, int64, mean
|
||||
from pandas import DataFrame, NaT, isnull
|
||||
from pandas import DataFrame, isnull
|
||||
|
||||
from freqtrade import __version__
|
||||
from freqtrade.configuration.timerange import TimeRange
|
||||
|
|
|
@ -7,6 +7,7 @@ from datetime import datetime, timedelta, timezone
|
|||
from pathlib import Path
|
||||
from unittest.mock import ANY, MagicMock, PropertyMock
|
||||
|
||||
import pandas as pd
|
||||
import pytest
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
|
@ -1181,6 +1182,24 @@ def test_api_pair_candles(botclient, ohlcv_history):
|
|||
0.7039405, 8.885e-05, 0, 0, 1511686800000, None, None]
|
||||
|
||||
])
|
||||
ohlcv_history['sell'] = ohlcv_history['sell'].astype('float64')
|
||||
ohlcv_history.at[0, 'sell'] = float('inf')
|
||||
ohlcv_history['date1'] = ohlcv_history['date']
|
||||
ohlcv_history.at[0, 'date1'] = pd.NaT
|
||||
|
||||
ftbot.dataprovider._set_cached_df("XRP/BTC", timeframe, ohlcv_history)
|
||||
rc = client_get(client,
|
||||
f"{BASE_URI}/pair_candles?limit={amount}&pair=XRP%2FBTC&timeframe={timeframe}")
|
||||
assert_response(rc)
|
||||
assert (rc.json()['data'] ==
|
||||
[['2017-11-26 08:50:00', 8.794e-05, 8.948e-05, 8.794e-05, 8.88e-05, 0.0877869,
|
||||
None, 0, None, '', 1511686200000, None, None],
|
||||
['2017-11-26 08:55:00', 8.88e-05, 8.942e-05, 8.88e-05,
|
||||
8.893e-05, 0.05874751, 8.886500000000001e-05, 1, 0.0, '2017-11-26 08:55:00',
|
||||
1511686500000, 8.893e-05, None],
|
||||
['2017-11-26 09:00:00', 8.891e-05, 8.893e-05, 8.875e-05, 8.877e-05,
|
||||
0.7039405, 8.885e-05, 0, 0.0, '2017-11-26 09:00:00', 1511686800000, None, None]
|
||||
])
|
||||
|
||||
|
||||
def test_api_pair_history(botclient, ohlcv_history):
|
||||
|
|
Loading…
Reference in New Issue
Block a user