idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
119,400 | private void removeEmptyGroups ( ) { for ( RosterGroup group : getGroups ( ) ) { if ( group . getEntryCount ( ) == 0 ) { groups . remove ( group . getName ( ) ) ; } } } | Removes all the groups with no entries . |
119,401 | private static void move ( BareJid entity , Map < BareJid , Map < Resourcepart , Presence > > from , Map < BareJid , Map < Resourcepart , Presence > > to ) { Map < Resourcepart , Presence > presences = from . remove ( entity ) ; if ( presences != null && ! presences . isEmpty ( ) ) { to . put ( entity , presences ) ; }... | Move presences from entity from one presence map to another . |
119,402 | private static boolean hasValidSubscriptionType ( RosterPacket . Item item ) { switch ( item . getItemType ( ) ) { case none : case from : case to : case both : return true ; default : return false ; } } | Ignore ItemTypes as of RFC 6121 2 . 1 . 2 . 5 . |
119,403 | public void addReaderListener ( ReaderListener readerListener ) { if ( readerListener == null ) { return ; } synchronized ( listeners ) { if ( ! listeners . contains ( readerListener ) ) { listeners . add ( readerListener ) ; } } } | Adds a reader listener to this reader that will be notified when new strings are read . |
119,404 | protected void shutdown ( ) { if ( isSmEnabled ( ) ) { try { sendSmAcknowledgementInternal ( ) ; } catch ( InterruptedException | NotConnectedException e ) { LOGGER . log ( Level . FINE , "Can not send final SM ack as connection is not connected" , e ) ; } } shutdown ( false ) ; } | Shuts the current connection down . After this method returns the connection must be ready for re - use by connect . |
119,405 | private void initConnection ( ) throws IOException , InterruptedException { compressionHandler = null ; initReaderAndWriter ( ) ; int availableReaderWriterSemaphorePermits = readerWriterSemaphore . availablePermits ( ) ; if ( availableReaderWriterSemaphorePermits < 2 ) { Object [ ] logObjects = new Object [ ] { this , ... | Initializes the connection by creating a stanza reader and writer and opening a XMPP stream to the server . |
119,406 | @ SuppressWarnings ( "LiteralClassName" ) private void proceedTLSReceived ( ) throws NoSuchAlgorithmException , CertificateException , IOException , KeyStoreException , NoSuchProviderException , UnrecoverableKeyException , KeyManagementException , SmackException { SmackTlsContext smackTlsContext = getSmackTlsContext ( ... | The server has indicated that TLS negotiation can start . We now need to secure the existing plain connection and perform a handshake . This method won t return until the connection has finished the handshake or an error occurred while securing the connection . |
119,407 | private static XMPPInputOutputStream maybeGetCompressionHandler ( Compress . Feature compression ) { for ( XMPPInputOutputStream handler : SmackConfiguration . getCompressionHandlers ( ) ) { String method = handler . getCompressionMethod ( ) ; if ( compression . getMethods ( ) . contains ( method ) ) return handler ; }... | Returns the compression handler that can be used for one compression methods offered by the server . |
119,408 | void openStream ( ) throws SmackException , InterruptedException , XmlPullParserException { sendStreamOpen ( ) ; packetReader . parser = PacketParserUtils . newXmppParser ( reader ) ; } | Resets the parser using the latest connection s reader . Resetting the parser is necessary when the plain connection has been secured or when a new opening stream element is going to be sent by the server . |
119,409 | public boolean isSmResumptionPossible ( ) { if ( smSessionId == null ) return false ; final Long shutdownTimestamp = packetWriter . shutdownTimestamp ; if ( shutdownTimestamp == null ) { return true ; } long current = System . currentTimeMillis ( ) ; long maxResumptionMillies = ( ( long ) getMaxSmResumptionTime ( ) ) *... | Returns true if the stream is resumable . |
119,410 | public static synchronized OmemoManager getInstanceFor ( XMPPConnection connection , Integer deviceId ) { if ( deviceId == null || deviceId < 1 ) { throw new IllegalArgumentException ( "DeviceId MUST NOT be null and MUST be greater than 0." ) ; } TreeMap < Integer , OmemoManager > managersOfConnection = INSTANCES . get... | Return an OmemoManager instance for the given connection and deviceId . If there was an OmemoManager for the connection and id before return it . Otherwise create a new OmemoManager instance and return it . |
119,411 | public static synchronized OmemoManager getInstanceFor ( XMPPConnection connection ) { TreeMap < Integer , OmemoManager > managers = INSTANCES . get ( connection ) ; if ( managers == null ) { managers = new TreeMap < > ( ) ; INSTANCES . put ( connection , managers ) ; } OmemoManager manager ; if ( managers . size ( ) =... | Returns an OmemoManager instance for the given connection . If there was one manager for the connection before return it . If there were multiple managers before return the one with the lowest deviceId . If there was no manager before return a new one . As soon as the connection gets authenticated the manager will look... |
119,412 | public void initialize ( ) throws SmackException . NotLoggedInException , CorruptedOmemoKeyException , InterruptedException , SmackException . NoResponseException , SmackException . NotConnectedException , XMPPException . XMPPErrorException , PubSubException . NotALeafNodeException { synchronized ( LOCK ) { if ( ! conn... | Initializes the OmemoManager . This method must be called before the manager can be used . |
119,413 | public void initializeAsync ( final InitializationFinishedCallback finishedCallback ) { Async . go ( new Runnable ( ) { public void run ( ) { try { initialize ( ) ; finishedCallback . initializationFinished ( OmemoManager . this ) ; } catch ( Exception e ) { finishedCallback . initializationFailed ( e ) ; } } } ) ; } | Initialize the manager without blocking . Once the manager is successfully initialized the finishedCallback will be notified . It will also get notified if an error occurs . |
119,414 | public Set < OmemoDevice > getDevicesOf ( BareJid contact ) { OmemoCachedDeviceList list = getOmemoService ( ) . getOmemoStoreBackend ( ) . loadCachedDeviceList ( getOwnDevice ( ) , contact ) ; HashSet < OmemoDevice > devices = new HashSet < > ( ) ; for ( int deviceId : list . getActiveDevices ( ) ) { devices . add ( n... | Return a set of all OMEMO capable devices of a contact . Note that this method does not explicitly refresh the device list of the contact so it might be outdated . |
119,415 | public OmemoMessage . Sent encrypt ( BareJid recipient , String message ) throws CryptoFailedException , UndecidedOmemoIdentityException , InterruptedException , SmackException . NotConnectedException , SmackException . NoResponseException , SmackException . NotLoggedInException { synchronized ( LOCK ) { Set < BareJid ... | OMEMO encrypt a cleartext message for a single recipient . Note that this method does NOT set the to attribute of the message . |
119,416 | public OmemoMessage . Sent encrypt ( Set < BareJid > recipients , String message ) throws CryptoFailedException , UndecidedOmemoIdentityException , InterruptedException , SmackException . NotConnectedException , SmackException . NoResponseException , SmackException . NotLoggedInException { synchronized ( LOCK ) { Logge... | OMEMO encrypt a cleartext message for multiple recipients . |
119,417 | public OmemoMessage . Sent encrypt ( MultiUserChat muc , String message ) throws UndecidedOmemoIdentityException , CryptoFailedException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException , NoOmemoSupportException , SmackException ... | Encrypt a message for all recipients in the MultiUserChat . |
119,418 | public List < MessageOrOmemoMessage > decryptMamQueryResult ( MamManager . MamQuery mamQuery ) throws SmackException . NotLoggedInException { return new ArrayList < > ( getOmemoService ( ) . decryptMamQueryResult ( new LoggedInOmemoManager ( this ) , mamQuery ) ) ; } | Decrypt messages from a MAM query . |
119,419 | public void trustOmemoIdentity ( OmemoDevice device , OmemoFingerprint fingerprint ) { if ( trustCallback == null ) { throw new IllegalStateException ( "No TrustCallback set." ) ; } trustCallback . setTrust ( device , fingerprint , TrustState . trusted ) ; } | Trust that a fingerprint belongs to an OmemoDevice . The fingerprint must be the lowercase hexadecimal fingerprint of the identityKey of the device and must be of length 64 . |
119,420 | public void sendRatchetUpdateMessage ( OmemoDevice recipient ) throws SmackException . NotLoggedInException , CorruptedOmemoKeyException , InterruptedException , SmackException . NoResponseException , NoSuchAlgorithmException , SmackException . NotConnectedException , CryptoFailedException , CannotEstablishOmemoSession... | Send a ratchet update message . This can be used to advance the ratchet of a session in order to maintain forward secrecy . |
119,421 | public boolean contactSupportsOmemo ( BareJid contact ) throws InterruptedException , PubSubException . NotALeafNodeException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException { synchronized ( LOCK ) { OmemoCachedDeviceList deviceList = getOmemoService ... | Returns true if the contact has any active devices published in a deviceList . |
119,422 | public static boolean serverSupportsOmemo ( XMPPConnection connection , DomainBareJid server ) throws XMPPException . XMPPErrorException , SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException { return ServiceDiscoveryManager . getInstanceFor ( connection ) . discoverInfo ... | Returns true if the Server supports PEP . |
119,423 | public OmemoFingerprint getOwnFingerprint ( ) throws SmackException . NotLoggedInException , CorruptedOmemoKeyException { synchronized ( LOCK ) { if ( getOwnJid ( ) == null ) { throw new SmackException . NotLoggedInException ( ) ; } return getOmemoService ( ) . getOmemoStoreBackend ( ) . getFingerprint ( getOwnDevice (... | Return the fingerprint of our identity key . |
119,424 | public OmemoFingerprint getFingerprint ( OmemoDevice device ) throws CannotEstablishOmemoSessionException , SmackException . NotLoggedInException , CorruptedOmemoKeyException , SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException { synchronized ( LOCK ) { if ( getOwnJid (... | Get the fingerprint of a contacts device . |
119,425 | public void requestDeviceListUpdateFor ( BareJid contact ) throws InterruptedException , PubSubException . NotALeafNodeException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException { synchronized ( LOCK ) { getOmemoService ( ) . refreshDeviceList ( connec... | Request a deviceList update from contact contact . |
119,426 | public void purgeDeviceList ( ) throws SmackException . NotLoggedInException , InterruptedException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException { synchronized ( LOCK ) { getOmemoService ( ) . purgeDeviceList ( new LoggedInOmemoManager ( this ) ) ;... | Publish a new device list with just our own deviceId in it . |
119,427 | public BareJid getOwnJid ( ) { if ( ownJid == null && connection ( ) . isAuthenticated ( ) ) { ownJid = connection ( ) . getUser ( ) . asBareJid ( ) ; } return ownJid ; } | Return the BareJid of the user . |
119,428 | public Toml read ( Reader reader ) { BufferedReader bufferedReader = null ; try { bufferedReader = new BufferedReader ( reader ) ; StringBuilder w = new StringBuilder ( ) ; String line = bufferedReader . readLine ( ) ; while ( line != null ) { w . append ( line ) . append ( '\n' ) ; line = bufferedReader . readLine ( )... | Populates the current Toml instance with values from reader . |
119,429 | public Toml read ( String tomlString ) throws IllegalStateException { Results results = TomlParser . run ( tomlString ) ; if ( results . errors . hasErrors ( ) ) { throw new IllegalStateException ( results . errors . toString ( ) ) ; } this . values = results . consume ( ) ; return this ; } | Populates the current Toml instance with values from tomlString . |
119,430 | public String write ( Object from ) { try { StringWriter output = new StringWriter ( ) ; write ( from , output ) ; return output . toString ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } | Write an Object into TOML String . |
119,431 | public User parseResponse ( JSONObject response ) throws JSONException { GsonBuilder gsonBuilder = new GsonBuilder ( ) ; gsonBuilder . registerTypeAdapter ( Date . class , new JsonDeserializer < Date > ( ) { public Date deserialize ( JsonElement jsonElement , Type type , JsonDeserializationContext jsonDeserializationCo... | Parses user details response from server . |
119,432 | public User parseArray ( User user , JSONObject response ) throws JSONException { JSONArray productArray = response . getJSONArray ( "products" ) ; user . products = new String [ productArray . length ( ) ] ; for ( int i = 0 ; i < productArray . length ( ) ; i ++ ) { user . products [ i ] = productArray . getString ( i... | Parses array details of product exchange and order_type from json response . |
119,433 | public JSONObject getRequest ( String url , String apiKey , String accessToken ) throws IOException , KiteException , JSONException { Request request = createGetRequest ( url , apiKey , accessToken ) ; Response response = client . newCall ( request ) . execute ( ) ; String body = response . body ( ) . string ( ) ; retu... | Makes a GET request . |
119,434 | public String getCSVRequest ( String url , String apiKey , String accessToken ) throws IOException , KiteException , JSONException { Request request = new Request . Builder ( ) . url ( url ) . header ( "User-Agent" , USER_AGENT ) . header ( "X-Kite-Version" , "3" ) . header ( "Authorization" , "token " + apiKey + ":" +... | Makes GET request to fetch CSV dump . |
119,435 | public Request createPostRequest ( String url , Map < String , Object > params , String apiKey , String accessToken ) { FormBody . Builder builder = new FormBody . Builder ( ) ; for ( Map . Entry < String , Object > entry : params . entrySet ( ) ) { builder . add ( entry . getKey ( ) , entry . getValue ( ) . toString (... | Creates a POST request . |
119,436 | public void getMargins ( KiteConnect kiteConnect ) throws KiteException , IOException { Margin margins = kiteConnect . getMargins ( "equity" ) ; System . out . println ( margins . available . cash ) ; System . out . println ( margins . utilised . debits ) ; System . out . println ( margins . utilised . m2mUnrealised ) ... | Gets Margin . |
119,437 | public void placeBracketOrder ( KiteConnect kiteConnect ) throws KiteException , IOException { OrderParams orderParams = new OrderParams ( ) ; orderParams . quantity = 1 ; orderParams . orderType = Constants . ORDER_TYPE_LIMIT ; orderParams . price = 30.5 ; orderParams . transactionType = Constants . TRANSACTION_TYPE_B... | Place bracket order . |
119,438 | public void placeCoverOrder ( KiteConnect kiteConnect ) throws KiteException , IOException { OrderParams orderParams = new OrderParams ( ) ; orderParams . price = 0.0 ; orderParams . quantity = 1 ; orderParams . transactionType = Constants . TRANSACTION_TYPE_BUY ; orderParams . orderType = Constants . ORDER_TYPE_MARKET... | Place cover order . |
119,439 | public void getTriggerRange ( KiteConnect kiteConnect ) throws KiteException , IOException { String [ ] instruments = { "BSE:INFY" , "NSE:APOLLOTYRE" , "NSE:SBIN" } ; Map < String , TriggerRange > triggerRangeMap = kiteConnect . getTriggerRange ( instruments , Constants . TRANSACTION_TYPE_BUY ) ; System . out . println... | Get trigger range . |
119,440 | public void getOrders ( KiteConnect kiteConnect ) throws KiteException , IOException { List < Order > orders = kiteConnect . getOrders ( ) ; for ( int i = 0 ; i < orders . size ( ) ; i ++ ) { System . out . println ( orders . get ( i ) . tradingSymbol + " " + orders . get ( i ) . orderId + " " + orders . get ( i ) . pa... | Get orderbook . |
119,441 | public void getOrder ( KiteConnect kiteConnect ) throws KiteException , IOException { List < Order > orders = kiteConnect . getOrderHistory ( "180111000561605" ) ; for ( int i = 0 ; i < orders . size ( ) ; i ++ ) { System . out . println ( orders . get ( i ) . orderId + " " + orders . get ( i ) . status ) ; } System . ... | Get order details |
119,442 | public void getTradesWithOrderId ( KiteConnect kiteConnect ) throws KiteException , IOException { List < Trade > trades = kiteConnect . getOrderTrades ( "180111000561605" ) ; System . out . println ( trades . size ( ) ) ; } | Get trades for an order . |
119,443 | public void modifyOrder ( KiteConnect kiteConnect ) throws KiteException , IOException { OrderParams orderParams = new OrderParams ( ) ; orderParams . quantity = 1 ; orderParams . orderType = Constants . ORDER_TYPE_LIMIT ; orderParams . tradingsymbol = "ASHOKLEY" ; orderParams . product = Constants . PRODUCT_CNC ; orde... | Modify order . |
119,444 | public void modifyFirstLegBo ( KiteConnect kiteConnect ) throws KiteException , IOException { OrderParams orderParams = new OrderParams ( ) ; orderParams . quantity = 1 ; orderParams . price = 31.0 ; orderParams . transactionType = Constants . TRANSACTION_TYPE_BUY ; orderParams . tradingsymbol = "SOUTHBANK" ; orderPara... | Modify first leg bracket order . |
119,445 | public void cancelOrder ( KiteConnect kiteConnect ) throws KiteException , IOException { Order order2 = kiteConnect . cancelOrder ( "180116000727266" , Constants . VARIETY_REGULAR ) ; System . out . println ( order2 . orderId ) ; } | Cancel an order |
119,446 | public void getPositions ( KiteConnect kiteConnect ) throws KiteException , IOException { Map < String , List < Position > > position = kiteConnect . getPositions ( ) ; System . out . println ( position . get ( "net" ) . size ( ) ) ; System . out . println ( position . get ( "day" ) . size ( ) ) ; } | Get all positions . |
119,447 | public void getHoldings ( KiteConnect kiteConnect ) throws KiteException , IOException { List < Holding > holdings = kiteConnect . getHoldings ( ) ; System . out . println ( holdings . size ( ) ) ; } | Get holdings . |
119,448 | public void getAllInstruments ( KiteConnect kiteConnect ) throws KiteException , IOException { List < Instrument > instruments = kiteConnect . getInstruments ( ) ; System . out . println ( instruments . size ( ) ) ; } | Get all instruments that can be traded using kite connect . |
119,449 | public void getInstrumentsForExchange ( KiteConnect kiteConnect ) throws KiteException , IOException { List < Instrument > nseInstruments = kiteConnect . getInstruments ( "CDS" ) ; System . out . println ( nseInstruments . size ( ) ) ; } | Get instruments for the desired exchange . |
119,450 | public void getQuote ( KiteConnect kiteConnect ) throws KiteException , IOException { String [ ] instruments = { "256265" , "BSE:INFY" , "NSE:APOLLOTYRE" , "NSE:NIFTY 50" } ; Map < String , Quote > quotes = kiteConnect . getQuote ( instruments ) ; System . out . println ( quotes . get ( "NSE:APOLLOTYRE" ) . instrumentT... | Get quote for a scrip . |
119,451 | public void getHistoricalData ( KiteConnect kiteConnect ) throws KiteException , IOException { SimpleDateFormat formatter = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; Date from = new Date ( ) ; Date to = new Date ( ) ; try { from = formatter . parse ( "2018-01-03 12:00:00" ) ; to = formatter . parse ( "2018-01-03... | Get historical data for an instrument . |
119,452 | public void logout ( KiteConnect kiteConnect ) throws KiteException , IOException { JSONObject jsonObject10 = kiteConnect . logout ( ) ; System . out . println ( jsonObject10 ) ; } | Logout user . |
119,453 | public void getMFInstruments ( KiteConnect kiteConnect ) throws KiteException , IOException { List < MFInstrument > mfList = kiteConnect . getMFInstruments ( ) ; System . out . println ( "size of mf instrument list: " + mfList . size ( ) ) ; } | Retrieve mf instrument dump |
119,454 | public User generateSession ( String requestToken , String apiSecret ) throws KiteException , JSONException , IOException { String hashableText = this . apiKey + requestToken + apiSecret ; String sha256hex = sha256Hex ( hashableText ) ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put... | Do the token exchange with the request_token obtained after the login flow and retrieve the access_token required for all subsequent requests . |
119,455 | public TokenSet renewAccessToken ( String refreshToken , String apiSecret ) throws IOException , KiteException , JSONException { String hashableText = this . apiKey + refreshToken + apiSecret ; String sha256hex = sha256Hex ( hashableText ) ; Map < String , Object > params = new HashMap < > ( ) ; params . put ( "api_key... | Get a new access token using refresh token . |
119,456 | public String sha256Hex ( String str ) { byte [ ] a = DigestUtils . sha256 ( str ) ; StringBuilder sb = new StringBuilder ( a . length * 2 ) ; for ( byte b : a ) sb . append ( String . format ( "%02x" , b ) ) ; return sb . toString ( ) ; } | Hex encodes sha256 output for android support . |
119,457 | public Profile getProfile ( ) throws IOException , KiteException , JSONException { String url = routes . get ( "user.profile" ) ; JSONObject response = new KiteRequestHandler ( proxy ) . getRequest ( url , apiKey , accessToken ) ; return gson . fromJson ( String . valueOf ( response . get ( "data" ) ) , Profile . class... | Get the profile details of the use . |
119,458 | public Margin getMargins ( String segment ) throws KiteException , JSONException , IOException { String url = routes . get ( "user.margins.segment" ) . replace ( ":segment" , segment ) ; JSONObject response = new KiteRequestHandler ( proxy ) . getRequest ( url , apiKey , accessToken ) ; return gson . fromJson ( String ... | Gets account balance and cash margin details for a particular segment . Example for segment can be equity or commodity . |
119,459 | public Map < String , Margin > getMargins ( ) throws KiteException , JSONException , IOException { String url = routes . get ( "user.margins" ) ; JSONObject response = new KiteRequestHandler ( proxy ) . getRequest ( url , apiKey , accessToken ) ; Type type = new TypeToken < Map < String , Margin > > ( ) { } . getType (... | Gets account balance and cash margin details for a equity and commodity . |
119,460 | public Order placeOrder ( OrderParams orderParams , String variety ) throws KiteException , JSONException , IOException { String url = routes . get ( "orders.place" ) . replace ( ":variety" , variety ) ; Map < String , Object > params = new HashMap < > ( ) ; if ( orderParams . exchange != null ) params . put ( "exchang... | Places an order . |
119,461 | public Order cancelOrder ( String orderId , String variety ) throws KiteException , JSONException , IOException { String url = routes . get ( "orders.cancel" ) . replace ( ":variety" , variety ) . replace ( ":order_id" , orderId ) ; Map < String , Object > params = new HashMap < String , Object > ( ) ; JSONObject jsonO... | Cancels an order . |
119,462 | public List < Order > getOrders ( ) throws KiteException , JSONException , IOException { String url = routes . get ( "orders" ) ; JSONObject response = new KiteRequestHandler ( proxy ) . getRequest ( url , apiKey , accessToken ) ; return Arrays . asList ( gson . fromJson ( String . valueOf ( response . get ( "data" ) )... | Fetches collection of orders from the orderbook . |
119,463 | public Map < String , List < Position > > getPositions ( ) throws KiteException , JSONException , IOException { Map < String , List < Position > > positionsMap = new HashMap < > ( ) ; JSONObject response = new KiteRequestHandler ( proxy ) . getRequest ( routes . get ( "portfolio.positions" ) , apiKey , accessToken ) ; ... | Retrieves the list of positions . |
119,464 | public JSONObject convertPosition ( String tradingSymbol , String exchange , String transactionType , String positionType , String oldProduct , String newProduct , int quantity ) throws KiteException , JSONException , IOException { Map < String , Object > params = new HashMap < > ( ) ; params . put ( "tradingsymbol" , ... | Modifies an open position s product type . Only an MIS CNC and NRML positions can be converted . |
119,465 | public List < Instrument > getInstruments ( ) throws KiteException , IOException , JSONException { KiteRequestHandler kiteRequestHandler = new KiteRequestHandler ( proxy ) ; return readCSV ( kiteRequestHandler . getCSVRequest ( routes . get ( "market.instruments.all" ) , apiKey , accessToken ) ) ; } | Retrieves list of market instruments available to trade . |
119,466 | public Map < String , Quote > getQuote ( String [ ] instruments ) throws KiteException , JSONException , IOException { KiteRequestHandler kiteRequestHandler = new KiteRequestHandler ( proxy ) ; JSONObject jsonObject = kiteRequestHandler . getRequest ( routes . get ( "market.quote" ) , "i" , instruments , apiKey , acces... | Retrieves quote and market depth for an instrument |
119,467 | public Map < String , TriggerRange > getTriggerRange ( String [ ] instruments , String transactionType ) throws KiteException , JSONException , IOException { String url = routes . get ( "market.trigger_range" ) . replace ( ":transaction_type" , transactionType . toLowerCase ( ) ) ; JSONObject response = new KiteRequest... | Retrieves buy or sell trigger range for Cover Orders . |
119,468 | public HistoricalData getHistoricalData ( Date from , Date to , String token , String interval , boolean continuous ) throws KiteException , IOException , JSONException { SimpleDateFormat format = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ) ; Map < String , Object > params = new HashMap < > ( ) ; params . put ( "fro... | Retrieves historical data for an instrument . |
119,469 | public List < MFInstrument > getMFInstruments ( ) throws KiteException , IOException , JSONException { KiteRequestHandler kiteRequestHandler = new KiteRequestHandler ( proxy ) ; return readMfCSV ( kiteRequestHandler . getCSVRequest ( routes . get ( "mutualfunds.instruments" ) , apiKey , accessToken ) ) ; } | Retrieves mutualfunds instruments . |
119,470 | public MFOrder placeMFOrder ( String tradingsymbol , String transactionType , double amount , double quantity , String tag ) throws KiteException , IOException , JSONException { Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( "tradingsymbol" , tradingsymbol ) ; params . put ( "tran... | Place a mutualfunds order . |
119,471 | public boolean cancelMFOrder ( String orderId ) throws KiteException , IOException , JSONException { KiteRequestHandler kiteRequestHandler = new KiteRequestHandler ( proxy ) ; kiteRequestHandler . deleteRequest ( routes . get ( "mutualfunds.cancel_order" ) . replace ( ":order_id" , orderId ) , new HashMap < String , Ob... | If cancel is successful then api will respond as 200 and send back true else it will be sent back to user as KiteException . |
119,472 | public MFOrder getMFOrder ( String orderId ) throws KiteException , IOException , JSONException { JSONObject response = new KiteRequestHandler ( proxy ) . getRequest ( routes . get ( "mutualfunds.order" ) . replace ( ":order_id" , orderId ) , apiKey , accessToken ) ; return gson . fromJson ( response . get ( "data" ) .... | Retrieves individual mutualfunds order . |
119,473 | public MFSIP placeMFSIP ( String tradingsymbol , String frequency , int installmentDay , int instalments , int initialAmount , double amount ) throws KiteException , IOException , JSONException { Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( "tradingsymbol" , tradingsymbol ) ; pa... | Place a mutualfunds sip . |
119,474 | public boolean modifyMFSIP ( String frequency , int day , int instalments , double amount , String status , String sipId ) throws KiteException , IOException , JSONException { Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( "frequency" , frequency ) ; params . put ( "day" , day ) ;... | Modify a mutualfunds sip . |
119,475 | public boolean cancelMFSIP ( String sipId ) throws KiteException , IOException , JSONException { new KiteRequestHandler ( proxy ) . deleteRequest ( routes . get ( "mutualfunds.sip" ) . replace ( ":sip_id" , sipId ) , new HashMap < String , Object > ( ) , apiKey , accessToken ) ; return true ; } | Cancel a mutualfunds sip . |
119,476 | public MFSIP getMFSIP ( String sipId ) throws KiteException , IOException , JSONException { JSONObject response = new KiteRequestHandler ( proxy ) . getRequest ( routes . get ( "mutualfunds.sip" ) . replace ( ":sip_id" , sipId ) , apiKey , accessToken ) ; return gson . fromJson ( response . get ( "data" ) . toString ( ... | Retrieve an individual sip . |
119,477 | public JSONObject invalidateAccessToken ( ) throws IOException , KiteException , JSONException { String url = routes . get ( "api.token" ) ; Map < String , Object > params = new HashMap < > ( ) ; params . put ( "api_key" , apiKey ) ; params . put ( "access_token" , accessToken ) ; return new KiteRequestHandler ( proxy ... | Kills the session by invalidating the access token . |
119,478 | public JSONObject invalidateRefreshToken ( String refreshToken ) throws IOException , KiteException , JSONException { Map < String , Object > param = new HashMap < > ( ) ; param . put ( "refresh_token" , refreshToken ) ; param . put ( "api_key" , apiKey ) ; String url = routes . get ( "api.token" ) ; return new KiteReq... | Kills the refresh token . |
119,479 | private List < Instrument > readCSV ( String input ) throws IOException { ICsvBeanReader beanReader = null ; File temp = File . createTempFile ( "tempfile" , ".tmp" ) ; BufferedWriter bw = new BufferedWriter ( new FileWriter ( temp ) ) ; bw . write ( input ) ; bw . close ( ) ; beanReader = new CsvBeanReader ( new FileR... | This method parses csv and returns instrument list . |
119,480 | private CellProcessor [ ] getProcessors ( ) { CellProcessor [ ] processors = new CellProcessor [ ] { new NotNull ( new ParseLong ( ) ) , new NotNull ( new ParseLong ( ) ) , new NotNull ( ) , new org . supercsv . cellprocessor . Optional ( ) , new NotNull ( new ParseDouble ( ) ) , new org . supercsv . cellprocessor . Op... | This method returns array of cellprocessor for parsing csv . |
119,481 | private CellProcessor [ ] getMfProcessors ( ) { CellProcessor [ ] processors = new CellProcessor [ ] { new org . supercsv . cellprocessor . Optional ( ) , new org . supercsv . cellprocessor . Optional ( ) , new org . supercsv . cellprocessor . Optional ( ) , new org . supercsv . cellprocessor . Optional ( new ParseBool... | This method returns array of cellprocessor for parsing mutual funds csv . |
119,482 | private TimerTask getTask ( ) { TimerTask checkForRestartTask = new TimerTask ( ) { public void run ( ) { if ( lastPongAt == 0 ) return ; Date currentDate = new Date ( ) ; long timeInterval = ( currentDate . getTime ( ) - lastPongAt ) ; if ( timeInterval >= 2 * pingInterval ) { doReconnect ( ) ; } } } ; return checkFor... | Returns task which performs check every second for reconnection . |
119,483 | public void doReconnect ( ) { if ( ! tryReconnection ) return ; if ( nextReconnectInterval == 0 ) { nextReconnectInterval = ( int ) ( 2000 * Math . pow ( 2 , count ) ) ; } else { nextReconnectInterval = ( int ) ( nextReconnectInterval * Math . pow ( 2 , count ) ) ; } if ( nextReconnectInterval > maxRetryInterval ) { ne... | Performs reconnection after a particular interval if count is less than maximum retries . |
119,484 | private void createUrl ( String accessToken , String apiKey ) { wsuri = new Routes ( ) . getWsuri ( ) . replace ( ":access_token" , accessToken ) . replace ( ":api_key" , apiKey ) ; } | Creates url for websocket connection . |
119,485 | public void connect ( ) { try { ws . setPingInterval ( pingInterval ) ; ws . connect ( ) ; } catch ( WebSocketException e ) { e . printStackTrace ( ) ; if ( onErrorListener != null ) { onErrorListener . onError ( e ) ; } if ( tryReconnection ) { if ( timer == null ) { if ( lastPongAt == 0 ) { lastPongAt = 1 ; } timer =... | Establishes a web socket connection . |
119,486 | public WebSocketAdapter getWebsocketAdapter ( ) { return new WebSocketAdapter ( ) { public void onConnected ( WebSocket websocket , Map < String , List < String > > headers ) { count = 0 ; nextReconnectInterval = 0 ; if ( onConnectedListener != null ) { onConnectedListener . onConnected ( ) ; } if ( tryReconnection ) {... | Returns a WebSocketAdapter to listen to ticker related events . |
119,487 | public void disconnect ( ) { if ( timer != null ) { timer . cancel ( ) ; } if ( ws != null && ws . isOpen ( ) ) { ws . disconnect ( ) ; subscribedTokens = new HashSet < > ( ) ; modeMap . clear ( ) ; } } | Disconnects websocket connection . |
119,488 | public void setMode ( ArrayList < Long > tokens , String mode ) { JSONObject jobj = new JSONObject ( ) ; try { JSONArray list = new JSONArray ( ) ; JSONArray listMain = new JSONArray ( ) ; listMain . put ( 0 , mode ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { list . put ( i , tokens . get ( i ) ) ; } listMain... | Setting different modes for an arraylist of tokens . |
119,489 | public void subscribe ( ArrayList < Long > tokens ) { if ( ws != null ) { if ( ws . isOpen ( ) ) { createTickerJsonObject ( tokens , mSubscribe ) ; ws . sendText ( createTickerJsonObject ( tokens , mSubscribe ) . toString ( ) ) ; subscribedTokens . addAll ( tokens ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { ... | Subscribes for list of tokens . |
119,490 | private JSONObject createTickerJsonObject ( ArrayList < Long > tokens , String action ) { JSONObject jobj = new JSONObject ( ) ; try { JSONArray list = new JSONArray ( ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { list . put ( i , tokens . get ( i ) ) ; } jobj . put ( "v" , list ) ; jobj . put ( "a" , action )... | Create a JSONObject to send message to server . |
119,491 | public void unsubscribe ( ArrayList < Long > tokens ) { if ( ws != null ) { if ( ws . isOpen ( ) ) { ws . sendText ( createTickerJsonObject ( tokens , mUnSubscribe ) . toString ( ) ) ; subscribedTokens . removeAll ( tokens ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { modeMap . remove ( tokens . get ( i ) ) ; ... | Unsubscribes ticks for list of tokens . |
119,492 | private Tick getIndeciesData ( byte [ ] bin , int x ) { int dec = 100 ; Tick tick = new Tick ( ) ; tick . setMode ( modeFull ) ; tick . setTradable ( false ) ; tick . setInstrumentToken ( x ) ; tick . setLastTradedPrice ( convertToDouble ( getBytes ( bin , 4 , 8 ) ) / dec ) ; tick . setHighPrice ( convertToDouble ( get... | Parses NSE indices data . |
119,493 | private Tick getLtpQuote ( byte [ ] bin , int x , int dec1 ) { Tick tick1 = new Tick ( ) ; tick1 . setMode ( modeLTP ) ; tick1 . setTradable ( true ) ; tick1 . setInstrumentToken ( x ) ; tick1 . setLastTradedPrice ( convertToDouble ( getBytes ( bin , 4 , 8 ) ) / dec1 ) ; return tick1 ; } | Parses LTP data . |
119,494 | private Tick getFullData ( byte [ ] bin , int dec , Tick tick ) { long lastTradedtime = convertToLong ( getBytes ( bin , 44 , 48 ) ) * 1000 ; if ( isValidDate ( lastTradedtime ) ) { tick . setLastTradedTime ( new Date ( lastTradedtime ) ) ; } else { tick . setLastTradedTime ( null ) ; } tick . setOi ( convertToDouble (... | Parses full mode data . |
119,495 | private Map < String , ArrayList < Depth > > getDepthData ( byte [ ] bin , int dec , int start , int end ) { byte [ ] depthBytes = getBytes ( bin , start , end ) ; int s = 0 ; ArrayList < Depth > buy = new ArrayList < Depth > ( ) ; ArrayList < Depth > sell = new ArrayList < Depth > ( ) ; for ( int k = 0 ; k < 10 ; k ++... | Reads all bytes and returns map of depth values for offer and bid |
119,496 | private ArrayList < byte [ ] > splitPackets ( byte [ ] bin ) { ArrayList < byte [ ] > packets = new ArrayList < byte [ ] > ( ) ; int noOfPackets = getLengthFromByteArray ( getBytes ( bin , 0 , 2 ) ) ; int j = 2 ; for ( int i = 0 ; i < noOfPackets ; i ++ ) { int sizeOfPacket = getLengthFromByteArray ( getBytes ( bin , j... | Each byte stream contains many packets . This method reads first two bits and calculates number of packets in the byte stream and split it . |
119,497 | private double convertToDouble ( byte [ ] bin ) { ByteBuffer bb = ByteBuffer . wrap ( bin ) ; bb . order ( ByteOrder . BIG_ENDIAN ) ; if ( bin . length < 4 ) return bb . getShort ( ) ; else if ( bin . length < 8 ) return bb . getInt ( ) ; else return bb . getDouble ( ) ; } | Convert binary data to double datatype |
119,498 | private int getLengthFromByteArray ( byte [ ] bin ) { ByteBuffer bb = ByteBuffer . wrap ( bin ) ; bb . order ( ByteOrder . BIG_ENDIAN ) ; return bb . getShort ( ) ; } | Returns length of packet by reading byte array values . |
119,499 | private void reconnect ( final ArrayList < Long > tokens ) { nonUserDisconnect ( ) ; try { ws = new WebSocketFactory ( ) . createSocket ( wsuri ) ; } catch ( IOException e ) { if ( onErrorListener != null ) { onErrorListener . onError ( e ) ; } return ; } ws . addListener ( getWebsocketAdapter ( ) ) ; connect ( ) ; fin... | Disconnects and reconnects com . zerodhatech . ticker . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.