Skip to content

Commit

Permalink
Fix formatting mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
kalmant committed Apr 23, 2021
1 parent a64a75d commit cffbc36
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion alpaca_trade_api/entity_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def __init__(self, raw):
class TradeV2(Remapped, _NanoTimestamped, Entity):
_tskeys = ('t',)


def __init__(self, raw):
super().__init__(trade_mapping_v2, raw)

Expand Down
8 changes: 6 additions & 2 deletions alpaca_trade_api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,16 @@ def get_latest_trade(self, symbol: str) -> TradeV2:
"""
Get the latest trade for the given symbol
"""
resp = self.data_get('/stocks/{}/trades/latest'.format(symbol), api_version='v2')
resp = self.data_get(
'/stocks/{}/trades/latest'.format(symbol),
api_version='v2')
return self.response_wrapper(resp['trade'], TradeV2)

def get_latest_quote(self, symbol: str) -> QuoteV2:
"""Get the latest quote for the given symbol"""
resp = self.data_get('/stocks/{}/quotes/latest'.format(symbol), api_version='v2')
resp = self.data_get(
'/stocks/{}/quotes/latest'.format(symbol),
api_version='v2')
return self.response_wrapper(resp['quote'], QuoteV2)

def get_clock(self) -> Clock:
Expand Down
7 changes: 3 additions & 4 deletions tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,9 @@ def test_data(reqmock):
)
latest_trade = api.get_latest_trade('AAPL')
assert latest_trade.exchange == "J"
assert latest_trade.price == 134.7
assert latest_trade.price == 134.7
assert latest_trade.size == 20
assert latest_trade.conditions == ["@","T","I"]
assert latest_trade.conditions == ["@", "T", "I"]
assert latest_trade.id == 32
assert latest_trade.tape == "C"
assert latest_trade.timestamp.day == 20
Expand All @@ -576,7 +576,6 @@ def test_data(reqmock):
assert type(latest_trade) == tradeapi.entity_v2.TradeV2
assert type(api_raw.get_latest_trade('AAPL')) == dict


# Latest quote
reqmock.get(
'https://data.alpaca.markets/v2/stocks/AAPL/quotes/latest',
Expand Down Expand Up @@ -611,7 +610,7 @@ def test_data(reqmock):
assert latest_quote.timestamp.day == 20
assert latest_quote.timestamp.nanosecond == 789
assert type(latest_quote) == tradeapi.entity_v2.QuoteV2
assert type(api_raw.get_latest_quote('AAPL')) == dict
assert type(api_raw.get_latest_quote('AAPL')) == dict


def test_watchlists(reqmock):
Expand Down

0 comments on commit cffbc36

Please sign in to comment.