Code Monkey home page Code Monkey logo

trading-algorithms's Introduction

Trading Algorithms with Technical Indicators and Sentiment Analysis

This repository implements trading algorithms based on technical indicators and sentiment analysis. It evaluates and executes strategies using historical stock data from Yahoo Finance, and real-time sentiment insights from news sources.

Key Files

  • final.ipynb: Contains the main code for strategies, backtesting, and performance visualizations.
  • constituents.csv: Lists S&P500 stock symbols for retrieving data.

Strategies

1. Technical Indicator Strategies

  • MACD (Moving Average Convergence Divergence): Measures momentum through divergences in moving averages (Learn more).
  • RSI (Relative Strength Index): Identifies overbought/oversold conditions (Learn more).
  • Bollinger Bands: Highlights price volatility using bands (Learn more).
  • Breakout Strategy: A momentum-based strategy that buys on price increases beyond a volatility threshold (Learn more).
  • MACD-Breakout: Combines MACD signals with breakout patterns for trading decisions.

2. Backtesting

  • Simulates historical performance of strategies using stock data.
  • Visualizes profit/loss results and calculates:
    • Win rate: Proportion of profitable trades.
    • Maximum Drawdown (MDD): Largest observed loss from a peak.

3. Market Conditions

  • The bullish_bearish function classifies market conditions.
  • Strategies are compared during bullish and bearish periods, with findings indicating outperformance in bearish markets compared to a simple buy-and-hold strategy.

4. Sentiment Analysis

  • Retrieves news headlines using GoogleNews (Library).
  • Analyzes sentiment polarity using NLP (Natural Language Processing) with NLTK.
  • Implements a sentiment strategy: Buys stocks with positive sentiment and sells on negative sentiment.
  • Categorizes sentiment into five levels: extremely negative, negative, neutral, positive, and extremely positive.

Performance Evaluation

  • Strategy performance is visualized using line and bar graphs.
  • p-values are calculated to determine statistical significance between strategy returns.
  • Comparison of strategy performance across different sentiment categories and market conditions helps assess overall effectiveness.

trading-algorithms's People

Contributors

haechan01 avatar

Watchers

 avatar

Forkers

webclinic017

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.