Giter Club home page Giter Club logo

javakiteconnect's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javakiteconnect's Issues

java.lang.IllegalStateException while calling kiteConnect.placeOrder()

Sometimes I get below error while placing CO LIMIT order

java.lang.IllegalStateException: closed
at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:398)
at okio.RealBufferedSource.rangeEquals(RealBufferedSource.java:392)
at okhttp3.internal.Util.bomAwareCharset(Util.java:449)
at okhttp3.ResponseBody.string(ResponseBody.java:174)
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:24)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.postRequest(KiteRequestHandler.java:85)
at com.zerodhatech.kiteconnect.KiteConnect.placeOrder(KiteConnect.java:282)

Please check

Incorrect margins are returned

public void getCombinedMarginCalculation() throws IOException, KiteException{
List params = new ArrayList<>();

    MarginCalculationParams param = new MarginCalculationParams();
    param.exchange = "NFO";
    param.tradingSymbol = "NIFTY21MAY15400PE";
    param.orderType = "MARKET";
    param.quantity = 75;
    param.product = "MIS";
    param.variety = "regular";
    param.transactionType = "SELL";
  // param.price = 141819;

    MarginCalculationParams param2 = new MarginCalculationParams();
    param2.exchange = "NFO";
    param2.tradingSymbol = "NIFTY21MAY14450PE";
    param2.orderType = "MARKET";
    param2.quantity = (int)(75*ImportantPosition.HEDGED_QTY_MULTIPLIER);
    param2.product = "MIS";
    param2.variety = "regular";
    param.transactionType = "BUY";
  //  param2.price = 300;

    params.add(param2);
    params.add(param);
    
    CombinedMarginData combinedMarginData = getKiteConnect().getCombinedMarginCalculation(params, true, false);
    System.out.println(combinedMarginData.initialMargin.total);
    System.out.println(combinedMarginData.finalMargin.total);
}

I tried gettting margins using above function. It seems SELL margins are wrongly computed. Kindly check.

IPO List

Hello Kite,

Is this library provide IPO/SME IPO List ?

Thanks

KiteTicker Java Reconnection Issue

Hi,

I have written following code for re-connection -

tickerProvider.setTryReconnection(true);
tickerProvider.setMaximumRetries(50);
tickerProvider.setMaximumRetryInterval(30);

But it is not working. Initially when we call KiteTicker connect() method we receive ticks properly. But once Internet Disconnected and then again Connected then reconnection not working. I recently updated to Kite API v3 and it is not working in v3 but in older version of API it was working properly.

I request you to please check this and help me as soon as possible.

Thanks

Proposal to add upper_limit and lower_limit into getQuote function

Hi

Requirement
getQuote function should be able to get the Upper limit and lower limit.

Current Behaviour:
Not getting Upper limit and lower limit with the getQuote function

Expected Behaviour:
Should be getting upper limit and lower limit, as the same is accessible thought API call.

API call details:
curl "https://api.kite.trade/quote?i={instruments]"
-H "X-Kite-Version: 3"
-H "Authorization: token api_key:access_token"

