ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Bash Script for Stock Market Analysis

    IT Discussion
    3
    5
    586
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      Laksh1999
      last edited by

      I am trying to analyse the stock market data through nsepy and this command works if I run this in my Ubuntu terminal with specific stock.Example )

      nsecli history --symbol WIPRO -s $start_date -e $end_date -0 test.csv
      

      When I try to get the data of same through bash script its not working

      #!/bin/bash
      cd /home/shiva/Desktop
      data=["WIPRO"]
      start_date=2017-01-01
      end_date=$(date "+%Y-%m-%d")
      nsecli history --symbol $data -s $start_date -e $end_date -o test.csv
      
      Empty DataFrame
      Columns:[Symbol,Sries]
      Index[]
      

      When checked that csv only the heading is there.Anyone tried this before ?

      dafyreD 1 Reply Last reply Reply Quote 0
      • dafyreD
        dafyre @Laksh1999
        last edited by

        @laksh1999 said in Bash Script for Stock Market Analysis:

        data=["WIPRO"]

        Should this not simply be

        data="WIPRO" ?

        L 1 Reply Last reply Reply Quote 1
        • L
          Laksh1999 @dafyre
          last edited by

          @dafyre said in Bash Script for Stock Market Analysis:

          @laksh1999 said in Bash Script for Stock Market Analysis:

          data=["WIPRO"]

          Should this not simply be

          data="WIPRO" ?

          i can do that,i am trying to download more companies like 50.So need to add through [] only

          stacksofplatesS 1 Reply Last reply Reply Quote 0
          • stacksofplatesS
            stacksofplates @Laksh1999
            last edited by stacksofplates

            @laksh1999 said in Bash Script for Stock Market Analysis:

            @dafyre said in Bash Script for Stock Market Analysis:

            @laksh1999 said in Bash Script for Stock Market Analysis:

            data=["WIPRO"]

            Should this not simply be

            data="WIPRO" ?

            i can do that,i am trying to download more companies like 50.So need to add through [] only

            In bash arrays are defined with parens, like data=("WIPRO"). Then you would need to loop over the items in the array. Something like

            for i in ${data[@]}; do
              nsecli history --symbol $i.....
            done
            
            L 1 Reply Last reply Reply Quote 0
            • L
              Laksh1999 @stacksofplates
              last edited by

              @stacksofplates said in Bash Script for Stock Market Analysis:

              @laksh1999 said in Bash Script for Stock Market Analysis:

              @dafyre said in Bash Script for Stock Market Analysis:

              @laksh1999 said in Bash Script for Stock Market Analysis:

              data=["WIPRO"]

              Should this not simply be

              data="WIPRO" ?

              i can do that,i am trying to download more companies like 50.So need to add through [] only

              In bash arrays are defined with parens, like data=("WIPRO"). Then you would need to loop over the items in the array. Something like

              for i in ${data[@]}; do
                nsecli history --symbol $i.....
              done
              

              This Worked.How to make multiple stock there ?

                GNU nano 5.4                         
              #!/bin/bash
              cd /home/shiva/Documents
              data=('WIPRO')
              start_date=2017-01-01
              end_date=$(date "+%Y-%m-%d")
              
              for i in ${data[@]}; do
                 nsecli history --symbol $i -s $start_date -e $end_date -o 01.wipro.csv
              done
              
              
              
              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post