Giter Site home page Giter Site logo

investopedia_simulator_api's Introduction

Investopedia Simulator API

REST API for communicating with the investopedia simulator

Example Requests (using python requests library) (all POST JSON body to '' endpoint):

import requests


def investopedia(body):
    # convert python dictionary to JSON to send to api
    data = json.dumps(body)
    endpoint = 'https://investopedia-simulator-api.herokuapp.com/'

    # Response will be in json form, under the key 'result'
    return requests.post(endpoint, data=data).json()['result'])


# Get Quote:
quote = investopedia({
    'function': 'get_quote',
    'symbol': 'NFLX'
})

"""
Response:
{"result": 321.09}
"""

# Get portfolio status
portfolio_status = investopedia({
    'function': 'get_portfolio_status',
    'email': INVESTOPEDIA_USERNAME,
    'password': INVESTOPEDIA_PASSWORD
})

"""
Response:
{
    "result": [102057.5, 51101.88, 146.27, 5.26]
}
"""

# Get current securities
current_securities = investopedia({
    'function': 'get_current_securities',
    'email': INVESTOPEDIA_USERNAME,
    'password': INVESTOPEDIA_PASSWORD
})

"""
Response:
{
    "result": [
        [
            ["MU", "MICRON TECHNOLOGY, INC.", 348, 58.75, 58.84, 20476.32],
            ["INTC", "INTEL CORPORATION", 399, 51.18, 50.88, 20301.12],
            ["ORCL", "ORACLE CORPORATION", 390, 52.51, 52.37, 20424.3],
            ["STX", "SEAGATE TECHNOLOGY PLC", 341, 59.9, 59.57, 20313.37],
            ["SAP", "SAP SE SPONSORED ADR", 188, 108.61, 108.49, 20396.12]
        ],
        [],
        []
    ]
}
"""

# Get open trades
open_trades = investopedia({
    'function': 'get_open_trades',
    'email': INVESTOPEDIA_USERNAME,
    'password': INVESTOPEDIA_PASSWORD
})

# Trade (orderType can be 'buy', 'sell', 'short', or 'cover')
investopedia({
    'function': 'trade',
    'email': INVESTOPEDIA_USERNAME,
    'password': INVESTOPEDIA_PASSWORD,
    'orderType': 'buy',
    'symbol': 'GOOG',
    'quantity': 20
})

"""
Response:
{"result": "True"}
"""

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.