Response:
{ "data": { "6401": { "ohlc": { "high": 1885, "low": 1826.05, "close": 1870.75, "open": 1855 }, "lower_circuit_limit": 1683.7, "upper_circuit_limit": 2057.8, "instrument_token": 6401, "average_price": 0, "oi_day_low": 0, "oi_day_high": 0, "last_trade_time": "2023-04-13 15:59:30", "sell_quantity": 0, "buy_quantity": 0, "net_change": 0, "volume": 0, "last_quantity": 2, "depth": { "buy": [ { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 } ], "sell": [ { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 } ] }, "oi": 0, "timestamp": "1970-01-01 05:30:00", "last_price": 1870.75 }, "341249": { "lower_circuit_limit": 1523.2, "ohlc": { "high": 1697.05, "low": 1678.15, "close": 1692.45, "open": 1688.3 }, "upper_circuit_limit": 1861.65, "instrument_token": 341249, "average_price": 0, "oi_day_low": 0, "oi_day_high": 0, "last_trade_time": "2023-04-13 15:58:21", "sell_quantity": 0, "buy_quantity": 0, "net_change": 0, "volume": 0, "last_quantity": 1, "depth": { "buy": [ { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 } ], "sell": [ { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 } ] }, "oi": 0, "timestamp": "1970-01-01 05:30:00", "last_price": 1692.45 }, "738561": { "lower_circuit_limit": 2119.95, "ohlc": { "high": 2365.8, "low": 2342, "close": 2355.5, "open": 2353 }, "upper_circuit_limit": 2591.05, "instrument_token": 738561, "average_price": 0, "oi_day_low": 0, "oi_day_high": 0, "last_trade_time": "2023-04-13 15:59:43", "sell_quantity": 0, "buy_quantity": 0, "net_change": 0, "volume": 0, "last_quantity": 9, "depth": { "buy": [ { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 } ], "sell": [ { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 } ] }, "oi": 0, "timestamp": "1970-01-01 05:30:00", "last_price": 2355.5 }, "895745": { "lower_circuit_limit": 96.75, "ohlc": { "high": 108.15, "low": 105.9, "close": 107.5, "open": 107.5 }, "upper_circuit_limit": 118.25, "instrument_token": 895745, "average_price": 0, "oi_day_low": 0, "oi_day_high": 0, "last_trade_time": "2023-04-13 15:58:32", "sell_quantity": 0, "buy_quantity": 0, "net_change": 0, "volume": 0, "last_quantity": 1, "depth": { "buy": [ { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 } ], "sell": [ { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 }, { "quantity": 0, "price": 0, "orders": 0 } ] }, "oi": 0, "timestamp": "1970-01-01 05:30:00", "last_price": 107.5 } }, "status": "success" }

In the above request I am getting "lower_circuit_limit", and "upper_circuit_limit".

But the quote bean which we are using does not have above two params.

Here by I Propose to add those two fields into the Quote Bean.

Class name: Quote

    public class Quote {

        @SerializedName("volume")
        public double volumeTradedToday;
        @SerializedName("last_quantity")
        public double lastTradedQuantity;
        @SerializedName("last_trade_time")
        public Date lastTradedTime;
        @SerializedName("net_change")
        public double change;
        @SerializedName("oi")
        public double oi;
        @SerializedName("sell_quantity")
        public double sellQuantity;
        @SerializedName("last_price")
        public double lastPrice;
        @SerializedName("buy_quantity")
        public double buyQuantity;
        @SerializedName("ohlc")
        public OHLC ohlc;
        @SerializedName("instrument_token")
        public long instrumentToken;
        @SerializedName("timestamp")
        public Date timestamp;
        @SerializedName("average_price")
        public double averagePrice;
        @SerializedName("day_high_oi")
        public double oiDayHigh;
        @SerializedName("day_low_oi")
        public double oiDayLow;
        @SerializedName("depth")
        public MarketDepth depth;
        **@SerializedName("lower_circuit_limit")
        public double lowerCircuitLimit;
        @SerializedName("upper_circuit_limit")
        public double upperCircuitLimit;**

}

change data on Tick class is different for nifty Index and Nifty Future

HI

i have using java library and subscribed for nifty and nifty future via java web socket library.
Everything works good, just one issue is there

With Nifty Index.
change filed contains net change from yesterday close

With Nifty Future

change filed display percentage change from yesterday close

Please find my logs

Token : 9604354
ltp : 17330.5
Close : 17647.6
change : -1.7968448967564914
Avg traded price : 17441.35
volume : 1.107595E7
OI : 1.21302E7
o : 17587.95
h : 17638.3
l : 17291.15
C :17647.6

