An API, written in Python, for Investopedia's paper trading stock simulator. Pull requests welcome!
For this API to be useful you need an Investopedia trading account, which you can make here.
- Python's mechanize library. See here.
- Backported enum library for Python 2.7. See here.
- Beautiful Soup. See here.
Import all the classes:
from investopedia import *Log into the simulator:
client = Account("emailaddress","password")Get account status (cash on hand, annual return, etc.):
status = client.get_portfolio_status()
print status.account_val
print status.buying_power
print status.cash
print status.annual_returnBuying 10 shares of Google (GOOG) at market price:
client.trade("GOOG", Action.buy, 10)Selling 10 shares of Google at market price:
client.trade("GOOG", Action.sell, 10)Shorting 10 shares of Google:
client.trade("GOOG", Action.short, 10)Buying 10 shares of Google with a limit order at $500
client.trade("GOOG", Action.buy, 10, "Limit", 500)