From fbf517adfdefbfe5efa7646465df6f09ecba3be7 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Fri, 27 Dec 2019 21:40:58 -0500 Subject: [PATCH] fixes #89, fixes #85 --- pyEX/client.py | 42 +++ pyEX/stocks.py | 599 +++++++++++++++++++++++++++++++++++++- pyEX/tests/test_stocks.py | 228 ++++++++++++++- 3 files changed, 860 insertions(+), 9 deletions(-) diff --git a/pyEX/client.py b/pyEX/client.py index 7256e9a..f3f8c5d 100644 --- a/pyEX/client.py +++ b/pyEX/client.py @@ -28,12 +28,14 @@ balanceSheet, balanceSheetDF, \ batch, batchDF, bulkBatch, bulkBatchDF, \ book, bookDF, \ + bonusIssue, bonusIssueDF, \ bulkMinuteBars, bulkMinuteBarsDF, \ cashFlow, cashFlowDF, \ chart, chartDF, \ company, companyDF, \ collections, collectionsDF, \ delayedQuote, delayedQuoteDF, \ + distribution, distributionDF, \ dividends, dividendsDF, \ earnings, earningsDF, \ earningsToday, earningsTodayDF, \ @@ -63,11 +65,23 @@ priceTarget, priceTargetDF, \ quote, quoteDF, \ relevant, relevantDF, \ + returnOfCapital, returnOfCapitalDF, \ + rightsIssue, rightsIssueDF, \ + rightToPurchase, rightToPurchaseDF, \ sectorPerformance, sectorPerformanceDF, \ + securityReclassification, securityReclassificationDF, \ + securitySwap, securitySwapDF, \ shortInterest, shortInterestDF, \ splits, splitsDF, \ + spinoff, spinoffDF, \ spread, spreadDF, \ + stockSplits, stockSplitsDF, \ threshold, thresholdDF, \ + upcomingEvents, upcomingEventsDF, \ + upcomingEarnings, upcomingEarningsDF, \ + upcomingDividends, upcomingDividendsDF, \ + upcomingSplits, upcomingSplitsDF, \ + upcomingIPOs, upcomingIPOsDF, \ volumeByVenue, volumeByVenueDF, \ yesterday, yesterdayDF @@ -178,6 +192,8 @@ ('balanceSheetDF', balanceSheetDF), ('batch', batch), ('batchDF', batchDF), + ('bonusIssue', bonusIssue), + ('bonusIssueDF', bonusIssueDF), ('bulkBatch', bulkBatch), ('bulkBatchDF', bulkBatchDF), ('book', book), @@ -194,6 +210,8 @@ ('collectionsDF', collectionsDF), ('delayedQuote', delayedQuote), ('delayedQuoteDF', delayedQuoteDF), + ('distribution', distribution), + ('distributionDF', distributionDF), ('dividends', dividends), ('dividendsDF', dividendsDF), ('earnings', earnings), @@ -266,10 +284,34 @@ ('quoteDF', quoteDF), ('relevant', relevant), ('relevantDF', relevantDF), + ('returnOfCapital', returnOfCapital), + ('returnOfCapitalDF', returnOfCapitalDF), + ('rightsIssue', rightsIssue), + ('rightsIssueDF', rightsIssueDF), + ('rightToPurchase', rightToPurchase), + ('rightToPurchaseDF', rightToPurchaseDF), ('sectorPerformance', sectorPerformance), ('sectorPerformanceDF', sectorPerformanceDF), + ('securityReclassification', securityReclassification), + ('securityReclassificationDF', securityReclassificationDF), + ('securitySwap', securitySwap), + ('securitySwapDF', securitySwapDF), + ('spinoff', spinoff), + ('spinoffDF', spinoffDF), ('splits', splits), ('splitsDF', splitsDF), + ('stockSplits', stockSplits), + ('stockSplitsDF', stockSplitsDF), + ('upcomingEvents', upcomingEvents), + ('upcomingEventsDF', upcomingEventsDF), + ('upcomingEarnings', upcomingEarnings), + ('upcomingEarningsDF', upcomingEarningsDF), + ('upcomingDividends', upcomingDividends), + ('upcomingDividendsDF', upcomingDividendsDF), + ('upcomingSplits', upcomingSplits), + ('upcomingSplitsDF', upcomingSplitsDF), + ('upcomingIPOs', upcomingIPOs), + ('upcomingIPOsDF', upcomingIPOsDF), ('volumeByVenue', volumeByVenue), ('volumeByVenueDF', volumeByVenueDF), # SSE Streaming diff --git a/pyEX/stocks.py b/pyEX/stocks.py index 4c93fae..c2bceb2 100644 --- a/pyEX/stocks.py +++ b/pyEX/stocks.py @@ -2113,7 +2113,7 @@ def sectorPerformanceDF(token='', version='', filter=''): @_expire(hour=9) -def splits(symbol, timeframe='ytd', token='', version='', filter=''): +def stockSplits(symbol, timeframe='ytd', token='', version='', filter=''): '''Stock split history https://iexcloud.io/docs/api/#splits @@ -2142,7 +2142,7 @@ def _splitsToDF(s): return df -def splitsDF(symbol, timeframe='ytd', token='', version='', filter=''): +def stockSplitsDF(symbol, timeframe='ytd', token='', version='', filter=''): '''Stock split history https://iexcloud.io/docs/api/#splits @@ -2350,3 +2350,598 @@ def marketShortInterestDF(date=None, token='', version='', filter=''): 'peers': _peersToDF, 'splits': _splitsToDF } + + +def bonusIssue(symbol='', refid='', token='', version='', filter=''): + '''Bonus Issue Obtain up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#bonus-issue + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_bonus/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_bonus/' + symbol, token, version, filter) + return _getJson('time-series/advanced_bonus', token, version, filter) + + +def bonusIssueDF(symbol='', refid='', token='', version='', filter=''): + '''Bonus Issue Obtain up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#bonus-issue + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(bonusIssue(symbol, refid, token, version, filter)) + + +def distribution(symbol='', refid='', token='', version='', filter=''): + '''Distribution Obtain up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#distribution + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_distribution/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_distribution/' + symbol, token, version, filter) + return _getJson('time-series/advanced_distribution', token, version, filter) + + +def distributionDF(symbol='', refid='', token='', version='', filter=''): + '''Distribution Obtain up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#distribution + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(distribution(symbol, refid, token, version, filter)) + + +def returnOfCapital(symbol='', refid='', token='', version='', filter=''): + '''Return of capital up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#return-of-capital + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_return_of_capital/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_return_of_capital/' + symbol, token, version, filter) + return _getJson('time-series/advanced_return_of_capital', token, version, filter) + + +def returnOfCapitalDF(symbol='', refid='', token='', version='', filter=''): + '''Return of capital up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#return-of-capital + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(returnOfCapital(symbol, refid, token, version, filter)) + + +def rightsIssue(symbol='', refid='', token='', version='', filter=''): + '''Rights issue up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#rights-issue + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_rights/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_rights/' + symbol, token, version, filter) + return _getJson('time-series/advanced_rights', token, version, filter) + + +def rightsIssueDF(symbol='', refid='', token='', version='', filter=''): + '''Rights issue up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#rights-issue + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(rightsIssue(symbol, refid, token, version, filter)) + + +def rightToPurchase(symbol='', refid='', token='', version='', filter=''): + '''Right to purchase up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#right-to-purchase + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_right_to_purchase/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_right_to_purchase/' + symbol, token, version, filter) + return _getJson('time-series/advanced_right_to_purchase', token, version, filter) + + +def rightToPurchaseDF(symbol='', refid='', token='', version='', filter=''): + '''Right to purchase up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#right-to-purchase + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(rightToPurchase(symbol, refid, token, version, filter)) + + +def securityReclassification(symbol='', refid='', token='', version='', filter=''): + '''Security reclassification up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#security-reclassification + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_security_reclassification/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_security_reclassification/' + symbol, token, version, filter) + return _getJson('time-series/advanced_security_reclassification', token, version, filter) + + +def securityReclassificationDF(symbol='', refid='', token='', version='', filter=''): + '''Security reclassification up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#security-reclassification + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(securityReclassification(symbol, refid, token, version, filter)) + + +def securitySwap(symbol='', refid='', token='', version='', filter=''): + '''Security Swap up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#security-swap + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_security_swap/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_security_swap/' + symbol, token, version, filter) + return _getJson('time-series/advanced_security_swap', token, version, filter) + + +def securitySwapDF(symbol='', refid='', token='', version='', filter=''): + '''Security Swap up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#security-swap + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(securitySwap(symbol, refid, token, version, filter)) + + +def spinoff(symbol='', refid='', token='', version='', filter=''): + '''Security spinoff up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#spinoff + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_spinoff/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_spinoff/' + symbol, token, version, filter) + return _getJson('time-series/advanced_spinoff', token, version, filter) + + +def spinoffDF(symbol='', refid='', token='', version='', filter=''): + '''Security spinoff up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#spinoff + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(spinoff(symbol, refid, token, version, filter)) + + +def splits(symbol='', refid='', token='', version='', filter=''): + '''Security splits up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#splits + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if refid and symbol: + return _getJson('time-series/advanced_splits/' + symbol + '/' + refid, token, version, filter) + elif symbol: + return _getJson('time-series/advanced_splits/' + symbol, token, version, filter) + return _getJson('time-series/advanced_splits', token, version, filter) + + +def splitsDF(symbol='', refid='', token='', version='', filter=''): + '''Security splits up-to-date and detailed information on all new announcements, as well as 12+ years of historical records. + + Updated at 5am, 10am, 8pm UTC daily + + https://iexcloud.io/docs/api/#splits + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.DataFrame(splits(symbol, refid, token, version, filter)) + + +def upcomingEvents(symbol='', refid='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if symbol: + return _getJson('stock/' + symbol + '/upcoming-events' + symbol, token, version, filter) + return _getJson('stock/market/upcoming-events' + symbol, token, version, filter) + + +def upcomingEventsDF(symbol='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.io.json.json_normalize(upcomingEvents(symbol, token, version, filter)) + + +def upcomingEarnings(symbol='', refid='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if symbol: + return _getJson('stock/' + symbol + '/upcoming-earnings' + symbol, token, version, filter) + return _getJson('stock/market/upcoming-earnings' + symbol, token, version, filter) + + +def upcomingEarningsDF(symbol='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.io.json.json_normalize(upcomingEarnings(symbol, token, version, filter)) + + +def upcomingDividends(symbol='', refid='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if symbol: + return _getJson('stock/' + symbol + '/upcoming-dividends' + symbol, token, version, filter) + return _getJson('stock/market/upcoming-dividends' + symbol, token, version, filter) + + +def upcomingDividendsDF(symbol='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.io.json.json_normalize(upcomingDividends(symbol, token, version, filter)) + + +def upcomingSplits(symbol='', refid='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if symbol: + return _getJson('stock/' + symbol + '/upcoming-splits' + symbol, token, version, filter) + return _getJson('stock/market/upcoming-splits' + symbol, token, version, filter) + + +def upcomingSplitsDF(symbol='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.io.json.json_normalize(upcomingSplits(symbol, token, version, filter)) + + +def upcomingIPOs(symbol='', refid='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict: result + ''' + _raiseIfNotStr(symbol) + if symbol: + return _getJson('stock/' + symbol + '/upcoming-ipos' + symbol, token, version, filter) + return _getJson('stock/market/upcoming-ipos' + symbol, token, version, filter) + + +def upcomingIPOsDF(symbol='', token='', version='', filter=''): + '''This will return all upcoming estimates, dividends, splits for a given symbol or the market. If market is passed for the symbol, IPOs will also be included. + + https://iexcloud.io/docs/api/#upcoming-events + + Args: + symbol (string); Symbol to look up + token (string); Access token + version (string); API version + filter (string); filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + DataFrame: result + ''' + return pd.io.json.json_normalize(upcomingIPOs(symbol, token, version, filter)) diff --git a/pyEX/tests/test_stocks.py b/pyEX/tests/test_stocks.py index 0ecd01f..2682959 100644 --- a/pyEX/tests/test_stocks.py +++ b/pyEX/tests/test_stocks.py @@ -434,8 +434,8 @@ def test_cryptoDF(self): cryptoDF() - def test_splits(self): - from pyEX import splits + def test_stockSplits(self): + from pyEX import stockSplits from pyEX.common import PyEXception with patch('requests.get') as mock, \ patch('pickle.dump'): @@ -443,22 +443,22 @@ def test_splits(self): mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) - splits(SYMBOL) + stockSplits(SYMBOL) try: - splits('test', 'test') + stockSplits('test', 'test') assert False except PyEXception: pass - def test_splitsDF(self): - from pyEX import splitsDF + def test_stockSplitsDF(self): + from pyEX import stockSplitsDF with patch('requests.get') as mock, \ patch('pickle.dump'): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) - splitsDF(SYMBOL, '5y') + stockSplitsDF(SYMBOL, '5y') def test_news(self): from pyEX import news @@ -869,3 +869,217 @@ def test_optionsDF(self): c = Client() c.optionsDF(SYMBOL, 'test') + + def test_bonusIssue(self): + from pyEX import bonusIssue + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + bonusIssue() + bonusIssue(SYMBOL) + bonusIssue(SYMBOL, 'test') + + def test_bonusIssueDF(self): + from pyEX import bonusIssueDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + bonusIssueDF() + bonusIssueDF(SYMBOL) + bonusIssueDF(SYMBOL, 'test') + + def test_distribution(self): + from pyEX import distribution + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + distribution() + distribution(SYMBOL) + distribution(SYMBOL, 'test') + + def test_distributionDF(self): + from pyEX import distributionDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + distributionDF() + distributionDF(SYMBOL) + distributionDF(SYMBOL, 'test') + + def test_returnOfCapital(self): + from pyEX import returnOfCapital + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + returnOfCapital() + returnOfCapital(SYMBOL) + returnOfCapital(SYMBOL, 'test') + + def test_returnOfCapitalDF(self): + from pyEX import returnOfCapitalDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + returnOfCapitalDF() + returnOfCapitalDF(SYMBOL) + returnOfCapitalDF(SYMBOL, 'test') + + def test_rightsIssue(self): + from pyEX import rightsIssue + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + rightsIssue() + rightsIssue(SYMBOL) + rightsIssue(SYMBOL, 'test') + + def test_rightsIssueDF(self): + from pyEX import rightsIssueDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + rightsIssueDF() + rightsIssueDF(SYMBOL) + rightsIssueDF(SYMBOL, 'test') + + def test_rightToPurchase(self): + from pyEX import rightToPurchase + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + rightToPurchase() + rightToPurchase(SYMBOL) + rightToPurchase(SYMBOL, 'test') + + def test_rightToPurchaseDF(self): + from pyEX import rightToPurchaseDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + rightToPurchaseDF() + rightToPurchaseDF(SYMBOL) + rightToPurchaseDF(SYMBOL, 'test') + + def test_securityReclassification(self): + from pyEX import securityReclassification + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + securityReclassification() + securityReclassification(SYMBOL) + securityReclassification(SYMBOL, 'test') + + def test_securityReclassificationDF(self): + from pyEX import securityReclassificationDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + securityReclassificationDF() + securityReclassificationDF(SYMBOL) + securityReclassificationDF(SYMBOL, 'test') + + def test_securitySwap(self): + from pyEX import securitySwap + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + securitySwap() + securitySwap(SYMBOL) + securitySwap(SYMBOL, 'test') + + def test_securitySwapDF(self): + from pyEX import securitySwapDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + securitySwapDF() + securitySwapDF(SYMBOL) + securitySwapDF(SYMBOL, 'test') + + def test_spinoff(self): + from pyEX import spinoff + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + spinoff() + spinoff(SYMBOL) + spinoff(SYMBOL, 'test') + + def test_spinoffDF(self): + from pyEX import spinoffDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + spinoffDF() + spinoffDF(SYMBOL) + spinoffDF(SYMBOL, 'test') + + def test_splits(self): + from pyEX import splits + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + splits() + splits(SYMBOL) + splits(SYMBOL, 'test') + + def test_splitsDF(self): + from pyEX import splitsDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + splitsDF() + splitsDF(SYMBOL) + splitsDF(SYMBOL, 'test') + + def test_upcomingEvents(self): + from pyEX import upcomingEvents, upcomingEarnings, upcomingDividends, upcomingSplits, upcomingIPOs + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + upcomingEvents() + upcomingEarnings() + upcomingDividends() + upcomingSplits() + upcomingIPOs() + upcomingEvents(SYMBOL) + upcomingEarnings(SYMBOL) + upcomingDividends(SYMBOL) + upcomingSplits(SYMBOL) + upcomingIPOs(SYMBOL) + + def test_upcomingEventsDF(self): + from pyEX import upcomingEventsDF, upcomingEarningsDF, upcomingDividendsDF, upcomingSplitsDF, upcomingIPOsDF + with patch('requests.get') as mock, \ + patch('pickle.dump'): + mock.return_value = MagicMock() + mock.return_value.status_code = 200 + upcomingEventsDF() + upcomingEarningsDF() + upcomingDividendsDF() + upcomingSplitsDF() + upcomingIPOsDF() + upcomingEventsDF(SYMBOL) + upcomingEarningsDF(SYMBOL) + upcomingDividendsDF(SYMBOL) + upcomingSplitsDF(SYMBOL) + upcomingIPOsDF(SYMBOL)