-
Python Script to Identify Hammer Candlestick Patterns in Trading Data
The Hammer candlestick forms when the open, high, and close are nearly the same, with a long lower shadow signaling a bullish rejection by buyers aiming to drive the market higher.The hammer is a reversal candlestick pattern when it occurs at the bottom of a downtrend . Characteristics of a Hammer Candlestick: Interpretation: Bullish Reversal Signal: The long lower shadow indicates that sellers pushed the price down significantly during the trading session, but strong buying pressure ultimately drove the price back up near the opening level. This suggests that buyers are starting to gain control. Hammer Implementation in python Line-by-Line Explanation 1. Importing Libraries 2. Change Current Working Directory 3.…
-
Factory Design Pattern in Java for Beginners
The Factory Design Pattern is a creational design pattern used to create objects without exposing the object creation logic to the client. Instead of using the new keyword directly, the client relies on a factory method to get the required object. Factory Design pattern is used when we have a super class with multiple subclass and based on input , we return the one of the subclasses . Super class in factory pattern can be an interface , abstract class ,or a normal java class . Example : Computer.java Pc.java Server.java ComputerFactory.java TestFactoryMain.java
-
Function Functional Interface in Java 8 – Definition, Syntax & Real-World Use Cases
The Function functional interface is a predefined interface introduced in Java 8 as part of the java.util.function package. It represents a function that accepts one input argument and produces one result. This interface is widely used in lambda expressions, Stream API operations, and functional programming. A key feature of the Function interface is that it enables developers to define reusable transformation logic, where an input object is converted into another form. For example, converting a String into its length, a Student object into a grade, or an entity into a DTO. Function is functional interface that takes one argument and produces a result , Syntax: Program1 : Write a program…
-
Predicate Functional Interface in Java 8 – Definition, Syntax & Real-World Use Cases
Java 8 introduced the concept of functional programming in Java through Lambda Expressions.To support this, Java provides a rich set of predefined functional interfaces . An Interface which contains single abstract method and any number of default and statics method .all predefined functional interface present in java.util.function package. Main Types of Predefined Functional Interfaces 1.Predicate : A predicate is a functional interface that represents a Boolean valued function of one argument . predicate takes one input and return either true or false . the Predicate functional interface is mainly used to represent business conditions or validation rules that return a boolean result and are frequently applied in filtering operations. A…
-
Stream API in Java 8: Complete Guide with Examples
Stream api is a powerful abstraction for processing sequence of elements in a functional and declarative style . it allows developers to perform complex data manipulations such as filtering , mapping , sorting and reducing with minimal boilerplate code . Stream represent a pipeline of operations that can be executed either sequentially or in parallel , improving both readability and performance . Purpose of Stream Api The main goals of the stream api are . 1.Simplify data processing: Replace verbose loops with expressive operations 2.Enable Functional programing : use lambda expressions and method references 3. Improve Performance: Support parallel execution with parallel stream . Pipeline in Java Stream A stream…
-
Default and Static Methods in Java 8 Interface – Features & Use Cases
A default method is a method define in an interface with a default implementation .it uses the default keyword and allows interfaces to have behavior without forcing all implementing classes to override it . Syntax: The main purpose of default methods is to enable backward combability when evolving interfaces before java8 , adding a new method to an interface would break all implementing classes with default methods, you can add new functionality without affecting existing code . Features of Default Methods in Java Interface with default method Abstract class Use Cases of Default Methods in Java What is Static Method in an Interface A static method in an interface is…
-
Functional Programming in Java Using Lambda Expressions
A lambda expression is a short and concise way to represent an anonymous function—a function without a name . Key Features 1.Why Lambda expression required Lambda expression required to enable functional programming ,lambda expression allow you to define small functions without naming them . this is useful when the function is simple and used only once or a few times . Lambda Syntax : 2.Lambda Expression Example Example 1: Addition of Number Without Lambda Expressions With Lambda Expressions Example 2: Find the length of String without Lambda Expressions With Lambda Expression if single statements are there then curly bracket not required , if body contained multiple lines of code then…
-
SOLID Design Principles in Java – A Complete Guide with Examples
SOLID is a set of five object-oriented design principles that help developers design clean, maintainable, scalable, and flexible software systems. These principles reduce tight coupling between classes, improve code readability, and make applications easier to extend and test. It is a set of 5 object-oriented design principles that help you write clean, maintainable, scalable, and testable Java code. Design patterns are often built on top of SOLID principles. 1.Single Responsibility Principle (SRP) there should never be more than one functionality for a class to change , single responsibility focused , single logic/functionality addresses a specific concern . Example: We have written a code in a single class that code is…
-
Python Script to Identify Doji Candlestick Patterns
A Doji candlestick is a special type of candlestick pattern in the stock market that shows indecision between buyers and sellers. When doji candlestick forms, it indicates that the market opens and closes at the same price. This means there is equality and indecision between buyers and sellers, with no one controlling the market How a Doji Candle Looks Line-by-Line Explanation 1. Importing Libraries 2. Change Current Working Directory 3. Generate Trading Session Opens the file access_token.txt and reads the access token (used for authenticated API calls). Reads API key & secret from api_key.txt and splits into a list.Example: ["your_api_key", "your_api_secret"] Creates a KiteConnect object with your API key. Sets…
-
How to fetch historical data using kite connect
Algo Trading is a method of trading in the stock market where computer programs automatically place buy and sell orders based on pre-defined rules. These rules are created using mathematical models, technical indicators, or market conditions. Explanation Learn how to use the Zerodha Kite Connect API in Python to fetch historical stock data. This step-by-step guide explains each line of code Importing Required Libraries Change Working Directory Generate Trading Session Fetch All NSE Instruments Helper Function: Fetch Instrument Token Fetch Historical OHLC Data 1.instrument = fetchInstrument(instrument_df, ticker)→ Finds the instrument token for the stock. 2. kite.historical_data(...) 3. Converts the returned JSON data into a Pandas DataFrame. 4. data.set_index("date", inplace=True)→ Sets the…
-
Understanding Zerodha’s place_order() Method in Python
Zerodha’s Kite Connect API stands out as one of the most powerful tools available to Indian traders.It allows developers to place, modify, and monitor trades programmatically using simple Python code. At the heart of this functionality lies a crucial method — place_order().This method acts as the execution engine that places your buy or sell orders directly on the Zerodha trading platform. In this blog, we’ll break down the purpose, parameters, and practical examples of the place_order() function so that you can start placing trades like a pro. Purpose of place_order() The place_order() method is used to place a new order (either BUY or SELL) in your Zerodha account via the…
-
How to Calculate Pivot Points in Python
Pivot point is a leading indicator used to assess directional movement of an asset and potential support and resistance level . How to calculate pivot points. then we calculate supports and resistance levels. How to trade using pivot points 1. Range trading strategy 2.Breakout strategy 3. How to Implement pivot point using python Explanation of above code Returns all calculated levels as a tuple. Output looks like:(Pivot, R1, R2, R3, S1, S2, S3)
-
Automating Zerodha Login with Python, Selenium, and TOTP.
This Python script automates the login process to Zerodha’s Kite Connect API using Selenium and TOTP-based two-factor authentication. It begins by setting the working directory and reading API credentials from a file, then initializes the Kite Connect session and opens the Zerodha login page in a Chrome browser. Using Selenium, it inputs the user ID and password, generates a time-based OTP using a secret key, and submits the login form. After successfully logging in and being redirected, the script extracts the request token from the URL, uses it along with the API secret to generate an access token, and saves this token to a file for future API interactions. Explanation…
-
Mastering the Pin Bar Pattern:How to Trade the Pin Bar Candlestick Pattern Like a Pro
Pin bar candlestick is one of the most famous candlestick it is widely used by price action traders to determine reversal points in the market . What is a Pin Bar Candlestick? A Pin Bar (Pinocchio Bar) is a powerful single-candle candlestick pattern that signals price rejection and a potential reversal in the market. It has: How to Identify pin bar Signals A Pin Bar candlestick is a powerful chart pattern in technical analysis. It is identified by a very long tail (or wick) that signals market rejection and indicates a possible reversal in price direction. A Bullish Pin Bar usually has a long lower wick, showing strong rejection of…
-
How to Automate Request Token Generation with Python
Generating the request_token in the Zerodha KiteConnect API is not only a mandatory daily step for accessing trading APIs but also crucial for automating stock market strategies and integrating seamlessly with Zerodha’s brokerage platform. However, doing it manually every single day can quickly become time-consuming for algo traders. Therefore, in this guide, we’ll clearly explain how to automate the entire process using Python and Selenium. Moreover, we will walk you through each step — from logging into Zerodha automatically to extracting the request_token from the redirect URL. Finally, by the end of this tutorial, you will have a fully working script that speeds up your trading setup and makes your…
