mirror of
https://github.com/hydrosquall/tiingo-python.git
synced 2025-12-17 20:04:19 +01:00
[errors] Be more specific about requiring tickers as list
This commit is contained in:
@@ -9,8 +9,14 @@ import sys
|
|||||||
import pkg_resources
|
import pkg_resources
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
from tiingo.restclient import RestClient
|
from tiingo.restclient import RestClient
|
||||||
from tiingo.exceptions import InstallPandasException, APIColumnNameError, InvalidFrequencyError, MissingRequiredArgumentError
|
from tiingo.exceptions import (
|
||||||
|
InstallPandasException,
|
||||||
|
APIColumnNameError,
|
||||||
|
InvalidFrequencyError,
|
||||||
|
MissingRequiredArgumentError)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@@ -223,7 +229,7 @@ class TiingoClient(RestClient):
|
|||||||
if metric_name is not None and metric_name not in valid_columns:
|
if metric_name is not None and metric_name not in valid_columns:
|
||||||
raise APIColumnNameError('Valid data items are: ' + str(valid_columns))
|
raise APIColumnNameError('Valid data items are: ' + str(valid_columns))
|
||||||
|
|
||||||
if metric_name is None and type(tickers) is not str:
|
if metric_name is None and isinstance(tickers, list):
|
||||||
raise MissingRequiredArgumentError("""When tickers is provided as a list, metric_name is a required argument.
|
raise MissingRequiredArgumentError("""When tickers is provided as a list, metric_name is a required argument.
|
||||||
Please provide a metric_name, or call this method with one ticker at a time.""")
|
Please provide a metric_name, or call this method with one ticker at a time.""")
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,5 @@ class APIColumnNameError(Exception):
|
|||||||
class InvalidFrequencyError(Exception):
|
class InvalidFrequencyError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MissingRequiredArgumentError(Exception):
|
class MissingRequiredArgumentError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user