Git Product home page Git Product logo

broker's Introduction

A Broker with a Stock Market Analysis Tool

This Python tool allows for the calculation of key stock market metrics, including the Dividend Yield, P/E Ratio, Volume Weighted Stock Price (VWSP), and the GBCE All Share Index for a predefined set of stocks.

Features

  • Calculate the Dividend Yield for a given stock.
  • Compute the P/E Ratio for a given stock.
  • Record trades for any stock, including timestamp, quantity, buy/sell indicator, and price.
  • Calculate the Volume Weighted Stock Price for trades within the past 15 minutes.
  • Calculate the GBCE All Share Index using the geometric mean of the volume weighted stock prices for all stocks.

Getting Started

Prerequisites

Ensure you have Python 3.7 or higher installed on your system.

Installation

Clone the repository to your local machine.

git clone https://github.com/ChuckTG/broker.git
cd broker

Usage Calculating Stock Metrics To use the tool for calculating stock metrics, import and create instances of the Stock class in broker.py. Here is a basic example:

from broker import Stock

# Create a stock instance
stock = Stock('GIN', 'Preferred', 8, 0.02, 100)

# Record some trades
stock.record_trade(100, 'buy', 105)
stock.record_trade(200, 'sell', 110)

# Calculate Dividend Yield
print(f"Dividend Yield: {stock.dividend_yield(105)}")

# Calculate P/E Ratio
print(f"P/E Ratio: {stock.pe_ratio(105)}")

# Calculate Volume Weighted Stock Price
print(f"Volume Weighted Stock Price: {stock.volume_weighted_stock_price()}")

Calculating the GBCE All Share Index To calculate the GBCE All Share Index for a list of stocks:

from broker import Stock, calculate_gbce_all_share_index
stocks = [
            Stock('TEA', 'Common', 0, None, 100),
            Stock('POP', 'Common', 8, None, 100),
            Stock('ALE', 'Common', 23, None, 60),
            Stock('GIN', 'Preferred', 8, 0.02, 100),
            Stock('JOE', 'Common', 13, None, 250)
        ]

stocks[0].record_trade(100, 'buy', 105)
stocks[1].record_trade(200, 'sell', 110)

# Assuming stocks is a list of Stock instances
print(f"GBCE All Share Index: {calculate_gbce_all_share_index(stocks)}")

Running Tests

To run tests use the following command:

python -m unittest test_broker.py

broker's People

Contributors

chucktg avatar

Watchers

 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.