Message Boards Message Boards

3 Replies
0 Total Likes
View groups...
Share this post:

How to slow down Dynamic?

Posted 10 years ago

I just started using Dynamic[..]. I am trying to watch bitcoin prices by a url call. While I am getting updates, they are too fast. Although the output changes only once a second (because there is a time returned that changes once a second) I worry that I am actually and needlessly querying the remote server many times a second. (Obviously, I don't want to be the source of an unintended DoS attack!) Trying either UpdateInterval->5 (see my code below) or Clock[{1,1},5] doesn't slow down the response. How can I slow it, or alternatively, can someone explain how often the remote server is actually being queried by this?

  UpdateInterval -> 5], DynamicEvaluationTimeout -> 10]
POSTED BY: Alan Lewis
3 Replies

Hello, Here is one possible solution:

This will import every 10 seconds, and repeat 100 times. See CreateScheduledTask to modify this.

  bitCoinVal = {DateString[], 
    Import[""]}, {10, 100}]]


The remote server queries are a mystery to me.

POSTED BY: W. Craig Carter
Posted 10 years ago

You need , TrackedSymbols :> {}, check documentation for Refresh, there is an example about that.

So the full code:

Style[Dynamic[  Import[""], 
                        UpdateInterval -> 5, TrackedSymbols :> {}], 
      DynamicEvaluationTimeout -> 10]
POSTED BY: Kuba Podkalicki
Posted 10 years ago

Thank you both very much. Since my original post, I discovered the exchange has a somewhat newer api and suggests a query no often than once every 2 secs. Also I just wanted a last price that I could feed to other modules. So, the code below is what I finally settled on for anybody interested.

      "last\":" ~~ x__ ~~ ",\"buy" -> x][[1]]]}, UpdateInterval -> 2, 
  TrackedSymbols :> {}], DynamicEvaluationTimeout -> 10]
POSTED BY: Alan Lewis
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract