Last active
July 19, 2020 23:58
-
-
Save alg0trader/b8d2cc1021851f547a89260271ee5ade to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import alpaca_trade_api as tradeapi | |
base_url = 'https://paper-api.alpaca.markets' | |
key_id = os.getenv("ALPCA_PAPER_KEY_ID") | |
secret_key = os.getenv("ALPCA_PAPER_KEY_SECRET") | |
api = tradeapi.REST(key_id, secret_key, base_url, api_version='v2') | |
account = api.get_account() | |
# Check if our account is restricted from trading | |
if account.trading_blocked: | |
print('Account is currently restricted from trading.') | |
# Check how much money we can use to open new positions | |
print('${} is available as buying power.'.format(account.buying_power)) | |
print('Positions: %s' % api.list_positions()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment