forked from joshyattridge/smart-money-concepts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
joshua attridge
authored and
joshua attridge
committed
Sep 23, 2023
0 parents
commit 71e9ce1
Showing
10 changed files
with
1,026 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 NeuralNine | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# smartmoneyconcepts | ||
|
||
<!-- write my README.md file this is a python packed for smart money indicators like orderblocks,liquidity,imbalance--> | ||
|
||
## Description | ||
|
||
This is a python packed for smart money indicators like orderblocks,liquidity,imbalance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from setuptools import setup | ||
import codecs | ||
import os | ||
|
||
VERSION = '0.0.1' | ||
DESCRIPTION = 'Getting indicators based on smart money concepts or ICT' | ||
LONG_DESCRIPTION = 'A package that allows users to get access to smart money concepts and ICT concepts in the form of indicators easily.' | ||
|
||
# Setting up | ||
setup( | ||
name="smartmoneyconcepts", | ||
version=VERSION, | ||
author="Joshua Attridge", | ||
description=DESCRIPTION, | ||
long_description_content_type="text/markdown", | ||
long_description=long_description, | ||
packages=["smartmoneyconcepts"], | ||
install_requires=["pandas", "numpy"], | ||
keywords=['python', 'smart money', 'ict', 'indicators', 'trading', 'forex', 'stocks', 'crypto', 'order blocks', 'liquidity'], | ||
url="https://github.com/joshyattridge/smartmoneyconcepts", | ||
classifiers=[ | ||
"Development Status :: 1 - Planning", | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python :: 3", | ||
"Operating System :: Unix", | ||
"Operating System :: MacOS :: MacOS X", | ||
"Operating System :: Microsoft :: Windows", | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from functools import wraps | ||
import pandas as pd | ||
import numpy as np | ||
from pandas import DataFrame, Series | ||
|
||
def inputvalidator(input_="ohlc"): | ||
def dfcheck(func): | ||
@wraps(func) | ||
def wrap(*args, **kwargs): | ||
|
||
args = list(args) | ||
i = 0 if isinstance(args[0], pd.DataFrame) else 1 | ||
|
||
args[i] = args[i].rename(columns={c: c.lower() for c in args[i].columns}) | ||
|
||
inputs = { | ||
"o": "open", | ||
"h": "high", | ||
"l": "low", | ||
"c": kwargs.get("column", "close").lower(), | ||
"v": "volume", | ||
} | ||
|
||
if inputs["c"] != "close": | ||
kwargs["column"] = inputs["c"] | ||
|
||
for l in input_: | ||
if inputs[l] not in args[i].columns: | ||
raise LookupError( | ||
'Must have a dataframe column named "{0}"'.format(inputs[l]) | ||
) | ||
|
||
return func(*args, **kwargs) | ||
|
||
return wrap | ||
|
||
return dfcheck | ||
|
||
|
||
def apply(decorator): | ||
def decorate(cls): | ||
for attr in cls.__dict__: | ||
if callable(getattr(cls, attr)): | ||
setattr(cls, attr, decorator(getattr(cls, attr))) | ||
|
||
return cls | ||
|
||
return decorate | ||
|
||
|
||
@apply(inputvalidator(input_="ohlc")) | ||
class SMC: | ||
|
||
__version__ = "0.01" | ||
|
||
@classmethod | ||
def FVG(cls, ohlc: DataFrame) -> Series: | ||
""" | ||
FVG - Fair Value Gap | ||
A fair value gap is when the previous high is lower than the next low if the current candle is bullish. | ||
Or when the previous low is higher than the next high if the current candle is bearish. | ||
""" | ||
|
||
fvg = np.where(((ohlc["high"].shift(1) < ohlc["low"].shift(-1)) & (ohlc["close"] > ohlc["open"])) | ((ohlc["low"].shift(1) > ohlc["high"].shift(-1)) & (ohlc["close"] < ohlc["open"])),1,0) | ||
direction = np.where(ohlc["close"] > ohlc["open"], 1, 0) | ||
start = np.where(ohlc["close"] > ohlc["open"], ohlc["high"].shift(1), ohlc["low"].shift(1)) | ||
end = np.where(ohlc["close"] > ohlc["open"], ohlc["low"].shift(-1), ohlc["high"].shift(-1)) | ||
size = abs(ohlc["high"].shift(1) - ohlc["low"].shift(-1)) | ||
|
||
# create a series for each of the keys in the dictionary | ||
fvg = pd.Series(fvg, name="FVG") | ||
direction = pd.Series(direction, name="Direction") | ||
start = pd.Series(start, name="Start") | ||
end = pd.Series(end, name="End") | ||
size = pd.Series(size, name="Size") | ||
|
||
print(pd.concat([fvg, direction, start, end, size], axis=1)) | ||
|
||
return pd.concat([fvg, direction, start, end, size], axis=1) | ||
|
||
if __name__ == "__main__": | ||
print([k for k in TA.__dict__.keys() if k[0] not in "_"]) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from smartmoneyconcepts.SMC import SMC |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pandas as pd | ||
import numpy as np | ||
from smartmoneyconcepts.SMC import SMC | ||
|
||
def test_FVG(): | ||
df = pd.read_csv('bittrex_btc-usdt.csv') | ||
SMC.FVG(df) | ||
|
||
test_FVG() |
Oops, something went wrong.