forked from brndnmtthws/thetagang
-
Notifications
You must be signed in to change notification settings - Fork 1
/
thetagang.toml
257 lines (219 loc) · 8.67 KB
/
thetagang.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# NOTE: It is STRONGLY recommended you read through all notes, config options,
# and documentation before proceeding. Be sure to update the configuration
# values according to your preferences. Additionally, any default values in
# this config do not constitute a recommendation or endorsement, or any provide
# claims abount returns or performance.
#
# Should you decide to use ThetaGang, please experiment with a paper trading
# account before trying on a live account.
[account]
# The account number to operate on
number = "DU1234567"
# Cancel any existing orders for the symbols configured at startup
cancel_orders = true
# Maximum amount of margin to use, as a ratio of net liquidation. IB lets
# you use varying amounts of margin, depending on the assets. To use up to 4x
# margin, set this to 4. It's recommended you always leave some additional
# cushion. IB will start to close positions if you go below certain thresholds
# of available margin in your account.
#
# For details on margin usage, see:
# https://www.interactivebrokers.com/en/index.php?f=24176
#
# The default value uses 50% of your available net liquidation value
# (i.e., half of your funds). Set this to 1.0 to use all your funds,
# or 1.5 to use 150% (which may incur margin interest charges).
#
# In other words, ThetaGang's buying power is calculated by taking your NLV and
# multiplying it by margin_usage.
margin_usage = 0.5
# Market data type (see
# https://interactivebrokers.github.io/tws-api/market_data_type.html)
market_data_type = 1
[orders]
# The exchange to route orders to. Can be overridden if desired. This is also
# used for fetching tickers/prices.
exchange = "SMART"
[orders.algo]
# By default we use adaptive orders with patient priority which gives reasonable
# results. You can also experiment with TWAP or other options, however the
# available order algos vary depending on what you trade.
#
# Note that the algo orders don't seem to work with combo orders, which are used
# when rolling positions, so AFAIK this has no effect for those orders. It only
# seems to take effect with regular open/close orders.
# Optional IBKR algo strategy. See
# https://interactivebrokers.github.io/tws-api/ibalgos.html for option details.
strategy = "Adaptive"
# For `algoParams`, the TagValue parameter has 2 values, so any values with
# anything other than 2 parameters are invalid. Pass an empty list to use the
# defaults (i.e., params = []).
params = [["adaptivePriority", "Patient"]]
[option_chains]
# The option chains are lazy loaded, and before you can determine the greeks
# (delta) or prices, you need to scan the chains. The settings here tell
# thetagang how many contracts to load. Don't make these values too high, as
# they will cause the chain scanning process to take too long, and it may fail.
#
# If you have issues where thetagang can't find suitable contracts, try
# increasing these values slightly.
#
# Number of expirations to load from option chains
expirations = 4
# Number of strikes to load from option chains
strikes = 15
[roll_when]
# Roll when P&L reaches 90%
pnl = 0.9
# Or, roll options when there are <= 15 days to expiry and P&L is at least
# min_pnl (min_pnl defaults to 0)
#
# NOTE: For cases where an option ends up deep ITM, notably when selling
# covered calls, it's possible that the P&L would be significantly negative,
# i.e., -100%. If you want to roll anyway in these situations, set min_pnl to a
# negative value such as -1 (for -100%).
dte = 15
min_pnl = 0.0
# Optional: Don't roll contracts when the current DTE is greater than this
# number of days. This helps avoid cases where you end up rolling out to LEAPs.
# max_dte = 180
# Optional: Create a closing order when the P&L reaches this threshold. This
# overrides the other parameters, i.e., it ignores DTE and everything else.
# If not specified, it has no effect. This can handle the case where you have
# long-dated options that have slowly become worthless and you just want to get
# them out of your portfolio.
# close_at_pnl = 0.99
[roll_when.calls]
# Roll calls to the next expiration even if they're in the money. Defaults to
# true if not specified.
itm = true
[roll_when.puts]
# Roll puts if they're in the money. Defaults to false if not specified.
itm = false
# optionally, only write calls or puts when they're green or red, respectively.
[write_when.calls]
green = true
[write_when.puts]
red = true
[target]
# Target 45 or more days to expiry
dte = 45
# Target delta of 0.3 or less. Defaults to 0.3 if not specified.
delta = 0.3
# When writing new contracts (either covered calls or naked puts), or rolling
# before `roll_when.dte` is reached, never write more than this amount of
# contracts at once. This can be useful to avoid bunching by spreading contract
# placement out over time (and possibly expirations) in order to protect
# yourself from large swings. This value does not affect rolling existing
# contracts to the next expiration. This value is expressed as a percentage of
# buying power based on the market price of the underlying ticker, as a range
# from [0.0-1.0].
#
# Once the `roll_when.dte` date is reached, all the remaining positions are
# rolled regardless of the current position quantity.
#
# Defaults to 5% of buying power. Set this to 1.0 to effectively disable the
# limit.
maximum_new_contracts_percent = 0.05
# Minimum amount of open interest for a contract to qualify
minimum_open_interest = 10
# Optional: specify delta separately for puts/calls. Takes precedent over
# target.delta.
#
# [target.puts]
# delta = 0.5
# [target.calls]
# delta = 0.3
[symbols]
# NOTE: Please change these symbols and weights according to your preferences.
# These are provided only as an example for the purpose of configuration. These
# values were chosen as sane values should someone decide to run this code
# without changes, however it is in no way a recommendation or endorsement.
#
# You can specify the weight either as a percentage of your buying power (which
# is calculated as your NLV * account.margin_usage), or in terms of parts. Parts
# are summed from all symbols, then the weight is calculated by dividing the
# parts by the total parts.
#
# You should try to choose ETFs or stocks that:
#
# 1) Have sufficient trading volume for the underlying
# 2) Have standard options contracts (100 shares per contract)
# 3) Have options with sufficient open interest and trading volume
#
# The target delta may also be specified per-symbol, and takes precedence over
# `target.delta` or `target.puts/calls.delta`. You can specify a value for the
# symbol, or override individually for puts/calls.
[symbols.SPY]
weight = 0.4
# OR: specify in terms of parts. Must use either weight or parts, but cannot mix
# both.
# parts = 40
[symbols.QQQ]
weight = 0.3
# parts = 30
[symbols.QQQ.puts]
# Override delta just for QQQ puts
delta = 0.5
# Also, optionally specify a strike limit, for either puts or calls.
# Interpreted as an upper bound for puts, and a lower bound for calls.
strike_limit = 1000.0 # never write a put with a strike above $1000
[symbols.QQQ.calls]
strike_limit = 100.0 # never write a call with a strike below $100
[symbols.TLT]
weight = 0.2
# parts = 20
# Override delta for this particular symbol, for both puts and calls.
delta = 0.4
[symbols.ABNB]
# For symbols that require an exchange, which is typically any company stock,
# you must specify the primary exchange.
primary_exchange = "NASDAQ"
weight = 0.05
# parts = 5
# Sometimes you may need to wrap the symbol in quotes.
[symbols."BRK B"]
# For symbols that require an exchange, which is typically any company stock,
# you must specify the primary exchange.
primary_exchange = "NYSE"
weight = 0.05
# parts = 5
[ib_insync]
logfile = '/etc/thetagang/ib_insync.log'
[ibc]
# IBC configuration parameters. See
# https://ib-insync.readthedocs.io/api.html#ibc for details.
gateway = true
ibcPath = '/opt/ibc'
tradingMode = 'paper'
# Set this to true if you want to raise an exception on request errors. Under
# normal operation this should be false because we often try to make "invalid"
# requests when scanning option chains for example.
RaiseRequestErrors = false
password = 'demo'
userid = 'demo'
# Change this to point to your config.ini for IBC
ibcIni = '/etc/thetagang/config.ini'
# Change or unset this to use something other than the Docker bundled OpenJDK.
javaPath = '/opt/java/openjdk/bin'
# twsPath = ''
# twsSettingsPath = ''
# fixuserid = ''
# fixpassword = ''
[watchdog]
# Watchdog configuration params. See
# https://ib-insync.readthedocs.io/api.html#watchdog for details.
appStartupTime = 30
appTimeout = 20
clientId = 1
connectTimeout = 2
host = '127.0.0.1'
port = 7497
probeTimeout = 4
readonly = false
retryDelay = 2
[watchdog.probeContract]
currency = 'USD'
exchange = 'SMART'
secType = 'STK'
symbol = 'SPY'