Git Product home page Git Product logo

mustakabsarkhan / simple_trading_strategy Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 137 KB

A repository containing a Python script for implementing a simple trading strategy based on moving average crossover.

License: MIT License

Python 100.00%
algorithmic-trading data-analysis financial-analysis financial-markets matplotlib moving-averages pandas python quantitative-finance simple-charts stock-analysis stock-market technical-analysis trading-signals trading-strategy

simple_trading_strategy's Introduction

Simple Trading Strategy

This repository contains a simple Python script for analyzing stock data and implementing a basic trading strategy. The script utilizes the pandas and matplotlib libraries to read and process stock data from a CSV file, calculate moving averages, and generate trading signals based on the moving average crossover strategy.

Usage

  1. Clone the repository to your local machine:

    git clone https://github.com/MustakAbsarKhan/simple_trading_strategy.git
  2. Navigate to the cloned repository:

    cd simple_trading_strategy
  3. Install the required dependencies (pandas and matplotlib). You can use pip to install the dependencies:

    pip install -r requirements.txt
  4. Run the script:

    python trading_strategy.py
  5. Follow the prompts to provide the file path of the stock data CSV file and the desired start and end dates for the analysis.

  6. The script will generate three plots:

    • The first plot shows the 10-day moving average (MAvg10) and the close prices of the stock within the specified date range.
    • The second plot shows the 50-day moving average (MAvg50) and the close prices of the stock within the specified date range.
    • The third plot displays the profit generated based on the trading signals derived from the moving average crossover strategy.

Inputs

When running the script, the following inputs are required:

  • File Path: Enter the file path of the stock data CSV file. Make sure the file is in the correct format and contains the necessary columns.
  • From Date: Specify the desired start date for the analysis in the format "dd/mm/yyyy".
  • Till Date: Specify the desired end date for the analysis in the format "dd/mm/yyyy".

Output

The script generates three plots using the matplotlib library:

  • Plot 1: MAvg10 and Close Prices
    Plot 1

  • Plot 2: MAvg50 and Close Prices
    Plot 2

  • Plot 3: Profit Generated
    Plot 3

  • Plot 4: Wealth Generated
    Plot 4

The plots provide visual representations of the moving averages and the profit generated based on the trading strategy.

Contributing

Contributions to the Simple Trading Strategy repository are welcome. If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

simple_trading_strategy's People

Contributors

mustakabsarkhan 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.