Git Product home page Git Product logo

syncretism's Introduction

Syncretism Clojure CI

Ops.Syncretism is an open source options search engine based on Yahoo! Finance market data.

Dependencies are Clojure, Leiningen, NodeJS, and MariaDB. We try to minimize dependencies to make it easy to install and run locally.

Join us on Discord for any question you might have. Use Github Issues for bug reports & feature requests.

Crawler /datops-crawler

This crawlers targets Yahoo Finance market data to extract options related information.

Running it

Dependency on MariaDB or MySQL. Set parameters in datops-crawler/resources/db.edn as illustrated Here.

For example, if your user is datops and the created database is opts, the db.edn becomes:

{:dbtype "mysql"
 :dbname "opts"
 :user "datops"
 :password "12345password"
 :rewriteBatchedStatements true}

You should also set datops-crawler/resources/config.edn as follows:

{;; Should we crawl out of market hours
 :force-crawl false
 ;; Do we log debug info
 :debug false
 ;; How often to we save & reorder the queue & the proxies (in seconds)
 :t-reorder 60
 ;; How often do we fully clean the queue (remove expired options & gather new symbols)
 :t-clean-queue 86400
 ;; Number of endpoints to use.
 :nb-endpoints 2
 ;; Max Batch size when writing to db
 :batch-size 10000
 ;; Where to save the options data
 :save-path "options"}

Initialize the db with lein run --init.

Run it with lein run

Logs are written in ./opts-crawler.log

Data generated

The crawler uses a scheduler to make sure that any [Ticker, Date] pair that failed to be crawled will be given priority in the queue.

With the above configuration file, the data is stored in the folder options. The crawler creates one folder per day, and one gzipped file per symbol.

Live DB

In options db:

  • live table contains some essential information about the latest measured state of all options. See live-table-def in db_init.clj.
  • live_quote contains essential information about the underlying stock. See live-quote-table-def in the same file.
  • fundamentals contains all the fundamental data available for a given ticker (e.g. earnings, dividends etc...).

Backend /datops-backend

Running it

As with the crawler, there is a dependency on MariaDB or MySQL. Set parameters in datops-backend/resources/db.edn as illustrated Here.

For example:

{:dbtype "mysql"
 :dbname "opts"
 :user "datops"
 :password "12345password"
 :rewriteBatchedStatements true}

Run it with lein ring server-headless, will default to port 3000.

If you want to run it on a different port, simply do lein ring server-headless 3001 to run it on the port 3001 for example.

Api documentation

Avaiable here.

Frontend /syncretism-frontend

Depends on NodeJS.

Change the server address in src/live_opts/communication.cljs to point to your local datops-backend, in the above example it would become "http://localhost:3000/".

Build with

npm install
./node_modules/.bin/shadow-cljs release :frontend

Copy & paste the /public folder wherever your local http server is.

[DEPRECATED] Frontend /datops-frontend

Depends on NodeJS.

Change the server address in src/live_opts/communication.cljs to point to your local datops-backend, in the above example it would become "http://localhost:3000/".

Build with

npm install
./node_modules/.bin/shadow-cljs release :frontend

Copy & paste the /public folder wherever your local http server is.

Data processing /datops-compute

Very early stage, software to do post processing on the crawled data. For the moment:

  • can be used to calculate the yield & monthly yield of all non expired options.
  • can be used to create aligned time series from the crawled data.

Syncretism library /syncretism

Contain the shared bits of the different utilities above.

Labs /labs

Quick examples / experiments regarding what can be done with the data.

Licence

Syncretism is licensed under the GNU Affero General Public License 3 or any later version at your choice.

syncretism's People

Contributors

northern-64bit avatar tyruiop avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

syncretism's Issues

Calculate average of columns at the end of each day

Using a statement like

SELECT timeseries.contractSymbol, AVG(timeseries.delta) FROM timeseries LEFT JOIN live ON timeseries.contractsymbol = live.contractsymbol WHERE live.expiration > 1627721273 GROUP BY timeseries.contractSymbol;

at the end of each days, update the live table with the average value of (most) columns as we go, to enable search by average.

Add two averages: 20days & 100 days averages for each column, for now.

This will allow identifying drops & peaks in movements of each contract.

Fix frontend on smartphones

The frontend is quite broken on smartphones, the worst being the Home view and the charts.

We need to fix the CSS (and possibly the chart generation).

Allow user to track options

Once the search engine becones a PWA, we should allow the user to select and track some options in particular, not to have to search them again every time.

Create "Home" view

