Coder Social home page Coder Social logo

anthonykrivonos / quantico Goto Github PK

View Code? Open in Web Editor NEW
17.0 9.0 10.0 161 KB

๐ŸŒฟ (Help wanted) Live quant trading engine for Robinhood in Python 3, now with backtesting.

License: MIT License

Python 100.00%
quantitative trading quant python python3 algorithmic-trading algorithms robinhood api

quantico's Introduction

๐ŸŒฟ Quantico

Live quantitative trading algorithms for Robinhood in Python 3.

Quantico

What's inside?

This project uses my fork of Jamonek's Robinhood Python wrapper to make servers calls warranted by the algorithms in this project given various financial data from the API. Calls include placing buys and sells, making calls and puts, and retrieving instrument data. This repository is a work in progress, and since I obviously don't store my credentials in this repo, anyone can fork it, give it a whirl, and perhaps contribute their own financial knowledge.

Getting Started

Installing and Running

  1. Clone this repository.
  2. Open a terminal window and cd to the project.
  3. Upgrade your setup tools with pip3 install --upgrade setuptools --user python.
  4. Install all required dependencies with pip3 install -r requirements.txt.
  5. Create a file called .env and fill it with your credentials:
[email protected]
PASSWORD=yourPassword123
  1. Run the driver with python3 driver/run.py. It will use python-dotenv to load your EMAIL and PASSWORD, so you don't have to worry about hardcoding these credentials.

Creating Your Own Algorithm

  1. Copy and paste src/algorithms/__skeleton.py into the same folder. Rename it to something of your choosing, and be sure to change the class name.
  2. Add from algorithms.your_algorithm import * to src/algorithms/__init__.py.
  3. Follow the instructions in the skeleton file to write your algorithm.
  4. After writing your algorithm, call it as follows at the bottom of driver/run.py:
  • If backtesting: YourAlgorithm(query, my_port, test=True, cash=1000) ($1000 is the starting cash amount)

  • If live trading: YourAlgorithm(query, my_port)

  1. Run your code with python3 driver/run.py.

Contributing

If you'd like to improve and/or expand the content of this library, feel free to submit pull requests. If you experience any issues with this code, please let me know promptly.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Vicki Shao for all the support and flames! ๐Ÿ”ฅ

quantico's People

Contributors

anthonykrivonos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quantico's Issues

Dotenv/.env loading

First want to say thanks for making this - I was working on something similar and you saved me some time :)

When I try to run the main script, with dotenv installed, I get an error:
ImportError: cannot import name 'Dotenv' from 'dotenv' (/usr/local/lib/python3.7/site-packages/dotenv/__init__.py)

I think you meant to have:
from dotenv import load_dotenv
instead of
from dotenv import Dotenv

or perhaps there is a mapping you have?

Login issue

Looks like you're maintaining the package more then other so here goes...having issues logging in and getting
400 Client Error: Bad Request for url: https://api.robinhood.com/oauth2/token/
at
res = self.session.post(login(), data=payload, timeout=15)
res.raise_for_status()

I'm assuming it has something to do with the payload but I'm not an oauth2 expert. Do you know how to fix?
Thanks,

Issue with login

I don't know if this is a holdover from Jamonek's login issue - I can't seem to log in, and can't follow the code flow

Is @anthonykrivonos able to login?

I'm getting different errors from different angles:

Looks like it doesn't find query.py in the sibling directory

~driver$ python3 driver/driver.py
2018-11-05T20:24:10.794065E: Could not log in: name 'Query' is not defined

Looks like it can't register utility.py - maybe change driver.py:10:sys.path.append('src')

~Quantico/driver$ python3 driver.py
Traceback (most recent call last):
File "driver.py", line 22, in <module>
     from utility import *
ModuleNotFoundError: No module named 'utility'```

putting driver.py in src ... no error specified

~Quantico/src$ python3 driver.py
gets_to_init
robinhood_initiialized
2018-11-05T20:27:21.434212E: Could not log in:

Debug lines added by me:

 18 class Query:
 19
 20     # __init__:Void
 21     # param email:String => Email of the Robinhood user.
 22     # param password:String => Password for the Robinhood user.
 23     def __init__(self, email, password):
 24         print('gets_to_init')
 25         self.trader = Robinhood()
 26         print('robinhood_initiialized')
 27         self.trader.login(username=email, password=password)
 28         print('logged_in')

Also I'd love to contribute on this project, but that would require me being able to use it :)

Arrays must all be same length

Hello I am getting this error after running driver.py with my login

Traceback (most recent call last):
File "driver/run.py", line 47, in
my_port = query.user_portfolio()
File "src/query.py", line 157, in user_portfolio
return Portfolio(self, quotes, 'User Portfolio')
File "src/models/portfolio.py", line 56, in init
self.update_assets()
File "src/models/portfolio.py", line 78, in update_assets
market_data = self.get_market_data_tuple()
File "src/models/portfolio.py", line 276, in get_market_data_tuple
df = pd.DataFrame(historicals)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 348, in init
mgr = self._init_dict(data, index, columns, dtype=dtype)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 459, in _init_dict
return _arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 7356, in _arrays_to_mgr
index = extract_index(arrays)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 7402, in extract_index
raise ValueError('arrays must all be same length')
ValueError: arrays must all be same length

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.