예제 #1
0
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
예제 #2
0
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)
예제 #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)
예제 #4
0
def test_quote():
    amzn = stock("amzn")
    assert bool(amzn.quote())
예제 #5
0
def test_logo():
    ibm = stock("IBM")
    assert bool(re.match('http.*.png', ibm.logo().get("url")))
예제 #6
0
def test_news():
    ibm = stock("IBM")
    assert len(ibm.news(last=1)) == 1
    assert len(ibm.news()) == 10
예제 #7
0
def test_stats():
    ibm = stock("IBM")
    assert ibm.stats().get(
        "companyName") == "International Business Machines Corporation"
예제 #8
0
def test_error():
    aapl = stock("AAPL")
    with raises(Exception):
        aapl._get("not_a_url")
예제 #9
0
def test_stock_book():
    aapl = stock("AAPL")
    assert aapl.book()['quote']['symbol'] == 'AAPL'
예제 #10
0
def test_datetime_format_as_isoformat():
    fb = stock("FB", date_format="isoformat")
    assert type(fb.delayed_quote().get("processedTime")) == str
예제 #11
0
def test_datetime_format_as_datetime():
    fb = stock("FB", date_format="datetime")
    fb.delayed_quote()
    assert type(fb.delayed_quote().get("processedTime")) == datetime.datetime
예제 #12
0
def test_delayed_quote():
    fb = stock("FB")
    fb.delayed_quote()
    assert type(fb.delayed_quote().get("delayedPrice")) == float
예제 #13
0
def test_company():
    fb = stock("FB")
    assert fb.company().get("companyName") == "Facebook Inc."
예제 #14
0
def test_chart_range_error():
    msft = stock("MSFT")
    with raises(ValueError):
        msft.chart(range="not_a_real_range")
예제 #15
0
def test_ohlc():
    ibm = stock("IBM")
    assert bool(ibm.ohlc().get('open'))
예제 #16
0
def test_earnings():
    ibm = stock("IBM")
    assert type(ibm.earnings()) == dict
예제 #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