The Home view should display, for the moment, tracked options.

In the future we might want to include general statistics about the market, this issue is quite open for now.

Syncretism standalone client

The standalone client should allow a variety of things:

  • Connect to the main Syncretism server & match all features from the frontend
  • Integrate an event driven backtesting system
  • Allow simple integration with external APIs (TD/IB)
  • Use Syncretism's global market watch to trigger more refined data extraction from TD/IB
  • Allow user to define patterns and be alerted when identified in live data.
  • Communicate with smartphone companion apps.
  • Allow simple control of a local instance of the crawler and of the backend
  • Possibility to publish user defined alerts on the Syncretism server and for other clients to subscribe to them.

Write tests

There are currently no tests whatsoever in the codebase.

I need to write tests at least for

  • datops-crawler
  • datops-compute
    And reach a good test coverage.

Crawl active stocks & options more often than inactive ones

Currently all options are crawled at the same rate, however some options have little to no variation over extended periods of time while others change rapidly during the day.

  • We need a heuristic to detect when a [ticker, expiration date] pair becomes active and high
  • We need the crawler to still provide coverage guarantees (e.g. make sure that all such pairs are crawled at least once a day).

%IV change option

Would like to have % IV changes to see option buys or option sells.

+IV % changes --- option buys.
-IV% change ---Option sells.

Features request..

  1. Looking for Ticker search to find cheap / long dated options for known ticker.
  2. Looking for Vol:OI ration in the search list.
  3. Looking for Calls val:Put Vol ratio in the search list.
  4. Denote "N" as like events for major News impacting options /share.
  5. Looking for "DTE" days to expiry in the search result to know how many days this option will expire.
  6. Sort by Volume or OI in result page (with an arrow next to Volume).
  7. Alerting on % change in Volume or price of the option (below 20 days moving average) would be good.

Calculate greeks as we crawl

The crawler is gathering almost all required data to calculate the greeks as we crawl (the only one missing is the risk free interest rate, which can be hardcoded).

So let's add this calculation (tentatively) to the crawler. If it proves to be too demanding (given the crawler's speed requirement), we will move it to regular computation in the datops-compute module.

Greeks' formulas can be found here https://www.macroption.com/black-scholes-formula/

Turn frontend into a PWA

If we create a PWA it will allow the user to

  1. Make less requests to the BE
  2. Work offline
  3. Keep their preferences over time.

Note that the "state" should be able to be downloaded and then uploaded to restore settings.

Aggregate and clean option's historical data in time series

Currently all the data is saved in date/TICKER.txt.gz (which are compressed 1 edn per line files) as we crawl.
We need a way to generate and store time series based on said data.

  • Normalize & align existing data (so all time series are the same, e.g. two measurements daily, at the same time, interpolate if needed)
  • Save corresponding vector somewhere
  • Update vectors at the end of each day

This is crucial to be able to calculate the greeks, and compare options among themselves.

Make columns sortables

On the frontend, the user should be able to click on a column's header to sort by it (like on the old frontend)

Refactor out all greek calculation code

It appears in both datops-crawler and datops-compute. Such code is likely to appear mode in the future (for greeks or other financial calculations). It would make sense to refactor it all in a separate library (e.g. datops-financial).

Allow user to save/restore filters

Two options:

  • use localStorage to save these (simpler, no need for login/pass)
  • create a proper user space (more difficult, but probably useful in the future & can be accessed from different devices).

Adding CI

Now that some tests have been written, it would be nice if we got some CI going on.

Search UI - Volume issue

Not sure if this is resolved..

When i tried last night volume filter throws volume + more option with out of band volume filtered.

Calculate Volume average & volume variance

For each option, keep track of the volume average and add a filter allowing to search by volume variance.

The volume average calculation should be done at the same time as monthly yield update.

Allow filters to have an automatic refresh

User should be allowed to set a timer for a given filter (e.g. 1 / hour) and have it be automatically refreshed following that timer (only during market hours).

Solution:
Allow multiple "listing" views in the options tab, each with its own associated fitler & timer.

Ability to customize columns in FE

Do a form of excel lite, where one can:

  • select which columns appear on FE (to reduce the clutter)
  • create new columns based on the values of the other columns
  • save these custom columns.

Allow ladder searches

e.g. be able to search options with a given filter and see their immediate successor on the ladder, e.g. strike 90 -> 95 for calls, or 90 -> 85 for puts

  • datops-compute should calculate ladders at the end of each day (only for options that require it).
  • Make a way for frontend to show this (sort by contractsymbol if the filter is active?)

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.