Skip to content

Releases: drspeaker/thetagang

ThetaGang 2023 for IBKR API locking at some tradingvew for ide

22 Jul 05:48
93ab979
Compare
Choose a tag to compare

ThetaGang 2023 for IBKR API ThetaGang 2023 for IBKR API ThetaGang 2023 for IBKR API ThetaGang 2023 for IBKR API ThetaGang 2023 for IBKR API
DRSPEAKER and ChatGPT4 consept for the Wheel of furtune with thetagang bot
import logging

import click
import click_log

logger = logging.getLogger(name)
click_log.basic_config(logger)

CONTEXT_SETTINGS = dict(
help_option_names=["-h", "--help"], auto_envvar_prefix="THETAGANG"
)

@click.command(context_settings=CONTEXT_SETTINGS)
@click_log.simple_verbosity_option(logger)
@click.option(
"-c",
"--config",
help="Path to toml config",
required=True,
default="thetagang.toml",
type=click.Path(exists=True, readable=True),
)
@click.option(
"--without-ibc",
is_flag=True,
help="Run without IBC. Enable this if you want to run the TWS "
"gateway yourself, without having ThetaGang manage it for you.",
)
def cli(config, without_ibc):
"""ThetaGang is an IBKR bot for collecting money.

You can configure this tool by supplying a toml configuration file.
There's a sample config on GitHub, here:
https://github.com/brndnmtthws/thetagang/blob/main/thetagang.toml
"""

from .thetagang import start

start(config, without_ibc)

ChatGPT
This is a Python script that defines a command-line interface (CLI) tool using the click library for managing a financial bot called "ThetaGang." The tool is designed to collect money and can be configured using a TOML configuration file. Let's break down the code:

The script imports necessary modules:

logging: Python's standard logging module for managing logging.
click: A library for creating command-line interfaces.
click_log: A Click extension for easily configuring logging with Click.
A logger named logger is created using the logging.getLogger() method and is configured to use Click's logging setup via click_log.basic_config(logger).

The script defines CONTEXT_SETTINGS, a dictionary containing various settings for the CLI context. It includes options like specifying help option names (-h and --help) and a prefix for environment variables (THETAGANG).

The main CLI command is defined using the @click.command decorator. The command is named cli and is passed the context_settings dictionary to set the desired context settings.

The click_log.simple_verbosity_option decorator is used to add verbosity options to the command, enabling the user to control the verbosity of the logging output.

Two options are defined for the CLI command:

-c, --config: An option for specifying the path to a TOML configuration file. It is required and has a default value of "thetagang.toml". The option type is set to click.Path(exists=True, readable=True), which ensures that the provided file path exists and is readable.
--without-ibc: A flag option that, when specified, will run the bot without using the IBC (Inter-Blockchain Communication) feature. It allows users to run their own TWS (Interactive Brokers) gateway without ThetaGang managing it.
The cli function is defined as the command's main function. It takes two parameters: config (the path to the TOML config file) and without_ibc (a boolean flag).

Within the cli function, the start function from the thetagang module is imported and called with the provided config and without_ibc arguments.

It is assumed that the actual implementation of the ThetaGang bot and its related functionality is present in the thetagang module, which is not shown in the provided code snippet. The start function likely handles the bot's main operations based on the provided configuration and other parameters.

To use this CLI tool, you can execute it in a terminal with the desired options, e.g.:

css
Copy code
python script.py -c thetagang_config.toml --without-ibc
This would run the ThetaGang bot with the specified TOML configuration file and without using IBC.

User
elaborat the strategy of the bot
ChatGPT
As the provided code snippet does not contain the implementation of the ThetaGang bot or its strategy, I can only provide a general outline of how a financial bot like ThetaGang might be designed and what strategies it could employ. Keep in mind that the actual strategy may be much more sophisticated and tailored to specific financial markets. Here's a general outline:

Objective:

The primary objective of the ThetaGang bot is to collect money, which implies generating consistent profits in the financial markets.
It may focus on various financial instruments, such as options, stocks, futures, or cryptocurrencies.
Market Analysis:

