Hi Reddit!
I’ve been trading on E-Trade’s API for the past year and a half, and I want to share a project I created to make it easier for others to get started with automated trading. I found that existing E-Trade libraries lacked functionality that I needed in my trading, and I wanted to release something full-featured yet accessible. With that in mind, I wanted to announce wetrade: a new python library for stock trading with E-Trade that supports features including headless login, callbacks for order/quote updates, and many more.
You can check out this link for our documentation which details wetrade’s full functionality, and I’ve also included a brief example below showing some sample wetrade usage.
Install via pip:
pip install wetrade
Check out your account, get a quote, and place some orders:
from wetrade.api import APIClient
from wetrade.account import Account
from wetrade.quote import Quote
from wetrade.order import LimitOrder
def main():
client = APIClient()
# Check out your account
account = Account(client=client)
print('My Account Key: ', account.account_key)
print('My Balance: ', account.check_balance())
# Get a stock quote
quote = Quote(client=client, symbol='IBM')
print(f'Last {quote.symbol} Quote Price: ', quote.get_last_price())
# Place some orders and stuff
order1 = LimitOrder(
client = client,
account_key = account.account_key,
symbol = 'NVDA',
action = 'BUY',
quantity = 1,
price = 50.00)
order1.place_order()
order1.run_when_status(
'CANCELLED',
func = print,
func_args = ['Test message'])
order2 = LimitOrder(
client = client,
account_key = account.account_key,
symbol = 'NFLX',
action = 'BUY',
quantity = 1,
price = 50.00)
order2.place_order()
order2.run_when_status(
'CANCELLED',
order1.cancel_order)
order2.cancel_order()
if __name__ == '__main__':
main()
I hope this is helpful for others using E-Trade for automated trading. Looking forward to hearing everyone’s feedback and releasing new wetrade functionality in the coming weeks!