def test_events(self): event = r.get_events(self.single_stock) assert (len(event) == 0) event = r.get_events(self.event_stock) assert (len(event) == 1) event = event[0] assert ('account' in event) assert ('cash_component' in event) assert ('chain_id' in event) assert ('created_at' in event) assert ('direction' in event) assert ('equity_components' in event) assert ('event_date' in event) assert ('id' in event) assert ('option' in event) assert ('position' in event) assert ('quantity' in event) assert ('state' in event) assert ('total_cash_amount' in event) assert ('type' in event) assert ('underlying_price' in event) assert ('updated_at' in event)
def test_events(self): event = r.get_events(self.single_stock) assert (len(event) == 0) event = r.get_events(self.event_stock) assert (len(event) != 0) event = event[0] assert ('account' in event) assert isinstance(event["account"], str) assert ('cash_component' in event) assert ('chain_id' in event) assert isinstance(event["chain_id"], str) assert ('created_at' in event) assert isinstance(event["created_at"], str) assert ('direction' in event) assert isinstance(event["direction"], str) assert ('equity_components' in event) assert isinstance(event["equity_components"], list) assert ('event_date' in event) assert isinstance(event["event_date"], str) assert ('id' in event) assert isinstance(event["id"], str) assert ('option' in event) assert isinstance(event["option"], str) assert ('position' in event) assert isinstance(event["position"], str) assert ('quantity' in event) assert isinstance(event["quantity"], float) assert ('state' in event) assert isinstance(event["state"], str) assert ('total_cash_amount' in event) assert isinstance(event["total_cash_amount"], float) assert ('type' in event) assert isinstance(event["type"], str) assert ('underlying_price' in event) assert isinstance(event["underlying_price"], float) assert ('updated_at' in event) assert isinstance(event["updated_at"], str)
def test_events(self): event = r.get_events(self.single_stock) self.assertEqual(len(event), 0) event = r.get_events(self.event_stock) self.assertEqual(len(event), 1) event = event[0] self.assertIn('account', event) self.assertIn('cash_component', event) self.assertIn('chain_id', event) self.assertIn('created_at', event) self.assertIn('direction', event) self.assertIn('equity_components', event) self.assertIn('event_date', event) self.assertIn('id', event) self.assertIn('option', event) self.assertIn('position', event) self.assertIn('quantity', event) self.assertIn('state', event) self.assertIn('total_cash_amount', event) self.assertIn('type', event) self.assertIn('underlying_price', event) self.assertIn('updated_at', event) fake_event = r.get_popularity(self.fake_stock) self.assertEqual(fake_event, '')
def getstockinfo(watchlistname): # fetch data from robinhood and parse data into a dictionary structure that stockcontainer can accept for stock in watchlist: week = r.get_historicals(stock, span='week', bounds="regular") month = r.get_historicals(stock, span='month', bounds="regular") year = r.get_historicals(stock, span='year', bounds="regular") fiveyear = r.get_historicals(stock, span='5year', bounds="regular") data = {} data['name'] = str(stock) data[ 'price'] = "Stock created using secondary method - price not supported" data['earnings'] = r.get_earnings(stock) data['events'] = r.get_events(stock) data['fundamentals'] = r.get_fundamentals(stock) x = stockcontainer(stock, data, "f**k off", week, month, year, fiveyear) traj = trajectory(x) x.addtrajectory(traj) stocksArray.append(x)
def _get(self, item): """ :param item: ticker: str :return: list of robinhood events related to ticker """ return robin_stocks.get_events(item)