Code for certain trading strategies
- Survivor Algo is Live
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:# Broker Configuration - Supports Fyers, Zerodha BROKER_NAME=fyers # or zerodha BROKER_API_KEY=<YOUR_API_KEY> BROKER_API_SECRET=<YOUR_API_SECRET> # items below can be skipped if not using TOTP (Fyers currently only has TOTP based login) BROKER_TOTP_ENABLE=false # or true BROKER_ID=<YOUR_BROKER_ID> BROKER_TOTP_REDIDRECT_URI=<YOUR_TOTP_REDIRECT_URI> BROKER_TOTP_KEY=<YOUR_TOTP_KEY> BROKER_TOTP_PIN=<YOUR_TOTP_PIN> BROKER_PASSWORD=<YOUR_BROKER_PASSWORD> # Required for Zerodha
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 managementorders.py
: Order management utilitieslogger.py
: Logging configurationstrategy/
: Place your trading strategies here
from brokers.fyers import FyersBroker
from brokers.zerodha import ZerodhaBroker
# Initialize broker based on environment
if os.getenv('BROKER_NAME') == 'fyers':
broker = FyersBroker(symbols=['NSE:SBIN-EQ'])
else:
broker = ZerodhaBroker(without_totp=True) # Only available for Zerodha
# Get historical data, place orders, etc.
For more details, check the individual broker implementations and example strategies in the strategy/
folder.