Token : 256265
ltp : 17320.55
Close : 17629.8
change : -309.25
Avg traded price : 0.0
volume : 0.0
OI : 0.0
o : 17593.85
h : 17642.15
l : 17291.65
C :17629.8

`Here is my java code

tickerProvider.setOnTickerArrivalListener(new OnTicks() {
@Override
public void onTicks(ArrayList ticks) {
System.out.println("tick "+ ticks.size());
ticks.forEach(i->{
System.out.println("Token : " + i.getInstrumentToken());
System.out.println("ltp : " + i.getLastTradedPrice());
System.out.println("Close : " + i.getClosePrice());
System.out.println("change : " + i.getChange());
System.out.println("Avg traded price : " + i.getAverageTradePrice()); // vwap
System.out.println("volume : " + i.getVolumeTradedToday()); // volume
System.out.println("OI : " + i.getOi()); // volume
System.out.println("o : " + i.getOpenPrice());
System.out.println("h : " + i.getHighPrice());
System.out.println("l : " + i.getLowPrice());
System.out.println("C :" + i.getClosePrice());
});

System.out.println("---------");
// FilterTickToDomain.filter(ticks);
}
});`

Add more information to exceptions

Currently all the failures returns exceptions like InputException, KiteException etc.
but they do not contain detailed error message that is coming from zerodha's rest API, for example, Markets are closed ....

This information is present in the mesasge field in the http response. It would be good if this message can be extracted and put it in the exception.

Random IllegalStateException with getInstruments api

I get a random and hard to reproduce IllegalStateException errors with calls to the api GetInstruments. Retrying the same , works. Exception trace below;

java.lang.IllegalStateException: closed
okio.RealBufferedSource.select(RealBufferedSource.kt:83)
okhttp3.internal.Util.readBomAsCharset(Util.kt:256)
okhttp3.ResponseBody.string(ResponseBody.kt:187)
com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(KiteResponseHandler.java:34)
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getCSVRequest(KiteRequestHandler.java:150)
at com.zerodhatech.kiteconnect.KiteConnect.getInstruments(KiteConnect.java:651)

Version:3.1.0

Need an example to get Historical Data

I am trying to get 15minute and 60minute data of Silver, Gold etc. My MCX commodity trading is enabled. I have been getting InputException which is very frustrating.

I tried finding an example, which I did find here. In this example, I get the parse error related to date formatter and date string. Which means, the example in this repo is outdated. Could you please give latest example in the repo to fetch historical data by minute, 15minute and 60minute?

On my own machine I run my "Scala" code like this:

    val historicalDayData = kiteConnect.getHistoricalData(
      Date.valueOf("2023-10-29"),
      Date.valueOf("2023-11-28"),
      "65953543",
      "day",
      true,
      true
    )

When I fetch the day data, there is no error. However, in case of 15minute and 60minute I am getting InputException error.

Update README: Add Maven and Gradle Instructions

The current README file instructs users to download the JAR file for the Kite Connect Java library. This approach is not ideal for project management.

This task involves updating the README file to include instructions for adding the library as a dependency using both Maven and Gradle.

Specific changes:

  • Add a section titled "Adding the Dependency" with subsections for:
    • Maven: Include instructions with an example dependency snippet in pom.xml.
    • Gradle: Include instructions with an example dependency snippet in build.gradle.
  • Update any other relevant sections of the README to reflect these changes.

Testing:

  • Verify that the updated README accurately reflects the Maven and Gradle dependency instructions.

Exponential representation of volumes in WebSocket API

{open=311.1, close=310.25, high=315.45, low=310.5, volume=1.8547441E7, lasttradedprice=312.85, change=0.8380338436744634, lasttradedquantity=200.0, volumetradedtoday=0.0, totalbuyquantity=0.0, totalsellquantity=0.0, tradetimestamp=1626421247000}

The volume as 1.8547441E7 is represented in exponential format

For further information please go through the forum discussion page https://kite.trade/forum/discussion/10122/incorrect-volume-data-from-websockets#latest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.