Merge pull request #417 from jblestang/fix_bv_key_not_present_in_ticker_data_clean

Fixing the 'BV' key being missing for USDT
This commit is contained in:
Samuel Husso 2018-01-21 19:03:33 +02:00 committed by GitHub
commit 408f120612
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View File

@ -30,8 +30,9 @@ def parse_ticker_dataframe(ticker: list) -> DataFrame:
"""
columns = {'C': 'close', 'V': 'volume', 'O': 'open', 'H': 'high', 'L': 'low', 'T': 'date'}
frame = DataFrame(ticker) \
.drop('BV', 1) \
.rename(columns=columns)
if 'BV' in frame:
frame.drop('BV', 1, inplace=True)
frame['date'] = to_datetime(frame['date'], utc=True, infer_datetime_format=True)
frame.sort_values('date', inplace=True)
return frame

View File

@ -217,3 +217,33 @@ def ticker_history():
"BV": 0.7039405
}
]
@pytest.fixture
def ticker_history_without_bv():
return [
{
"O": 8.794e-05,
"H": 8.948e-05,
"L": 8.794e-05,
"C": 8.88e-05,
"V": 991.09056638,
"T": "2017-11-26T08:50:00"
},
{
"O": 8.88e-05,
"H": 8.942e-05,
"L": 8.88e-05,
"C": 8.893e-05,
"V": 658.77935965,
"T": "2017-11-26T08:55:00"
},
{
"O": 8.891e-05,
"H": 8.893e-05,
"L": 8.875e-05,
"C": 8.877e-05,
"V": 7920.73570705,
"T": "2017-11-26T09:00:00"
}
]

View File

@ -72,3 +72,16 @@ def test_get_signal_handles_exceptions(mocker):
side_effect=Exception('invalid ticker history '))
assert get_signal('BTC-ETH', 5) == (False, False)
def test_parse_ticker_dataframe(ticker_history, ticker_history_without_bv):
columns = ['close', 'high', 'low', 'open', 'date', 'volume']
# Test file with BV data
dataframe = parse_ticker_dataframe(ticker_history)
assert dataframe.columns.tolist() == columns
# Test file without BV data
dataframe = parse_ticker_dataframe(ticker_history_without_bv)
assert dataframe.columns.tolist() == columns