Skip to content

MrRoper/investopedia-trading-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

investopedia-trading-api

An API, written in Python, for Investopedia's paper trading stock simulator. Pull requests welcome!

Dependencies

For this API to be useful you need an Investopedia trading account, which you can make here.

  1. Python's mechanize library. See here.
  2. Backported enum library for Python 2.7. See here.
  3. Beautiful Soup. See here.

Usage examples:

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_return

Buying 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)

About

An api, written in Python, for Investopedia's paper trading stock simulator.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%