Convert Figma logo to code with AI

mcdallas logowallstreet

Real time stock and option data.

1,312
201
1,312
17

Top Related Projects

Extract data from a wide range of Internet sources into a pandas DataFrame.

12,935

Download market data from Yahoo! Finance's API

1,897

ffn - a financial function library for Python

17,485

Zipline, a Pythonic Algorithmic Trading Library

Python wrapper for TA-Lib (http://ta-lib.org/).

2,109

Common financial technical indicators implemented in Pandas.

Quick Overview

The mcdallas/wallstreet repository is a Python library that provides a set of tools and utilities for working with financial data, particularly stock market data. It includes features for fetching and analyzing historical stock prices, as well as tools for backtesting trading strategies.

Pros

  • Comprehensive Data Fetching: The library provides a wide range of data sources, including Yahoo Finance, Alpha Vantage, and IEX Cloud, making it easy to fetch historical stock data.
  • Backtesting Capabilities: The library includes a robust backtesting framework that allows users to test and evaluate trading strategies on historical data.
  • Visualization Tools: The library includes various visualization tools, such as candlestick charts and technical indicators, to help users analyze and interpret financial data.
  • Active Development: The project is actively maintained, with regular updates and bug fixes.

Cons

  • Limited Documentation: The project's documentation could be more comprehensive, making it challenging for new users to get started.
  • Dependency on External APIs: The library relies on external APIs for data fetching, which can be subject to rate limits and service disruptions.
  • Performance Concerns: The library's performance may be a concern for users working with large datasets or high-frequency trading strategies.
  • Limited Scope: The library is primarily focused on stock market data and may not be suitable for users working with other types of financial instruments.

Code Examples

Here are a few examples of how to use the mcdallas/wallstreet library:

  1. Fetching historical stock data:
from wallstreet import Stock

# Fetch historical data for Apple (AAPL)
aapl = Stock('AAPL')
aapl_data = aapl.history(start='2020-01-01', end='2020-12-31')
print(aapl_data.head())
  1. Calculating technical indicators:
from wallstreet import indicators

# Calculate the 20-day simple moving average for Apple (AAPL)
aapl_sma = indicators.sma(aapl_data['close'], 20)
print(aapl_sma.head())
  1. Backtesting a simple trading strategy:
from wallstreet import backtest

# Define a simple trading strategy
def strategy(data):
    signals = data['close'].shift(1) > data['close'].shift(2)
    return signals

# Backtest the strategy on Apple (AAPL) data
results = backtest.backtest(aapl_data, strategy)
print(results.summary())

Getting Started

To get started with the mcdallas/wallstreet library, follow these steps:

  1. Install the library using pip:
pip install wallstreet
  1. Import the necessary modules and classes:
from wallstreet import Stock, indicators, backtest
  1. Fetch historical stock data:
aapl = Stock('AAPL')
aapl_data = aapl.history(start='2020-01-01', end='2020-12-31')
  1. Analyze the data using technical indicators:
aapl_sma = indicators.sma(aapl_data['close'], 20)
  1. Backtest a trading strategy:
def strategy(data):
    signals = data['close'].shift(1) > data['close'].shift(2)
    return signals

results = backtest.backtest(aapl_data, strategy)
print(results.summary())

For more detailed information and advanced usage, please refer to the project's documentation.

Competitor Comparisons

Extract data from a wide range of Internet sources into a pandas DataFrame.

Pros of pandas-datareader

  • Broader data source support, including financial and economic databases
  • Seamless integration with pandas DataFrame structures
  • More active development and community support

Cons of pandas-datareader

  • Steeper learning curve for beginners
  • Heavier dependency on the pandas library
  • May be overkill for simple stock data retrieval tasks

Code Comparison

pandas-datareader:

import pandas_datareader as pdr
data = pdr.get_data_yahoo("AAPL", start="2022-01-01", end="2022-12-31")
print(data.head())

wallstreet:

from wallstreet import Stock
apple = Stock('AAPL')
print(apple.price)
print(apple.historical(start_date="2022-01-01", end_date="2022-12-31"))

The pandas-datareader code retrieves historical data and returns a DataFrame, while wallstreet provides a more object-oriented approach with simpler syntax for current price retrieval. wallstreet offers a more straightforward interface for basic stock data, making it easier for beginners. However, pandas-datareader provides more comprehensive data manipulation capabilities through its integration with pandas.

12,935

Download market data from Yahoo! Finance's API

Pros of yfinance

  • More comprehensive data retrieval, including options and fundamentals
  • Actively maintained with frequent updates and bug fixes
  • Larger community and better documentation

Cons of yfinance

  • Slower performance for large datasets
  • Occasional inconsistencies in data due to Yahoo Finance API changes

Code Comparison

wallstreet:

from wallstreet import Stock
s = Stock('AAPL')
print(s.price)

yfinance:

import yfinance as yf
ticker = yf.Ticker('AAPL')
print(ticker.info['regularMarketPrice'])

Key Differences

  • wallstreet focuses on options data, while yfinance offers a broader range of financial data
  • yfinance provides more detailed company information and financial statements
  • wallstreet has a simpler API, making it easier for beginners to use
  • yfinance allows for downloading historical data more easily

Use Cases

wallstreet is better suited for:

  • Quick option price checks
  • Simple stock price retrieval

yfinance is preferable for:

  • Comprehensive financial analysis
  • Historical data analysis
  • Accessing detailed company information

Both libraries serve different purposes and can be useful depending on the specific requirements of your project.

1,897

ffn - a financial function library for Python

Pros of ffn

  • More comprehensive financial analysis toolkit with a wider range of functions
  • Better documentation and examples for users
  • Actively maintained with regular updates and contributions

Cons of ffn

  • Steeper learning curve due to more complex functionality
  • Heavier dependencies, potentially leading to longer setup time
  • May be overkill for simple options analysis tasks

Code Comparison

ffn example:

import ffn

data = ffn.get('spy,agg', start='2010-01-01')
stats = data.calc_stats()
print(stats.display())

wallstreet example:

from wallstreet import Stock, Call, Put

s = Stock('AAPL')
c = Call('AAPL', d=15, m=3, y=2023, strike=150)
print(f"Stock price: {s.price}, Call price: {c.price}")

Summary

ffn is a more comprehensive financial analysis library, offering a wide range of tools for performance analysis, risk assessment, and portfolio management. It's well-documented and actively maintained, but may have a steeper learning curve.

wallstreet, on the other hand, focuses specifically on options and stock price retrieval. It's simpler to use for basic options analysis but lacks the broader analytical capabilities of ffn.

Choose ffn for in-depth financial analysis and portfolio management, or wallstreet for quick and straightforward options and stock price information.

17,485

Zipline, a Pythonic Algorithmic Trading Library

Pros of Zipline

  • More comprehensive and feature-rich backtesting engine
  • Larger community and better documentation
  • Supports multiple asset classes (stocks, futures, options)

Cons of Zipline

  • Steeper learning curve due to complexity
  • Slower performance for simple backtests
  • Requires more setup and configuration

Code Comparison

Zipline example:

from zipline.api import order, record, symbol

def initialize(context):
    context.asset = symbol('AAPL')

def handle_data(context, data):
    order(context.asset, 10)
    record(AAPL=data.current(context.asset, 'price'))

Wallstreet example:

from wallstreet import Stock

aapl = Stock('AAPL')
print(aapl.price)
print(aapl.volume)

Zipline provides a more structured approach for backtesting strategies, while Wallstreet offers a simpler interface for quick stock data retrieval. Zipline is better suited for complex trading strategies and thorough backtesting, whereas Wallstreet is more appropriate for basic stock information and simple analyses. The choice between the two depends on the specific requirements of your project and the level of complexity you need in your financial analysis tools.

Python wrapper for TA-Lib (http://ta-lib.org/).

Pros of ta-lib-python

  • Comprehensive library with over 150 technical analysis indicators
  • Well-established and widely used in the financial industry
  • Optimized C implementation for faster calculations

Cons of ta-lib-python

  • Requires separate installation of TA-Lib C library
  • Steeper learning curve due to extensive functionality
  • Less Pythonic API compared to wallstreet

Code Comparison

wallstreet:

from wallstreet import Stock

msft = Stock('MSFT')
print(msft.price)
print(msft.volume)

ta-lib-python:

import talib
import numpy as np

close = np.random.random(100)
output = talib.SMA(close, timeperiod=10)
print(output)

The wallstreet library provides a more intuitive and Pythonic interface for basic stock data retrieval, while ta-lib-python offers powerful technical analysis functions but requires more setup and understanding of numpy arrays.

2,109

Common financial technical indicators implemented in Pandas.

Pros of finta

  • More comprehensive set of technical indicators and financial analysis tools
  • Better documentation with detailed explanations of each function
  • Actively maintained with regular updates and contributions

Cons of finta

  • Larger codebase, potentially more complex to understand and modify
  • Slower execution time for some functions due to more extensive calculations
  • Requires additional dependencies like pandas and numpy

Code Comparison

finta:

def SMA(ohlc: pd.DataFrame, period: int = 41, column: str = "close") -> pd.Series:
    return pd.Series(ohlc[column].rolling(window=period).mean(), name=f"SMA_{period}")

wallstreet:

def sma(data, period):
    return data.rolling(window=period).mean()

Both libraries provide similar functionality for calculating Simple Moving Average (SMA), but finta offers more customization options and returns a named Series. wallstreet's implementation is more concise but less flexible.

finta generally provides more detailed implementations of financial indicators, while wallstreet focuses on simplicity and ease of use. The choice between the two depends on the specific requirements of your project and the level of complexity you're comfortable with.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Wallstreet: Real time Stock and Option tools

Wallstreet is a Python 3 library for monitoring and analyzing real time Stock and Option data. Quotes are provided from the Google Finance API. Wallstreet requires minimal input from the user, it uses available online data to calculate option greeks and even scrapes the US Treasury website to get the current risk free rate.

Usage

Stocks:

.. code-block:: Python

from wallstreet import Stock, Call, Put

s = Stock('AAPL') s.price 96.44 s.price 96.48 s.change -0.35 s.last_trade '21 Jan 2016 13:32:12'

Options:

.. code-block:: Python

g = Call('GOOG', d=12, m=2, y=2016, strike=700) g.price 38.2 g.implied_volatility() 0.49222968442691889 g.delta() 0.56522039722040063 g.vega() 0.685034827159825 g.underlying.price 706.59

Alternative construction:

.. code-block:: Python

g = Call('GOOG', d=12, m=2, y=2016) g Call(ticker=GOOG, expiration='12-02-2016') g.strikes (580, 610, 620, 630, 640, 650, 660, 670, 680, 690, 697.5, 700, 702.5, 707.5, 710, 712.5, 715, 720, ...) g.set_strike(712.5) g Call(ticker=GOOG, expiration='12-02-2016', strike=712.5)

or

.. code-block:: Python

g = Put("GOOG") 'No options listed for given date, using 22-01-2016 instead' g.expirations ['22-01-2016', '29-01-2016', '05-02-2016', '12-02-2016', '19-02-2016', '26-02-2016', '04-03-2016', ...] g Put(ticker=GOOG, expiration='22-01-2016')

Yahoo Finance Support (keep in mind that YF quotes might be delayed):

.. code-block:: Python

>>> apple = Stock('AAPL', source='yahoo')
>>> call = Call('AAPL', strike=apple.price, source='yahoo')
No options listed for given date, using '26-05-2017' instead
No option for given strike, using 155 instead

Download historical data (requires pandas)

.. code-block:: Python

s = Stock('BTC-USD')
>>> df = s.historical(days_back=30, frequency='d')
>>> df
         Date          Open          High           Low         Close     Adj Close      Volume
0  2019-07-10  12567.019531  13183.730469  11569.940430  12099.120117  12099.120117  1554955347
1  2019-07-11  12099.120117  12099.910156  11002.389648  11343.120117  11343.120117  1185222449
2  2019-07-12  11343.120117  11931.910156  11096.610352  11797.370117  11797.370117   647690095
3  2019-07-13  11797.370117  11835.870117  10827.530273  11363.969727  11363.969727   668325183
4  2019-07-14  11363.969727  11447.919922  10118.849609  10204.410156  10204.410156   814667763
5  2019-07-15  10204.410156  11070.179688   9877.019531  10850.259766  10850.259766   965178341
6  2019-07-16  10850.259766  11025.759766   9366.820313   9423.440430   9423.440430  1140137759
7  2019-07-17   9423.440430   9982.240234   9086.509766   9696.150391   9696.150391   965256823
8  2019-07-18   9696.150391  10776.540039   9292.610352  10638.349609  10638.349609  1033842556
9  2019-07-19  10638.349609  10757.410156  10135.160156  10532.940430  10532.940430   658190962
10 2019-07-20  10532.940430  11094.320313  10379.190430  10759.419922  10759.419922   608954333
11 2019-07-21  10759.419922  10833.990234  10329.889648  10586.709961  10586.709961   405339891
12 2019-07-22  10586.709961  10676.599609  10072.070313  10325.870117  10325.870117   524442852
13 2019-07-23  10325.870117  10328.440430   9820.610352   9854.150391   9854.150391   529438124
14 2019-07-24   9854.150391   9920.540039   9535.780273   9772.139648   9772.139648   531611909
15 2019-07-25   9772.139648  10184.429688   9744.700195   9882.429688   9882.429688   403576364
16 2019-07-26   9882.429688   9890.049805   9668.519531   9847.450195   9847.450195   312717110
17 2019-07-27   9847.450195  10202.950195   9310.469727   9478.320313   9478.320313   512612117
18 2019-07-28   9478.320313   9591.519531   9135.639648   9531.769531   9531.769531   267243770
19 2019-07-29   9531.769531   9717.690430   9386.900391   9506.929688   9506.929688   299936368
20 2019-07-30   9506.929688   9749.530273   9391.780273   9595.519531   9595.519531   276402322
21 2019-07-31   9595.519531  10123.940430   9581.599609  10089.250000  10089.250000   416343142
22 2019-08-01  10089.250000  10488.809570   9890.490234  10409.790039  10409.790039   442037342
23 2019-08-02  10409.790039  10666.639648  10340.820313  10528.990234  10528.990234   463688251
24 2019-08-03  10528.990234  10915.000000  10509.349609  10820.410156  10820.410156   367536516
25 2019-08-04  10820.410156  11074.950195  10572.240234  10978.910156  10978.910156   431699306
26 2019-08-05  10978.910156  11945.379883  10978.889648  11807.959961  11807.959961   870917186
27 2019-08-06  11807.959961  12316.849609  11224.099609  11467.099609  11467.099609   949534020
28 2019-08-07  11467.099609  12138.549805  11393.980469  11974.280273  11974.280273   834719365
29 2019-08-08  11974.280273  12042.870117  11498.040039  11982.799805  11982.799805   588463519
30 2019-08-09  11983.620117  12027.570313  11674.059570  11810.679688  11810.679688   366160288

Installation

Simply

.. code-block:: bash

$ pip install wallstreet

Stock Attributes

  • ticker
  • price
  • id
  • exchange
  • last_trade
  • change (change in currency)
  • cp (percentage change)

Option Attributes and Methods

  • strike

  • expiration

  • underlying (underlying stock object)

  • ticker

  • bid

  • ask

  • price (option price)

  • id

  • exchange

  • change (in currency)

  • cp (percentage change)

  • volume

  • open_interest

  • code

  • expirations (list of possible expiration dates for option chain)

  • strikes (list of possible strike prices)

  • set_strike()

  • implied_volatility()

  • delta()

  • gamma()

  • vega()

  • theta()

  • rho()