def test_tables():
    ibm = stock("IBM")
    assert ibm.chart_table().empty == False
    assert ibm.dividends_table().empty == False
    assert ibm.effective_spread_table().empty == False
    assert ibm.financials_table().empty == False
    assert ibm.volume_by_venue_table().empty == False
def test_stock_chart():
    tsla = stock("TSLA")
    # Sometimes these are returned as empty arrays; so don't
    # do much testing for now. Appears to be IEX bug.
    tsla.chart(range='20180514')
    tsla.chart(range='1d', chartReset=True)  # Returns nothing?
    tsla.chart(range='1d', chartReset=False)
    tsla.chart(range='1d', chartSimplify=True)
    tsla.chart(range='1m', chartInterval=10)
Exemple #3
0
 def get_api(self):
     """
     creates the right api based on the name
     :return: Api object
     """
     if self._api == 'iex':
         return stock(self._ticker)
     elif self._api == 'iexfinance':
         return Stock(self._ticker)
def test_quote():
    amzn = stock("amzn")
    assert bool(amzn.quote())
def test_logo():
    ibm = stock("IBM")
    assert bool(re.match('http.*.png', ibm.logo().get("url")))
def test_news():
    ibm = stock("IBM")
    assert len(ibm.news(last=1)) == 1
    assert len(ibm.news()) == 10
def test_stats():
    ibm = stock("IBM")
    assert ibm.stats().get(
        "companyName") == "International Business Machines Corporation"
def test_error():
    aapl = stock("AAPL")
    with raises(Exception):
        aapl._get("not_a_url")
def test_stock_book():
    aapl = stock("AAPL")
    assert aapl.book()['quote']['symbol'] == 'AAPL'
def test_datetime_format_as_isoformat():
    fb = stock("FB", date_format="isoformat")
    assert type(fb.delayed_quote().get("processedTime")) == str
def test_datetime_format_as_datetime():
    fb = stock("FB", date_format="datetime")
    fb.delayed_quote()
    assert type(fb.delayed_quote().get("processedTime")) == datetime.datetime
def test_delayed_quote():
    fb = stock("FB")
    fb.delayed_quote()
    assert type(fb.delayed_quote().get("delayedPrice")) == float
def test_company():
    fb = stock("FB")
    assert fb.company().get("companyName") == "Facebook Inc."
def test_chart_range_error():
    msft = stock("MSFT")
    with raises(ValueError):
        msft.chart(range="not_a_real_range")
def test_ohlc():
    ibm = stock("IBM")
    assert bool(ibm.ohlc().get('open'))
def test_earnings():
    ibm = stock("IBM")
    assert type(ibm.earnings()) == dict
Exemple #17
0
# ax.set_xlabel('x')
# ax.set_ylabel('y')
# ax.set_title('HTML tooltips', size=20)
#
# tooltip = plugins.PointHTMLTooltip(points[0], labels,
#                                    voffset=10, hoffset=10, css=css)
# plugins.connect(fig, tooltip)
#
# mpld3.show()
#
#
# np.random.seed(9615)

# generate df

df1 = stock("AAPL").chart_table(range='1m')
df2 = stock("AAPL").chart_table(range='1y')
df3 = stock("AAPL").chart_table(range='2y')
df4 = stock("AAPL").chart_table(range='5y')
df1 = df1.to_list()
df = pd.Series(df1).to_json(orient='values')

# plot line + confidence interval
fig, ax = plt.subplots()
ax.grid(True, alpha=0.3)

for key, val in df.iteritems():
    l, = ax.plot(val.index, val.values, label=key)
    ax.fill_between(val.index, 1, 3, color=l.get_color(), alpha=.4)

# define interactive legend