Group Abstract Group Abstract

Message Boards Message Boards

0
|
15.6K Views
|
14 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Simulating a real-time ticker

POSTED BY: Henrick Jeanty
14 Replies
POSTED BY: Vitaliy Kaurov
Posted 5 years ago
POSTED BY: Rohit Namjoshi
Posted 5 years ago
POSTED BY: Rohit Namjoshi

The answer to your query is already contained in the use of the function InteractiveTradingChart. At the bottom of its display, just under the date boxes and above the chart type menu, there is a timeline for the entire history chosen in the command, with a slider control. That slider can be moved to any point in the financial history and its edges can be moved in or out so that the displayed data can be concentrated on as few points or as many points as you wish.

POSTED BY: Michael Kelly
POSTED BY: Henrick Jeanty
POSTED BY: Michael Kelly
POSTED BY: Henrick Jeanty
Posted 5 years ago

Henrick:

I'd be interested in collaborating with you on this sort of thing. But, I won't have any availability for a couple of weeks.

If you want a collaborator, just let me know.

POSTED BY: Mike Besso
POSTED BY: Henrick Jeanty

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?

POSTED BY: Henrick Jeanty
Posted 5 years 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]

enter image description here

POSTED BY: Rohit Namjoshi

Hello Rohit, This is much better. I will try it. Thanks.

POSTED BY: Henrick Jeanty

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 BY: Henrick Jeanty

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 BY: Henrick Jeanty
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard