Personal Finance & Money Asked on June 11, 2021
I am familiar with building moving averages (whether SMA or EMA) from candle/OHLC data or indeed from a ticker which reports the price at a fixed interval.
But I would like to extend this to a raw trades feed I have access to. Now clearly trades can come at irregular intervals and depending on the resolution of the feed, likely I may have multiple trades with the same time.
Of course one approach is to aggregate trades into fixed time intervals – basically building my own candles (or ‘buckets’). But then some intervals might have zero trades so this approach has issues.
Is there a way to extend SMA/EMA calculations to arbitrary trade times, given a trade time resolution of say 1 second?
To create moving average for a non-timeseries data. You need to consider normalize your data with timestamp. You can fill the gaps between trades with scaled datas, values that smooth the curve from your last trade to your next trade. Make use of the e constant, you can multiply the last value with a result from a function of e to time.
For example: Your last trade is 1405, your next trade is 1550, the time span is n.
You can make something like: 1405, e/(n-1) * 1405, e/(n-2) * 1405, ... e/(n-t) * 1405 < 1550
It will smooth the curve and does nothing to the shape of your intended moving average.
Answered by Khoa Doãn on June 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP