Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. 91priyansh
    3. Topics
    9
    • Profile
    • Following 0
    • Followers 1
    • Topics 7
    • Posts 22
    • Best 0
    • Groups 0

    Topics created by 91priyansh

    • 9

      Getting data from websocket of stock that i did not enter in script
      Bugs • • 91priyansh

      4
      0
      Votes
      4
      Posts
      50
      Views

      A

      Hi @91priyansh kindly let us know update of your above mentioned issue.

    • 9

      Not getting data from websocket for some stock
      Bugs • • 91priyansh

      6
      0
      Votes
      6
      Posts
      34
      Views

      J

      @91priyansh You can check if you are receiving ltp in the response or not. If you haven't received ltp let's say for 2 to 3 minutes, you can close the connection. Minutes depends on your choice.

    • 9

      is there built in method to find ltp of stock?
      Bugs • • 91priyansh

      2
      0
      Votes
      2
      Posts
      33
      Views

      J

      @91priyansh You can use ltpData(exchange,symbol,token) function for it.

    • 9

      is there any way to find only nfo stock data?
      General Discussion • • 91priyansh

      9
      0
      Votes
      9
      Posts
      48
      Views

      9

      @rajanprabu Thanks

    • 9

      Not getting data from web-socket
      Bugs • • 91priyansh

      4
      0
      Votes
      4
      Posts
      53
      Views

      9

      @admin ohh sorry i was accessing after 4 in evening

    • 9

      How can i use this with dart(flutter)?
      General Discussion • • 91priyansh

      12
      0
      Votes
      12
      Posts
      83
      Views

      C

      import 'dart:convert';
      import 'dart:io';
      import 'package:flutter/material.dart';
      import 'package:web_socket_channel/web_socket_channel.dart';

      class ScreenAngelWebSocket extends StatefulWidget {
      const ScreenAngelWebSocket({Key? key}) : super(key: key);

      @override
      State<ScreenAngelWebSocket> createState() => _ScreenAngelWebSocketState();
      }

      class _ScreenAngelWebSocketState extends State<ScreenAngelWebSocket> {
      WebSocketChannel? channel;

      @override
      void initState() {
      super.initState();
      channel = WebSocketChannel.connect(Uri.parse(ApiPath.WSS_ANGEL));
      channel!.sink.add(
      jsonEncode({
      "task": "cn",
      "channel": "",
      "token": "feed_token",
      "user": "client_id",
      "acctid": "client_id"
      }),
      );

      channel!.sink.add(
      jsonEncode({
      "task": "mw",
      // "channel": "nse_cm|3045",
      "channel": "nse_cm|3045&nse_cm|2885", // SBI & Reliance
      "token": "feed_token",
      "user": "client_id",
      "acctid": "client_id"
      }),
      );
      channel!.stream.listen(
      (data) {
      String response = data.toString();
      debugPrint('wss Response before Decode: ' + response);
      var step1 = base64.decode(response);
      debugPrint('wss Response Decode Step 1: ' + step1.toString());
      var inflated = zlib.decode(step1);
      var step2 = utf8.decode(inflated);
      debugPrint('wss Response Decode Step 2: ' + step2.toString());

      var step3 = json.decode(step2);
      debugPrint('wss Response Decode Step 3: ' + step3.toString());

      if (step3.toString().contains('task') &&
      step3[0]['task'].toString() == 'cn' &&
      step3[0]['msg'].toString() == 'cn') {
      debugPrint('wss Socket Connected');
      }
      },
      onDone: () {
      debugPrint('wss Socket Connected');
      },
      onError: (error) => debugPrint('wss Error: ' + error.toString()),
      );
      }

      @override
      void dispose() {
      super.dispose();
      channel!.sink.close();
      }

      @override
      Widget build(BuildContext context) {
      return Column(
      mainAxisSize: MainAxisSize.max,
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: [
      Text('Web Socket Demo'),
      ],
      );
      }
      }

      Decoded Data in Log

      wss Response Decode Step 3: [{e: nse_cm, name: sf, ltp: 2597.25, ltq: 20, tk: 2885, ltt: NA}, {e: nse_cm, name: sf, ltp: 518.90, ltq: 8, tk: 3045, ltt: NA}]

      Also find answer here https://smartapi.angelbroking.com/topic/1887/how-to-decode-web-socket-response-in-flutter-dart/2