├── .gitignore ├── LICENSE ├── README.md ├── releases ├── latest │ ├── any_platform.zip │ └── metadata.yaml ├── profile │ └── lorentzian-classification_profile.zip ├── v-0.5.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.7.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.8.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.8.5.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.8.5 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.8.6 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.8.7 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.8.8.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.8.8 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.9.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.9.1.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.9.1.2 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.9.1.3 │ ├── any_platform.zip │ └── metadata.yaml ├── v-0.9.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.0.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.0.1.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.0.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.1.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.1.1.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.1.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.1.2.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.1.2 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.2.0.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.2.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.2.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.2.2 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.2.3 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.2.4 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.2.5 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.3.0.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.3.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.4.0 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.5.0.1 │ ├── any_platform.zip │ └── metadata.yaml ├── v-1.5.0 │ ├── any_platform.zip │ └── metadata.yaml └── v-1.5.1 │ ├── any_platform.zip │ └── metadata.yaml └── source ├── profile └── lorentzian_classification_default │ ├── LICENSE │ ├── matrix-icon.png │ ├── profile.json │ ├── specific_config │ ├── LorentzianClassificationMode.json │ ├── OctoUi2Plugin.json │ ├── OctoUi2ProPlugin.json │ ├── PingPongStorage.json │ ├── RunAnalysisModePlugin.json │ ├── TimeFrameStrategyEvaluator.json │ ├── backtesting_script.py │ └── profile_trading_script.py │ └── tentacles_config.json └── tentacles ├── Evaluator └── Strategies │ └── time_frame_strategy_evaluator │ ├── __init__.py │ ├── config │ └── TimeFrameStrategyEvaluator.json │ ├── metadata.json │ ├── resources │ └── TimeFrameStrategyEvaluator.md │ └── time_frame_strategy.py ├── Meta └── Keywords │ └── basic_tentacles │ ├── __init__.py │ ├── basic_modes │ ├── __init__.py │ ├── mode_base │ │ ├── __init__.py │ │ ├── abstract_mode_base.py │ │ ├── abstract_producer_base.py │ │ └── producer_base.py │ ├── scripted_trading_mode │ │ ├── __init__.py │ │ └── use_scripted_trading_mode.py │ └── spot_master │ │ ├── __init__.py │ │ ├── asset.py │ │ ├── spot_master_3000_trading_mode.py │ │ ├── spot_master_3000_trading_mode_settings.py │ │ └── spot_master_enums.py │ ├── matrix_basic_keywords │ ├── __init__.py │ ├── backtesting │ │ ├── __init__.py │ │ └── skip_runs.py │ ├── data │ │ ├── __init__.py │ │ ├── exchange_private_data │ │ │ ├── __init__.py │ │ │ └── position.py │ │ ├── public_exchange_data.py │ │ └── write_evaluator_cache.py │ ├── matrix_enums.py │ ├── matrix_errors.py │ ├── ml_utils │ │ ├── __init__.py │ │ ├── classification_functions │ │ │ ├── _init__.py │ │ │ ├── classification_utils.py │ │ │ └── downsampling.py │ │ ├── kernel_functions │ │ │ ├── __init__.py │ │ │ └── kernel.py │ │ ├── ml_extensions_2 │ │ │ ├── __init__.py │ │ │ └── ml_extensions.py │ │ └── utils.py │ ├── orders │ │ ├── __init__.py │ │ ├── close_all_trades.py │ │ ├── expired_orders_cancelling.py │ │ ├── managed_order_pro │ │ │ ├── __init__.py │ │ │ ├── activate_managed_order.py │ │ │ ├── calculators │ │ │ │ ├── __init__.py │ │ │ │ ├── position_sizing.py │ │ │ │ ├── stop_loss.py │ │ │ │ ├── stop_losses │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── stop_loss_types │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ ├── based_on_atr.py │ │ │ │ │ │ ├── based_on_indicator.py │ │ │ │ │ │ ├── based_on_low_high.py │ │ │ │ │ │ ├── based_on_percent.py │ │ │ │ │ │ └── based_on_static_price.py │ │ │ │ │ └── stop_loss_utilities.py │ │ │ │ ├── take_profit.py │ │ │ │ └── take_profits │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── based_on_indicator.py │ │ │ │ │ ├── based_on_percent.py │ │ │ │ │ ├── based_on_risk_reward.py │ │ │ │ │ ├── based_on_static_price.py │ │ │ │ │ └── take_profits.py │ │ │ ├── daemons │ │ │ │ ├── __init__.py │ │ │ │ ├── ping_pong │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── metadata.json │ │ │ │ │ ├── ping_pong_constants.py │ │ │ │ │ ├── ping_pong_storage │ │ │ │ │ │ ├── __init__.py │ │ │ │ │ │ ├── element.py │ │ │ │ │ │ ├── group.py │ │ │ │ │ │ └── storage.py │ │ │ │ │ └── simple_ping_pong.py │ │ │ │ └── trailing_stop_loss │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── trail_stop_losses.py │ │ │ │ │ └── trailing_types │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── based_on_indicator.py │ │ │ │ │ ├── based_on_sl_settings.py │ │ │ │ │ └── break_even.py │ │ │ ├── managed_orders.py │ │ │ ├── metadata.json │ │ │ ├── order_notification.py │ │ │ ├── order_placement.py │ │ │ ├── settings │ │ │ │ ├── __init__.py │ │ │ │ ├── all_settings.py │ │ │ │ ├── entry_settings.py │ │ │ │ ├── entry_types.py │ │ │ │ ├── order_settings_group.py │ │ │ │ ├── ping_pong_settings.py │ │ │ │ ├── position_size_settings.py │ │ │ │ ├── sl_settings.py │ │ │ │ └── tp_settings.py │ │ │ └── utilities.py │ │ └── scaled_orders.py │ ├── plottings │ │ ├── __init__.py │ │ └── plots.py │ ├── tools │ │ ├── __init__.py │ │ └── utilities.py │ ├── trade_analysis │ │ ├── __init__.py │ │ ├── order_plotting.py │ │ ├── tp_sl_analysis.py │ │ └── trade_analysis_activation.py │ └── user_inputs2 │ │ ├── __init__.py │ │ ├── select_time_frame.py │ │ └── user_input2_.py │ └── metadata.json └── Trading └── Mode └── lorentzian_classification ├── __init__.py ├── classification.py ├── config ├── LorentzianClassificationMode.json └── LorentzianClassificationMode_schema.json ├── metadata.json ├── resources └── LorentzianClassificationMode.md ├── settings.py ├── trade_execution.py └── trading_mode_entry.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # octobot-lorentzian-classification 4 | OctoBot Lorentzian Classification evaluator, based on the trading view indicator from [©jdehorty](https://www.tradingview.com/script/WhBzgfDu-Machine-Learning-Lorentzian-Classification) 5 | 6 | # installation 7 | ## 1. tentacle package installation 8 | ### Install with Octane (a OctoBot distribution) 9 | 1. Octane comes pre installed with Lorentzian Calssification - [install Octane from here](https://github.com/techfreaque/octane) 10 | 11 | ### Install package directly 12 | * If you are updating from version before v 0.9, you need to delete the tentacles folder first 13 | 14 | 1. Make sure you have the latest OctoBot version ready -> https://octobot.online 15 | 2. to be able to install Tentacles, enable a login password for your OctoBot under "Accounts -> Interface" 16 | 3. then go to yourOctobotDomain.com:5001/advanced/tentacle_packages - paste the URL for the latest version (see at the bottom) and install it 17 | 18 | ## 2. set up the profile 19 | * This trading mode can be either enabled with a copy of a default profile or you import the profile as described below 20 | ### Import the default profile 21 | 1. go to my-octobot-url.com/profile 22 | 2. click on any profile 23 | 3. click the "import a profile" button at the bottom right 24 | 4. paste the profile URL (latest version at the bottom) 25 | 5. click on "import" (might take a while) 26 | 27 | 28 | # Plots / Charts on OctoBot 29 | * To be able to display plots from this trading mode you can [install octo-ui2 from here](https://github.com/techfreaque/octo-ui-2) 30 | 31 | # Questions, issues, feature requests, ideas, etc 32 | [Post it here](https://github.com/techfreaque/octobot-lorentzian-classification/issues) 33 | 34 | # Change Log 35 | [You can find the change log here](https://github.com/techfreaque/octobot-lorentzian-classification/commits/main) 36 | 37 | # Your Donation Makes a Difference 38 | 39 | Thank you for considering donating to support this open source project! Your support allows me to continue working on new and exciting features for everyone to enjoy. As this project is developed in my free time, every donation helps to motivate me to spend more time on it and bring new ideas to life. Your contribution will go towards funding the development and maintenance of this project, and will help ensure that it remains a valuable resource for the community. Thank you for your support and for helping to make this project a reality! 40 | 41 | ## USDT wallets: 42 | 43 | USDT - TRX (Tron TRC20): TYfDkrjMeL6KpDFbB5A667V5BwYE3vzium\ 44 | USDT - BSC (BNB Smart Chain BEP20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4\ 45 | USDT - SOL (Solana): 8MeDCMQHXZJdhipkyoVUxahemuLy3ueEzuA8d8LTZe8o 46 | 47 | ## BUSD wallets: 48 | 49 | BUSD - BSC (BNB Smart Chain BEP20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4 50 | 51 | ## BTC wallets 52 | 53 | BTC - BTC: 163A8EDxQPjuUYUoP9u9f91dyRPAALmER7\ 54 | BTC - BSC (BNB Smart Chain BEP20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4\ 55 | BTC - SegWit BTC: bc1q2qnte70sdee0mw2h33jazx0dg4qd6erexzdajl\ 56 | BTC - ETH (ERC20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4 57 | 58 | ## BNB Wallets 59 | 60 | BNB - BSC (BNB Smart Chain BEP20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4\ 61 | BNB - ETH (ERC20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4 62 | 63 | ## ETH wallets 64 | 65 | ETH - ETH (ERC20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4 \ 66 | ETH - BSC (BNB Smart Chain BEP20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4 67 | 68 | ## DOGE wallets 69 | 70 | DOGE - DOGE: D5WteSP23WTAhM7Jh4dXxgkCL2CRjrdFJK\ 71 | DOGE - BSC (BNB Smart Chain BEP20): 0x723d447181844fb4f1a6e0bafefa3bfeff0623b4 72 | 73 | # Tentacle Package Download URL 74 | https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/main/releases/latest/any_platform.zip 75 | 76 | # Trading Profile Download URL 77 | https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/main/releases/profile/lorentzian-classification_profile.zip 78 | -------------------------------------------------------------------------------- /releases/latest/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/latest/any_platform.zip -------------------------------------------------------------------------------- /releases/latest/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - basic_tentacles@1.2.0 9 | - lorentzian_classification@1.5.1 10 | - time_frame_strategy_evaluator@1.4.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/profile/lorentzian-classification_profile.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/profile/lorentzian-classification_profile.zip -------------------------------------------------------------------------------- /releases/v-0.5.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.5.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.5.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.4.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.7.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.7.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.7.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.7.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.8.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.8.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.8.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.8.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.8.5.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.8.5.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.8.5.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.8.5 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.8.5/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.8.5/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.8.5/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.8.5 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.8.6/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.8.6/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.8.6/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.8.6 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.8.7/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.8.7/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.8.7/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.8.7 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.8.8.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.8.8.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.8.8.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.8.8 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.8.8/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.8.8/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.8.8/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.8.8 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.9.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.9.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.9.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - matrix_basic_keywords@0.6.9 10 | - lorentzian_classification@0.9.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.9.1.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.9.1.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.9.1.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.7.0 10 | - lorentzian_classification@0.9.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.9.1.2/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.9.1.2/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.9.1.2/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.7.0 10 | - lorentzian_classification@0.9.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.9.1.3/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.9.1.3/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.9.1.3/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.7.0 10 | - lorentzian_classification@0.9.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-0.9.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-0.9.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-0.9.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.7.0 10 | - lorentzian_classification@0.9.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.0.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.0.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.0.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.7.0 10 | - lorentzian_classification@1.0.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.0.1.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.0.1.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.0.1.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.8.0 10 | - lorentzian_classification@1.0.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.0.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.0.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.0.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.8.0 10 | - lorentzian_classification@1.0.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.1.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.1.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.1.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.8.0 10 | - lorentzian_classification@1.1.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.1.1.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.1.1.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.1.1.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.8.0 10 | - lorentzian_classification@1.1.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.1.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.1.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.1.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.8.0 10 | - lorentzian_classification@1.1.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.1.2.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.1.2.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.1.2.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.8.0 10 | - lorentzian_classification@1.1.2 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.1.2/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.1.2/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.1.2/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.8.0 10 | - lorentzian_classification@1.1.2 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.2.0.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.2.0.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.2.0.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.9.0 10 | - lorentzian_classification@1.2.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.2.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.2.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.2.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@0.9.0 10 | - lorentzian_classification@1.2.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.2.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.2.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.2.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@1.0.0 10 | - lorentzian_classification@1.2.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.2.2/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.2.2/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.2.2/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@1.0.0 10 | - lorentzian_classification@1.2.2 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.2.3/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.2.3/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.2.3/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@1.0.0 10 | - lorentzian_classification@1.2.3 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.2.4/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.2.4/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.2.4/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - time_frame_strategy_evaluator@1.3.1 9 | - basic_tentacles@1.0.0 10 | - lorentzian_classification@1.2.4 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.2.5/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.2.5/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.2.5/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - basic_tentacles@1.0.0 9 | - lorentzian_classification@1.2.5 10 | - time_frame_strategy_evaluator@1.3.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.3.0.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.3.0.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.3.0.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - basic_tentacles@1.1.0 9 | - lorentzian_classification@1.3.0 10 | - time_frame_strategy_evaluator@1.3.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.3.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.3.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.3.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - basic_tentacles@1.0.0 9 | - lorentzian_classification@1.3.0 10 | - time_frame_strategy_evaluator@1.3.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.4.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.4.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.4.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - basic_tentacles@1.1.0 9 | - lorentzian_classification@1.4.0 10 | - time_frame_strategy_evaluator@1.3.1 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.5.0.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.5.0.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.5.0.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - basic_tentacles@1.2.0 9 | - lorentzian_classification@1.5.0 10 | - time_frame_strategy_evaluator@1.4.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.5.0/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.5.0/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.5.0/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - basic_tentacles@1.2.0 9 | - lorentzian_classification@1.5.0 10 | - time_frame_strategy_evaluator@1.4.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /releases/v-1.5.1/any_platform.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/releases/v-1.5.1/any_platform.zip -------------------------------------------------------------------------------- /releases/v-1.5.1/metadata.yaml: -------------------------------------------------------------------------------- 1 | author: DrakkarSoftware 2 | description: '' 3 | name: any_platform.zip 4 | repository: Unknown repository location 5 | short-name: any_platform.zip 6 | tags: [] 7 | tentacles: 8 | - basic_tentacles@1.2.0 9 | - lorentzian_classification@1.5.1 10 | - time_frame_strategy_evaluator@1.4.0 11 | type: tentacle_package 12 | version: unknown_version 13 | -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/source/profile/lorentzian_classification_default/LICENSE -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/matrix-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/bf55a1f744ee79106f8872a120d7b1efc9fc6f46/source/profile/lorentzian_classification_default/matrix-icon.png -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/profile.json: -------------------------------------------------------------------------------- 1 | { 2 | "config": { 3 | "crypto-currencies": { 4 | "Bitcoin": { 5 | "enabled": true, 6 | "pairs": [ 7 | "BTC/USDT" 8 | ] 9 | }, 10 | "Ethereum": { 11 | "enabled": true, 12 | "pairs": [ 13 | "ETH/USDT" 14 | ] 15 | } 16 | }, 17 | "exchanges": { 18 | "binance": { 19 | "enabled": true, 20 | "exchange-type": "spot" 21 | }, 22 | "binanceusdm": { 23 | "enabled": false, 24 | "exchange-type": "future" 25 | } 26 | }, 27 | "trader": { 28 | "enabled": false, 29 | "load-trade-history": true 30 | }, 31 | "trader-simulator": { 32 | "enabled": true, 33 | "fees": { 34 | "maker": 0.01, 35 | "taker": 0.01 36 | }, 37 | "starting-portfolio": { 38 | "USDT": 10000 39 | } 40 | }, 41 | "trading": { 42 | "reference-market": "USDT", 43 | "risk": 0.5 44 | } 45 | }, 46 | "profile": { 47 | "avatar": "matrix-icon.png", 48 | "complexity": 2, 49 | "description": "see https://github.com/techfreaque/octobot-lorentzian-classification for more details", 50 | "id": "my_lorentzian_classification", 51 | "imported": true, 52 | "name": "My Lorentzian Classification", 53 | "origin_url": "https://raw.githubusercontent.com/techfreaque/octobot-lorentzian-classification/main/releases/profile/lorentzian-classification_profile.zip", 54 | "read_only": false, 55 | "risk": 2, 56 | "type": "live" 57 | } 58 | } -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/specific_config/LorentzianClassificationMode.json: -------------------------------------------------------------------------------- 1 | { 2 | "activation_method": "once per bar close", 3 | "adx_filter_settings": { 4 | "use_adx_filter": false 5 | }, 6 | "candle_source": "close", 7 | "data_source_settings": { 8 | "candle_source": "close", 9 | "data_source_settings_BTC/USDT": { 10 | "enable_custom_source_BTC/USDT": false, 11 | "inverse_signals_BTC/USDT": false, 12 | "trade_on_BTC/USDT": true 13 | }, 14 | "data_source_settings_ETH/USDT": { 15 | "enable_custom_source_ETH/USDT": false, 16 | "inverse_signals_ETH/USDT": false, 17 | "trade_on_ETH/USDT": true 18 | } 19 | }, 20 | "data_source_settings_BTC/USDT": { 21 | "enable_custom_source_BTC/USDT": false, 22 | "inverse_signals_BTC/USDT": false, 23 | "trade_on_BTC/USDT": true 24 | }, 25 | "data_source_settings_ETH/USDT": { 26 | "enable_custom_source_ETH/USDT": false, 27 | "inverse_signals_ETH/USDT": false, 28 | "trade_on_ETH/USDT": true 29 | }, 30 | "default_config": [ 31 | "TimeFrameStrategyEvaluator" 32 | ], 33 | "display_settings": { 34 | "enable_additional_plots": false, 35 | "plotting_mode": "Replot history mode", 36 | "show_bar_predictions": false 37 | }, 38 | "down_sampler": "Use every x candles down sampler", 39 | "ema_filter_settings": { 40 | "use_ema_filter": false 41 | }, 42 | "enable_additional_plots": false, 43 | "enable_custom_source_BTC/USDT": false, 44 | "enable_custom_source_ETH/USDT": false, 45 | "enable_long_orders": true, 46 | "enable_short_orders": true, 47 | "exit_type": "switch sides on exits / entries", 48 | "f1_paramA": 35, 49 | "f1_paramB": 1, 50 | "f1_string": "RSI", 51 | "f2_paramA": 40, 52 | "f2_paramB": 11, 53 | "f2_string": "WT", 54 | "f3_paramA": 40, 55 | "f3_paramB": 1, 56 | "f3_string": "CCI", 57 | "f4_paramA": 50, 58 | "f4_paramB": 2, 59 | "f4_string": "ADX", 60 | "f5_paramA": 19, 61 | "f5_paramB": 1, 62 | "f5_string": "RSI", 63 | "feature_1_settings": { 64 | "f1_paramA": 35, 65 | "f1_paramB": 1, 66 | "f1_string": "RSI" 67 | }, 68 | "feature_2_settings": { 69 | "f2_paramA": 40, 70 | "f2_paramB": 11, 71 | "f2_string": "WT" 72 | }, 73 | "feature_3_settings": { 74 | "f3_paramA": 40, 75 | "f3_paramB": 1, 76 | "f3_string": "CCI" 77 | }, 78 | "feature_4_settings": { 79 | "f4_paramA": 50, 80 | "f4_paramB": 2, 81 | "f4_string": "ADX" 82 | }, 83 | "feature_5_settings": { 84 | "f5_paramA": 19, 85 | "f5_paramB": 1, 86 | "f5_string": "RSI" 87 | }, 88 | "feature_count": 5, 89 | "feature_engineering_settings": { 90 | "feature_1_settings": { 91 | "f1_paramA": 35, 92 | "f1_paramB": 1, 93 | "f1_string": "RSI" 94 | }, 95 | "feature_2_settings": { 96 | "f2_paramA": 40, 97 | "f2_paramB": 11, 98 | "f2_string": "WT" 99 | }, 100 | "feature_3_settings": { 101 | "f3_paramA": 40, 102 | "f3_paramB": 1, 103 | "f3_string": "CCI" 104 | }, 105 | "feature_4_settings": { 106 | "f4_paramA": 50, 107 | "f4_paramB": 2, 108 | "f4_string": "ADX" 109 | }, 110 | "feature_5_settings": { 111 | "f5_paramA": 19, 112 | "f5_paramB": 1, 113 | "f5_string": "RSI" 114 | }, 115 | "feature_count": 5, 116 | "plot_features": false 117 | }, 118 | "filter_settings": { 119 | "adx_filter_settings": { 120 | "use_adx_filter": false 121 | }, 122 | "ema_filter_settings": { 123 | "use_ema_filter": false 124 | }, 125 | "regime_filter_settings": { 126 | "plot_regime_filter": false, 127 | "regime_threshold": -0.1, 128 | "use_regime_filter": true 129 | }, 130 | "sma_filter_settings": { 131 | "use_sma_filter": false 132 | }, 133 | "volatility_filter_settings": { 134 | "plot_volatility_filter": false, 135 | "use_volatility_filter": true 136 | } 137 | }, 138 | "general_settings": { 139 | "down_sampler": "Use every x candles down sampler", 140 | "max_bars_back": 4900, 141 | "neighbors_count": 16, 142 | "only_train_on_x_bars": 4, 143 | "use_remote_fractals": false 144 | }, 145 | "inverse_signals_BTC/USDT": false, 146 | "inverse_signals_ETH/USDT": false, 147 | "kernel_settings": { 148 | "lag": 2, 149 | "lookback_window": 8, 150 | "regression_level": 25, 151 | "relative_weighting": 8, 152 | "show_kernel_estimate": true, 153 | "use_kernel_filter": true, 154 | "use_kernel_smoothing": false 155 | }, 156 | "lag": 2, 157 | "long_order_size": "50%", 158 | "lookback_window": 8, 159 | "max_bars_back": 4900, 160 | "neighbors_count": 16, 161 | "only_train_on_x_bars": 4, 162 | "order_settings": { 163 | "enable_long_orders": true, 164 | "enable_short_orders": true, 165 | "exit_type": "switch sides on exits / entries", 166 | "long_order_size": "50%", 167 | "order_type": "regular Order", 168 | "short_order_size": "50%" 169 | }, 170 | "order_type": "regular Order", 171 | "plot_features": false, 172 | "plot_regime_filter": false, 173 | "plot_volatility_filter": false, 174 | "plotting_mode": "Replot history mode", 175 | "regime_filter_settings": { 176 | "plot_regime_filter": false, 177 | "regime_threshold": -0.1, 178 | "use_regime_filter": true 179 | }, 180 | "regime_threshold": -0.1, 181 | "regression_level": 25, 182 | "relative_weighting": 8, 183 | "required_strategies": [ 184 | "TimeFrameStrategyEvaluator" 185 | ], 186 | "short_order_size": "50%", 187 | "show_bar_predictions": false, 188 | "show_kernel_estimate": true, 189 | "sma_filter_settings": { 190 | "use_sma_filter": false 191 | }, 192 | "trade_on_BTC/USDT": true, 193 | "trade_on_ETH/USDT": true, 194 | "use_adx_filter": false, 195 | "use_ema_filter": false, 196 | "use_kernel_filter": true, 197 | "use_kernel_smoothing": false, 198 | "use_regime_filter": true, 199 | "use_remote_fractals": false, 200 | "use_sma_filter": false, 201 | "use_volatility_filter": true, 202 | "volatility_filter_settings": { 203 | "plot_volatility_filter": false, 204 | "use_volatility_filter": true 205 | } 206 | } -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/specific_config/PingPongStorage.json: -------------------------------------------------------------------------------- 1 | { 2 | "ping_pong_info_storage": { 3 | "last_order_chain_id": 0 4 | }, 5 | "ping_pong_storage": {} 6 | } -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/specific_config/RunAnalysisModePlugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "backtesting": { 3 | "backtesting_dictionary": {}, 4 | "backtesting_plot": { 5 | "backtesting_plot_cached_values": { 6 | "enable_backtesting_plot_cached_values": true 7 | }, 8 | "backtesting_plot_candles": { 9 | "backtesting_plot_candles_chart_location": "main-chart", 10 | "enable_backtesting_plot_candles": true 11 | }, 12 | "backtesting_plot_trades": { 13 | "backtesting_plot_trades_chart_location": "main-chart", 14 | "backtesting_plot_trades_enabled_symbols": "Current Symbol", 15 | "enable_backtesting_plot_trades": true 16 | }, 17 | "backtesting_plothistorical_fees": { 18 | "enable_backtesting_plothistorical_fees": false 19 | }, 20 | "backtesting_plotplot_unrealized_portfolio_value": { 21 | "backtesting_plotplot_unrealized_portfolio_value_chart_location": "sub-chart", 22 | "enable_backtesting_plotplot_unrealized_portfolio_value": true 23 | } 24 | }, 25 | "backtesting_table": { 26 | "backtesting_table_trades_table": { 27 | "enable_backtesting_table_trades_table": false 28 | } 29 | }, 30 | "backtestingenable_run_analysis_mode": true, 31 | "backtestingenabled_run_analyzers": [ 32 | "plot_realized_portfolio_value", 33 | "plot_best_case_growth", 34 | "trades_table", 35 | "historical_wins_and_losses", 36 | "plot_trades", 37 | "realized_portfolio_value", 38 | "historical_win_rates", 39 | "realized_trade_pnl", 40 | "positions_table", 41 | "historical_fees", 42 | "plot_realized_trade_gains", 43 | "unrealized_portfolio_value", 44 | "withdrawals_table", 45 | "best_case_growth", 46 | "plot_cached_values", 47 | "plot_candles", 48 | "display_metadata" 49 | ] 50 | }, 51 | "live": { 52 | "live_dictionary": {}, 53 | "live_plot": { 54 | "live_plot_cached_values": { 55 | "enable_live_plot_cached_values": true 56 | }, 57 | "live_plot_candles": { 58 | "enable_live_plot_candles": true, 59 | "live_plot_candles_chart_location": "main-chart" 60 | }, 61 | "live_plot_trades": { 62 | "enable_live_plot_trades": true, 63 | "live_plot_trades_chart_location": "main-chart", 64 | "live_plot_trades_enabled_symbols": "Current Symbol" 65 | }, 66 | "live_plothistorical_fees": { 67 | "enable_live_plothistorical_fees": false 68 | }, 69 | "live_plotplot_unrealized_portfolio_value": { 70 | "enable_live_plotplot_unrealized_portfolio_value": true, 71 | "live_plotplot_unrealized_portfolio_value_chart_location": "sub-chart" 72 | } 73 | }, 74 | "live_table": { 75 | "live_table_trades_table": { 76 | "enable_live_table_trades_table": false 77 | } 78 | }, 79 | "liveenable_run_analysis_mode": true, 80 | "liveenabled_run_analyzers": [ 81 | "plot_realized_portfolio_value", 82 | "plot_best_case_growth", 83 | "trades_table", 84 | "historical_wins_and_losses", 85 | "plot_trades", 86 | "realized_portfolio_value", 87 | "historical_win_rates", 88 | "realized_trade_pnl", 89 | "positions_table", 90 | "historical_fees", 91 | "plot_realized_trade_gains", 92 | "unrealized_portfolio_value", 93 | "withdrawals_table", 94 | "best_case_growth", 95 | "plot_cached_values", 96 | "plot_candles", 97 | "display_metadata" 98 | ] 99 | } 100 | } -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/specific_config/TimeFrameStrategyEvaluator.json: -------------------------------------------------------------------------------- 1 | { 2 | "default_config": [], 3 | "required_candles_count": 5000, 4 | "required_evaluators": [], 5 | "required_time_frames": [ 6 | "1h" 7 | ] 8 | } -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/specific_config/backtesting_script.py: -------------------------------------------------------------------------------- 1 | 2 | async def script(ctx): 3 | pass 4 | -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/specific_config/profile_trading_script.py: -------------------------------------------------------------------------------- 1 | from octobot_trading.modes.script_keywords.context_management import Context 2 | 3 | 4 | async def script(ctx: Context): 5 | pass 6 | -------------------------------------------------------------------------------- /source/profile/lorentzian_classification_default/tentacles_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "installation_context": { 3 | "octobot_version": "0.4.42" 4 | }, 5 | "registered_tentacles": { 6 | "Lorentzian-Classification": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 7 | "Matrix-Library": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 8 | "Matrix-Octo-UI2": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 9 | "Matrix-Octo-UI2-Pro": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 10 | "Matrix-Pro-Tentacles": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 11 | "Matrix-Strategies": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 12 | "Matrix-Strategy-Maker": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 13 | "OctoBot-Default-Tentacles": "", 14 | "OctoBot-Private-Tentacles": "", 15 | "Semi-Auto-Trading-Mode": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 16 | "Spot-Master-3000": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip", 17 | "matrix-strategy-maker": "C:/Users/Max1/Desktop/projects/Octobot-Project/tentacle_zips/any_platform.zip" 18 | }, 19 | "tentacle_activation": { 20 | "Automation": { 21 | "CancelOpenOrders": true, 22 | "NoCondition": true, 23 | "PeriodicCheck": true, 24 | "PriceThreshold": true, 25 | "ProfitabilityThreshold": true, 26 | "SellAllCurrencies": true, 27 | "SendNotification": true, 28 | "StopTrading": true 29 | }, 30 | "Backtesting": { 31 | "ExchangeBotSnapshotCollector": true, 32 | "ExchangeHistoryDataCollector": true, 33 | "ExchangeLiveDataCollector": true, 34 | "GenericExchangeDataImporter": true, 35 | "LegacyDataConverter": true 36 | }, 37 | "Evaluator": { 38 | "ADXMomentumEvaluator": false, 39 | "BBMomentumEvaluator": false, 40 | "BlankStrategyEvaluator": false, 41 | "CandlesUtil": true, 42 | "DeathAndGoldenCrossEvaluator": false, 43 | "DipAnalyserStrategyEvaluator": false, 44 | "DoubleMovingAverageTrendEvaluator": false, 45 | "EMADivergenceTrendEvaluator": false, 46 | "GPTEvaluator": false, 47 | "GoogleTrendsEvaluator": false, 48 | "InstantFluctuationsEvaluator": false, 49 | "InstantMAEvaluator": false, 50 | "KlingerOscillatorMomentumEvaluator": false, 51 | "KlingerOscillatorReversalConfirmationMomentumEvaluator": false, 52 | "MACDMomentumEvaluator": false, 53 | "MoveSignalsStrategyEvaluator": false, 54 | "OverallStateAnalyser": true, 55 | "PatternAnalyser": true, 56 | "RSIMomentumEvaluator": false, 57 | "RSIWeightMomentumEvaluator": false, 58 | "RealTimeStrategyEvaluator": false, 59 | "RedditForumEvaluator": false, 60 | "SimpleStrategyEvaluator": false, 61 | "StatisticAnalysis": true, 62 | "StochasticRSIVolatilityEvaluator": false, 63 | "SuperTrendEvaluator": false, 64 | "TechnicalAnalysisStrategyEvaluator": false, 65 | "TelegramChannelSignalEvaluator": false, 66 | "TelegramSignalEvaluator": false, 67 | "TextAnalysis": true, 68 | "TimeFrameStrategyEvaluator": true, 69 | "TrendAnalysis": true, 70 | "TwitterNewsEvaluator": false, 71 | "trade_analysis": false 72 | }, 73 | "Meta": { 74 | "RunAnalysis": true, 75 | "basic_tentacles": true, 76 | "pro_tentacles": true 77 | }, 78 | "RunAnalysis": {}, 79 | "Services": { 80 | "GPTService": true, 81 | "GoogleService": true, 82 | "GoogleServiceFeed": true, 83 | "OctoUi2Plugin": true, 84 | "OctoUi2ProPlugin": true, 85 | "RedditService": true, 86 | "RedditServiceFeed": true, 87 | "RunAnalysisModePlugin": true, 88 | "TelegramApiService": true, 89 | "TelegramApiServiceFeed": true, 90 | "TelegramBotInterface": true, 91 | "TelegramNotifier": true, 92 | "TelegramService": true, 93 | "TelegramServiceFeed": true, 94 | "TradingViewService": true, 95 | "TradingViewServiceFeed": true, 96 | "TwitterNotifier": true, 97 | "TwitterService": true, 98 | "TwitterServiceFeed": true, 99 | "WebHookService": true, 100 | "WebInterface": true, 101 | "WebNotifier": true, 102 | "WebService": true 103 | }, 104 | "Trading": { 105 | "ArbitrageProTradingMode": false, 106 | "ArbitrageTradingMode": false, 107 | "AscendEx": true, 108 | "AscendexCCXTWebsocketConnector": true, 109 | "Binance": true, 110 | "BinanceCCXTWebsocketConnector": true, 111 | "BinanceUS": true, 112 | "BinanceUSCCXTFeedConnector": true, 113 | "BinanceUsdM": true, 114 | "Bitfinex": true, 115 | "BitfinexCCXTWebsocketConnector": true, 116 | "Bitget": true, 117 | "BitgetCCXTWebsocketConnector": true, 118 | "Bithumb": true, 119 | "Bitmex": true, 120 | "Bitso": true, 121 | "Bitstamp": true, 122 | "Bittrex": true, 123 | "BittrexCCXTWebsocketConnector": true, 124 | "BlankTradingMode": false, 125 | "Bybit": true, 126 | "BybitCCXTWebsocketConnector": true, 127 | "Coinbase": true, 128 | "CoinbasePro": true, 129 | "CoinbaseProCCXTWebsocketConnector": true, 130 | "Coinex": true, 131 | "ConfigurableDefaultCCXTRestExchange": true, 132 | "CryptoCom": true, 133 | "CryptoComCCXTWebsocketConnector": true, 134 | "DCATradingMode": false, 135 | "DailyTradingMode": false, 136 | "DipAnalyserTradingMode": false, 137 | "GateIO": true, 138 | "GateIOCCXTWebsocketConnector": true, 139 | "GridTradingMode": false, 140 | "Hitbtc": true, 141 | "HollaexCCXTWebsocketConnector": true, 142 | "Huobi": true, 143 | "HuobiCCXTWebsocketConnector": true, 144 | "HuobiPro": true, 145 | "HuobiProCCXTWebsocketConnector": true, 146 | "Kraken": true, 147 | "KrakenCCXTWebsocketConnector": true, 148 | "Kucoin": true, 149 | "KucoinCCXTWebsocketConnector": true, 150 | "LorentzianClassificationMode": true, 151 | "Ndax": true, 152 | "OKXCCXTWebsocketConnector": true, 153 | "Okcoin": true, 154 | "Okx": true, 155 | "Phemex": true, 156 | "PhemexCCXTWebsocketConnector": true, 157 | "Poloniex": true, 158 | "RemoteTradingSignalsTradingMode": false, 159 | "ScriptedTradingMode": false, 160 | "SemiAutoTradingMode": false, 161 | "SignalTradingMode": false, 162 | "SpotMaster3000Mode": false, 163 | "StaggeredOrdersTradingMode": false, 164 | "StrategyMakerMode": false, 165 | "TradingViewSignalsTradingMode": false, 166 | "UpbitExchange": true, 167 | "WavesExchange": true, 168 | "hollaex": true 169 | }, 170 | "profiles": {}, 171 | "tentacles": {} 172 | } 173 | } -------------------------------------------------------------------------------- /source/tentacles/Evaluator/Strategies/time_frame_strategy_evaluator/__init__.py: -------------------------------------------------------------------------------- 1 | from .time_frame_strategy import TimeFrameStrategyEvaluator 2 | -------------------------------------------------------------------------------- /source/tentacles/Evaluator/Strategies/time_frame_strategy_evaluator/config/TimeFrameStrategyEvaluator.json: -------------------------------------------------------------------------------- 1 | { 2 | "required_time_frames" : ["1h"], 3 | "required_evaluators" : [], 4 | "required_candles_count" : 5000, 5 | "default_config" : [] 6 | } -------------------------------------------------------------------------------- /source/tentacles/Evaluator/Strategies/time_frame_strategy_evaluator/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.4.0", 3 | "origin_package": "Octane-Default-Tentacles", 4 | "tentacles": [ 5 | "TimeFrameStrategyEvaluator" 6 | ], 7 | "tentacles-requirements": [] 8 | } -------------------------------------------------------------------------------- /source/tentacles/Evaluator/Strategies/time_frame_strategy_evaluator/resources/TimeFrameStrategyEvaluator.md: -------------------------------------------------------------------------------- 1 | TimeFrameStrategyEvaluator is forwarding evaluator values to the trading mode. 2 | -------------------------------------------------------------------------------- /source/tentacles/Evaluator/Strategies/time_frame_strategy_evaluator/time_frame_strategy.py: -------------------------------------------------------------------------------- 1 | # Drakkar-Software OctoBot-Tentacles 2 | # Copyright (c) Drakkar-Software, All rights reserved. 3 | # 4 | # This library is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU Lesser General Public 6 | # License as published by the Free Software Foundation; either 7 | # version 3.0 of the License, or (at your option) any later version. 8 | # 9 | # This library is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # Lesser General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public 15 | # License along with this library. 16 | import octobot_commons.constants as common_constants 17 | import octobot_commons.enums as common_enums 18 | import octobot_evaluators.evaluators as evaluators 19 | import octobot_evaluators.constants as constants 20 | 21 | 22 | class TimeFrameStrategyEvaluator(evaluators.StrategyEvaluator): 23 | def init_user_inputs(self, inputs: dict) -> None: 24 | """ 25 | Called right before starting the tentacle, 26 | should define all the tentacle's user inputs unless 27 | those are defined somewhere else. 28 | """ 29 | self.UI.user_input( 30 | constants.STRATEGIES_REQUIRED_TIME_FRAME, 31 | common_enums.UserInputTypes.MULTIPLE_OPTIONS, 32 | [common_enums.TimeFrames.ONE_HOUR.value], 33 | inputs, 34 | options=[tf.value for tf in common_enums.TimeFrames], 35 | title="Loaded time frames (requires a restart of Octobot)", 36 | other_schema_values={ 37 | "description": "The time frames that can be accessed by the trading mode" 38 | }, 39 | show_in_optimizer=False, 40 | show_in_summary=False, 41 | ) 42 | self.UI.user_input( 43 | common_constants.CONFIG_TENTACLES_REQUIRED_CANDLES_COUNT, 44 | common_enums.UserInputTypes.INT, 45 | 200, 46 | inputs, 47 | min_val=200, 48 | title="Amount of historical live candles (requires a restart of Octobot)", 49 | other_schema_values={ 50 | "description": "The number of historical bars you see on the chart. " 51 | "And also how much historical data your trading mode gets for" 52 | " each execution on each bar. " 53 | "The lower this value is, the faster each bar will get executed!" 54 | }, 55 | show_in_optimizer=False, 56 | show_in_summary=False, 57 | ) 58 | # # TODO replace with common_constants.CONFIG_TENTACLES_BACKTESTING_REQUIRED_CANDLES_COUNT 59 | # self.specific_config["backtesting_required_candles_count"] = 200 60 | 61 | def get_full_cycle_evaluator_types(self) -> tuple: 62 | return tuple() 63 | 64 | async def matrix_callback( 65 | self, 66 | matrix_id, 67 | evaluator_name, 68 | evaluator_type, 69 | eval_note, 70 | eval_note_type, 71 | exchange_name, 72 | cryptocurrency, 73 | symbol, 74 | time_frame, 75 | ): 76 | self.eval_note = eval_note 77 | await self.strategy_completed(cryptocurrency, symbol, time_frame=time_frame) 78 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/__init__.py: -------------------------------------------------------------------------------- 1 | from .matrix_basic_keywords import * 2 | from .basic_modes import * 3 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/basic_modes/__init__.py: -------------------------------------------------------------------------------- 1 | from .mode_base import * 2 | from .spot_master import * 3 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/basic_modes/mode_base/__init__.py: -------------------------------------------------------------------------------- 1 | from .abstract_mode_base import * 2 | from .producer_base import * 3 | from .abstract_producer_base import * 4 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/basic_modes/mode_base/producer_base.py: -------------------------------------------------------------------------------- 1 | import time 2 | from octobot_services import interfaces 3 | import octobot_commons.enums as commons_enums 4 | import octobot_trading.enums as trading_enums 5 | import octobot_trading.modes.script_keywords.basic_keywords as basic_keywords 6 | import octobot_trading.modes.script_keywords.context_management as context_management 7 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.matrix_enums as matrix_enums 8 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.user_inputs2.select_time_frame as select_time_frame 9 | import tentacles.Meta.Keywords.scripting_library.data.writing.plotting as plotting 10 | 11 | 12 | class MatrixProducerBase: 13 | action: str = None 14 | 15 | consumable_indicator_cache: dict = {} 16 | standalone_indicators: dict = {} 17 | initialized_managed_order_settings: dict = {} 18 | 19 | any_ping_pong_mode_active: bool = False 20 | 21 | plot_settings_name = "plot_settings" 22 | default_live_plotting_mode: str = ( 23 | matrix_enums.LivePlottingModes.PLOT_RECORDING_MODE.value 24 | ) 25 | default_backtest_plotting_mode: str = ( 26 | matrix_enums.BacktestPlottingModes.DISABLE_PLOTTING.value 27 | ) 28 | live_plotting_modes: list = [ 29 | matrix_enums.LivePlottingModes.DISABLE_PLOTTING.value, 30 | matrix_enums.LivePlottingModes.REPLOT_VISIBLE_HISTORY.value, 31 | matrix_enums.LivePlottingModes.PLOT_RECORDING_MODE.value, 32 | ] 33 | backtest_plotting_modes: list = [ 34 | matrix_enums.BacktestPlottingModes.ENABLE_PLOTTING.value, 35 | matrix_enums.BacktestPlottingModes.DISABLE_PLOTTING.value, 36 | ] 37 | 38 | backtest_plotting_mode: str = None 39 | live_plotting_mode: str = matrix_enums.LivePlottingModes.PLOT_RECORDING_MODE.value 40 | 41 | enable_plot: bool = True 42 | plot_signals: bool = False 43 | enable_ping_pong: bool = None 44 | 45 | # todo remove 46 | live_recording_mode: bool = None 47 | trigger_time_frames: list = None 48 | 49 | SUPPORTS_PLOT_SIGNALS: bool = True 50 | 51 | def __init__(self, channel, config, trading_mode, exchange_manager): 52 | self.candles_manager: dict = {} 53 | self.ctx: context_management.Context = None 54 | self.candles: dict = {} 55 | 56 | async def handle_trigger_time_frame(self): 57 | self.trigger_time_frames = await select_time_frame.set_trigger_time_frames( 58 | self.ctx 59 | ) 60 | self.cancel_non_trigger_time_frames() 61 | 62 | def cancel_non_trigger_time_frames(self): 63 | select_time_frame.cancel_non_trigger_time_frames( 64 | self.ctx, self.trigger_time_frames 65 | ) 66 | 67 | def disable_trading_if_just_started(self): 68 | if not self.exchange_manager.is_backtesting: 69 | running_seconds = time.time() - interfaces.get_bot_api().get_start_time() 70 | if running_seconds < 200: 71 | self.ctx.enable_trading = False 72 | 73 | def allow_trading_only_on_execution(self, ctx, allow_trading_without_action=False): 74 | if not self.exchange_manager.is_backtesting: 75 | if self.action in (matrix_enums.TradingModeCommands.EXECUTE,): 76 | ctx.enable_trading = True 77 | elif self.action in ( 78 | matrix_enums.TradingModeCommands.OHLC_CALLBACK, 79 | matrix_enums.TradingModeCommands.KLINE_CALLBACK, 80 | ): 81 | ctx.enable_trading = True 82 | self.disable_trading_if_just_started() 83 | else: 84 | if allow_trading_without_action: 85 | ctx.enable_trading = True 86 | else: 87 | ctx.enable_trading = False 88 | 89 | async def set_position_mode_to_one_way(self): 90 | if self.exchange_manager.is_future: 91 | try: 92 | await self.exchange_manager.trader.set_position_mode( 93 | self.ctx.symbol, trading_enums.PositionMode.ONE_WAY 94 | ) 95 | except Exception as e: 96 | # not important 97 | pass 98 | 99 | async def init_plot_settings(self, enable_plotting_modes: bool = True): 100 | await basic_keywords.user_input( 101 | self.ctx, 102 | self.plot_settings_name, 103 | commons_enums.UserInputTypes.OBJECT, 104 | def_val=None, 105 | title="Plot settings", 106 | show_in_summary=False, 107 | show_in_optimizer=False, 108 | editor_options={ 109 | commons_enums.UserInputEditorOptionsTypes.GRID_COLUMNS.value: 12, 110 | }, 111 | other_schema_values={ 112 | commons_enums.UserInputOtherSchemaValuesTypes.DESCRIPTION.value: "Use " 113 | "those options wisely when backtesting, " 114 | "as it will slow down the backtesting speed by quit a lot", 115 | }, 116 | ) 117 | if enable_plotting_modes: 118 | await self.init_plotting_modes( 119 | self.plot_settings_name, self.plot_settings_name 120 | ) 121 | 122 | async def init_plotting_modes(self, live_parent_input, backtesting_parent_input): 123 | self.backtest_plotting_mode = await basic_keywords.user_input( 124 | self.ctx, 125 | "backtest_plotting_mode", 126 | commons_enums.UserInputTypes.OPTIONS, 127 | title="Backtest plotting mode", 128 | def_val=self.default_backtest_plotting_mode, 129 | options=self.backtest_plotting_modes, 130 | show_in_summary=False, 131 | show_in_optimizer=False, 132 | parent_input_name=backtesting_parent_input, 133 | ) 134 | if self.SUPPORTS_PLOT_SIGNALS: 135 | self.plot_signals = await basic_keywords.user_input( 136 | self.ctx, 137 | "plot_signals", 138 | commons_enums.UserInputTypes.BOOLEAN, 139 | title="Plot signals", 140 | def_val=False, 141 | show_in_summary=False, 142 | show_in_optimizer=False, 143 | parent_input_name=backtesting_parent_input, 144 | ) 145 | if self.exchange_manager.is_backtesting: 146 | if ( 147 | self.backtest_plotting_mode 148 | == matrix_enums.BacktestPlottingModes.DISABLE_PLOTTING.value 149 | ): 150 | self.enable_plot = False 151 | elif ( 152 | self.backtest_plotting_mode 153 | == matrix_enums.BacktestPlottingModes.ENABLE_PLOTTING.value 154 | ): 155 | self.enable_plot = True 156 | else: 157 | self.live_plotting_mode = await basic_keywords.user_input( 158 | self.ctx, 159 | "live_plotting_mode", 160 | commons_enums.UserInputTypes.OPTIONS, 161 | title="Live plotting mode", 162 | def_val=self.default_live_plotting_mode, 163 | options=self.live_plotting_modes, 164 | show_in_summary=False, 165 | show_in_optimizer=False, 166 | parent_input_name=live_parent_input, 167 | ) 168 | if ( 169 | self.live_plotting_mode 170 | == matrix_enums.LivePlottingModes.PLOT_RECORDING_MODE.value 171 | ): 172 | self.live_recording_mode = True 173 | self.enable_plot = True 174 | elif ( 175 | self.live_plotting_mode 176 | == matrix_enums.LivePlottingModes.DISABLE_PLOTTING.value 177 | ): 178 | self.enable_plot = False 179 | self.live_recording_mode = True 180 | await plotting.disable_candles_plot(self.ctx) 181 | elif ( 182 | self.live_plotting_mode 183 | == matrix_enums.LivePlottingModes.REPLOT_VISIBLE_HISTORY.value 184 | ): 185 | self.live_recording_mode = False 186 | self.enable_plot = True 187 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/basic_modes/scripted_trading_mode/__init__.py: -------------------------------------------------------------------------------- 1 | from .use_scripted_trading_mode import * 2 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/basic_modes/scripted_trading_mode/use_scripted_trading_mode.py: -------------------------------------------------------------------------------- 1 | def initialize_scripted_trading_mode(trading_mode)->bool: 2 | try: 3 | import backtesting_script 4 | 5 | trading_mode.register_script_module(backtesting_script, live=False) 6 | except (AttributeError, ModuleNotFoundError): 7 | pass 8 | try: 9 | import profile_trading_script 10 | trading_mode.register_script_module(profile_trading_script) 11 | return True 12 | except (AttributeError, ModuleNotFoundError): 13 | return False 14 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/basic_modes/spot_master/__init__.py: -------------------------------------------------------------------------------- 1 | from .asset import * 2 | from .spot_master_enums import * 3 | from .spot_master_3000_trading_mode import * 4 | from .spot_master_3000_trading_mode_settings import * 5 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/basic_modes/spot_master/spot_master_enums.py: -------------------------------------------------------------------------------- 1 | import enum 2 | 3 | 4 | class SpotMasterOrderTypes(enum.Enum): 5 | MARKET = "Market Orders" 6 | LIMIT = "Limit Orders" 7 | MANAGED_ORDER = "Order Manager Pro" 8 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/__init__.py: -------------------------------------------------------------------------------- 1 | from .data import * 2 | from .plottings import * 3 | from .tools import * 4 | from .user_inputs2 import * 5 | from .matrix_enums import * 6 | from .matrix_errors import * 7 | from .ml_utils import * 8 | from .orders import * 9 | from .trade_analysis import * 10 | from .backtesting import * 11 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/backtesting/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .skip_runs import * 22 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/backtesting/skip_runs.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import octobot_backtesting.api as backtesting_api 22 | from tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.close_all_trades import ( 23 | close_all_positions, 24 | ) 25 | 26 | 27 | async def skip_backtesting_runs_if_condition(ctx, skip_runs_balance): 28 | if skip_runs_balance: 29 | current_total_balance = ( 30 | ctx.exchange_manager.exchange_personal_data.portfolio_manager.portfolio_value_holder.portfolio_current_value 31 | ) 32 | origin_total_balance = ( 33 | ctx.exchange_manager.exchange_personal_data.portfolio_manager.portfolio_value_holder.portfolio_origin_value 34 | ) 35 | 36 | if current_total_balance < origin_total_balance * skip_runs_balance / 100: 37 | await close_all_positions(ctx) 38 | register_backtesting_timestamp_whitelist(ctx, [], append_to_whitelist=False) 39 | 40 | 41 | def register_backtesting_timestamp_whitelist(ctx, timestamps, append_to_whitelist=True): 42 | def _open_order_and_position_check(): 43 | # by default, avoid skipping timestamps when there are open orders or active positions 44 | if ctx.exchange_manager.exchange_personal_data.orders_manager.get_open_orders(): 45 | return True 46 | for ( 47 | position 48 | ) in ( 49 | ctx.exchange_manager.exchange_personal_data.positions_manager.positions.values() 50 | ): 51 | if not position.is_idle(): 52 | return True 53 | return False 54 | 55 | if backtesting_api.get_backtesting_timestamp_whitelist( 56 | ctx.exchange_manager.exchange.backtesting 57 | ) != sorted(set(timestamps)): 58 | backtesting_api.register_backtesting_timestamp_whitelist( 59 | ctx.exchange_manager.exchange.backtesting, 60 | timestamps, 61 | _open_order_and_position_check, 62 | append_to_whitelist=append_to_whitelist, 63 | ) 64 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/data/__init__.py: -------------------------------------------------------------------------------- 1 | from .public_exchange_data import * 2 | from .exchange_private_data import * 3 | from .write_evaluator_cache import * 4 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/data/exchange_private_data/__init__.py: -------------------------------------------------------------------------------- 1 | from .position import * 2 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/data/exchange_private_data/position.py: -------------------------------------------------------------------------------- 1 | import decimal 2 | import octobot_commons.symbols.symbol_util as symbol_util 3 | import octobot_trading.modes.script_keywords.context_management as context_management 4 | 5 | 6 | def get_position_size(ctx: context_management.Context) -> decimal.Decimal: 7 | if ctx.exchange_manager.is_future: 8 | try: 9 | return ( 10 | ctx.exchange_manager.exchange_personal_data.positions_manager.positions[ 11 | ctx.symbol 12 | ].size 13 | ) 14 | except KeyError: 15 | return decimal.Decimal("0") 16 | currency = symbol_util.parse_symbol(ctx.symbol).base 17 | portfolio = ctx.exchange_manager.exchange_personal_data.portfolio_manager.portfolio 18 | return portfolio.get_currency_portfolio(currency).total 19 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/data/write_evaluator_cache.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import octobot_commons.enums as commons_enums 3 | import octobot_commons.constants as commons_constants 4 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.data.public_exchange_data as public_exchange_data 5 | from tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.matrix_enums import ( 6 | PriceDataSources, 7 | ) 8 | 9 | 10 | async def store_evaluator_history( 11 | maker, 12 | ctx, 13 | indicator_values, 14 | signals_data, 15 | plot_enabled=True, 16 | additional_values_by_key=None, 17 | ): 18 | # store it in one go 19 | times = await public_exchange_data.get_candles_( 20 | maker, PriceDataSources.TIME.value, time_frame=maker.ctx.time_frame 21 | ) 22 | data_length = len(signals_data) 23 | times = times[-data_length:] 24 | 25 | if plot_enabled: 26 | plot_cache_key = ( 27 | f"{commons_enums.CacheDatabaseColumns.VALUE.value}" 28 | f"{commons_constants.CACHE_RELATED_DATA_SEPARATOR}y" 29 | ) 30 | y_cache = [] 31 | y_times = [] 32 | indicator_values = indicator_values[-data_length:] 33 | for index, signal_value in enumerate(signals_data): 34 | if signal_value: 35 | y_cache.append(indicator_values[index]) 36 | y_times.append(times[index]) 37 | await ctx.set_cached_values( 38 | values=y_cache, cache_keys=y_times, value_key=plot_cache_key 39 | ) 40 | await ctx.set_cached_values( 41 | values=signals_data, 42 | cache_keys=times, 43 | value_key=commons_enums.CacheDatabaseColumns.VALUE.value, 44 | additional_values_by_key=additional_values_by_key, 45 | ) 46 | # write cache flag on the first candle, 47 | # cause we dont know on which timestamp the first cached result is 48 | await ctx.set_cached_value(value=True, value_key="csh") 49 | 50 | 51 | async def store_indicator_history( 52 | maker, 53 | indicator_values, 54 | value_key=commons_enums.CacheDatabaseColumns.VALUE.value, 55 | additional_values_by_key=None, 56 | enable_rounding=True, 57 | filter_nan_for_plots=False, 58 | ): 59 | if additional_values_by_key is None: 60 | additional_values_by_key = {} 61 | round_decimals = None 62 | if enable_rounding: 63 | if max(indicator_values) < 1 and min(indicator_values) > -1: 64 | round_decimals = 8 65 | else: 66 | round_decimals = 3 67 | # store it in one go 68 | time_data = await public_exchange_data.get_candles_( 69 | maker, PriceDataSources.TIME.value, time_frame=maker.ctx.time_frame 70 | ) 71 | cut_t = time_data[-len(indicator_values) :] 72 | if round_decimals: 73 | indicator_values = np.round(indicator_values, decimals=round_decimals) 74 | if additional_values_by_key: 75 | for key in additional_values_by_key: 76 | additional_values_by_key[key] = np.round( 77 | additional_values_by_key[key], decimals=2 78 | ) 79 | if filter_nan_for_plots: 80 | additional_values_by_key[value_key] = indicator_values 81 | for _value_key, values in additional_values_by_key.items(): 82 | final_values = [] 83 | final_times = [] 84 | cut_t = time_data[-len(values) :] 85 | for index, value in enumerate(values): 86 | if str(value) != str(np.nan): 87 | final_values.append(value) 88 | final_times.append(cut_t[index]) 89 | await maker.ctx.set_cached_values( 90 | values=final_values, 91 | cache_keys=final_times, 92 | value_key=_value_key, 93 | ) 94 | else: 95 | await maker.ctx.set_cached_values( 96 | values=indicator_values, 97 | cache_keys=cut_t, 98 | value_key=value_key, 99 | additional_values_by_key=additional_values_by_key, 100 | ) 101 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/matrix_enums.py: -------------------------------------------------------------------------------- 1 | import enum 2 | 3 | 4 | class LivePlottingModes(enum.Enum): 5 | DISABLE_PLOTTING = "disable live plotting" 6 | PLOT_RECORDING_MODE = "plot recording mode" 7 | REPLOT_VISIBLE_HISTORY = "replot visible history" 8 | 9 | 10 | class BacktestPlottingModes(enum.Enum): 11 | DISABLE_PLOTTING = "disable backtest indicator plotting" 12 | ENABLE_PLOTTING = "enable backtest indicator plotting" 13 | 14 | 15 | CURRENT_TIME_FRAME = "current time frame" 16 | 17 | 18 | class TradingModeCommands: 19 | EXECUTE = "execute" 20 | ACTIVATE_REALTIME_STRATEGY = "activate_realtime_strategy" 21 | DISABLE_REALTIME_STRATEGY = "disable_realtime_strategy" 22 | SAVE = "save" 23 | INIT_CALL = "init_call" 24 | OHLC_CALLBACK = "ohlc_callback" 25 | KLINE_CALLBACK = "kline_callback" 26 | TRADING_VIEW_CALLBACK = "trading_view_callback" 27 | 28 | 29 | class TradingSideKeys: 30 | LONG = "l" 31 | LONG_EXIT = "el" 32 | SHORT = "s" 33 | SHORT_EXIT = "es" 34 | 35 | 36 | class TradingSidesNames: 37 | LONG_TITLE = "Long" 38 | LONG_EXIT_TITLE = "Long Exit" 39 | SHORT_TITLE = "Short" 40 | SHORT_EXIT_TITLE = "Short Exit" 41 | LONG = LONG_TITLE.lower() 42 | LONG_EXIT = LONG_EXIT_TITLE.lower() 43 | SHORT = SHORT_TITLE.lower() 44 | SHORT_EXIT = SHORT_EXIT_TITLE.lower() 45 | 46 | 47 | class UserInputOtherSchemaValuesTypes(enum.Enum): 48 | DISPLAY_AS_TAB = "display_as_tab" # used by octo ui2 49 | TAB_ORDER = "order" # used by octo ui2 50 | 51 | 52 | class UserInputEditorOptionsTypes(enum.Enum): 53 | ANT_ICON = "antIcon" # used by octo ui2 54 | 55 | 56 | class PriceDataSources(enum.Enum): 57 | """ 58 | Default candle price str 59 | """ 60 | 61 | TIME = "Time" 62 | CLOSE = "Close" 63 | OPEN = "Open" 64 | HIGH = "High" 65 | LOW = "Low" 66 | VOLUME = "Volume" 67 | LIVE = "Live" 68 | HL2 = "HL2" 69 | HLC3 = "HLC3" 70 | OHLC4 = "OHLC4" 71 | HEIKIN_ASHI_CLOSE = "Heikin Ashi close" 72 | HEIKIN_ASHI_OPEN = "Heikin Ashi open" 73 | HEIKIN_ASHI_HIGH = "Heikin Ashi high" 74 | HEIKIN_ASHI_LOW = "Heikin Ashi low" 75 | 76 | 77 | TAG_SEPERATOR = "xx" 78 | TAKE_PROFIT = "tp" 79 | ENTRY = "e" 80 | STOP_LOSS = "sl" 81 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/matrix_errors.py: -------------------------------------------------------------------------------- 1 | class MaximumOpenPositionReachedError(Exception): 2 | pass 3 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/ml_utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .ml_extensions_2 import * 2 | from .kernel_functions import * 3 | from .classification_functions import * 4 | from .utils import * -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/ml_utils/classification_functions/_init__.py: -------------------------------------------------------------------------------- 1 | from .classification_utils import * 2 | from .downsampling import * 3 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/ml_utils/classification_functions/downsampling.py: -------------------------------------------------------------------------------- 1 | 2 | import typing 3 | 4 | def no_down_sampler(candles_back: int, only_train_on_every_x_bars: int) -> bool: 5 | return candles_back % 4 6 | 7 | 8 | def skip_every_x_down_sampler( 9 | candles_back: int, only_train_on_every_x_bars: int 10 | ) -> bool: 11 | return candles_back % only_train_on_every_x_bars 12 | 13 | 14 | def use_every_x_down_sampler( 15 | candles_back: int, only_train_on_every_x_bars: int 16 | ) -> bool: 17 | return not (candles_back % only_train_on_every_x_bars) 18 | 19 | 20 | class DownSamplers: 21 | SKIP_EVERY_X_DOWN_SAMPLER: str = ( 22 | "Skip every x candles down sampler (TradingView downsampler)" 23 | ) 24 | USE_EVERY_X_DOWN_SAMPLER: str = "Use every x candles down sampler" 25 | NO_DOWN_SAMPLER: str = "No down sampler" 26 | DEFAULT_DOWN_SAMPLER: str = USE_EVERY_X_DOWN_SAMPLER 27 | AVAILABLE_DOWN_SAMPLERS: list = [ 28 | USE_EVERY_X_DOWN_SAMPLER, 29 | SKIP_EVERY_X_DOWN_SAMPLER, 30 | NO_DOWN_SAMPLER, 31 | ] 32 | DOWN_SAMPLERS_BY_TITLES: typing.Dict[str, typing.Callable[[int, int], bool]] = { 33 | SKIP_EVERY_X_DOWN_SAMPLER: skip_every_x_down_sampler, 34 | NO_DOWN_SAMPLER: no_down_sampler, 35 | USE_EVERY_X_DOWN_SAMPLER: use_every_x_down_sampler, 36 | } 37 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/ml_utils/kernel_functions/__init__.py: -------------------------------------------------------------------------------- 1 | from .kernel import * 2 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/ml_utils/kernel_functions/kernel.py: -------------------------------------------------------------------------------- 1 | import math 2 | import typing 3 | import numpy.typing as npt 4 | import numpy as numpy 5 | 6 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.tools.utilities as basic_utilities 7 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.ml_utils.utils as utils 8 | 9 | 10 | def rationalQuadratic( 11 | data_source: npt.NDArray[numpy.float64], 12 | look_back: int, 13 | relative_weight: float, 14 | start_at_Bar: int, 15 | ) -> npt.NDArray[numpy.float64]: 16 | yhat: typing.List[float] = [] 17 | start_at_Bar += 1 # because this is 1 on tv: _size = array.size(array.from(_src)) 18 | for index in range(start_at_Bar, len(data_source)): 19 | _currentWeight: float = 0 20 | _cumulativeWeight: float = 0 21 | for bars_back_index in range(0, start_at_Bar): 22 | y = data_source[index - bars_back_index] 23 | w = pow( 24 | 1 25 | + ( 26 | pow(bars_back_index, 2) 27 | / ((pow(look_back, 2) * 2 * relative_weight)) 28 | ), 29 | -relative_weight, 30 | ) 31 | _currentWeight += y * w 32 | _cumulativeWeight += w 33 | yhat.append(_currentWeight / _cumulativeWeight) 34 | return numpy.array(yhat) 35 | 36 | 37 | def gaussian( 38 | data_source: npt.NDArray[numpy.float64], look_back: int, start_at_Bar: int 39 | ) -> npt.NDArray[numpy.float64]: 40 | start_at_Bar += 1 41 | yhat: typing.List[float] = [] 42 | for index in range(start_at_Bar, len(data_source)): 43 | _currentWeight: float = 0 44 | _cumulativeWeight: float = 0 45 | for bars_back_index in range(0, start_at_Bar): 46 | y = data_source[index - bars_back_index] 47 | w = math.exp(-pow(bars_back_index, 2) / (2 * pow(look_back, 2))) 48 | _currentWeight += y * w 49 | _cumulativeWeight += w 50 | yhat.append(_currentWeight / _cumulativeWeight) 51 | return numpy.array(yhat) 52 | 53 | 54 | def get_kernel_data( 55 | kernel_settings, user_selected_candles: npt.NDArray[numpy.float64], data_length: int 56 | ) -> tuple: 57 | # TODO colors 58 | # c_green = color.new(#009988, 20) 59 | # c_red = color.new(#CC3311, 20) 60 | # transparent = color.new(#000000, 100) 61 | 62 | yhat1: npt.NDArray[numpy.float64] = rationalQuadratic( 63 | user_selected_candles, 64 | kernel_settings.lookback_window, 65 | kernel_settings.relative_weighting, 66 | kernel_settings.regression_level, 67 | ) 68 | yhat2: npt.NDArray[numpy.float64] = gaussian( 69 | user_selected_candles, 70 | kernel_settings.lookback_window - kernel_settings.lag, 71 | kernel_settings.regression_level, 72 | ) 73 | yhat1, yhat2 = basic_utilities.cut_data_to_same_len((yhat1, yhat2)) 74 | 75 | kernel_estimate: npt.NDArray[numpy.float64] = yhat1 76 | # Kernel Rates of Change 77 | # shift and cut data for numpy 78 | yhat1_cutted_1, yhat1_shifted_1 = basic_utilities.shift_data(yhat1, 1) 79 | yhat1_cutted_2, yhat1_shifted_2 = basic_utilities.shift_data(yhat1, 2) 80 | was_bearish_rates: npt.NDArray[numpy.bool_] = yhat1_shifted_2 > yhat1_cutted_2 81 | was_bullish_rates: npt.NDArray[numpy.bool_] = yhat1_shifted_2 < yhat1_cutted_2 82 | 83 | is_bearish_rates: npt.NDArray[numpy.bool_] = yhat1_shifted_1 > yhat1_cutted_1 84 | is_bullish_rates: npt.NDArray[numpy.bool_] = yhat1_shifted_1 < yhat1_cutted_1 85 | 86 | is_bearish_rates, was_bullish_rates = basic_utilities.cut_data_to_same_len( 87 | (is_bearish_rates, was_bullish_rates) 88 | ) 89 | is_bearish_changes: npt.NDArray[numpy.bool_] = numpy.logical_and( 90 | is_bearish_rates, was_bullish_rates 91 | ) 92 | is_bullish_rates, was_bearish_rates = basic_utilities.cut_data_to_same_len( 93 | (is_bullish_rates, was_bearish_rates) 94 | ) 95 | is_bullish_changes: npt.NDArray[numpy.bool_] = numpy.logical_and( 96 | is_bullish_rates, was_bearish_rates 97 | ) 98 | # Kernel Crossovers 99 | is_bullish_cross_alerts, is_bearish_cross_alerts = utils.get_is_crossing_data( 100 | yhat2, yhat1 101 | ) 102 | is_bullish_smooths: npt.NDArray[numpy.bool_] = yhat2 >= yhat1 103 | is_bearish_smooths: npt.NDArray[numpy.bool_] = yhat2 <= yhat1 104 | 105 | # # Kernel Colors 106 | # TODO 107 | # # color colorByCross = isBullishSmooth ? c_green : c_red 108 | # # color colorByRate = isBullishRate ? c_green : c_red 109 | # # color plotColor = showKernelEstimate ? (useKernelSmoothing ? colorByCross : colorByRate) : transparent 110 | # # plot(kernelEstimate, color=plotColor, linewidth=2, title="Kernel Regression Estimate") 111 | 112 | # # Alert Variables 113 | alerts_bullish: npt.NDArray[numpy.bool_] = ( 114 | is_bullish_cross_alerts 115 | if kernel_settings.use_kernel_smoothing 116 | else is_bullish_changes 117 | ) 118 | alerts_bearish: npt.NDArray[numpy.bool_] = ( 119 | is_bearish_cross_alerts 120 | if kernel_settings.use_kernel_smoothing 121 | else is_bearish_changes 122 | ) 123 | # Bullish and Bearish Filters based on Kernel 124 | is_bullishs: npt.NDArray[numpy.bool_] = ( 125 | ( 126 | is_bullish_smooths 127 | if kernel_settings.use_kernel_smoothing 128 | else is_bullish_rates 129 | ) 130 | if kernel_settings.use_kernel_filter 131 | else [True] * data_length 132 | ) 133 | is_bearishs: npt.NDArray[numpy.bool_] = ( 134 | ( 135 | is_bearish_smooths 136 | if kernel_settings.use_kernel_smoothing 137 | else is_bearish_rates 138 | ) 139 | if kernel_settings.use_kernel_filter 140 | else [True] * data_length 141 | ) 142 | return ( 143 | alerts_bullish, 144 | alerts_bearish, 145 | is_bullishs, 146 | is_bearishs, 147 | is_bearish_changes, 148 | is_bullish_changes, 149 | is_bullish_cross_alerts, 150 | is_bearish_cross_alerts, 151 | kernel_estimate, 152 | yhat2, 153 | is_bearish_rates, 154 | was_bullish_rates, 155 | is_bullish_rates, 156 | was_bearish_rates, 157 | ) 158 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/ml_utils/ml_extensions_2/__init__.py: -------------------------------------------------------------------------------- 1 | from .ml_extensions import * -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/__init__.py: -------------------------------------------------------------------------------- 1 | from .expired_orders_cancelling import * 2 | from .managed_order_pro import * 3 | from .scaled_orders import * 4 | from .close_all_trades import * 5 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/close_all_trades.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import octobot_trading.personal_data as trading_personal_data 22 | import octobot_trading.enums as trading_enums 23 | from octobot_trading.modes.script_keywords import basic_keywords 24 | import decimal 25 | 26 | 27 | async def close_all_positions(ctx): 28 | should_buy = None 29 | if ctx.exchange_manager.is_future: 30 | try: 31 | open_positions = ( 32 | ctx.exchange_manager.exchange_personal_data.positions_manager.positions[ 33 | ctx.symbol 34 | ].size 35 | ) 36 | if open_positions: 37 | should_buy = ( 38 | ctx.exchange_manager.exchange_personal_data.positions_manager.positions[ 39 | ctx.symbol 40 | ].side 41 | == trading_enums.PositionSide.SHORT.value 42 | ) 43 | except: 44 | open_positions = None 45 | should_buy = False 46 | else: 47 | asset, _ = ctx.symbol.split("/") 48 | open_positions = ctx.exchange_manager.exchange_personal_data.portfolio_manager.portfolio.portfolio[ 49 | asset 50 | ].total 51 | 52 | if open_positions: 53 | await ctx.trader.cancel_open_orders(ctx.symbol, cancel_loaded_orders=True) 54 | # fees_currency_side = ctx.exchange_manager.exchange.get_pair_future_contract(ctx.symbol).get_fees_currency_side() 55 | order = trading_personal_data.create_order_instance( 56 | trader=ctx.trader, 57 | order_type=trading_enums.TraderOrderType.BUY_MARKET 58 | if should_buy 59 | else trading_enums.TraderOrderType.SELL_MARKET, 60 | symbol=ctx.symbol, 61 | current_price=decimal.Decimal(ctx.trigger_value[1]), 62 | quantity=open_positions, 63 | price=decimal.Decimal(ctx.trigger_value[1]), 64 | filled_price=decimal.Decimal(ctx.trigger_value[1]), 65 | # fees_currency_side=fees_currency_side 66 | ) 67 | 68 | order = await ctx.trader.create_order(order) 69 | ctx.just_created_orders.append(order) 70 | await basic_keywords.store_orders(ctx, [order], ctx.exchange_manager) 71 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/expired_orders_cancelling.py: -------------------------------------------------------------------------------- 1 | import octobot_commons.enums as commons_enums 2 | import tentacles.Meta.Keywords.scripting_library.orders.cancelling as cancelling 3 | 4 | 5 | async def cancel_expired_orders_for_this_candle( 6 | ctx, 7 | limit_max_age_in_bars: int, 8 | symbol: str = None, 9 | time_frame: str = None, 10 | tag: str = None, 11 | ): 12 | until = int( 13 | ctx.trigger_cache_timestamp 14 | - ( 15 | commons_enums.TimeFramesMinutes[ 16 | commons_enums.TimeFrames(time_frame or ctx.time_frame) 17 | ] 18 | * limit_max_age_in_bars 19 | * 60 20 | ) 21 | ) 22 | await cancelling.cancel_orders( 23 | ctx, symbol=symbol or ctx.symbol, until=until, tag=tag 24 | ) 25 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .daemons import * 22 | from .calculators import * 23 | from .settings import * 24 | from .activate_managed_order import * 25 | from .managed_orders import * 26 | from .order_notification import * 27 | from .order_placement import * 28 | from .utilities import * 29 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/activate_managed_order.py: -------------------------------------------------------------------------------- 1 | import decimal 2 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.all_settings as all_settings 3 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.managed_orders as managed_orders 4 | 5 | 6 | async def activate_managed_orders( 7 | maker, 8 | # user_input_path: str = "evaluator/Managed_Order_Settings", 9 | parent_input_name: str = None, 10 | order_tag_prefix: str = "Managed order", 11 | name_prefix: str = None, 12 | enable_position_size_settings: bool = True, 13 | enable_stop_loss_settings: bool = True, 14 | enable_trailing_stop_settings: bool = False, 15 | enable_take_profit_settings: bool = True, 16 | ) -> all_settings.ManagedOrdersSettings: 17 | try: 18 | orders_settings = all_settings.ManagedOrdersSettings() 19 | await orders_settings.initialize( 20 | maker, 21 | parent_user_input_name=parent_input_name, 22 | order_tag_prefix=order_tag_prefix, 23 | unique_name_prefix=name_prefix, 24 | enable_position_size_settings=enable_position_size_settings, 25 | enable_trailing_stop_settings=enable_trailing_stop_settings, 26 | enable_stop_loss_settings=enable_stop_loss_settings, 27 | enable_take_profit_settings=enable_take_profit_settings, 28 | ) 29 | return orders_settings 30 | except Exception as error: 31 | raise RuntimeError( 32 | "Managed Order: There is an issue in your Managed Order " 33 | "configuration. Check the settings: " + str(error) 34 | ) from error 35 | 36 | 37 | async def managed_order( 38 | maker, 39 | order_block, 40 | trading_side: str, 41 | orders_settings: all_settings.ManagedOrdersSettings, 42 | forced_amount: decimal.Decimal = None, 43 | order_preview_mode: bool = False, 44 | ) -> managed_orders.ManagedOrder: 45 | """ 46 | :param maker: 47 | :param trading_side: 48 | can be "long" or short 49 | :param orders_settings: 50 | pass custom settings or use activate_managed_orders(ctx) 51 | 52 | :return: 53 | """ 54 | _managed_order = managed_orders.ManagedOrder() 55 | return await _managed_order.initialize_and_trade( 56 | maker=maker, 57 | order_block=order_block, 58 | trading_side=trading_side, 59 | orders_settings=orders_settings, 60 | forced_amount=forced_amount, 61 | order_preview_mode=order_preview_mode, 62 | ) 63 | 64 | 65 | async def managed_order_preview( 66 | maker, 67 | order_block, 68 | trading_side: str, 69 | orders_settings: all_settings.ManagedOrdersSettings, 70 | ) -> managed_orders.ManagedOrder or None: 71 | if not maker.exchange_manager.is_backtesting: 72 | return await managed_order( 73 | maker, 74 | order_block=order_block, 75 | trading_side=trading_side, 76 | orders_settings=orders_settings, 77 | order_preview_mode=True, 78 | ) 79 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .position_sizing import * 22 | from .stop_loss import * 23 | from .take_profit import * 24 | from .stop_losses import * 25 | from .take_profits import * 26 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_loss.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal as decimal 22 | import typing 23 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.stop_losses.stop_loss_types as stop_loss_types 24 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.sl_settings as sl_settings 25 | import tentacles.Meta.Keywords.scripting_library.data.reading.exchange_public_data as exchange_public_data 26 | 27 | 28 | async def get_manged_order_stop_loss( 29 | maker, 30 | order_block, 31 | stop_loss_settings, 32 | trading_side, 33 | entry_price: decimal.Decimal, 34 | current_price: decimal.Decimal, 35 | get_from_current_price: bool = False, 36 | ) -> typing.Tuple[float, float]: 37 | sl_price: float = None 38 | sl_in_p: float = None 39 | current_price = current_price or float( 40 | await exchange_public_data.current_live_price(maker.ctx) 41 | ) 42 | entry_price = entry_price or current_price 43 | if trading_side == "buy": 44 | entry_price = entry_price if entry_price < current_price else current_price 45 | else: 46 | entry_price = entry_price if entry_price > current_price else current_price 47 | if ( 48 | stop_loss_settings.sl_type 49 | != sl_settings.ManagedOrderSettingsSLTypes.NO_SL_DESCRIPTION 50 | ): 51 | # SL based on low/high 52 | if ( 53 | stop_loss_settings.sl_type 54 | == sl_settings.ManagedOrderSettingsSLTypes.AT_LOW_HIGH_DESCRIPTION 55 | ): 56 | sl_in_p, sl_price = await stop_loss_types.get_stop_loss_based_on_low_high( 57 | maker=maker, 58 | stop_loss_settings=stop_loss_settings, 59 | trading_side=trading_side, 60 | entry_price=current_price if get_from_current_price else entry_price, 61 | ) 62 | # SL based on percent from entry price 63 | elif ( 64 | stop_loss_settings.sl_type 65 | == sl_settings.ManagedOrderSettingsSLTypes.BASED_ON_PERCENT_ENTRY_DESCRIPTION 66 | ): 67 | sl_in_p, sl_price = stop_loss_types.get_stop_loss_based_on_entry_percent( 68 | maker=maker, 69 | stop_loss_settings=stop_loss_settings, 70 | trading_side=trading_side, 71 | entry_price=current_price if get_from_current_price else entry_price, 72 | ) 73 | # SL based on percent of current price 74 | elif ( 75 | stop_loss_settings.sl_type 76 | == sl_settings.ManagedOrderSettingsSLTypes.BASED_ON_PERCENT_PRICE_DESCRIPTION 77 | ): 78 | ( 79 | sl_in_p, 80 | sl_price, 81 | ) = stop_loss_types.get_stop_loss_based_on_current_price_percent( 82 | maker=maker, 83 | stop_loss_settings=stop_loss_settings, 84 | trading_side=trading_side, 85 | current_price=current_price, 86 | ) 87 | # SL based on indicator 88 | elif ( 89 | stop_loss_settings.sl_type 90 | == sl_settings.ManagedOrderSettingsSLTypes.BASED_ON_INDICATOR_DESCRIPTION 91 | ): 92 | sl_in_p, sl_price = await stop_loss_types.get_stop_loss_based_on_indicator( 93 | order_block=order_block, 94 | stop_loss_settings=stop_loss_settings, 95 | trading_side=trading_side, 96 | entry_price=current_price if get_from_current_price else entry_price, 97 | ) 98 | # SL based on static price 99 | elif ( 100 | stop_loss_settings.sl_type 101 | == sl_settings.ManagedOrderSettingsSLTypes.BASED_ON_STATIC_PRICE_DESCRIPTION 102 | ): 103 | sl_in_p, sl_price = stop_loss_types.get_stop_loss_based_on_static_price( 104 | maker=maker, 105 | stop_loss_settings=stop_loss_settings, 106 | trading_side=trading_side, 107 | entry_price=current_price if get_from_current_price else entry_price, 108 | ) 109 | 110 | # SL based on ATR 111 | elif ( 112 | stop_loss_settings.sl_type 113 | == sl_settings.ManagedOrderSettingsSLTypes.BASED_ON_ATR_DESCRIPTION 114 | ): 115 | sl_in_p, sl_price = await stop_loss_types.get_stop_loss_based_on_atr( 116 | maker=maker, 117 | stop_loss_settings=stop_loss_settings, 118 | trading_side=trading_side, 119 | entry_price=current_price if get_from_current_price else entry_price, 120 | ) 121 | return ( 122 | exchange_public_data.get_digits_adapted_price(maker.ctx, sl_price), 123 | sl_in_p, 124 | ) 125 | # no SL 126 | return None, None 127 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_losses/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .stop_loss_utilities import * 22 | from .stop_loss_types import * 23 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_losses/stop_loss_types/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .based_on_indicator import * 22 | from .based_on_low_high import * 23 | from .based_on_percent import * 24 | from .based_on_atr import * 25 | from .based_on_static_price import * 26 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_losses/stop_loss_types/based_on_atr.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | import tulipy as tulipy 23 | import octobot_trading.enums as trading_enums 24 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.stop_losses.stop_loss_utilities as stop_loss_utilities 25 | import tentacles.Meta.Keywords.scripting_library.data.reading.exchange_public_data as exchange_public_data 26 | import tentacles.Meta.Keywords.scripting_library.settings.script_settings as script_settings 27 | 28 | 29 | async def get_stop_loss_based_on_atr( 30 | maker, 31 | stop_loss_settings, 32 | trading_side: str, 33 | entry_price: decimal.Decimal, 34 | ): 35 | script_settings.set_minimum_candles(maker.ctx, stop_loss_settings.atr_period) 36 | if trading_side in ( 37 | trading_enums.PositionSide.LONG.value, 38 | trading_enums.TradeOrderSide.BUY.value, 39 | ): 40 | sl_price = entry_price - decimal.Decimal( 41 | str( 42 | tulipy.atr( 43 | await exchange_public_data.High(maker.ctx), 44 | await exchange_public_data.Low(maker.ctx), 45 | await exchange_public_data.Close(maker.ctx), 46 | int(stop_loss_settings.atr_period), 47 | )[-1] 48 | ) 49 | ) 50 | sl_in_p, sl_price = stop_loss_utilities.trim_sl_long_price( 51 | sl_price, 52 | entry_price, 53 | decimal.Decimal(str(stop_loss_settings.sl_max_p)), 54 | decimal.Decimal(str(stop_loss_settings.sl_min_p)), 55 | ) 56 | 57 | elif trading_side in ( 58 | trading_enums.PositionSide.SHORT.value, 59 | trading_enums.TradeOrderSide.SELL.value, 60 | ): 61 | sl_price = entry_price + decimal.Decimal( 62 | str( 63 | tulipy.atr( 64 | await exchange_public_data.High(maker.ctx), 65 | await exchange_public_data.Low(maker.ctx), 66 | await exchange_public_data.Close(maker.ctx), 67 | int(stop_loss_settings.atr_period), 68 | )[-1] 69 | ) 70 | ) 71 | sl_in_p, sl_price = stop_loss_utilities.trim_sl_short_price( 72 | sl_price, 73 | entry_price, 74 | decimal.Decimal(str(stop_loss_settings.sl_max_p)), 75 | decimal.Decimal(str(stop_loss_settings.sl_min_p)), 76 | ) 77 | else: 78 | raise RuntimeError('Side needs to be "long" or "short" for your managed order') 79 | return sl_in_p, sl_price 80 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_losses/stop_loss_types/based_on_indicator.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | 23 | import numpy 24 | import octobot_trading.enums as trading_enums 25 | from tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords import matrix_enums 26 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.stop_losses.stop_loss_utilities as stop_loss_utilities 27 | from tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.tools.utilities import ( 28 | cut_data_to_same_len, 29 | ) 30 | 31 | 32 | async def get_stop_loss_based_on_indicator( 33 | order_block, 34 | stop_loss_settings, 35 | trading_side: str, 36 | entry_price: decimal.Decimal, 37 | ): 38 | sl_indicator_value = order_block.get_indicator_value(stop_loss_settings) 39 | if trading_side in ( 40 | trading_enums.PositionSide.LONG.value, 41 | trading_enums.TradeOrderSide.BUY.value, 42 | ): 43 | sl_in_p, sl_price = stop_loss_utilities.trim_sl_long_price( 44 | sl_indicator_value, 45 | entry_price, 46 | decimal.Decimal(str(stop_loss_settings.sl_max_p)), 47 | decimal.Decimal(str(stop_loss_settings.sl_min_p)), 48 | ) 49 | 50 | elif trading_side in ( 51 | trading_enums.PositionSide.SHORT.value, 52 | trading_enums.TradeOrderSide.SELL.value, 53 | ): 54 | sl_in_p, sl_price = stop_loss_utilities.trim_sl_short_price( 55 | sl_indicator_value, 56 | entry_price, 57 | decimal.Decimal(str(stop_loss_settings.sl_max_p)), 58 | decimal.Decimal(str(stop_loss_settings.sl_min_p)), 59 | ) 60 | else: 61 | raise RuntimeError('Side needs to be "long" or "short" for your managed order') 62 | return sl_in_p, sl_price 63 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_losses/stop_loss_types/based_on_low_high.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | import tentacles.Meta.Keywords.scripting_library.data.reading.exchange_public_data as exchange_public_data 23 | import tentacles.Meta.Keywords.scripting_library.settings.script_settings as script_settings 24 | import octobot_trading.enums as trading_enums 25 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.stop_losses.stop_loss_utilities as stop_loss_utilities 26 | 27 | 28 | async def get_stop_loss_based_on_low_high( 29 | maker, 30 | stop_loss_settings, 31 | trading_side: str, 32 | entry_price: decimal.Decimal, 33 | ): 34 | script_settings.set_minimum_candles( 35 | maker.ctx, stop_loss_settings.sl_low_high_lookback 36 | ) 37 | if trading_side in ( 38 | trading_enums.PositionSide.LONG.value, 39 | trading_enums.TradeOrderSide.BUY.value, 40 | ): 41 | lows = await exchange_public_data.Low( 42 | maker.ctx, limit=int(stop_loss_settings.sl_low_high_lookback) 43 | ) 44 | sl_price = (decimal.Decimal(min(lows))) * ( 45 | 1 - (stop_loss_settings.sl_low_high_buffer / 100) 46 | ) 47 | 48 | return stop_loss_utilities.trim_sl_long_price( 49 | sl_price, 50 | entry_price, 51 | stop_loss_settings.sl_max_p, 52 | stop_loss_settings.sl_min_p, 53 | ) 54 | 55 | if trading_side in ( 56 | trading_enums.PositionSide.SHORT.value, 57 | trading_enums.TradeOrderSide.SELL.value, 58 | ): 59 | highs = await exchange_public_data.High( 60 | maker.ctx, limit=int(stop_loss_settings.sl_low_high_lookback) 61 | ) 62 | sl_price = (decimal.Decimal(max(highs))) * ( 63 | 1 + (stop_loss_settings.sl_low_high_buffer / 100) 64 | ) 65 | 66 | return stop_loss_utilities.trim_sl_short_price( 67 | sl_price, 68 | entry_price, 69 | stop_loss_settings.sl_max_p, 70 | stop_loss_settings.sl_min_p, 71 | ) 72 | raise RuntimeError('Side needs to be "long" or "short" for your managed order') 73 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_losses/stop_loss_types/based_on_percent.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | import octobot_trading.enums as trading_enums 23 | 24 | 25 | def get_stop_loss_based_on_entry_percent( 26 | maker, 27 | stop_loss_settings, 28 | trading_side: str, 29 | entry_price: decimal.Decimal, 30 | ): 31 | if trading_side in ( 32 | trading_enums.PositionSide.LONG.value, 33 | trading_enums.TradeOrderSide.BUY.value, 34 | ): 35 | sl_in_p = decimal.Decimal(str(stop_loss_settings.sl_in_p_value)) 36 | sl_price = entry_price * (1 - (sl_in_p / 100)) 37 | elif trading_side in ( 38 | trading_enums.PositionSide.SHORT.value, 39 | trading_enums.TradeOrderSide.SELL.value, 40 | ): 41 | sl_in_p = decimal.Decimal(str(stop_loss_settings.sl_in_p_value)) 42 | sl_price = entry_price * (1 + (sl_in_p / 100)) 43 | else: 44 | raise RuntimeError('Side needs to be "long" or "short" for your managed order') 45 | return sl_in_p, sl_price 46 | 47 | 48 | def get_stop_loss_based_on_current_price_percent( 49 | maker, 50 | stop_loss_settings, 51 | trading_side: str, 52 | current_price: decimal.Decimal, 53 | ): 54 | if trading_side in ( 55 | trading_enums.PositionSide.LONG.value, 56 | trading_enums.TradeOrderSide.BUY.value, 57 | ): 58 | sl_in_p = decimal.Decimal(str(stop_loss_settings.sl_in_p_value)) 59 | sl_price = current_price * (1 - (sl_in_p / 100)) 60 | elif trading_side in ( 61 | trading_enums.PositionSide.SHORT.value, 62 | trading_enums.TradeOrderSide.SELL.value, 63 | ): 64 | sl_in_p = decimal.Decimal(str(stop_loss_settings.sl_in_p_value)) 65 | sl_price = current_price * (1 + (sl_in_p / 100)) 66 | else: 67 | raise RuntimeError('Side needs to be "long" or "short" for your managed order') 68 | return sl_in_p, sl_price 69 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_losses/stop_loss_types/based_on_static_price.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | import octobot_trading.enums as trading_enums 23 | 24 | 25 | def get_stop_loss_based_on_static_price( 26 | maker, 27 | stop_loss_settings, 28 | trading_side: str, 29 | entry_price: decimal.Decimal, 30 | ): 31 | sl_in_p = (entry_price - decimal.Decimal(str(stop_loss_settings.sl_price))) / ( 32 | entry_price / 100 33 | ) 34 | if trading_side in ( 35 | trading_enums.PositionSide.LONG.value, 36 | trading_enums.TradeOrderSide.BUY.value, 37 | ): 38 | if sl_in_p < 0: 39 | raise RuntimeError( 40 | "Not able to open a position, because " 41 | "the stop loss for a long needs to be below the current price" 42 | ) 43 | elif trading_side in ( 44 | trading_enums.PositionSide.SHORT.value, 45 | trading_enums.TradeOrderSide.SELL.value, 46 | ): 47 | if sl_in_p > 0: 48 | raise RuntimeError( 49 | "Not able to open a position, because " 50 | "the stop loss for a short needs to be above the current price" 51 | ) 52 | else: 53 | raise RuntimeError('Side needs to be "long" or "short" for your managed order') 54 | return sl_in_p, decimal.Decimal(str(stop_loss_settings.sl_price)) 55 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/stop_losses/stop_loss_utilities.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal as decimal 22 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.stop_loss as stop_loss 23 | import tentacles.Meta.Keywords.scripting_library.data.reading.exchange_public_data as exchange_public_data 24 | import tentacles.Meta.Keywords.scripting_library.orders.editing as editing 25 | import tentacles.Meta.Keywords.scripting_library.orders.waiting as waiting 26 | 27 | 28 | def trim_sl_long_price(sl_price, current_price, sl_max_p, sl_min_p): 29 | sl_in_p = (current_price - sl_price) / current_price * 100 30 | if sl_in_p > sl_max_p: 31 | return sl_max_p, (1 - (sl_max_p / 100)) * current_price 32 | elif sl_in_p < sl_min_p: 33 | return sl_min_p, (1 - (sl_min_p / 100)) * current_price 34 | return sl_in_p, sl_price 35 | 36 | 37 | def trim_sl_short_price(sl_price, current_price, sl_max_p, sl_min_p): 38 | sl_in_p = (current_price - sl_price) / current_price * 100 39 | sl_max_p *= -1 40 | sl_min_p *= -1 41 | if sl_in_p < sl_max_p: 42 | return sl_max_p, (1 + (-sl_max_p / 100)) * current_price 43 | elif sl_in_p > sl_min_p: 44 | return sl_min_p, (1 + (-sl_min_p / 100)) * current_price 45 | return sl_in_p, sl_price 46 | 47 | 48 | async def adjust_managed_stop_loss(maker, managed_orders_settings, managed_order_data): 49 | # edit stop loss to accurate values in real trading 50 | 51 | # wait for market order to be filled 52 | await waiting.wait_for_orders_close( 53 | maker.ctx, managed_order_data.created_orders, timeout=60 54 | ) 55 | 56 | # get up-to-date entry filled price and size 57 | managed_order_data.entry_price = float( 58 | managed_order_data.created_orders[0].filled_price 59 | ) 60 | managed_order_data.exit_amount = float( 61 | managed_order_data.created_orders[0].filled_quantity 62 | ) 63 | 64 | # # wait for initial stop loss to be placed 65 | init_stop_order = await waiting.wait_for_stop_loss_open( 66 | maker.ctx, 67 | managed_order_data.exit_order_tag, 68 | managed_order_data.order_group, 69 | timeout=45, 70 | ) 71 | 72 | ( 73 | new_sl_price, 74 | managed_order_data.sl_in_p, 75 | ) = await stop_loss.get_manged_order_stop_loss( 76 | maker.ctx, 77 | managed_orders_settings, 78 | managed_order_data.trading_side, 79 | entry_price=managed_order_data.entry_price, 80 | sl_indicator_value=managed_order_data.sl_indicator_value, 81 | ) 82 | # # update stop loss on exchange 83 | new_sl_price = exchange_public_data.get_digits_adapted_price( 84 | maker.ctx, decimal.Decimal(new_sl_price) 85 | ) 86 | if init_stop_order: 87 | if init_stop_order.origin_price != new_sl_price: 88 | try: 89 | await editing.edit_order( 90 | maker.ctx, order=init_stop_order, edited_stop_price=new_sl_price 91 | ) 92 | managed_order_data.sl_in_d = float(new_sl_price) 93 | except ( 94 | Exception 95 | ) as error: # fails if we try to set an SL above the current price 96 | # retry one more time before giving up editing the order 97 | try: 98 | await editing.edit_order( 99 | maker.ctx, order=init_stop_order, edited_stop_price=new_sl_price 100 | ) 101 | managed_order_data.sl_in_d = float(new_sl_price) 102 | except ( 103 | Exception 104 | ) as error: # catch all errors to continue placing take profits 105 | maker.ctx.logger.exception( 106 | error, 107 | True, 108 | "Managed order: adjusting stop loss failed. This happened probably" 109 | f" because the adjusted stop loss would have been trigger instantly error: {e}", 110 | ) 111 | 112 | else: 113 | maker.ctx.logger.error( 114 | "Managed Order: failed to get stop loss from exchange. " 115 | "Could not adjust stop loss based on filled price" 116 | ) 117 | managed_order_data.enabled_order_group = False 118 | return managed_order_data 119 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/take_profit.py: -------------------------------------------------------------------------------- 1 | import decimal 2 | 3 | # a42.ch CONFIDENTIAL 4 | # __________________ 5 | # 6 | # [2021] - [∞] a42.ch Incorporated 7 | # All Rights Reserved. 8 | # 9 | # NOTICE: All information contained herein is, and remains 10 | # the property of a42.ch Incorporated and its suppliers, 11 | # if any. The intellectual and technical concepts contained 12 | # herein are proprietary to a42.ch Incorporated 13 | # and its suppliers and may be covered by U.S. and Foreign Patents, 14 | # patents in process, and are protected by trade secret or copyright law. 15 | # Dissemination of this information or reproduction of this material 16 | # is strictly forbidden unless prior written permission is obtained 17 | # from a42.ch Incorporated. 18 | # 19 | # If you want to use any code for commercial purposes, 20 | # or you want your own custom solution, 21 | # please contact me at max@a42.ch 22 | 23 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.take_profits.based_on_indicator as based_on_indicator 24 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.take_profits.based_on_percent as based_on_percent 25 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.take_profits.based_on_risk_reward as based_on_risk_reward 26 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.take_profits.based_on_static_price as based_on_static_price 27 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.tp_settings as tp_settings 28 | 29 | 30 | def get_manged_order_take_profits( 31 | maker, 32 | order_block, 33 | take_profit_settings, 34 | entry_side: str, 35 | current_price: decimal.Decimal, 36 | entry_price: decimal.Decimal, 37 | stop_loss_price: decimal.Decimal, 38 | entry_fee: decimal.Decimal, 39 | market_fee: decimal.Decimal, 40 | ) -> None or decimal.Decimal: 41 | if ( 42 | tp_settings.ManagedOrderSettingsTPTypes.NO_TP_DESCRIPTION 43 | != take_profit_settings.tp_type 44 | ): 45 | # take profit based on risk reward 46 | if ( 47 | take_profit_settings.tp_type 48 | == tp_settings.ManagedOrderSettingsTPTypes.SINGLE_RISK_REWARD_DESCRIPTION 49 | ): 50 | return based_on_risk_reward.calculate_take_profit_based_on_risk_reward( 51 | maker=maker, 52 | take_profit_settings=take_profit_settings, 53 | entry_side=entry_side, 54 | current_price=current_price, 55 | entry_price=entry_price, 56 | stop_loss_price=stop_loss_price, 57 | entry_fee=entry_fee, 58 | market_fee=market_fee, 59 | ) 60 | 61 | # # scaled take profit based on risk reward 62 | # elif ( 63 | # take_profit_settings.tp_type 64 | # == tp_settings.ManagedOrderSettingsTPTypes.SCALED_RISK_REWARD_DESCRIPTION 65 | # ): 66 | 67 | # take_profits.calculate_take_profit_scaled_based_on_risk_reward( 68 | # take_profit_settings, entry_price 69 | # ) 70 | 71 | # take profit based on percent 72 | elif ( 73 | take_profit_settings.tp_type 74 | == tp_settings.ManagedOrderSettingsTPTypes.SINGLE_PERCENT_DESCRIPTION 75 | ): 76 | return based_on_percent.calculate_take_profit_based_on_percent( 77 | maker=maker, 78 | take_profit_settings=take_profit_settings, 79 | entry_side=entry_side, 80 | current_price=current_price, 81 | entry_price=entry_price, 82 | stop_loss_price=stop_loss_price, 83 | entry_fee=entry_fee, 84 | market_fee=market_fee, 85 | ) 86 | # take profit based on indicator 87 | elif ( 88 | take_profit_settings.tp_type 89 | == tp_settings.ManagedOrderSettingsTPTypes.SINGLE_INDICATOR_DESCRIPTION 90 | ): 91 | return based_on_indicator.calculate_take_profit_based_on_indicator( 92 | order_block=order_block, 93 | take_profit_settings=take_profit_settings, 94 | entry_side=entry_side, 95 | current_price=current_price, 96 | entry_price=entry_price, 97 | stop_loss_price=stop_loss_price, 98 | entry_fee=entry_fee, 99 | market_fee=market_fee, 100 | ) 101 | 102 | # # scaled take profit based on percent 103 | # elif ( 104 | # take_profit_settings.tp_type 105 | # == tp_settings.ManagedOrderSettingsTPTypes.SCALED_PERCENT_DESCRIPTION 106 | # ): 107 | 108 | # take_profits.calculate_take_profit_scaled_based_on_percent( 109 | # take_profit_settings, entry_price 110 | # ) 111 | 112 | # single take profit based on static price 113 | elif ( 114 | take_profit_settings.tp_type 115 | == tp_settings.ManagedOrderSettingsTPTypes.SINGLE_STATIC_DESCRIPTION 116 | ): 117 | return based_on_static_price.calculate_take_profit_based_on_static_price( 118 | maker=maker, 119 | take_profit_settings=take_profit_settings, 120 | entry_side=entry_side, 121 | current_price=current_price, 122 | entry_price=entry_price, 123 | stop_loss_price=stop_loss_price, 124 | entry_fee=entry_fee, 125 | market_fee=market_fee, 126 | ) 127 | 128 | return None 129 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/take_profits/__init__.py: -------------------------------------------------------------------------------- 1 | from .based_on_indicator import * 2 | from .based_on_static_price import * 3 | from .based_on_risk_reward import * 4 | from .based_on_percent import * 5 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/take_profits/based_on_indicator.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | import octobot_trading.enums as trading_enums 23 | 24 | # import tentacles.Meta.Keywords.pro_tentacles.standalone_data_source.standalone_data_sources as standalone_data_sources 25 | import tentacles.Meta.Keywords.scripting_library.orders.order_types as order_types 26 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.stop_losses.stop_loss_utilities as stop_loss_utilities 27 | 28 | 29 | def calculate_take_profit_based_on_indicator( 30 | order_block, 31 | take_profit_settings, 32 | entry_side: str, 33 | current_price: decimal.Decimal, 34 | entry_price: decimal.Decimal, 35 | stop_loss_price: decimal.Decimal, 36 | entry_fee: decimal.Decimal, 37 | market_fee: decimal.Decimal, 38 | ): 39 | tp_indicator_value = order_block.get_indicator_value(take_profit_settings) 40 | 41 | if entry_side in ( 42 | trading_enums.TradeOrderSide.BUY.value, 43 | trading_enums.PositionSide.LONG.value, 44 | ): 45 | _, tp_price = stop_loss_utilities.trim_sl_short_price( 46 | tp_indicator_value, 47 | current_price, 48 | take_profit_settings.tp_max_p, 49 | take_profit_settings.tp_min_p, 50 | ) 51 | 52 | elif entry_side in ( 53 | trading_enums.TradeOrderSide.SELL.value, 54 | trading_enums.PositionSide.SHORT.value, 55 | ): 56 | _, tp_price = stop_loss_utilities.trim_sl_long_price( 57 | tp_indicator_value, 58 | current_price, 59 | take_profit_settings.tp_max_p, 60 | take_profit_settings.tp_min_p, 61 | ) 62 | else: 63 | raise RuntimeError('Side needs to be "long" or "short" for your managed order') 64 | return tp_price 65 | 66 | 67 | async def place_take_profit_based_on_indicator( 68 | created_orders, ctx, take_profit_data, entry_quantity: float 69 | ) -> None: 70 | await order_types.limit( 71 | ctx, 72 | side=take_profit_data.side, 73 | amount=entry_quantity, 74 | target_position=take_profit_data.target_position, 75 | offset=take_profit_data.offset, 76 | group=take_profit_data.group, 77 | tag=take_profit_data.tag, 78 | reduce_only=True, 79 | wait_for=created_orders, 80 | ) 81 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/take_profits/based_on_percent.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | import decimal 21 | import tentacles.Meta.Keywords.scripting_library.orders.order_types as order_types 22 | import octobot_trading.enums as trading_enums 23 | 24 | 25 | def calculate_take_profit_based_on_percent( 26 | maker, 27 | take_profit_settings, 28 | entry_side: str, 29 | current_price: decimal.Decimal, 30 | entry_price: decimal.Decimal, 31 | stop_loss_price: decimal.Decimal, 32 | entry_fee: decimal.Decimal, 33 | market_fee: decimal.Decimal, 34 | ) -> float: 35 | profit_in_d = ( 36 | entry_price * (1 + (take_profit_settings.tp_in_p / 100)) 37 | if entry_side == trading_enums.TradeOrderSide.BUY.value 38 | else entry_price 39 | * (1 - (take_profit_settings.tp_in_p / 100)) 40 | ) 41 | return profit_in_d 42 | 43 | 44 | async def place_take_profit_based_on_percent( 45 | created_orders, ctx, take_profit_data, entry_quantity: decimal.Decimal 46 | ) -> None: 47 | await order_types.limit( 48 | ctx, 49 | side=take_profit_data.side, 50 | amount=entry_quantity, 51 | target_position=take_profit_data.target_position, 52 | offset=take_profit_data.offset, 53 | group=take_profit_data.group, 54 | tag=take_profit_data.tag, 55 | reduce_only=True, 56 | wait_for=created_orders, 57 | ) 58 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/take_profits/based_on_risk_reward.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | import tentacles.Meta.Keywords.scripting_library.orders.order_types as order_types 23 | import octobot_trading.enums as trading_enums 24 | 25 | 26 | async def place_take_profit_based_on_risk_reward( 27 | created_orders, ctx, take_profit_data, entry_quantity: float 28 | ) -> None: 29 | await order_types.limit( 30 | ctx, 31 | side=take_profit_data.side, 32 | amount=entry_quantity, 33 | target_position=take_profit_data.target_position, 34 | offset=take_profit_data.offset, 35 | group=take_profit_data.group, 36 | tag=take_profit_data.tag, 37 | reduce_only=True, 38 | wait_for=created_orders, 39 | ) 40 | 41 | 42 | def calculate_take_profit_based_on_risk_reward( 43 | maker, 44 | take_profit_settings, 45 | entry_side: str, 46 | current_price: decimal.Decimal, 47 | entry_price: decimal.Decimal, 48 | stop_loss_price: decimal.Decimal, 49 | entry_fee: decimal.Decimal, 50 | market_fee: decimal.Decimal, 51 | ) -> decimal.Decimal: 52 | stop_loss_in_percent = (entry_price - stop_loss_price) / (entry_price / 100) 53 | if stop_loss_in_percent < 0: 54 | stop_loss_in_percent *= -1 55 | if entry_side == trading_enums.TradeOrderSide.BUY.value: 56 | profit_in_p = take_profit_settings.tp_rr * ( 57 | stop_loss_in_percent + market_fee + entry_fee 58 | ) 59 | take_profit_price = entry_price * (1 + (profit_in_p / 100)) 60 | else: 61 | profit_in_p = take_profit_settings.tp_rr * ( 62 | stop_loss_in_percent + market_fee + entry_fee 63 | ) 64 | take_profit_price = entry_price * (1 - (profit_in_p / 100)) 65 | return take_profit_price 66 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/take_profits/based_on_static_price.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | import decimal 21 | import tentacles.Meta.Keywords.scripting_library.orders.order_types as order_types 22 | 23 | 24 | def calculate_take_profit_based_on_static_price( 25 | maker, 26 | take_profit_settings, 27 | entry_side: str, 28 | current_price: decimal.Decimal, 29 | entry_price: decimal.Decimal, 30 | stop_loss_price: decimal.Decimal, 31 | entry_fee: decimal.Decimal, 32 | market_fee: decimal.Decimal, 33 | ) -> decimal.Decimal: 34 | return decimal.Decimal(str(take_profit_settings.tp_in_d)) 35 | 36 | 37 | async def place_take_profit_based_on_static_price( 38 | created_orders, ctx, take_profit_data, entry_quantity: decimal.Decimal 39 | ) -> None: 40 | await order_types.limit( 41 | ctx, 42 | side=take_profit_data.side, 43 | amount=entry_quantity, 44 | target_position=take_profit_data.target_position, 45 | offset=take_profit_data.offset, 46 | group=take_profit_data.group, 47 | tag=take_profit_data.tag, 48 | reduce_only=True, 49 | wait_for=created_orders, 50 | ) 51 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/calculators/take_profits/take_profits.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | # import tentacles.Meta.Keywords.scripting_library.orders.order_types as order_types 22 | # import octobot_trading.enums as trading_enums 23 | 24 | 25 | # class ManagedOrderTakeProfit: 26 | # def __init__( 27 | # self, 28 | # side, 29 | # amount, 30 | # target_position, 31 | # group, 32 | # tag, 33 | # offset_price=None, 34 | # scale_from=None, 35 | # scale_to=None, 36 | # order_count=None, 37 | # ): 38 | # self.side = side 39 | # self.amount = amount 40 | # self.target_position = target_position 41 | # self.scale_from = scale_from 42 | # self.scale_to = scale_to 43 | # self.order_count = order_count 44 | # self.group = group 45 | # self.offset_price = offset_price 46 | # self.offset = f"@{offset_price}" 47 | # self.tag = tag 48 | 49 | 50 | # def calculate_take_profit_scaled_based_on_percent( 51 | # self, entry_price 52 | # ) -> ManagedOrderTakeProfit: 53 | # if self.entry_side == trading_enums.TradeOrderSide.BUY.value: 54 | # scale_from = entry_price * (1 + (self.managed_orders_settings.p_tp_min / 100)) 55 | # scale_from = f"@{scale_from}" 56 | # scale_to = entry_price * (1 + (self.managed_orders_settings.p_tp_max / 100)) 57 | # scale_to = f"@{scale_to}" 58 | # else: 59 | # scale_from = entry_price * (1 + (self.managed_orders_settings.p_tp_max / 100)) 60 | # scale_from = f"@{scale_from}" 61 | # scale_to = entry_price * (1 + (self.managed_orders_settings.p_tp_min / 100)) 62 | # scale_to = f"@{scale_to}" 63 | # return ManagedOrderTakeProfit( 64 | # side=self.exit_side, 65 | # amount=self.exit_amount, 66 | # target_position=self.exit_target_position, 67 | # group=self.order_group, 68 | # tag=self.exit_order_tag, 69 | # order_count=self.managed_orders_settings.p_tp_order_count, 70 | # scale_from=scale_from, 71 | # scale_to=scale_to, 72 | # ) 73 | 74 | 75 | # async def place_take_profit_scaled_based_on_percent( 76 | # created_orders, ctx, take_profit_data, entry_quantity: float 77 | # ) -> None: 78 | # await order_types.scaled_limit( 79 | # ctx, 80 | # side=take_profit_data.side, 81 | # amount=entry_quantity, 82 | # target_position=take_profit_data.target_position, 83 | # scale_from=take_profit_data.scale_from, 84 | # scale_to=take_profit_data.scale_to, 85 | # order_count=take_profit_data.order_count, 86 | # group=take_profit_data.group, 87 | # tag=take_profit_data.tag, 88 | # reduce_only=True, 89 | # wait_for=created_orders, 90 | # ) 91 | 92 | 93 | 94 | 95 | 96 | # def calculate_take_profit_scaled_based_on_risk_reward( 97 | # self, entry_price 98 | # ) -> ManagedOrderTakeProfit: 99 | # self.entry_fees = self.market_fee if self.entry_type == "market" else self.limit_fee 100 | # if self.entry_side == trading_enums.TradeOrderSide.BUY.value: 101 | # scale_from = entry_price * ( 102 | # 1 103 | # + ( 104 | # self.managed_orders_settings.rr_tp_min 105 | # * (self.sl_in_p + self.market_fee + self.entry_fees) 106 | # / 100 107 | # ) 108 | # ) 109 | # scale_from = f"@{scale_from}" 110 | # scale_to = entry_price * ( 111 | # 1 112 | # + ( 113 | # self.managed_orders_settings.rr_tp_max 114 | # * (self.sl_in_p + self.market_fee + self.entry_fees) 115 | # / 100 116 | # ) 117 | # ) 118 | # scale_to = f"@{scale_to}" 119 | # else: 120 | # scale_from = entry_price * ( 121 | # 1 122 | # - ( 123 | # self.managed_orders_settings.rr_tp_max 124 | # * (self.sl_in_p + self.market_fee + self.entry_fees) 125 | # / 100 126 | # ) 127 | # ) 128 | # scale_from = f"@{scale_from}" 129 | # scale_to = entry_price * ( 130 | # 1 131 | # - ( 132 | # self.managed_orders_settings.rr_tp_min 133 | # * (self.sl_in_p + self.market_fee + self.entry_fees) 134 | # / 100 135 | # ) 136 | # ) 137 | # scale_to = f"@{scale_to}" 138 | # return ManagedOrderTakeProfit( 139 | # side=self.exit_side, 140 | # amount=self.exit_amount, 141 | # target_position=self.exit_target_position, 142 | # group=self.order_group, 143 | # tag=self.exit_order_tag, 144 | # order_count=self.managed_orders_settings.rr_tp_order_count, 145 | # scale_from=scale_from, 146 | # scale_to=scale_to, 147 | # ) 148 | 149 | 150 | # async def place_take_profit_scaled_based_on_risk_reward( 151 | # created_orders, ctx, take_profit_data, entry_quantity: float 152 | # ) -> None: 153 | # await order_types.scaled_limit( 154 | # ctx, 155 | # side=take_profit_data.side, 156 | # amount=entry_quantity, 157 | # target_position=take_profit_data.target_position, 158 | # scale_from=take_profit_data.scale_from, 159 | # scale_to=take_profit_data.scale_to, 160 | # order_count=take_profit_data.managed_orders_settings.order_count, 161 | # group=take_profit_data.group, 162 | # tag=take_profit_data.tag, 163 | # reduce_only=True, 164 | # wait_for=created_orders, 165 | # ) 166 | 167 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/__init__.py: -------------------------------------------------------------------------------- 1 | from .ping_pong import * 2 | from .trailing_stop_loss import * 3 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/ping_pong/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .ping_pong_storage.storage import * 22 | from .simple_ping_pong import * 23 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/ping_pong/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.6.3", 3 | "origin_package": "Matrix-Pro-Keywords", 4 | "tentacles": ["PingPongStorage"], 5 | "tentacles-requirements": ["matrix_pro_keywords"] 6 | } 7 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/ping_pong/ping_pong_constants.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import enum 22 | 23 | TAKE_PROFIT = "tp" 24 | ENTRY = "e" 25 | STOP_LOSS = "sl" 26 | 27 | class PingPongOrderToOrderGroupIdConstants: 28 | GROUP_KEY = "group_key" 29 | ORDER_GROUP_ID = "order_group_id" 30 | GRID_ID = "grid_id" 31 | ENTRY_ORDER = "entry_order" 32 | 33 | 34 | class PingPongConstants: 35 | FIRST_ORDER_CHAIN_ID = 0 36 | LAST_ORDER_CHAIN_ID = "last_order_chain_id" 37 | START_INFO_DATA: dict = { 38 | LAST_ORDER_CHAIN_ID: FIRST_ORDER_CHAIN_ID, 39 | } 40 | PING_PONG_INFO_STORAGE = "ping_pong_info_storage" 41 | PING_PONG_STORAGE = "ping_pong_storage" 42 | 43 | ENTRIES = "entries" 44 | EXITS = "exits" 45 | 46 | 47 | class PingPongSingleDataColumns: 48 | GRID_ID = "grid_id" 49 | CALCULATED_ENTRY = "calculated_entry" 50 | ENTRY_COUNTER = "entry_counter" 51 | ORIGINAL_ENTRY_ORDER = "original_entry_order" 52 | ALL_RECREATED_ENTRY_ORDERS = "all_recreated_entry_orders" 53 | LAST_ORDER = "last_order" 54 | IS_FIRST_ENTRY = "is_first_entry" 55 | PING_PONG_ACTIVE = "ping_pong_active" 56 | EXIT_ORDERS = "exit_orders" 57 | ENTRY_ORDER = "entry_orders" 58 | 59 | 60 | class PingPongOrderColumns(enum.Enum): 61 | SIDE = "side" 62 | AMOUNT = "amount" 63 | ENTRY_PRICE = "entry_price" 64 | ENTRY_TAG = "entry_tag" 65 | TAKE_PROFIT_PRICE = "take_profit_price" 66 | STOP_LOSS_PRICE = "stop_loss_price" 67 | TAKE_PROFIT_TAG = "take_profit_tag" 68 | STOP_LOSS_TAG = "stop_loss_tag" -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/ping_pong/ping_pong_storage/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .storage import * 22 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/ping_pong/ping_pong_storage/group.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import typing 22 | from tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.daemons.ping_pong import ( 23 | ping_pong_constants, 24 | ) 25 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.daemons.ping_pong.ping_pong_storage.element as element 26 | 27 | 28 | class PingPongGroupData: 29 | group_data: typing.Dict[str, element.PingPongSingleData] = {} 30 | 31 | def __init__( 32 | self, 33 | ping_pong_info_storage, 34 | group_key: str, 35 | order_group_id: str, 36 | entry_orders: list = None, 37 | calculated_entries: list = None, 38 | init_only: bool = False, 39 | ): 40 | self.ping_pong_info_storage = ping_pong_info_storage 41 | self.order_group_id: str = order_group_id 42 | self.group_key: str = group_key 43 | if not init_only: 44 | for grid_id, order in enumerate(entry_orders): 45 | self.set_grid_data( 46 | grid_id=str(grid_id), 47 | order=order, 48 | calculated_entry=calculated_entries[grid_id], 49 | ) 50 | 51 | async def restore_from_raw(self, raw_group_instance) -> None: 52 | for grid_id, raw_grid in raw_group_instance.items(): 53 | self.group_data[grid_id] = element.PingPongSingleData( 54 | ping_pong_storage=self.ping_pong_info_storage, 55 | grid_id=grid_id, 56 | calculated_entry=raw_grid[ 57 | ping_pong_constants.PingPongSingleDataColumns.CALCULATED_ENTRY 58 | ], 59 | order_group_id=self.order_group_id, 60 | group_key=self.group_key, 61 | init_only=True, 62 | ) 63 | await self.group_data[grid_id].restore_from_raw(raw_grid) 64 | 65 | def set_grid_data(self, grid_id, order, calculated_entry) -> None: 66 | self.group_data[grid_id] = element.PingPongSingleData( 67 | ping_pong_storage=self.ping_pong_info_storage, 68 | grid_id=grid_id, 69 | entry_order=order, 70 | calculated_entry=calculated_entry, 71 | order_group_id=self.order_group_id, 72 | group_key=self.group_key, 73 | ) 74 | 75 | def get_grid_data(self, grid_id) -> element.PingPongSingleData: 76 | return self.group_data[str(grid_id)] 77 | 78 | # def log_replaced_entry_order( 79 | # self, 80 | # grid_id: str, 81 | # recreated_entry_order, 82 | # ): 83 | # self.get_grid_data(grid_id).log_replaced_entry_order(recreated_entry_order) 84 | 85 | # def get_last_entry_order(self, grid_id) -> PingPongSingleData: 86 | # return self.get_grid_data(grid_id).get_last_entry_order() 87 | 88 | # def get_single_data_if_enabled(self, grid_id) -> element.PingPongSingleData or None: 89 | # single_data: element.PingPongSingleData = self.get_grid_data(grid_id) 90 | # if ( 91 | # self.order_group_settings.ping_pong.ping_pong_mode_enabled 92 | # and single_data.enabled 93 | # ): 94 | # return single_data 95 | # return None 96 | 97 | # def get_original_calculated_entry_price(self, grid_id): 98 | # return self.get_grid_data(grid_id).get_calculated_entry() 99 | 100 | def to_dict(self): 101 | grid_dict = {} 102 | for grid_id, this_group_data in self.group_data.items(): 103 | grid_dict[grid_id] = this_group_data.to_dict() 104 | return grid_dict 105 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/trailing_stop_loss/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .trail_stop_losses import * 22 | from .trailing_types import * 23 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/trailing_stop_loss/trailing_types/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .break_even import * 22 | from .based_on_indicator import * 23 | from .based_on_sl_settings import * 24 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/trailing_stop_loss/trailing_types/based_on_indicator.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal as decimal 22 | import tentacles.Meta.Keywords.scripting_library.data.reading.exchange_public_data as exchange_public_data 23 | import octobot_trading.enums as trading_enums 24 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.stop_losses.stop_loss_utilities as stop_loss_utilities 25 | # import tentacles.Meta.Keywords.pro_tentacles.standalone_data_source.standalone_data_sources as standalone_data_sources 26 | 27 | 28 | async def trail_to_indicator(maker, order_group_settings, orders_settings): 29 | sl_price, _, _ = await get_managed_trailing_stop_from_indicator( 30 | maker, orders_settings, order_group_settings 31 | ) 32 | return sl_price 33 | 34 | 35 | async def get_managed_trailing_stop_from_indicator( 36 | maker, managed_orders_settings, order_group_settings 37 | ): 38 | current_price_val = await exchange_public_data.current_live_price(maker.ctx) 39 | sl_in_p = None 40 | sl_indicator_value = decimal.Decimal( 41 | str( 42 | standalone_data_sources.get_standalone_data_source( 43 | order_group_settings.stop_loss.trailing_indicator_id, maker 44 | ) 45 | ) 46 | ) 47 | 48 | if managed_orders_settings.trading_side in ( 49 | trading_enums.PositionSide.LONG.value, 50 | trading_enums.TradeOrderSide.BUY.value, 51 | ): 52 | sl_in_p, sl_indicator_value = stop_loss_utilities.trim_sl_long_price( 53 | sl_indicator_value, 54 | current_price_val, 55 | order_group_settings.stop_loss.sl_trailing_max_p, 56 | order_group_settings.stop_loss.sl_trailing_min_p, 57 | ) 58 | elif managed_orders_settings.trading_side in ( 59 | trading_enums.PositionSide.SHORT.value, 60 | trading_enums.TradeOrderSide.SELL.value, 61 | ): 62 | sl_in_p, sl_indicator_value = stop_loss_utilities.trim_sl_short_price( 63 | sl_indicator_value, 64 | current_price_val, 65 | order_group_settings.stop_loss.sl_trailing_max_p, 66 | order_group_settings.stop_loss.sl_trailing_min_p, 67 | ) 68 | else: 69 | raise RuntimeError('Side needs to be "long" or "short" for your managed order') 70 | return sl_indicator_value, sl_in_p, current_price_val 71 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/trailing_stop_loss/trailing_types/based_on_sl_settings.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.stop_loss as stop_loss_calculators 22 | 23 | 24 | async def trail_to_stop_loss_settings( 25 | maker, trading_side, order_group_settings, entry_price, current_price 26 | ): 27 | sl_price, sl_in_p = await stop_loss_calculators.get_manged_order_stop_loss( 28 | maker=maker, 29 | stop_loss_settings=order_group_settings.stop_loss, 30 | trading_side=trading_side, 31 | entry_price=entry_price, 32 | current_price=current_price, 33 | ) 34 | return sl_price 35 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/daemons/trailing_stop_loss/trailing_types/break_even.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | import tentacles.Meta.Keywords.scripting_library.data.reading.exchange_public_data as exchange_public_data 23 | import octobot_trading.enums as trading_enums 24 | 25 | 26 | async def trail_to_break_even(ctx, trading_side, av_entry:decimal.Decimal): 27 | fees = decimal.Decimal(exchange_public_data.symbol_fees(ctx)["taker"]) 28 | if trading_side == trading_enums.PositionSide.LONG.value: 29 | break_even_price = (1 + (fees / 100)) * av_entry 30 | else: 31 | break_even_price = (1 - (fees) / 100) * av_entry 32 | return break_even_price 33 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/managed_orders.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import decimal 22 | 23 | # import tentacles.Meta.Keywords.pro_tentacles.pro_keywords.orders.managed_order_pro.order_notification as order_notification 24 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.order_placement as order_placement 25 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.all_settings as all_settings 26 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.matrix_errors as matrix_errors 27 | 28 | 29 | class ManagedOrder: 30 | managed_orders_settings: all_settings.ManagedOrdersSettings = None 31 | market_fee: decimal.Decimal = None 32 | limit_fee: decimal.Decimal = None 33 | trading_side: str = None 34 | executed_groups: list = [] 35 | symbol: str = None 36 | 37 | async def initialize_and_trade( 38 | self, 39 | maker, 40 | order_block, 41 | trading_side, 42 | orders_settings: all_settings.ManagedOrdersSettings, 43 | forced_amount: decimal.Decimal = None, 44 | order_preview_mode: bool = False, 45 | ): 46 | if not maker.ctx.enable_trading and not order_preview_mode: 47 | return 48 | self.managed_orders_settings = orders_settings 49 | self.executed_groups: list = [] 50 | self.trading_side = trading_side 51 | success = False 52 | for group_orders_settings in self.managed_orders_settings.order_groups.values(): 53 | managed_group = order_placement.ManagedOrderPlacement() 54 | self.executed_groups.append(managed_group) 55 | # create entry and exit orders orders if possible 56 | try: 57 | await managed_group.place_managed_entry_and_exits( 58 | maker=maker, 59 | order_block=order_block, 60 | trading_side=self.trading_side, 61 | group_orders_settings=group_orders_settings, 62 | managed_orders_settings=self.managed_orders_settings, 63 | forced_amount=forced_amount, 64 | order_preview_mode=order_preview_mode, 65 | ) 66 | success = managed_group.created_orders or success 67 | except matrix_errors.MaximumOpenPositionReachedError: 68 | # should have logged already 69 | # maker.ctx.logger.warning( 70 | # "Managed order cant open a new position, " 71 | # "Make sure the position size is at " 72 | # f"least the minimum size required by the exchange for {maker.ctx.symbol}" 73 | # ) 74 | return self 75 | # if success: 76 | 77 | # # send an alert in live mode 78 | # await order_notification.send_managed_order_notification(maker.ctx, self) 79 | return self 80 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.6.9", 3 | "origin_package": "Matrix-Pro-Keywords", 4 | "tentacles": ["OrderManagerPro"], 5 | "tentacles-requirements": ["matrix_pro_keywords"] 6 | } 7 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/order_notification.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import octobot_commons.symbols.symbol_util as symbol_util 22 | import octobot_services.api as services_api 23 | import octobot_services.enums as services_enum 24 | from tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.calculators.position_sizing import ( 25 | get_current_open_risk, 26 | ) 27 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.entry_types as entry_types 28 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.position_size_settings as size_settings 29 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.sl_settings as sl_settings 30 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.tp_settings as tp_settings 31 | 32 | 33 | async def send_managed_order_notification(ctx, managed_order_data): 34 | if ( 35 | ctx.exchange_manager.is_backtesting is not True 36 | and managed_order_data.managed_orders_settings.enable_alerts 37 | ): 38 | alert_title = f"opened a new {managed_order_data.trading_side} trade" 39 | entry_part = "" 40 | if ( 41 | managed_order_data.managed_orders_settings.entry_type 42 | == entry_types.ManagedOrderSettingsEntryTypes.SINGLE_MARKET_IN_DESCRIPTION 43 | ): 44 | entry_part = ( 45 | f"entry price: {managed_order_data.entry_price} \n" 46 | f"entry type: {managed_order_data.entry_type} \n" 47 | ) 48 | 49 | stop_loss_part = "" 50 | if ( 51 | managed_order_data.managed_orders_settings.sl_type 52 | != sl_settings.ManagedOrderSettingsSLTypes.NO_SL_DESCRIPTION 53 | ): 54 | stop_loss_part = ( 55 | f"stop loss in %: {managed_order_data.sl_in_p} \n" 56 | f"stop loss @: {managed_order_data.sl_price}\n" 57 | ) 58 | take_profit_part = "" 59 | if ( 60 | managed_order_data.managed_orders_settings.tp_type 61 | == tp_settings.ManagedOrderSettingsTPTypes.SINGLE_RISK_REWARD_DESCRIPTION 62 | ): 63 | take_profit_part = ( 64 | f"take profit risk reward: {managed_order_data.managed_orders_settings.tp_rr} \n" 65 | f"take profit in %: {managed_order_data.profit_in_p} \n" 66 | f"take profit @: {managed_order_data.profit_in_d} \n" 67 | ) 68 | elif ( 69 | managed_order_data.managed_orders_settings.tp_type 70 | == tp_settings.ManagedOrderSettingsTPTypes.SINGLE_PERCENT_DESCRIPTION 71 | ): 72 | take_profit_part = ( 73 | f"take profit in %: {managed_order_data.profit_in_p} \n" 74 | f"take profit @: {managed_order_data.profit_in_d} \n" 75 | ) 76 | position_size_part = "" 77 | if ( 78 | managed_order_data.managed_orders_settings.position_size_type 79 | == size_settings.ManagedOrderSettingsPositionSizeTypes.PERCENT_RISK_OF_ACCOUNT_DESCRIPTION 80 | ): 81 | # get up-to-date open risk 82 | managed_order_data.entry_price = ( 83 | managed_order_data.entry_price 84 | or managed_order_data.expected_entry_price 85 | ) 86 | old_open_risk = round( 87 | managed_order_data.current_open_risk * managed_order_data.entry_price, 3 88 | ) 89 | new_open_risk = round( 90 | await get_current_open_risk(ctx, managed_order_data.market_fee) 91 | * managed_order_data.entry_price, 92 | 3, 93 | ) 94 | ref_market = symbol_util.parse_symbol(ctx.symbol).quote 95 | position_size_part = ( 96 | f"position size: {managed_order_data.exit_amount} \n" 97 | f"position size {ref_market}:" 98 | f" {round(managed_order_data.exit_amount * managed_order_data.entry_price, 3)} \n" 99 | f"\n" 100 | f"risk details before trade opened: \n" 101 | f" open risk: {ref_market} {old_open_risk} \n" 102 | f" max position size: {managed_order_data.max_position_size} \n" 103 | f" available exchange balance: {managed_order_data.max_buying_power} \n" 104 | f"\n" 105 | f"risk details after trade opened: \n" 106 | f" open risk: {ref_market} {new_open_risk}" 107 | ) 108 | 109 | alert_content = ( 110 | entry_part + stop_loss_part + take_profit_part + position_size_part 111 | ) 112 | await services_api.send_notification( 113 | services_api.create_notification( 114 | alert_content, 115 | title=alert_title, 116 | markdown_text=alert_content, 117 | category=services_enum.NotificationCategory.TRADING_SCRIPT_ALERTS, 118 | ) 119 | ) 120 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/settings/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .ping_pong_settings import * 22 | from .order_settings_group import * 23 | from .entry_settings import * 24 | from .all_settings import * 25 | from .sl_settings import * 26 | from .position_size_settings import * 27 | from .tp_settings import * 28 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/settings/entry_types.py: -------------------------------------------------------------------------------- 1 | class ManagedOrderSettingsEntryTypes: 2 | SINGLE_MARKET_IN = "market_in" 3 | SINGLE_LIMIT_IN = "limit_in" 4 | SINGLE_TRY_LIMIT_IN = "try_limit_in" 5 | SCALED_OVER_TIME = "time_grid_orders" 6 | SCALED_DYNAMIC = "scaled_entry" 7 | SCALED_STATIC = "grid_entry" 8 | 9 | SINGLE_MARKET_IN_DESCRIPTION = "Single market in" 10 | SINGLE_LIMIT_IN_DESCRIPTION = "Single limit in" 11 | SINGLE_TRY_LIMIT_IN_DESCRIPTION = "Single try limit in" 12 | SCALED_OVER_TIME_DESCRIPTION = "Scale entry orders over time" 13 | SCALED_DYNAMIC_DESCRIPTION = "Scale limit orders over a dynamic price range" 14 | SCALED_STATIC_DESCRIPTION = "Scale limit orders over a static price range" 15 | 16 | LIMIT_ENTRY_TYPES = [ 17 | SINGLE_LIMIT_IN_DESCRIPTION, 18 | SCALED_DYNAMIC_DESCRIPTION, 19 | SCALED_OVER_TIME_DESCRIPTION, 20 | SCALED_STATIC_DESCRIPTION, 21 | ] 22 | 23 | KEY_TO_DESCRIPTIONS = { 24 | SINGLE_MARKET_IN: SINGLE_MARKET_IN_DESCRIPTION, 25 | SINGLE_LIMIT_IN: SINGLE_LIMIT_IN_DESCRIPTION, 26 | SINGLE_TRY_LIMIT_IN: SINGLE_TRY_LIMIT_IN_DESCRIPTION, 27 | SCALED_OVER_TIME: SCALED_OVER_TIME_DESCRIPTION, 28 | SCALED_DYNAMIC_DESCRIPTION: SCALED_DYNAMIC_DESCRIPTION, 29 | SCALED_STATIC: SCALED_STATIC_DESCRIPTION, 30 | } 31 | DESCRIPTIONS = [ 32 | SINGLE_MARKET_IN_DESCRIPTION, 33 | SINGLE_LIMIT_IN_DESCRIPTION, 34 | # SINGLE_TRY_LIMIT_IN_DESCRIPTION, 35 | # SCALED_OVER_TIME_DESCRIPTION, 36 | SCALED_DYNAMIC_DESCRIPTION, 37 | SCALED_STATIC_DESCRIPTION, 38 | ] 39 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/settings/order_settings_group.py: -------------------------------------------------------------------------------- 1 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.ping_pong_settings as ping_pong_settings 2 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.entry_settings as entry_settings 3 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.sl_settings as sl_settings 4 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.position_size_settings as position_size_settings 5 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.tp_settings as tp_settings 6 | import tentacles.Meta.Keywords.scripting_library.orders.grouping as grouping 7 | 8 | 9 | class ManagedOrderSettingsOrderGroup: 10 | stop_loss: sl_settings.ManagedOrderSettingsSL = sl_settings.ManagedOrderSettingsSL 11 | take_profit: tp_settings.ManagedOrderSettingsTP = tp_settings.ManagedOrderSettingsTP 12 | entry: entry_settings.ManagedOrderSettingsEntry = ( 13 | entry_settings.ManagedOrderSettingsEntry 14 | ) 15 | position_size: position_size_settings.ManagedOrderSettingsPositionSize = ( 16 | position_size_settings.ManagedOrderSettingsPositionSize 17 | ) 18 | ping_pong: ping_pong_settings.ManagedOrderSettingsPingPong = ( 19 | ping_pong_settings.ManagedOrderSettingsPingPong 20 | ) 21 | 22 | def __init__(self, order_manager_id, group_id, order_tag_prefix): 23 | self.order_tag_prefix = f"{order_tag_prefix}_{group_id}" 24 | self.stop_loss = self.stop_loss() 25 | self.take_profit = self.take_profit() 26 | self.entry = self.entry() 27 | self.position_size = self.position_size() 28 | self.ping_pong = self.ping_pong() 29 | self.order_manager_group_id = f"{order_manager_id}_{group_id}" 30 | self.order_groups: list = [] 31 | self.enabled_order_group = False 32 | 33 | async def create_managed_order_group(self, ctx): 34 | if ( 35 | tp_settings.ManagedOrderSettingsTPTypes.NO_TP_DESCRIPTION 36 | != self.take_profit.tp_type 37 | and sl_settings.ManagedOrderSettingsSLTypes.NO_SL_DESCRIPTION 38 | != self.stop_loss.sl_type 39 | ): 40 | try: 41 | order_group = ( 42 | grouping.get_or_create_balanced_take_profit_and_stop_group(ctx) 43 | ) 44 | self.order_groups.append(order_group) 45 | except AttributeError: 46 | # try to continue creating exits without grouping as entries are probably placed already 47 | self.enabled_order_group = False 48 | ctx.logger.error( 49 | "Managed order: failed to activate exit order grouping, " 50 | "one cancels the other will not work" 51 | ) 52 | return self 53 | # disable group to be able to create stop and take profit orders sequentially 54 | await grouping.enable_group(order_group, True) 55 | self.enabled_order_group = True 56 | return order_group 57 | 58 | async def enable_managed_order_groups(self): 59 | if self.order_groups: 60 | for order_group in self.order_groups: 61 | await grouping.enable_group(order_group, True) 62 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/settings/ping_pong_settings.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import octobot_commons.enums as commons_enums 22 | 23 | import octobot_trading.modes.script_keywords.basic_keywords as basic_keywords 24 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.orders.managed_order_pro.settings.entry_types as entry_types 25 | 26 | 27 | class ManagedOrderSettingsPingPongTypes: 28 | SIMPLE_PING_PONG = "simple_ping_pong" 29 | SIMPLE_PING_PONG_DESCRIPTION = ( 30 | "Recreate entry orders when take profits get filled " 31 | "and repeat the process until the order gets canceled" 32 | ) 33 | NO_PING_PONG = "no_ping_pong" 34 | NO_PING_PONG_DESCRIPTION = "dont use ping pong mode" 35 | 36 | KEY_TO_DESCRIPTIONS = { 37 | SIMPLE_PING_PONG: SIMPLE_PING_PONG_DESCRIPTION, 38 | NO_PING_PONG: NO_PING_PONG_DESCRIPTION, 39 | } 40 | DESCRIPTIONS = [ 41 | SIMPLE_PING_PONG_DESCRIPTION, 42 | NO_PING_PONG_DESCRIPTION, 43 | ] 44 | 45 | 46 | class ManagedOrderSettingsPingPong: 47 | ping_pong_mode_enabled: bool = False 48 | 49 | def __init__(self) -> None: 50 | self.ping_pong_type: str = None 51 | 52 | async def initialize_ping_pong_settings( 53 | self, 54 | maker, 55 | entry_type: str, 56 | parent_user_input_name: str, 57 | managed_order_group_id: int, 58 | ): 59 | if entry_type in ( 60 | entry_types.ManagedOrderSettingsEntryTypes.SCALED_DYNAMIC_DESCRIPTION, 61 | entry_types.ManagedOrderSettingsEntryTypes.SCALED_STATIC_DESCRIPTION, 62 | ): 63 | ping_pong_name_prefix = f"{managed_order_group_id}" 64 | ping_pong_settings_name = f"{managed_order_group_id}_ping_pong_settings" 65 | await basic_keywords.user_input( 66 | maker.ctx, 67 | ping_pong_settings_name, 68 | "object", 69 | title="Ping pong settings", 70 | def_val=None, 71 | parent_input_name=parent_user_input_name, 72 | editor_options={ 73 | commons_enums.UserInputEditorOptionsTypes.COLLAPSED.value: True, 74 | commons_enums.UserInputEditorOptionsTypes.DISABLE_COLLAPSE.value: False, 75 | commons_enums.UserInputEditorOptionsTypes.GRID_COLUMNS.value: 12, 76 | }, 77 | ) 78 | self.ping_pong_type = await basic_keywords.user_input( 79 | maker.ctx, 80 | f"{ping_pong_name_prefix}_ping_pong_type", 81 | "options", 82 | ManagedOrderSettingsPingPongTypes.NO_PING_PONG_DESCRIPTION, 83 | title="Ping pong type", 84 | options=ManagedOrderSettingsPingPongTypes.DESCRIPTIONS, 85 | parent_input_name=ping_pong_settings_name, 86 | ) 87 | 88 | if ( 89 | self.ping_pong_type 90 | == ManagedOrderSettingsPingPongTypes.SIMPLE_PING_PONG_DESCRIPTION 91 | ): 92 | maker.any_ping_pong_mode_active = True 93 | self.ping_pong_mode_enabled = True 94 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/orders/managed_order_pro/utilities.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import octobot_trading.enums as trading_enums 22 | import random as random 23 | 24 | from tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.matrix_enums import TAG_SEPERATOR 25 | 26 | 27 | def add_order_counter_to_tags( 28 | order_id, 29 | entry_order_tag: str, 30 | bundled_sl_tag: str or None, 31 | bundled_tp_tag: str or None, 32 | ): 33 | entry_order_tag = _format_tag(entry_order_tag, order_id) 34 | if bundled_sl_tag: 35 | bundled_sl_tag = _format_tag(bundled_sl_tag, order_id) 36 | if bundled_tp_tag: 37 | bundled_tp_tag = _format_tag(bundled_tp_tag, order_id) 38 | return entry_order_tag, bundled_sl_tag, bundled_tp_tag 39 | 40 | 41 | def _format_tag(order_tag, order_id): 42 | return f"{order_tag}{TAG_SEPERATOR}{order_id}" 43 | 44 | 45 | # class ManagedOrderUtilities: 46 | # maker = None 47 | # trading_side = "" 48 | # entry_side = "" 49 | # exit_side = "" 50 | # exit_target_position = 0 51 | # exit_amount = 0 52 | # exit_order_tag = "" 53 | # entry_order_tag = "" 54 | # order_group = None 55 | # enabled_order_group = False 56 | # created_orders = None 57 | # managed_orders_settings: all_settings.ManagedOrdersSettings = None 58 | # position_size_market = 0 59 | 60 | # async def handle_order_recreate_mode(self, ctx): 61 | # if self.managed_orders_settings.recreate_exits: 62 | # # todo use edit orders instead 63 | # await cancelling.cancel_orders(ctx, self.exit_order_tag) 64 | 65 | # # async def set_managed_amount_and_order_tag(self, ctx): 66 | # # # either replace existing exits or keep them and add new exits for new entry 67 | # # self.exit_amount = None 68 | # # self.exit_target_position = None 69 | # # if self.managed_orders_settings.recreate_exits: 70 | # # self.exit_target_position = 0 71 | # # self.exit_order_tag = f"managed_order {self.trading_side} exit:" 72 | # # self.entry_order_tag = f"managed_order {self.trading_side} entry:" 73 | # # # todo use edit orders instead 74 | # # await cancelling.cancel_orders(ctx, self.exit_order_tag) 75 | # # await cancelling.cancel_orders(ctx, self.entry_order_tag) 76 | # # else: # keep existing exit orders and only add new exits 77 | # # self.exit_amount = self.position_size 78 | # # # todo use something unique to avoid canceling eventual other orders in the same candle 79 | # # order_tag_id = random.randint(0, 999999999) 80 | # # self.exit_order_tag = ( 81 | # # f"managed_order {self.trading_side} exit (id: {order_tag_id})" 82 | # # ) 83 | # # self.entry_order_tag = ( 84 | # # f"managed_order {self.trading_side} entry (id: {order_tag_id})" 85 | # # ) 86 | 87 | 88 | def get_trading_sides(trading_side): 89 | if trading_side == trading_enums.PositionSide.LONG.value: 90 | entry_side = trading_enums.TradeOrderSide.BUY.value 91 | exit_side = trading_enums.TradeOrderSide.SELL.value 92 | 93 | elif trading_side == trading_enums.PositionSide.SHORT.value: 94 | entry_side = trading_enums.TradeOrderSide.SELL.value 95 | exit_side = trading_enums.TradeOrderSide.BUY.value 96 | else: 97 | raise RuntimeError( 98 | f'managed order: trading side must be "short" or "long" but it was {trading_side}' 99 | ) 100 | return entry_side, exit_side 101 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/plottings/__init__.py: -------------------------------------------------------------------------------- 1 | from .plots import * 2 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/plottings/plots.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from octobot_trading.modes.script_keywords.context_management import Context 3 | from tentacles.Meta.Keywords.scripting_library.data.writing import plotting 4 | 5 | 6 | async def plot_conditional( 7 | ctx: Context, 8 | title: str, 9 | signals, 10 | values, 11 | times, 12 | value_key: str, 13 | chart_location: str = "main-chart", 14 | color: typing.Optional[str] = None, 15 | own_yaxis: bool = False, 16 | is_recording_mode: bool = False, 17 | size: typing.Optional[int] = 10, 18 | ): 19 | y_values = [] 20 | y_times = [] 21 | for index, signal in enumerate(signals): 22 | if signal: 23 | y_values.append(values[index]) 24 | y_times.append(times[index]) 25 | if len(y_values) > 0: 26 | if is_recording_mode: 27 | if signals[-1]: 28 | await ctx.set_cached_value( 29 | value=values[-1], 30 | value_key=value_key, 31 | ) 32 | else: 33 | await ctx.set_cached_values( 34 | values=y_values, 35 | cache_keys=y_times, 36 | value_key=value_key, 37 | ) 38 | await plotting.plot( 39 | ctx, 40 | title=title, 41 | cache_value=value_key, 42 | chart=chart_location, 43 | own_yaxis=own_yaxis, 44 | mode="markers", 45 | size=size, 46 | color=color, 47 | line_shape=None, 48 | ) 49 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/tools/__init__.py: -------------------------------------------------------------------------------- 1 | from .utilities import * 2 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/trade_analysis/__init__.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | from .order_plotting import * 22 | from .tp_sl_analysis import * 23 | from .trade_analysis_activation import * 24 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/trade_analysis/trade_analysis_activation.py: -------------------------------------------------------------------------------- 1 | # a42.ch CONFIDENTIAL 2 | # __________________ 3 | # 4 | # [2021] - [∞] a42.ch Incorporated 5 | # All Rights Reserved. 6 | # 7 | # NOTICE: All information contained herein is, and remains 8 | # the property of a42.ch Incorporated and its suppliers, 9 | # if any. The intellectual and technical concepts contained 10 | # herein are proprietary to a42.ch Incorporated 11 | # and its suppliers and may be covered by U.S. and Foreign Patents, 12 | # patents in process, and are protected by trade secret or copyright law. 13 | # Dissemination of this information or reproduction of this material 14 | # is strictly forbidden unless prior written permission is obtained 15 | # from a42.ch Incorporated. 16 | # 17 | # If you want to use any code for commercial purposes, 18 | # or you want your own custom solution, 19 | # please contact me at max@a42.ch 20 | 21 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.trade_analysis as trade_analysis 22 | 23 | 24 | async def handle_trade_analysis_for_current_candle(ctx, parent_input: str): 25 | await trade_analysis.plot_orders_if_enabled(ctx, parent_input) 26 | await trade_analysis.plot_current_position(ctx, parent_input) 27 | await trade_analysis.plot_average_entry(ctx, parent_input) 28 | await trade_analysis.plot_balances(ctx, parent_input) 29 | 30 | 31 | async def handle_trade_analysis_for_backtesting_first_candle(ctx, maker): 32 | all_winrates = {} 33 | for tp_target in maker.trade_analysis_mode_settings["requested_long_tp"]: 34 | long_win_rates, short_win_rates = await trade_analysis.stop_loss_analysis( 35 | maker, 36 | ctx, 37 | requested_long_sl=maker.trade_analysis_mode_settings["requested_long_sl"], 38 | requested_short_sl=maker.trade_analysis_mode_settings["requested_short_sl"], 39 | take_profit_in_p=tp_target, 40 | ) 41 | all_winrates[tp_target] = { 42 | "long_win_rates": long_win_rates, 43 | "short_win_rates": short_win_rates, 44 | } 45 | return all_winrates 46 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/user_inputs2/__init__.py: -------------------------------------------------------------------------------- 1 | from .user_input2_ import * 2 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/user_inputs2/select_time_frame.py: -------------------------------------------------------------------------------- 1 | # Drakkar-Software OctoBot-Trading 2 | # Copyright (c) Drakkar-Software, All rights reserved. 3 | # 4 | # This library is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU Lesser General Public 6 | # License as published by the Free Software Foundation; either 7 | # version 3.0 of the License, or (at your option) any later version. 8 | # 9 | # This library is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # Lesser General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public 15 | # License along with this library. 16 | 17 | import octobot_commons.time_frame_manager as time_frame_manager 18 | import octobot_commons.errors as commons_errors 19 | import octobot_trading.modes.script_keywords.basic_keywords as basic_keywords 20 | 21 | 22 | async def set_trigger_time_frames( 23 | ctx, def_val=None, show_in_summary=True, show_in_optimizer=False, order=None 24 | ): 25 | available_timeframes = [ 26 | tf.value 27 | for tf in time_frame_manager.sort_time_frames( 28 | ctx.exchange_manager.exchange_config.get_relevant_time_frames() 29 | ) 30 | ] 31 | def_val = def_val or available_timeframes 32 | trigger_timeframes = await basic_keywords.user_input( 33 | ctx, 34 | "trading_mode_trigger_time_frames", 35 | input_type="multiple-options", 36 | def_val=def_val or [], 37 | title="Trading mode trigger time frames", 38 | options=available_timeframes, 39 | show_in_summary=show_in_summary, 40 | show_in_optimizer=show_in_optimizer, 41 | order=order, 42 | ) 43 | return trigger_timeframes 44 | 45 | 46 | def cancel_non_trigger_time_frames(ctx, trigger_timeframes): 47 | if ctx.time_frame not in trigger_timeframes: 48 | # ctx.time_frame == "1d" or 49 | # if isinstance(ctx.tentacle, evaluators.AbstractEvaluator): 50 | 51 | # For evaluators, make sure that undesired time frames are not in matrix anymore. 52 | # Otherwise a strategy might wait for their value before pushing its evaluation to trading modes 53 | # matrix.delete_tentacle_node( 54 | # matrix_id=ctx.tentacle.matrix_id, 55 | # tentacle_path=matrix.get_matrix_default_value_path( 56 | # exchange_name=ctx.exchange_manager.exchange_name, 57 | # tentacle_type=ctx.tentacle.evaluator_type.value, 58 | # tentacle_name=ctx.tentacle.get_name(), 59 | # cryptocurrency=ctx.cryptocurrency, 60 | # symbol=ctx.symbol, 61 | # time_frame=ctx.time_frame if ctx.time_frame else None, 62 | # ), 63 | # ) 64 | # if ctx.exchange_manager.is_backtesting: 65 | # skip_runs.register_backtesting_timestamp_whitelist(ctx, [], append_to_whitelist=False) 66 | raise commons_errors.ExecutionAborted( 67 | f"Execution aborted: disallowed time frame: {ctx.time_frame}" 68 | ) 69 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/matrix_basic_keywords/user_inputs2/user_input2_.py: -------------------------------------------------------------------------------- 1 | import octobot_commons.enums as commons_enums 2 | import octobot_trading.modes.script_keywords.basic_keywords.user_inputs as user_inputs 3 | 4 | 5 | async def user_input2( 6 | maker, 7 | indicator, 8 | name, 9 | input_type, 10 | def_val, 11 | min_val=None, 12 | max_val=None, 13 | title=None, 14 | options=None, 15 | show_in_summary=True, 16 | show_in_optimizer=True, 17 | item_title: str = None, 18 | order=None, 19 | parent_input_name=None, 20 | grid_columns=None, 21 | description=None, 22 | other_schema_values: dict = {}, 23 | editor_options: dict = {}, 24 | ): 25 | parent_input_name = parent_input_name or indicator.config_path_short 26 | editor_options = ( 27 | { 28 | **editor_options, 29 | commons_enums.UserInputEditorOptionsTypes.GRID_COLUMNS.value: grid_columns, 30 | } 31 | if grid_columns 32 | else editor_options 33 | ) 34 | other_schema_values = ( 35 | {**other_schema_values, "description": description} 36 | if description 37 | else other_schema_values 38 | ) 39 | return await user_inputs.user_input( 40 | maker.ctx, 41 | f"{indicator.config_path_short}_{name.replace(' ', '_')}", 42 | input_type=input_type, 43 | title=title or name, 44 | def_val=def_val, 45 | min_val=min_val, 46 | max_val=max_val, 47 | options=options, 48 | item_title=item_title, 49 | show_in_summary=show_in_summary, 50 | show_in_optimizer=show_in_optimizer, 51 | editor_options=editor_options, 52 | other_schema_values=other_schema_values, 53 | order=order, 54 | parent_input_name=parent_input_name, 55 | ) 56 | -------------------------------------------------------------------------------- /source/tentacles/Meta/Keywords/basic_tentacles/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.2.0", 3 | "origin_package": "Octane-Default-Tentacles", 4 | "tentacles": [ 5 | "basic_tentacles" 6 | ], 7 | "tentacles-requirements": [] 8 | } -------------------------------------------------------------------------------- /source/tentacles/Trading/Mode/lorentzian_classification/__init__.py: -------------------------------------------------------------------------------- 1 | from .trading_mode_entry import LorentzianClassificationMode 2 | -------------------------------------------------------------------------------- /source/tentacles/Trading/Mode/lorentzian_classification/config/LorentzianClassificationMode.json: -------------------------------------------------------------------------------- 1 | { 2 | "default_config": [ 3 | "TimeFrameStrategyEvaluator" 4 | ], 5 | "required_strategies": [ 6 | "TimeFrameStrategyEvaluator" 7 | ] 8 | } -------------------------------------------------------------------------------- /source/tentacles/Trading/Mode/lorentzian_classification/config/LorentzianClassificationMode_schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "title": "LorentzianClassificationMode" 4 | } -------------------------------------------------------------------------------- /source/tentacles/Trading/Mode/lorentzian_classification/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.1", 3 | "origin_package": "Octane-Default-Tentacles", 4 | "tentacles": ["LorentzianClassificationMode"], 5 | "tentacles-requirements": ["TimeFrameStrategyEvaluator", "basic_tentacles"] 6 | } -------------------------------------------------------------------------------- /source/tentacles/Trading/Mode/lorentzian_classification/resources/LorentzianClassificationMode.md: -------------------------------------------------------------------------------- 1 | Lorentzian classification evaluator, based on the trading view indicator from jdehorty and ported to OctoBot by Max https://github.com/techfreaque 2 | -------------------------------------------------------------------------------- /source/tentacles/Trading/Mode/lorentzian_classification/trading_mode_entry.py: -------------------------------------------------------------------------------- 1 | import typing 2 | from tulipy import InvalidOptionError 3 | 4 | import octobot_commons.logging as logging 5 | import octobot_trading.enums as trading_enums 6 | import octobot_trading.modes.script_keywords.context_management as context_management 7 | import tentacles.Meta.Keywords.basic_tentacles.basic_modes.scripted_trading_mode.use_scripted_trading_mode as use_scripted_trading_mode 8 | import tentacles.Meta.Keywords.basic_tentacles.matrix_basic_keywords.matrix_enums as matrix_enums 9 | 10 | import tentacles.Trading.Mode.lorentzian_classification.classification as classification 11 | import tentacles.Trading.Mode.lorentzian_classification.settings as settings 12 | 13 | 14 | class LorentzianClassificationMode(settings.LorentzianClassificationModeInputs): 15 | ENABLE_PRO_FEATURES = False 16 | 17 | def __init__(self, config, exchange_manager): 18 | super().__init__(config, exchange_manager) 19 | self.producer = LorentzianClassificationProducer 20 | if exchange_manager: 21 | # allow scripted trading if a 22 | # profile_trading_script.py is in the current profile 23 | use_scripted_trading_mode.initialize_scripted_trading_mode(self) 24 | else: 25 | logging.get_logger(self.get_name()).error( 26 | "At least one exchange must be enabled " 27 | "to use LorentzianClassificationMode" 28 | ) 29 | 30 | def get_mode_producer_classes(self) -> list: 31 | return [LorentzianClassificationProducer] 32 | 33 | @classmethod 34 | def get_supported_exchange_types(cls) -> list: 35 | """ 36 | :return: The list of supported exchange types 37 | """ 38 | return [ 39 | trading_enums.ExchangeTypes.SPOT, 40 | trading_enums.ExchangeTypes.FUTURE, 41 | ] 42 | 43 | 44 | class LorentzianClassificationProducer(classification.LorentzianClassificationScript): 45 | async def make_strategy( 46 | self, 47 | ctx: context_management.Context, 48 | action: str, 49 | action_data: typing.Optional[dict] = None, 50 | ): 51 | self.action = action 52 | if matrix_enums.TradingModeCommands.INIT_CALL != action: 53 | self.allow_trading_only_on_execution(ctx) 54 | try: 55 | await self.evaluate_lorentzian_classification( 56 | ctx=ctx, 57 | ) 58 | except InvalidOptionError as error: 59 | ctx.logger.exception( 60 | error, 61 | True, 62 | "Failed generate Filters or Features. " 63 | "Most likely due to not enough available historical bars. " 64 | "Check the historical bars in the TimeFrameStrategyEvaluator " 65 | "settings", 66 | ) 67 | --------------------------------------------------------------------------------