import alpaca_trade_api as tradeapi

api = tradeapi.REST('PKEVTUZEU8JACZ6PH0ML',
        'exetSvXaOrexPTKblGYrgJEhR1duYtB0PwdeiCkZ',
        'https://paper-api.alpaca.markets')

# Check if the market is open now.
clock = api.get_clock()
print('The market is {}'.format('open.' if clock.is_open else 'closed.'))

# Check when the market was open on Dec. 1, 2018
date = '2018-12-01'
calendar = api.get_calendar(start=date, end=date)[0]
print('The market opened at {} and closed at {} on {}.'.format(
    calendar.open,
    calendar.close,
    date
))
import alpaca_trade_api as tradeapi

api = tradeapi.REST('PKEVTUZEU8JACZ6PH0ML',
        'exetSvXaOrexPTKblGYrgJEhR1duYtB0PwdeiCkZ',
        'https://paper-api.alpaca.markets')

# Check if the market is open now.
clock = api.get_clock()
print('The market is {}'.format('open.' if clock.is_open else 'closed.'))

# Check when the market was open on Dec. 1, 2018
date = '2018-12-01'
calendar = api.get_calendar(start=date, end=date)[0]
print('The market opened at {} and closed at {} on {}.'.format(
    calendar.open,
    calendar.close,
    date
))
# Check if the market is open now. # Check when the market was open on Dec. 1, 2018