AutoTrader Web API Java library can be used for automated trading on Supports leading Indian Stock Brokers.
Following steps need to be taken in order to use the Java Library.
Download
Our java library can be installed in one of the following ways. Please choose based on your project’s build system.
- Gradle (build system)
- Maven (build system)
- Plain java project
Gradle
1. Add our repository to your build.gradle file. See highlighed lines below.
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
maven {
url "https://raw.githubusercontent.com/Pritesh-Mhatre/maven_repo/main"
}
}
2. Add following dependency. See highlighed lines below.
dependencies {
implementation 'com.dakshata:at-api:1.9.0'
}
Maven
1. Add our repository to your pom.xml file. See highlighed lines below.
<repositories>
<repository>
<id>stocks-developer</id>
<url>https://raw.githubusercontent.com/Pritesh-Mhatre/maven_repo/main</url>
</repository>
</repositories>
2. Add following dependency. See highlighed lines below.
<dependency>
<groupId>com.dakshata</groupId>
<artifactId>at-api</artifactId>
<version>1.9.0</version>
</dependency>
Download Jar
If you are not using maven or gradle build system, then you can download the following jar. This is a fat jar (library as well as all it’s dependencies are combined into a single jar).
Add the downloaded jar to your project’s classpath.
Initialize
You need to make an instance of com.dakshata.autotrader.api.AutoTrader class. See the sample code below:
IAutoTrader autotrader = AutoTrader.createInstance("<your-api-key>");
You can find your API Key on AutoTrader Web.
You must share this instance across all of your application. There is no need to create an instance again and again.
Usage
Using the client is pretty straightforward, you invoke appropriate functions on the autotrader instance. For example,
// Place a regular order
final IOperationResponse<String> response = autotrader
.placeRegularOrder("ACC_NAME", "NSE",
"BANKNIFTY_25-JUN-2020_FUT", TradeType.BUY,
OrderType.MARKET, ProductType.INTRADAY, 20, 0f, 0f);
Shutdown
You can invoke a shutdown() method just before your application exits. This is not mandatory, but recommended.
autotrader.shutdown();
API Functions
A detailed explanation is provided for each function along with examples in the API documentation.
GitHub
If you are interested to look at the code of this library, it is available on GitHub.