- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The exponential moving average is probably the most commonly used moving average
in financial applications. The 'C' version is shown below.
Test case is also shown at the bottom.
Anyone up to converting this to a IPP optimized function. Shouldn't
be to hard, it just consists of addition/subtraction/division. I might
be able to pay you for your time. I also have other 'c' functions
that could be rewritten if someone gets motiviated. Test case
with performance before and after would be useful.
This would be a good function to add to IPP, its used very commonly.
For more on EMA:
//(Close - EMA(previous day)) x multiplier + EMA(previous day)
void ema_32f(const float* src, float* out, int size, int factor)
{
IppStatus status;
float k;
int n;
n = size - factor;
ippsMean_32f(src + n, factor, &out, ippAlgHintFast);
--n;
k = 2.0f / (factor + 1.0f);
for(int m = n; m >= 0; --m)
out = ((src - out[m + 1]) * k) + out[m + 1];
}
float data[] = {22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23, 22.43, 22.24, 22.29, 22.15, 22.39,22.38, 22.61, 23.36, 24.05, 23.75, 23.83, 23.95, 23.63, 23.82, 23.87, 23.65, 23.19,23.10, 23.33, 22.68, 23.10, 22.40, 22.17, 22.17, 22.17, 22.17, 22.17};
float result[20];
ema_32f(data, result, 30, 10);
assert(std::abs(22.296 - result[0]) <= 0.01)
assert(std::abs(23.222 - result[19]) <= 0.01)
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
thanks for letting us know. I tracked it into our database, so we can review it during furture release implementation.
Thanks,
Chao
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, that would be great and very useful. The EMA is pretty obvious, but there are others, maybe not so obvious in financial domain that would be pretty useful too. I could provide 'C' implementations of these, with test cases.
Many financial algorithms could really benefit from being converted to IPP. These financial algorithms are all pretty simple and no more complicated than EMA.
I use IPP where I can, but we still need to do straight 'C' for much of our work. I'd love for IPP to do the heavy lifting. Most of these financial algorithms are in the public domain and would be perfect for IPP. I just don't have much background in low level SSE2 and SSE3 or however IPP is done. As a 'C' programmer, IPP abstracts away the difficult bits, so I can just code in 'C'. Thanks for awesome library.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page