Git Product home page Git Product logo

assetuniverse's Introduction

Asset Universe

The asset universe is a collection of historical daily returns of user-specified stocks and alternetive assets. It downloads historical data from the following sources:

Setup

Install the IB API to your Python environment.

Open and log in to Interactive Brokers Trader Workstation with the API enabled:

  1. In Configuration, go to API > Settings
  2. Check "Enable ActiveX and Socket Clients"
  3. Check "Read-Only API"
  4. Set the "Socket port" to 7496

Installation

Install Asset Universe using pip:

git clone URL
cd assetuniverse
python3 -m pip install .

Using

Define your contracts (stocks and/or futures) as a list of AssetUniverse.AssetUniverseContract class:

from assetuniverse import AssetUniverseContract, AssetUniverse
contracts = []
contract = AssetUniverseContract(
    secType = 'FUT',
    currency = 'USD',
    exchange = 'GLOBEX',
    localSymbol = 'ESU1', # "Local Name" on the IB details page (link below)
    data_source = 'TWS'
)
contracts.append(contract)

contract = AssetUniverseContract(
    secType='FUT',
    currency='USD',
    exchange='ECBOT',
    localSymbol='ZB   SEP 21',
    data_source='TWS'
)
contracts.append(contract)

contract = AssetUniverseContract(
    symbol='SPY',
    secType='STK',
    currency='USD',
    exchange='SMART',
    data_source='TWS'
)
contracts.append(contract)

contract = AssetUniverseContract(
    symbol='AAPL',
    secType='STK',
    currency='USD',
    exchange='SMART',
    data_source='TWS' 
)
contracts.append(contract)

contract = AssetUniverseContract(
    symbol='SBUX',
    secType='STK',
    currency='USD',
    exchange='SMART',
    data_source='Yahoo Finance' # Alternate data source is Yahoo Finance
)
contracts.append(contract)

# Instantiate asset universe - will start the download
days = 365
end = datetime.date.today()
start = end - datetime.timedelta(days=days)
AU = AssetUniverse(start, end, contracts, offline=False)

# Plot and calculate correlations
AU.plotprices()
print(AU.correlation_matrix())
print(AU.correlation_matrix(['SPY', 'ESU1']))

Local Name

Here is an example of the details for the ES futures contract.

assetuniverse's People

Contributors

matthewtrotter avatar

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.