empirical-soft / empirical-lang

A language for time-series analysis
https://www.empirical-soft.com/
Other
168 stars 13 forks source link

Add int-to-float arithmetic operators #72

Closed chrisaycock closed 4 years ago

chrisaycock commented 4 years ago

Currently we can't mix Int64 and Float64 in arithmetic. Let's fix that.

func wavg(ws, vs) = sum(ws * vs) / sum(ws)

from price select vwap = wavg(volume, price) by symbol, bar(time, 5m)

In the above example, volume is an integer and price is a floating point. The weighted-average function will be easy to define without the need for a cast, which the user would have done anyway.