Skip to content

Commit

Permalink
Merge pull request #4 from deerfieldgreen/3-fixing-code-merge-clobber
Browse files Browse the repository at this point in the history
3 fixing code merge clobber
  • Loading branch information
kevinostoll-dfg authored Nov 1, 2024
2 parents 0d9edec + 30229bf commit 6f461fc
Show file tree
Hide file tree
Showing 9 changed files with 798 additions and 568 deletions.
Binary file removed .DS_Store
Binary file not shown.
166 changes: 166 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class


# MacOS
.DS_Store

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
86 changes: 83 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,77 @@
# daily-levels-panting
Updates daily range levels and save the pine script in daily_range_pine.txt
We need to create a pine script for TradingView to "paint" the levels each day, to automated creating 8 levels by 8 symbols.
In tradingview, you add the script to the Pine Editor, Save and Add to Chart, as an indicator.

- Updates daily range levels and save the pine script in daily_range_pine.txt
- We need to create a pine script for TradingView to "paint" the levels each day, to automated creating 8 levels by 8 symbols.
- In tradingview, you add the script to the Pine Editor, Save and Add to Chart, as an indicator.

## How to use Daily Levels
- COMPLETE ME


## What each level means
- that's a long story ...
- There are 5 prediction levels and 2 straddle levels
- There are a set of Straddle Percent SMAs (10-50)
- You can see how these are presented in the screenshot below.
- this code snippet is from quantconnect/main.py (line #450)
```
prediction_dict = {}
prediction_dict["ticker"] = ticker
prediction_dict["datetime"] = str(self.Time)
prediction_dict["spot_price"] = pred_df['price'].iloc[0]
prediction_dict["straddle_value"] = pred_df['straddle_front_premium'].iloc[0]
prediction_dict["straddle_pct_value"] = pred_df['straddle_front_premium_pct'].iloc[0]
prediction_dict["past_straddle_value"] = model_df['straddle_front_premium'].mean()
prediction_dict["past_straddle_pct_value"] = model_df['straddle_front_premium_pct'].mean()
prediction_dict["past_straddle_value_std"] = model_df['straddle_front_premium'].std()
prediction_dict["past_straddle_pct_value_std"] = model_df['straddle_front_premium_pct'].std()
prediction_dict["upper_value"] = prediction_dict["spot_price"] + prediction_dict["straddle_value"]
prediction_dict["lower_value"] = prediction_dict["spot_price"] - prediction_dict["straddle_value"]
prediction_dict["straddle_pct_sma10"] = data_df['straddle_front_premium_pct'].tail(10).mean()
prediction_dict["straddle_pct_sma20"] = data_df['straddle_front_premium_pct'].tail(20).mean()
prediction_dict["straddle_pct_sma30"] = data_df['straddle_front_premium_pct'].tail(30).mean()
prediction_dict["straddle_pct_sma50"] = data_df['straddle_front_premium_pct'].tail(50).mean()
implied_vol_cur = yearly_data_df.tail(1)['implied_vol'].iloc[0]
implied_vol_min = yearly_data_df['implied_vol'].min()
implied_vol_max = yearly_data_df['implied_vol'].max()
prediction_dict["implied_vol_rank"] = (implied_vol_cur - implied_vol_min) / (implied_vol_max - implied_vol_min)
prediction_dict["implied_vol_percentile"] = (yearly_data_df['implied_vol'] < implied_vol_cur).mean()
```
## What's the Universe?
- you can find this in code: quantconnect/config.py
```
## General Settings
general_setting = {
"tickers": {
"QQQ": {"type": "equity"},
"SPY": {"type": "equity"},
"SPX": {"type": "equity"},
"NVDA": {"type": "equity"},
"TSLA": {"type": "equity"},
"BABA": {"type": "equity"},
"META": {"type": "equity"},
"AMZN": {"type": "equity"},
"TLT": {"type": "equity"},
"GLD": {"type": "equity"},
"SLV": {"type": "equity"},
"EWZ": {"type": "equity"},
"IWM": {"type": "equity"}
},
```

## Stock Splits
- we needed to account for stock splits in the universe set. the price changes based on the ratio of split 2:1 or 4:1, whatever.
- The quantconnect code pulls from another github repository () for this list, back 5 years (60 months * 30.5 days to be exact)

```
data = self.download("https://raw.githubusercontent.com/deerfieldgreen/yfinance-scaling-system/refs/heads/main/data/stock_splits_data.csv")
```

## Flow
1) Receives webhook from QC
Expand All @@ -10,3 +80,13 @@ In tradingview, you add the script to the Pine Editor, Save and Add to Chart, as



## Code layout
- QuantConnect
- Docker container code
- WebHook running in GCP CloudRun



## TradingView Screenshot

![Screenshot of TradingView in $META.](images/META_2024-10-31_22-52-47_a1298.png)
27 changes: 0 additions & 27 deletions drlp.crontab.txt

This file was deleted.

Binary file added images/META_2024-10-31_22-52-47_a1298.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6f461fc

Please sign in to comment.