Skip to content

Commit

Permalink
N/A check was removed from quotation downloaders but was put into onl…
Browse files Browse the repository at this point in the history
…y one place in _store_quotations() method
  • Loading branch information
titov-vv committed Mar 26, 2024
1 parent b4167bb commit daf9589
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion jal/db/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def quotes(self, begin: int, end: int, currency_id: int) -> list:
quotes.append((timestamp, quote))
return quotes

# Returns tuple (begin_timestamp: int, end_timestamp: int) that defines timestamp range for which quotest are
# Returns tuple (begin_timestamp: int, end_timestamp: int) that defines timestamp range for which quotations are
# available in database for given currency
def quotes_range(self, currency_id: int) -> tuple:
try:
Expand Down
8 changes: 1 addition & 7 deletions jal/net/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def _adjust_start(self, asset: JalAsset, currency_id: int, start) -> int:

def _store_quotations(self, asset: JalAsset, currency_id: int, data: pd.DataFrame) -> None:
if data is not None:
data.dropna(inplace=True)
quotations = []
for date, quote in data.iterrows(): # Date in pandas dataset is in UTC by default
quotations.append({'timestamp': int(date.timestamp()), 'quote': quote[0]})
Expand Down Expand Up @@ -193,7 +194,6 @@ def CBR_DataReader(self, currency, start_timestamp, end_timestamp):
data['Multiplier'] = data['Multiplier'].apply(Decimal)
data['Rate'] = data['Rate'] / data['Multiplier']
data.drop('Multiplier', axis=1, inplace=True)
data.dropna(inplace=True)
rates = data.set_index("Date")
return rates

Expand All @@ -212,7 +212,6 @@ def ECB_DataReader(self, currency, start_timestamp, end_timestamp):
data['Rate'] = data['Rate'].apply(Decimal) # Convert from str to Decimal
data['Rate'] = Decimal('1') / data['Rate']
data['Rate'] = data['Rate'].apply(round, args=(10, ))
data.dropna(inplace=True)
rates = data.set_index("Date")
return rates

Expand Down Expand Up @@ -392,7 +391,6 @@ def MOEX_DataReader(self, asset, currency_id, start_timestamp, end_timestamp, up
data = pd.DataFrame(quotes, columns=["Date", "Close"])
data['Date'] = pd.to_datetime(data['Date'], format="%Y-%m-%d")
data['Close'] = data['Close'].apply(Decimal)
data.dropna(inplace=True)
close = data.set_index("Date")
return close

Expand All @@ -408,7 +406,6 @@ def Yahoo_Downloader(self, asset, currency_id, start_timestamp, end_timestamp, s
data['Date'] = pd.to_datetime(data['Date'], format="%Y-%m-%d")
data['Close'] = data['Close'].apply(Decimal)
data = data.drop(columns=['Open', 'High', 'Low', 'Adj Close', 'Volume'])
data.dropna(inplace=True)
close = data.set_index("Date")
return close

Expand Down Expand Up @@ -447,7 +444,6 @@ def Euronext_DataReader(self, asset, currency_id, start_timestamp, end_timestamp
data['Close'] = data['Close'].apply(Decimal)
data = data.drop(columns=['Open', 'High', 'Low', 'Last', 'Number of Shares', 'Number of Trades', 'Turnover', 'vwap'],
errors='ignore') # Ignore errors as some columns might be missing
data.dropna(inplace=True)
close = data.set_index("Date")
close.sort_index(inplace=True)
return close
Expand Down Expand Up @@ -482,7 +478,6 @@ def TMX_Downloader(self, asset, _currency_id, start_timestamp, end_timestamp):
data['Date'] = pd.to_datetime(data['Date'], format="%Y-%m-%d")
data['Close'] = data['Close'].apply(str) # Convert from float to str
data['Close'] = data['Close'].apply(Decimal) # Convert from str to Decimal
data.dropna(inplace=True)
close = data.set_index("Date")
close.sort_index(inplace=True)
return close
Expand Down Expand Up @@ -563,7 +558,6 @@ def Coinbase_Downloader(self, asset, currency_id, start_timestamp, end_timestamp
quotes.append({"Date": datetime.utcfromtimestamp(ts), "Close": quote})
data = pd.DataFrame(quotes, columns=["Date", "Close"])
data['Close'] = data['Close'].apply(Decimal)
data.dropna(inplace=True)
close = data.set_index("Date")
return close

Expand Down

0 comments on commit daf9589

Please sign in to comment.