The bot likely employs technical analysis and/or fundamental analysis to understand the current market conditions and potential opportunities.
It may use indicators, patterns, and historical price data to make decisions.
Options Trading:

ThetaGang might specialize in options trading since its name suggests a focus on theta, a Greek letter representing the time decay component of options.
Options strategies could include covered calls, cash-secured puts, credit spreads, iron condors, etc.
It may aim to capture option premium through selling options with high probabilities of expiring worthless.
Risk Management:

An essential aspect of any trading bot is risk management to control losses and protect capital.
The bot may use predefined stop-loss levels, position sizing, and portfolio diversification to manage risk.
Volatility Management:

Since options are sensitive to changes in volatility, the bot may dynamically adjust its strategies based on market volatility levels.
It might favor strategies suitable for low volatility environments and adapt to higher volatility by adjusting position sizes or choosing different strategies.
Automation and Execution:

The bot is designed to execute trades automatically based on its predefined rules and strategies.
It may integrate with brokers or exchanges via APIs to place orders.
Backtesting and Optimization:

Before going live, the bot may undergo extensive backtesting on historical data to evaluate its performance and refine its strategies.
Optimization techniques may be used to fine-tune parameters and select the most profitable strategies.
Monitoring and Reporting:

The bot likely provides real-time monitoring of its positions, profits, and risk exposure.
It may generate reports on trading performance and strategy effectiveness.
Adaptability:

The financial markets are dynamic and subject to changing conditions. The bot should be designed to adapt to evolving market scenarios.
Security and Reliability:

Given the potential financial risks involved, the bot must be built with robust security measures and be reliable in its operations.
Please note that the actual implementation of the ThetaGang bot's strategy could be more complex and may include proprietary algorithms and techniques specific to the developer's expertise and insights into the financial markets. Additionally, successful trading bots require constant monitoring, updates, and ongoing refinement to maintain their effectiveness in changing market conditions.

User
the weel (aka Triple Income) Strategy Explained this is the options strategy I use most often and IMHO it is about as safe and reliable as options trading gets. You will NOT get fantastic returns and it is quite boring and slow, but with the proper stock and patience, it can result in reliable profits and income. A 10% to 20%+ return is not difficult depending on a few factors, mostly based on stock selection, experience managing short puts and calls, plus the trader's patience.

The Wheel (sometimes called the Triple Income Strategy) is a strategy where a trader sells cash secured Puts to collect premiums on a stock or stocks they wouldn't mind owning long term. If the options expire or closed for a profit without being assigned, the premiums are all profit. The goal is to set up trades and avoid being assigned, but it is understood that if the put is assigned the account will buy and hold the stock. Through the collection of premiums, the initial cost basis of the stock can often be lower than the strike price paid.

The next step of The Wheel is to sell covered calls on the stock shares if assigned. It is highly preferable to sell a call with a strike higher than the stock's cost basis, but this is not always possible. This is repeated over and over to collect even more premiums that continue to lower the stocks cost basis, and along with any rising stock price movement, works back to break-even or a profit.

At some point the call is exercised and the stock called away, or you can simply sell the stock, but when you add up all the premiums collected from selling the puts and calls, plus it is desired and common to end up selling the stock for a profit, this results in the Triple Income. If the stock pays a dividend while you own it then you can collect that as well (Quadruple income!).

Below is a graphic showing a simple spreadsheet to track the Credits and Debits to keep track of the overall position.

Step #1: Stock Selection - Most traders who have had a bad experience with the wheel have chosen the wrong stock. The stock(s) you chose must be a good candidate and one you don't mind owning for some length of time, as it is possible you could own it for months.

Use your own criteria that fits your account and there is no one-size-fits-all way to choose stocks as only you can determine if you think the company is a good one to trade and hold if needed. Below are my general guidelines:

A profitable company that has solid cash flow

Bullish, or at least neutral chart trend and analyst ratings

Priced around $10 to $50 Edit: $15 to up to about $100 now due to a higher account balance, but so I can afford to take the assignment if needed and I stay away from sub-$10 stocks as a rule

A stable chart without wild gy...

Read more