Esempio n. 1
0
    def test_last_pandas(self):
        df = get_last(output_format='pandas')
        df2 = get_last("AAPL", output_format='pandas')
        df3 = get_last(["AAPL", "TSLA"], output_format='pandas')

        assert isinstance(df, DataFrame)
        assert isinstance(df2, DataFrame)
        assert isinstance(df3, DataFrame)
Esempio n. 2
0
 def test_last_too_many_symbols(self):
     with pytest.raises(ValueError):
         get_last(self.bad)
Esempio n. 3
0
    def test_last_json_default(self):
        ls = get_last()

        assert isinstance(ls, list) and len(ls) > 7500
Esempio n. 4
0
    def test_last_json_syms(self):
        ls = get_last("AAPL")
        ls2 = get_last(["AAPL", "TSLA"])

        assert isinstance(ls, list) and len(ls) == 1
        assert isinstance(ls2, list) and len(ls2) == 2
Esempio n. 5
0
a = Stock("AAPL", token="sk_434806dae94a4ee69daa8375f33da6f5")  # token is the secret API key for our account
IEX_TOKEN = 'sk_434806dae94a4ee69daa8375f33da6f5'

time_offset = timedelta(hours=3)
nyc_time = datetime.now() + time_offset

intraday_prices = []
time = []
counter = 0

while counter < 180:
    # while (nyc_time.hour > 9) and (nyc_time.minute > 30):
    # intraday_prices.append(a.get_price())

    print(counter)
    df = get_last(symbols="AAPL", output_format='pandas', token=IEX_TOKEN)
    intraday_prices.append(df['price'])

    time.append(str(nyc_time.minute) + str(":") + str(nyc_time.second))
    # time.append(nyc_time)

    Time.sleep(1)
    nyc_time = datetime.now() + time_offset

    if (nyc_time.hour > 14) and (nyc_time.minute > 30) and (nyc_time.second > 0):
        break
    counter += 1

fig, ax = plt.subplots()
ax.plot(time, intraday_prices, color="green")