ajhpark / ib_nope Goto Github PK
View Code? Open in Web Editor NEWAutomated trading system for NOPE strategy over IBKR TWS
License: GNU Affero General Public License v3.0
Automated trading system for NOPE strategy over IBKR TWS
License: GNU Affero General Public License v3.0
When NOPE entry is selected, pick the strike closest to 30 delta (or -30 delta in the case of a put) in order to take advantage of an OTM's gamma move towards ITM.
Two possible scenarios:
Scene. 1.
Scene. 2.
Currently the bot closes the open positions from the above scenarios as soon as the market opens, since all it looks at is NOPE and NOPE resets to 0 at open. This is not ideal, need a better exit strategy for this case.
After an auto restart enter/exit tasks are duplicated
Use kelly criterion to dynamically size max call/put contract limits based on portfolio value to avoid portfolio blowout.
https://explore.paulbutler.org/bet/
Half kelly is normally a good betting size if you want to stay conservative, but base logic is that you don't bet so much that you blow up your account in a few trades.
Log trades after fills not submits
list(filter(lambda a: a.tag == 'CashBalance' and a.currency == 'USD', self.ib.accountValues(account='MYACCOUNT')))
asyncio needs to be patched to handle nested event loops, otherwise we see an event loop already running error when using ib_insync
Unit/integration
"After a certain NOPE intraday (at least, assuming all trades close out EOD), you are better to play directionally with the trend than against it. This since 2018 shows up around +70/-100 or so."
https://twitter.com/nope_its_lily/status/1375548914842050562
Reason for using Questrade for NOPE data is because there's no efficient way to use IB API to get NOPE, especially since we need to update frequently. Click here see how to get option chain data using the IB API. You need to send a separate request for each contract in the chain which is too slow and there is no endpoint to get it all at once.
Why Questrade? Because I happened to have a Questrade account and their API is good for NOPE, that's about it. Good news is this project can very easily be modified to use a different source for NOPE such as TDA or ORATS if you don't have a Questrade account.
How:
NopeStrategy.__init__
:self.qt = QuestradeClient(token_yaml=self.QT_ACCESS_TOKEN)
self.run_qt_tasks()
NopeStrategy.set_nope_value
to use the client you want. For example if using TDA, import the TDAClient
from tda/tda_client.py
and replace self.qt.get_nope()
with self.tda.get_nope()
. If using neither TDA or Questrade, you will need to write your own client for your NOPE source.asyncio
task to run NopeStrategy.set_nope_value
every minute (see NopeStrategy.run_qt_tasks
to see how it's done)The rest of NopeStrategy
doesn't care how the NOPE value is set and should work fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.