Simulating a real-time ticker

Posted 24 days ago
355 Views
|
11 Replies
|
6 Total Likes
|
11 Replies
Sort By:
Posted 23 days ago
 Hi Henrick,I could not find a way to programmatically change the date range in InteractiveTradingChart. You could try something like this. data = FinancialData["GE", "OHLCV", {{2020, 01, 01}, Today, "Week"}]["DatePath"]; frames = Table[TradingChart[data[[1 ;; n]]], {n, 2, Length@data}]; (* Update every second, scale DefaultDuration to reduce update frequency *) ListAnimate[frames, DefaultDuration -> Length@data] 
Posted 23 days ago
 Thank you Rohit. Your solution is a start. I put it in and it does animate the chart. However, I see that as the chart is updated, it might have 4 or 3 or 1 new candlestick added to the previous ones. I really would like to have it update with only 1 new candlestick Interestingly enough, while your example was running, the cell had the Orange bar on the right with the + sign at the top that indicates that there is an error. So, I aborted the evaluation and looked at the frames variable. It was very informative. Thank you very much. I am not marking your reply as a solution yet, as I would like to see what others might contribute. However, I could use what you sent, with some changes. Again, thank you very much.
Posted 23 days ago
 Henrick,I also noticed that the animation is sluggish / erratic when it starts, but tends to smooth out if it is left running for a full cycle. Did not see any error display in the expression though. One way to improve performance is to rasterize the frames. Takes longer up-front but the animation works better. rasterFrames = Rasterize[#, "Image"] & /@ frames; ListAnimate[rasterFrames, DefaultDuration -> Length@data] 
Posted 23 days ago
 Hello Rohit, This is much better. I will try it. Thanks.
Posted 23 days ago
 To add a variant of @Rohit's nice example I'd mention possibility of creating a GIF where you can define time each frame duration with option "DisplayDurations" in seconds (in the images above it is 0.1 and o.5 seconds to see the difference). You also can speed up and control appearance with some options (ParallelTable, PerformanceGoal, etc). It would go something like this: data = FinancialData["GE", "OHLCV", {{2020, 01, 01}, Today, "Week"}]["DatePath"]; frames = ParallelTable[ TradingChart[data[[1 ;; n]], AspectRatio->1/4,PerformanceGoal->"Speed",ImageSize->800], {n, 2, Length@data}]; Export["itcanim.gif",frames,"DisplayDurations"->.5] 
Posted 23 days ago
 Hello Vitaly, Wow! This looks great. Let me first say this. This Wolfram Community is absolutely wonderful. You ask a question and very quickly you get replies from knowledgeable people. I love it !However, I have another problem which has to do with my previous way (meaning C# in Windows) to do things. I really love how you even provide code AND the resulting animation. Thank you so much. I would have an event that would say that I have a new candlestick. Upon receiving the event, I would then have code execute to update the effect of the new candlestick on the data we had so far. My question becomes, how can I use the new animation to call my code (basically, analyzeNewBar[newBar] where I would pass the new bar to my algorithm. Perhaps you can send me some code where you could show me where I would: 1) Know what the latest candle (newCandle) is. 2) call analyzeNewBar[newCandle]I have a new question, but I will be starting a new discussion with it.
Posted 22 days ago
 Henrick,Is there a reason for wanting to couple the analysis with the animation? All of the data that is going to be animated is already available in data so you can pre-compute. Here is a trivial example that precomputes the change in volume between samples and adds it to the chart as a label during the frame generation. analyzeData[data_] := data[[All, 2, 5]] // Differences volumeChange = analyzeData[data]; frames = ParallelTable[TradingChart[data[[1 ;; n]], PlotLabel -> "Volume Change: " <> ToString[DecimalForm[volumeChange[[n - 1]], DigitBlock -> 3]], AspectRatio -> 1/4, PerformanceGoal -> "Speed", ImageSize -> 800], {n, 2, Length@data}]; Export["tcanim.gif", frames, "DisplayDurations" -> 1] 
Posted 22 days ago
 Rohit, I've been looking at your solution a bit more in order to try to understand what it does. You get the data through FinancialData[...] You then make a table of individual frames, with one frame for each new bar. The frame goes contains as many bars as the index of the frame (i.e. Frame # 20 would show 20 bars) and the defaultDuration is the number of frames/second. What I really want to do is draw my own graphics (mostly lines) on individual frames. Is that even possible to do ?
Posted 22 days ago
 Hello Rohit. Yes, it is true that once I've loaded the stock data, it is all there and I can compute all the patterns, waves, etc... However, my algorithm works incrementally, meaning that having analyzed the last N bars, it updates new patterns, waves, etc,,, when the new bar comes in. So, for example, say I am looking at 1 minute bars and started doing so when the market opened on a particular day. After 30 minutes I would have 30 bars and, presumably, information about patterns, waves, etc... up to that point. Then, at minute 31 I receive bar #31. At that point, I don't want to have to recompute everything with 31 bars. Instead, my algorithm uses the newest bar to update its patterns, waves, etc... So, I want to simulate a ticker that updates, let's say, every minute with new 1 minute bar ( Could have the update be every second to go faster) and on every new bar, I want to display on the chart (that is another question I have) extension of trendlines, appearance of patterns, waves, etc... I could even display BUY or SELL signals or display the appearance of support or resistance lines.Now, perhaps you can answer this question. Can one draw lines on individual frame, and if so, how?