-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper scripts for quickstart, update docs accordingly
- Loading branch information
1 parent
849be29
commit 0400298
Showing
10 changed files
with
191 additions
and
58 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
__pycache__ | ||
config.py | ||
__pycache__ |
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# These are our API keys and other configuration settings | ||
# for the Alpaca API and the trading algorithm. | ||
# ALPACA_PUBLIC_KEY is the API key ID for your account. | ||
# ALPACA_SECRET_KEY is the "passphrase" for your API key. | ||
# PAPER is a boolean value that determines whether we are | ||
# using the paper trading API or the live trading API. | ||
# You can configure these values by running the helpers/auth.py script. | ||
ALPACA_PUBLIC_KEY = "<my api id key>" | ||
ALPACA_SECRET_KEY = "<my api secret key>" | ||
PAPER = True | ||
|
||
# ALPACA_TIMEOUT is the number of seconds we will wait for | ||
# to avoid rate limiting. This same value is used for both | ||
# Yahoo Finance and Alpaca. It defaults to 3 seconds. | ||
ALPACA_TIMEOUT = 3.0 | ||
|
||
# SHARES_BY_PRICE is a dictionary that maps the price of a | ||
# share to the number of shares we want to buy at that price. | ||
# For example, we want to buy 200 shares at $1, 100 shares | ||
# at $2, 40 shares at $5, 20 shares at $10, 10 shares at $20, ... | ||
# You can configure this dictionary by running the helpers/amount.py script. | ||
SHARES_BY_PRICE = {1: 200, 2: 100, 5: 40, 10: 20, 50: 4, 100: 2} | ||
|
||
# TRADE_TICKERS is a list of the tickers we want to trade. | ||
# We will use the first 100 tickers in the S&P 500 by default. | ||
# You can change this list to any other tickers you want. | ||
# You can configure this list by running the helpers/tickers.py script. | ||
TRADE_TICKERS = [ "AAPL", "MSFT", "AMZN", "GOOG", "FB", "JPM", "JNJ", "V", "PG", "UNH", "MA", "HD", "VZ", "DIS", "BAC", "INTC", "T", "PFE", "CMCSA", "WFC", "KO", "PEP", "NFLX", "NVDA", "ADBE", "CRM", "TMO", "CSCO", "ABT", "NKE", "MRK", "MDT", "ACN", "COST", "AVGO", "TXN", "QCOM", "UNP", "NEE", "PYPL", "LIN", "PM", "CVX", "MCD", "ORCL", "UPS", "IBM", "LOW", "MMM", "AMGN", "GS", "BA", "CAT", "XOM", "WMT", "DHR", "AMT", "AXP", "HON", "CVS", "BKNG", "CHTR", "SBUX", "GILD", "MDLZ", "BLK", "INTU", "TGT", "ZTS", "WBA", "MU", "GE", "MCK", "GPN", "FIS", "USB", "DUK", "DOW", "PLD", "RTX", "ANTM", "DE", "ISRG", "SYK", "LMT", "CI", "MS", "TJX", "BK", "C", "PNC", "SPGI", "ADP", "CL", "SO", "CME", "COP", "MDXG", "CNC", "CARR", "CRL", "CPB", "COF", "CAH", "KMX", "KHC", "K", "KEY", "KMB", "KIM", "KMI", "KLAC", "KSS", "KDP", "KR", "LB", "LHX", "LH", "LRCX", "LW", "LVS", "LEG", "LDOS", "LEN", "LLY", "LNC", "LIN", "LYB", "LKQ", "LMT", "L", "LOW", "LUMN", "LYV", "MTB", "MRO", "MPC", "MKTX", "MAR", "MMC", "MLM", "MAS", "MA", "MKC", "MXIM", "MCD", "MCK", "MDT", "MRK", "MET", "MTD", "MGM", "MCHP", "MU", "MSFT", "MAA", "MHK", "TAP", "MDLZ", "MNST", "MCO", "MS", "MOS", "MSI", "MSCI", "MYL", "NDAQ", "NOV", "NTAP", "NFLX", "NWL", "NEM", "NWSA", "NWS", "NEE", "NLSN", "NKE", "NI", "NSC", "NTRS", "NOC", "NLOK", "NCLH", "NRG", "NUE", "NVDA", "NVR", "ORLY", "OXY", "ODFL", "OMC", "OKE", "ORCL", "PCAR", "PKG", "PH", "PAYX", "PAYC", "PYPL", "PNR", "PBCT", "PEP", "PKI", "PRGO", "PFE", "PM", "PSX", "PNW", "PXD", "PNC", "POOL", "PPG", "PPL", "PFG", "PG", "PGR", "PLD", "PRU", "PTC", "PEG", "PSA", "PHM", "PVH", "QRVO", "PWR", "QCOM", "DGX", "RL", "RJF", "RTX", "O", "REG", "REGN", "RF", "RSG", "RMD", "RHI", "ROK", "ROL", "ROP", "ROST", "RCL", "SPGI", "CRM", "SBAC", "SLB", "STX", "SEE", "SRE", "NOW", "SHW", "SPG", "SWKS", "SLG", "SNA", "SO", "LUV", "SWK", "SBUX", "STT", "STE", "SYK", "SIVB", "SYF", "SNPS", "SYY", "TMUS", "TROW", "TTWO", "TPR", "TGT", "TEL", "TDY", "TFX", "TER", "TSLA", "TXN", "TXT", "TMO", "TJX", "TSCO", "TT", "TDG", "TRV", "TRMB", "TFC", "TWTR", "TYL", "TSN", "UDR", "ULTA", "USB", "UAA", "UA", "UNP", "UAL", "UNH", "UPS", "URI", "UHS", "UNM", "VLO", "VTR", "VRSN", "VRSK", "VZ", "VRTX", "VFC", "VIAC", "VTRS", "V", "VNO", "VMC", "WRB", "WAB", "WMT", "WBA", "DIS", "WM", "WAT", "WEC", "WFC", "WELL", "WST", "WDC", "WU", "WRK", "WY", "WHR", "WMB", "WLTW", "WYNN", "XEL", "XRX", "XYL", "YUM", "ZBRA", "ZBH", "ZION", "ZTS"] | ||
|
||
# CHOOSE_AMOUNT is a function that takes a price and returns | ||
# the number of shares we want to buy at that price. It is not | ||
# configurable, but you can change it if you want. | ||
def CHOOSE_AMOUNT(value): | ||
for key in SHARES_BY_PRICE: | ||
if value <= key: | ||
return SHARES_BY_PRICE[key] | ||
return 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class COLORS: | ||
BLUE = "\033[94m" | ||
END = "\033[0m" | ||
RED = "\033[91m" | ||
YELLOW = "\033[93m" | ||
GREEN = "\033[92m" | ||
|
||
|
||
def main(): | ||
shares_by_price = {} | ||
|
||
# Ask the user to enter their preferred stock prices and corresponding shares to buy | ||
while True: | ||
try: | ||
price = int( | ||
# print blue text | ||
input( | ||
f"""{COLORS.BLUE}Enter a stock price for a new rule (or -1 to stop). | ||
For example, entering 1000 will allow you to set the amount of shares to | ||
buy when the stock price is $1000 or less:{COLORS.END} """ | ||
) | ||
) | ||
if price == -1: | ||
break | ||
shares = int(input(f"{COLORS.YELLOW}Enter the number of shares to buy for this rule:{COLORS.END} ")) | ||
shares_by_price[price] = shares | ||
except ValueError: | ||
print("Invalid input, please try again.") | ||
|
||
with open('../config.py', 'r') as f: | ||
lines = f.readlines() | ||
with open("../config.py", "w") as f: | ||
for line in lines: | ||
if line.startswith("SHARES_BY_PRICE"): | ||
f.write(f"SHARES_BY_PRICE = {shares_by_price}\n") | ||
else: | ||
f.write(line) | ||
|
||
print(f"{COLORS.GREEN}Successfully updated config.py!{COLORS.END}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class COLORS: | ||
BLUE = "\033[94m" | ||
END = "\033[0m" | ||
RED = "\033[91m" | ||
YELLOW = "\033[93m" | ||
GREEN = "\033[92m" | ||
|
||
|
||
def main(): | ||
try: | ||
public = str(input(f"{COLORS.BLUE}Enter your Alpaca API Key ID:{COLORS.END} ")) | ||
private = str(input(f"{COLORS.BLUE}Enter your Alpaca API Secret Key:{COLORS.END} ")) | ||
paper = str(input(f"{COLORS.BLUE}Are you using a paper account? (y/n):{COLORS.END} ")) | ||
except ValueError: | ||
print("Invalid input, please try again.") | ||
|
||
with open("../config.py", "r") as f: | ||
lines = f.readlines() | ||
# Generate the dictionary and save it to the config file | ||
with open("../config.py", "w") as f: | ||
for line in lines: | ||
if line.startswith("ALPACA_PUBLIC_KEY"): | ||
f.write(f"ALPACA_PUBLIC_KEY = '{str(public)}'\n") | ||
elif line.startswith("ALPACA_SECRET_KEY"): | ||
f.write(f"ALPACA_SECRET_KEY = '{str(private)}'\n") | ||
elif line.startswith("PAPER"): | ||
boolean = paper.lower() == "y" or paper.lower() == "yes" | ||
f.write(f"PAPER = {boolean}\n") | ||
else: | ||
f.write(line) | ||
|
||
print(f"{COLORS.GREEN}Successfully updated config.py!{COLORS.END}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class COLORS: | ||
BLUE = "\033[94m" | ||
END = "\033[0m" | ||
RED = "\033[91m" | ||
YELLOW = "\033[93m" | ||
GREEN = "\033[92m" | ||
|
||
|
||
def main(): | ||
tickers = [] | ||
|
||
while True: | ||
try: | ||
ticker = str(input(f"{COLORS.BLUE}Enter a ticker you would like to trade (or -1 to stop):{COLORS.END} ")) | ||
if ticker == '-1': break | ||
tickers.append(ticker) | ||
except ValueError: | ||
print("Invalid input, please try again.") | ||
|
||
with open("../config.py", "r") as f: | ||
lines = f.readlines() | ||
with open("../config.py", "w") as f: | ||
for line in lines: | ||
if line.startswith("TRADE_TICKERS"): | ||
f.write(f"TRADE_TICKERS = {tickers}\n") | ||
else: | ||
f.write(line) | ||
|
||
print(f"{COLORS.GREEN}Successfully updated config.py!{COLORS.END}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.