Code for certain trading strategies
- Survivor Algo
- Wave Algo
This algorithm is provided for educational and informational purposes only. Trading in financial markets involves substantial risk, and you may lose all or more than your initial investment. By using this algorithm, you acknowledge that all trading decisions are made at your own risk and discretion. The creators of this algorithm assume no liability or responsibility for any financial losses or damages incurred through its use. Always do your own research and consult with a qualified financial advisor before trading.
To insall uv, use:
curl -LsSf https://astral.sh/uv/install.sh | sh
or
pip install uv
This uses uv
for dependency management. Install dependencies:
uv sync
Or if you prefer using pip:
pip install -r requirements.txt # You may need to generate this from pyproject.toml
-
Copy the sample environment file:
cp .sample.env .env
-
Edit
.env
and fill in your broker credentials:# should be one of - fyers, zeodha BROKER_NAME=<INPUT_YOUR_BROKER_NAME> BROKER_API_KEY=<INPUT_YOUR_API_KEY> BROKER_API_SECRET=<INPUT_YOUR_API_SECRET> BROKER_LOGIN_MODE='auto' # manual or auto - fyers only with 'auto' for now BROKER_ID=<INPUT_YOUR_BROKER_ID> BROKER_TOTP_REDIDRECT_URI=<INPUT_YOUR_TOTP_REDIRECT_URI> BROKER_TOTP_KEY=<INPUT_YOUR_TOTP_KEY> BROKER_TOTP_PIN=<INPUT_YOUR_TOTP_PIN> # Required for fyers, not zerodha BROKER_PASSWORD=<INPUT_YOUR_BROKER_PASSWORD> # Required for zerodha, not fyers
Strategies should be placed in the strategy/
folder.
Basic usage (using default config):
cd strategy/
python survivor.py
With custom parameters:
cd strategy/
python survivor.py \
--symbol-initials NIFTY25JAN30 \
--pe-gap 25 --ce-gap 25 \
--pe-quantity 50 --ce-quantity 50 \
--min-price-to-sell 15
View current configuration:
cd strategy/
python survivor.py --show-config
- Fyers: Supports REST API for historical data, quotes, and WebSocket for live data
- Zerodha: Supports KiteConnect API with order management and live data streaming
brokers/
: Broker implementations (Fyers, Zerodha)dispatcher.py
: Data routing and queue management - WIPorders.py
: Order management utilities - WIPlogger.py
: Logging configurationstrategy/
: Place your trading strategies here
# ==================
# IMPORTANT - Strategies are tested with Zerodha, although it should work with fyers as well
# testing might be required to make sure the results are as expected
# ==================
from brokers import BrokerGateway
broker = BrokerGateway.from_name(os.getenv("BROKER_NAME")) # fyers or zerodha
# Get historical data, place orders, etc.
For more details, check the individual broker implementations and example strategies in the strategy/
folder.