-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
114 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
def calculate_perc_missing(df): | ||
""" | ||
Parameters | ||
---------- | ||
df, pandas dataframe check | ||
Returns | ||
------- | ||
perc_missing, float, a float of the percentage of rows with the missing closing price | ||
""" | ||
|
||
total_missing = df.close.isna().sum() | ||
|
||
perc_missing = 0.0 | ||
if total_missing: | ||
total_tics = len(df.index) | ||
perc_missing = (total_missing / total_tics) * 100 | ||
|
||
perc_missing = round(perc_missing, 2) | ||
|
||
return perc_missing, total_missing |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from datetime import datetime | ||
import pandas as pd | ||
import numpy as np | ||
from pandas.core.base import DataError | ||
from fast_trade.calculate_perc_missing import calculate_perc_missing | ||
|
||
|
||
def test_calculate_perc_missing_none_missing(): | ||
mock_df = pd.read_csv("./test/ohlcv_data.csv.txt", parse_dates=True).set_index( | ||
"date" | ||
) | ||
|
||
[perc_missinng, total_missing] = calculate_perc_missing(mock_df) | ||
|
||
assert perc_missinng == 0.0 | ||
assert total_missing == 0 | ||
|
||
|
||
def test_calculate_perc_missing_some_missing(): | ||
mock_df = pd.read_csv("./test/ohlcv_data.csv.txt", parse_dates=True) | ||
# mock_df.index = pd.to_datetime(mock_df.date, unit="s") | ||
# print(mock_df.iloc[0].name) | ||
print(mock_df.iloc[0].date) | ||
# wtf = mock_df.index.get_loc(pd.to_datetime(1523938263, unit="s")) | ||
|
||
# print(mock_df.iloc[wtf]) | ||
mock_df.close = [np.nan, np.nan, 2, 3, 4, 5, 6, 7, 8] | ||
# print(mock_df["1523937784"]) | ||
# mock_df[1523937784].close = np.nan | ||
[perc_missinng, total_missing] = calculate_perc_missing(mock_df) | ||
# | ||
assert perc_missinng == 22.22 | ||
assert total_missing == 2 | ||
# print(perc_missinng) | ||
# assert True is False |
This file was deleted.
Oops, something went wrong.