Last active
January 30, 2021 23:34
-
-
Save McKlayne/b4a7bf0ee69cd4a060d6759394a027b8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
import pandas as pd | |
import numpy as np | |
import boto3 | |
import ta | |
s3 = boto3.client('s3') | |
sns = boto3.client('sns') | |
def handler(event, context): | |
#List of phone numbers to text | |
numbers = [''] | |
os.environ["APCA_API_BASE_URL"] = "https://paper-api.alpaca.markets" | |
#Insert API Credentials | |
api = tradeapi.REST('API_KEY','API_SECRET_KEY', api_version='v2') | |
#Capture Unealized P&L | |
unrealizedProfit = 0 | |
for position in api.list_positions(): | |
try: | |
unrealizedProfit += position.unrealized_pl | |
except: | |
pass | |
#Your trading strategy here | |
# | |
# | |
# | |
# | |
# | |
# | |
# | |
#Send text message | |
sns.publish(PhoneNumber = numbers, message = f'the current unrealized profit or loss of the portfolio is {unrealizedProfit}') | |
return('Trading is complete') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment