Giter VIP home page Giter VIP logo

alpaca-trading-2's Introduction

alpaca-trading

This repository contains a bot that uses Bollinger bands strategy to trade a specified instrument via Alpaca markets API. The repository contains 2 scripts:

'back_testing.py' - used for backtesting the bollinger bands strategy. Logs info about when the buys and sells would have occurred and how the portfolio size would have changed over time. Prints the total return that would have been produced over the trading period and compares it with the return that would be produced by a buy-and-hold strategy. Calculates Sharpe ratio for buy-and-hold too.

'bollinger_bands.py' - used for running the bot to trade via alpaca markets API in real time. The buy and sell orders are executed via handlers that are triggered when a new bar of data comes in.

To run 'back_testing.py':

python back_testing.py
Enter ticker to trade: SPY
Enter size of portfolio to trade with in $USD: 10000
Enter start date in form YYYY-MM-DD: 2015-01-01
Enter end date in form YYYY-MM-DD: 2022-01-01
Enter frequency of data to backtest against. Options: (1) 'day', (2) 'hour', (3) 'minute': day

To run 'bollinger_bands.py':

python bollinger_bands.py
Enter ticker to trade: SPY
Enter size of portfolio to trade with in $USD: 10000
Enter instrument type. Options: (1) 'crypto' or (2) 'stock' based on the type of instrument you want to trade: stock
Enter frequency of data to backtest against. Options: (1) 'minute', (2) 'daily': daily 

alpaca-trading-2's People

Contributors

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