def test_ah_all_symbol(self):
     # method test_ah_all_symbol checks if the symbol value
     # being returned from ah_all is equal to the test symbol
     # used in unittest, aapl
     stock_symbol = 'aapl'
     test = after_hours.ah_all(stock_symbol)
     self.assertEqual(test[0], 'aapl', msg='Test ah_all symbol failed')
 def test_ah_all_symbol(self):
     # method test_ah_all_symbol checks if the symbol value
     # being returned from ah_all is equal to the test symbol
     # used in unittest, aapl
     stock_symbol = 'aapl'
     test = after_hours.ah_all(stock_symbol)
     self.assertEqual(test[0], 'aapl', msg='Test ah_all symbol failed')
 def test_ah_all_price(self):
     # method test_ah_all_price checks if the price value
     # being returned from ah_all is greater than 0
     # using symbol yhoo for testing
     stock_symbol = 'yhoo'
     test = after_hours.ah_all(stock_symbol)
     test1 = test[2][0]
     self.assertGreater(float(test1), 0, msg='Test ah_all price failed')
 def test_ah_all_time(self):
     # method test_ah_all_time checks if the time value
     # being return from ah_all is not empty using symbol
     # yhoo for testing
     stock_symbol = 'yhoo'
     test = after_hours.ah_all(stock_symbol)
     test3 = str(test)
     self.assertNotEqual(test3, '', msg='Test ah_all time failed')
 def test_ah_all_price(self):
     # method test_ah_all_price checks if the price value
     # being returned from ah_all is greater than 0
     # using symbol yhoo for testing
     stock_symbol = 'yhoo'
     test = after_hours.ah_all(stock_symbol)
     test1 = test[2][0]
     self.assertGreater(float(test1), 0, msg='Test ah_all price failed')
 def test_ah_all_time(self):
     # method test_ah_all_time checks if the time value
     # being return from ah_all is not empty using symbol
     # yhoo for testing
     stock_symbol = 'yhoo'
     test = after_hours.ah_all(stock_symbol)
     test3 = str(test)
     self.assertNotEqual(test3, '', msg='Test ah_all time failed')
 def test_ah_all_volume(self):
     # method test_ah_all_volume checks if the volume value
     # being returned from ah_all is not blank using
     # test symbol yhoo
     stock_symbol = 'yhoo'
     test = after_hours.ah_all(stock_symbol)
     test1 = test[3]
     test2 = test1[0]
     test3 = str(test2)
     self.assertNotEqual(test3, '', msg='Test ah_all volume failed')
 def test_ah_all_volume(self):
     # method test_ah_all_volume checks if the volume value
     # being returned from ah_all is not blank using
     # test symbol yhoo
     stock_symbol = 'yhoo'
     test = after_hours.ah_all(stock_symbol)
     test1 = test[3]
     test2 = test1[0]
     test3 = str(test2)
     self.assertNotEqual(test3, '', msg='Test ah_all volume failed')
Ejemplo n.º 9
0
#!/usr/bin/env python3

import after_hours
from math import *
import datetime
ticker = "ibm"

now = datetime.datetime.now()
today = "{0}-{1}-{2}".format(now.year,
                             str(now.month).zfill(2),
                             str(now.day).zfill(2))
print(today)

trades = after_hours.ah_all(ticker)[2]
open = trades[0]
close = trades[-1]
sorted_trades = sorted(trades)
low = sorted_trades[0]
high = sorted_trades[-1]
if open > close:
    trend = "bearish"
else:
    trend = "bullish"
print(high, open, close, low, trend)

#print (all_stock[2]


def bs_call(S, X, T, r, sigma):
    d1 = (log(S / X) + (r + sigma * sigma / 2.) * T) / (sigma * sqrt(T))
    d2 = d1 - sigma * sqrt(T)
Ejemplo n.º 10
0
__author__ = 'analyticsmachine'
import after_hours

print(after_hours.ah_all('ibm'))