Exemple #1
0
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 25 09:56:39 2018

@author: kuifenhu
"""
from iexfinance import get_market_book

a = get_market_book("LPX")
#%%
a = get_market_deep("KEYS")
b = a['trades']
for c in b:
    print(
        datetime.datetime.fromtimestamp(int(c['timestamp']) /
                                        1000).strftime('%Y-%m-%d %H:%M:%S') +
        ' Price::$' + str(c['price']) + ', Size ' + str(c['size']))
#%%
import plotly.plotly as py
import plotly.graph_objs as go
from datetime import datetime
a = p1.ts_result[0]['t']
df = pd.DataFrame.from_dict(p1.ts_result[0]['data'])
dt = pd.DataFrame.from_dict({'Date': a})
trace = go.Candlestick(x=dt.Date,
                       open=df.open,
                       high=df.high,
                       low=df.low,
                       close=df.close)
data = [trace]
py.iplot(data, filename='simple_candlestick')
Exemple #2
0
    def test_Book_pandas(self):
        df = get_market_book("AAPL", output_format='pandas')
        df2 = get_market_book(["AAPL", "TSLA"], output_format='pandas')

        assert isinstance(df, DataFrame)
        assert isinstance(df2, DataFrame)
Exemple #3
0
 def test_Book_json_default(self):
     with pytest.raises(ValueError):
         get_market_book()
Exemple #4
0
    def test_Book_json_syms(self):
        js = get_market_book("AAPL")
        js2 = get_market_book(["AAPL", "TSLA"])

        assert isinstance(js, dict) and len(js) == 1
        assert isinstance(js2, dict) and len(js2) == 2
Exemple #5
0
 def test_Book_too_many_symbols(self):
     with pytest.raises(ValueError):
         get_market_book(self.bad)