Coder Social home page Coder Social logo

suchak1 / hyperdrive Goto Github PK

View Code? Open in Web Editor NEW
138.0 5.0 19.0 15.66 MB

algorithmic trading using machine learning

Home Page: https://FORCEPU.SH

License: MIT License

Python 98.88% Shell 1.12%
algorithmic-trading algotrading algotrading-machine-learning algorithmic-trading-python financial-machine-learning robinhood

hyperdrive's Issues

Add checks for update scripts

For scripts using multiple processes, use a lock or manager to manage a shared variable and figure out if > 5% of data saves / function calls fail.

Create Split Worker

Create split worker that updates historical data accordingly (dividends, eod ohlc, intraday ohlc)

Get/Store Historical Dividend Data

Get historical dividend data for all stocks in portfolio using Yahoo Finance (yahooquery package) or Nasdaq. Save table as csv in data/ and preload as part of load_portfolio.

Looking into import pandas_datareader as pdr as well.

Keep Low Dimension models for visualization

Create 2 and 3 dimensional models as part of a script that runs after create_model.py.
(First, use pca, lda, tsne, umap to reduce dimensionality.)
(Will add 1-2 hrs to workflow runtime or use matrix and decide whether to use dimensionality reduction in create_model.py thru env var (DIMENSIONALITY_REDUCTION: ['None', 'PCA', 'LDA', 'TSNE', 'UMAP'])
Create csvs or jsons for 2d and 3d plottable data or plotly html file.

Fix Symbols

Fix symbols to include only symbols in holdings not all in portfolio history.

Fix dependency update version/tag bump

Best soln:
Try anothrNick/github-tag-action w dry run enabled first, then use version output (steps.bumpVersion.outputs.new_tag) for INPUT_TAGGING_MESSAGE in stefanzweifel/git-auto-commit-action, then create new release (action from release.yml)

Walk through portfolio history

Create a function to walk through the portfolio and simulate the actions that led to the current holdings. Might be useful to create the simulation functions for buying and maybe selling here.

buy(symbol, quantity, price)

S3 Integration

Save data in S3 rather than in repo
Smart load of data (check if data is 1 day or 1 week old?) - local
Mock data for CI tests + step to download relevant data files used in tests from s3 ('AAPL.csv')

Polygon OHLC isn't updating for new symbols (post Oct. 30)

Namely MARA, RIOT, ARK*

Probably from this commit: 9c338b7

Theory: The time related update didn't work, and the response from Polygon is empty for '1d', so MarketData obj is either returning nothing or most recent row in cached data (csv) instead of previous day's data directly from Polygon.

Make Config Class

Make a Config class that loads all environment variables in config.env and import/load config when needed. Move Pathfinder into its own file.

Add more data

Check easily accessible sources. Look into adding ๐Ÿ’ฑ โฌ…๏ธ๐ŸŒŠ and ๐Ÿ’ฑโžก๏ธ๐ŸŒŠ (ex. inflow vs outflow)

Remake the model

  • Clean up model to use preprocess fx instead of undersample.
  • Add SMOTE
  • Use ddof=0
  • Don't convert date to int64 for derivative, just assume dx = 1
  • Don't use PCA for final

Moving average function

Create a function that calculates n-day moving average for a symbol.

moving_avg(n, symbol, date=today)

Look into use of the ta library for incorporation of even more indicators.

Add Double Redundancy

Use Polygon.io as a secondary data provider to add double redundancy to the data collection pipeline.

Automatically generate docs

google "python library docs generator", pick best one, and refactor library to autogenerate docs

get a linter to make sure functions are compliant w doc generation during pr validation?

generate html doc, push to forcepu.sh bucket (better for making docs public acl read - remove delete flag from deploy units workflow) or hyperdrive bucket (better for showing docs from hyperdrive) and serve from forcepush - pull in locally as part of build process s3 download w creds (hyperdrive bucket) or just make request to object url (public access - forcepush bucket) or git checkout hyperdrive and generate docs on the fly

Plot annualized dividend yield over time

At each point in time, find total dividend / total account value as percentage. Then, divide resulting value at each time t by current time in years. This is the annual dividend yield for all t.

Plot Historicals

Create a function to plot historicals for a given instrument or symbol.

plot(symbol, start, end, instrument=None)

Fix holiday error

If Fri or Mon is a holiday, then the OHLC script will produce an error on Mon or Tue bc there is no market data returned during the 3 day buffer.

Check if market holiday is in date range and don't produce error.

Figure out position sizing

Find a way to get optimal position sizing for each time t with size 0 <= s <= 1.0 and s being the proportion of quote asset used to buy base asset or base asset sold for quote asset.

Rewrite readme

  • Remove mention of "Robinhood"
  • Describe as library for algotrading research and execution
  • Provide example of how to get data (iex env var), store data (s3 and iex env var), create model, backtest model predictions, execute order based on prediction, visualize research
  • Use new logo

Split script false-positive failure

Split script reports a failure bc <5% of symbols tracked have had stock splits in the last 3 months. Find a solution to stop false positive failures. Reduce threshold to 1%?

Scarlett init function

We should make a Scarlett class with an init function that

  1. authenticates the current user with Robinhood
  2. loads the user's current portfolio holdings
  3. loads their portfolio history
  4. loads the historical data for each instrument in their portfolio history
  5. creates an instrument: symbol lookup table for each instrument above

Check account balance during should_order

In execute_order script, should_order script should consider account balance when deciding to order (BTC balance when selling, USD balance when buying) after consecutive same signals.

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.