• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Stocks

Scheduled Pinned Locked Moved Utilities
36 Posts 15 Posters 30.3k Views 14 Watching
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.
  • Z Offline
    ZTA0796
    last edited by Dec 17, 2016, 8:53 PM

    Upon looking at it further-- in the “socketNotificationReceived: function(notification, payload)” function in the module.js file, it seems that when I run console.log(this.result), it outputs my JSON:

    Object { symbol: “MSFT”, price: “62.30”, date: “12/16/2016”, time: “4:00pm”, change: “-0.28”, col1: “62.95”, high: “62.95”, low: “62.12”, col2: “42453083” }

    When I go to the “getDom” function and run “console.log(this.result)”, I get:

    [object Object]

    I’m just not sure why that change occurs, but that seems to be my issue. Any help is massively appreciated!

    A 1 Reply Last reply Dec 18, 2016, 3:48 PM Reply Quote 0
    • A Offline
      alexyak @ZTA0796
      last edited by Dec 18, 2016, 3:48 PM

      @ZTA0796 The object that you get int the stocks.js is the deserialized javascript object. In your case it’s going to be a single row object. You could just access the properties list this:

      this.result.symbol, this.result.price, etc…

      -Alex

      Z 1 Reply Last reply Dec 18, 2016, 7:31 PM Reply Quote 0
      • Z Offline
        ZTA0796 @alexyak
        last edited by Dec 18, 2016, 7:31 PM

        @alexyak So that’s what I expected as well. Unfortunately, it is somehow getting messed up between the “socketNotificationReceived” function and the “getDom” function.

        socketNotificationReceived: function(notification, payload) {
            if (notification === "STOCKS_RESULT") {
                this.result = payload;
                console.log(this.result);  //prints my JSON correctly console
                this.updateDom(self.config.fadeSpeed);
            }       
        

        So the above works correctly. Below, however, it doesn’t seem to maintain and I can’t figure out why.

        getDom: function() {
        
            var wrapper = document.createElement("table");
            wrapper.className = 'normal regular small';
            
            var count = 0;
        
            var _this = this;
        
        	console.log("result is " + this.result); //prints "result is [object Object]"
        	console.log("result length is " + this.result.length); //prints "result length is 0"
        	console.log(this.symbol);  //prints "undefined"
            }
        

        I apologize if I’m being thick, but I can’t figure out why it’s not working…

        1 Reply Last reply Reply Quote 0
        • Z Offline
          ZTA0796
          last edited by Dec 18, 2016, 8:30 PM

          Ok, so I think i figured it out. Still not sure why it worked, but for some reason, running a console.log("descriptive text " + this) seems to corrupt or change the type of “this”. If I put two consecutive console.log() calls–first with descriptive text, second with just “this”–then it works. Basically in the example above, if I just comment out the first two console.log() calls, then it no longer prints “undefined” and instead prints “MSFT”. Sorry for all the trouble!

          1 Reply Last reply Reply Quote 0
          • M Offline
            Mitch1138
            last edited by Sep 22, 2017, 1:16 PM

            Several weeks ago this module seemed to stop working. It doesn’t generate any errors, just won’t display. Has anyone else seen this?

            Thanks, Dave

            P M 2 Replies Last reply Oct 13, 2017, 1:13 AM Reply Quote 0
            • P Offline
              pugsly @Mitch1138
              last edited by Oct 13, 2017, 1:13 AM

              @Mitch1138 Yes same for me, this module no longer works.

              1 Reply Last reply Reply Quote 0
              • M Offline
                Mykle1 Project Sponsor Module Developer @Mitch1138
                last edited by Oct 13, 2017, 2:22 AM

                @Mitch1138 said in Stocks: > Has anyone else seen this?

                @pugsly > Yes same for me, this module no longer works.

                At first glance, putting the url into a browser results in a 404 error
                http://finance.google.com/finance/info?client=ig&q=.DJI,MSFT,AAPL,GOOG,INTC,CICS,TSLA,FB

                Create a working config
                How to add modules

                H 1 Reply Last reply Dec 27, 2017, 10:38 PM Reply Quote 0
                • C Offline
                  cowboysdude Module Developer
                  last edited by Oct 13, 2017, 2:55 AM

                  The url in the module no longer works… it won’t give an error it’s a 404 error…

                  I’m seeing if I can find a url replacement…

                  H 1 Reply Last reply Dec 27, 2017, 10:19 PM Reply Quote 0
                  • H Offline
                    homebrew @alexyak
                    last edited by Dec 27, 2017, 10:16 PM

                    @alexyak
                    can’t seem to get this updating on the MM display, any ideas? Was there any change to the original code?

                    G 1 Reply Last reply Jan 3, 2018, 10:50 AM Reply Quote 1
                    • H Offline
                      homebrew @cowboysdude
                      last edited by Dec 27, 2017, 10:19 PM

                      @cowboysdude
                      Did you find a working URL replacement?
                      Have you been using another Stocks module instead?

                      C 1 Reply Last reply Dec 27, 2017, 10:24 PM Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 2 / 4
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy