Indie is a subset of Python syntax constructs, namely:
supported features in Indie:
if
, for
, while
int
, float
, bool
, str
@indicator
, @func
and others)raise
-ing exceptionslist
, dict
, set
. Indie requires explicit typing of
the contained itemsnot (yet) supported in Indie:
try
..except
constructwith
..as
constructlist
, dict
, set
cannot contain elements of various typesctx.calc_on
actually accepts a function as one of it's arguments... But you cannot
write your own custom functions that do the same thing.Indie requires to explicitly declare types of all variables, function parameters and function return values, except for the cases when Indie compiler is able to infer types from the context around. Luckily, in most cases it is able to do so. For example:
a = 25 # No need to declare type of `a`, because it is initialized with an int literal. So type of `a` is int
b = a + 5 # No need to declare type of `b`, it's type is inferred as int too
Another example:
hist_color: Optional[Color] = None # We have to declare type of `hist_color` here explicitly
# otherwise `hist_color = None` tells compiler nothing about the type of
# `hist_color` variable
if hist[1] < hist[0]:
hist_color = color.NAVY
else:
hist_color = color.BLUE
Example of a function signature with typing:
def sma(price: Series, length: int) -> Series:
# ...
In Python, variables declared in if
-statements, for
-loop blocks, and while
-loop blocks are not local variables,
and stay in scope outside of the block. Indie, on the other hand, has 'block-level' scoping which is very similar to
such languages like C/C++, Java, Go. For example, in Python it's normal to write (but will fail to compile in Indie):
def some_func(cond: bool) -> int:
if cond:
res = 42
else:
res = 0
return res
In Indie, variable res
will not exist after the if
..else
statements. Moreover res
of the if
block is a different
variable than the res
from the else
block. So this example in Indie should be rewritten into:
def some_func(cond: bool) -> int:
res: int
if cond:
res = 42
else:
res = 0
return res
There are a few language constructs in Indie, which behave weird from the point of view of a standard Python. We jokinly call them 'magic' language elements. They are nothing more but a syntactic sugar for stuff and they make writing technical analysis indicators simpler. They are:
mut_series()
Function@func
and @ctx_func
(aka series processors)You may think, 'Indie is a Python-like language... so... I will import numpy, pandas, yfinance, matplotlib, talib and a lot more cool and very helpful stuff into my TakeProfit indicators right now and have some fun!' but... unfortunately you cannot do this. Well, at least right now.
There are number of reasons why. Here are some of them:
So, in other words, the fact that Indie is a Python-like language gives it an additional point of growth here. But this is a very complicated task, and it is hard to give any promises/estimates right now about it.
Now, what you can import into Indie right now, is:
indie
,
like indicator
, func
, ctx_func
, Series
, etc.indie.algorithm
,
like sma
, ema
, highest
, lowest
, etc.math.pow
math.sqrt
math.nan
math.isnan
statistics.mean
statistics.fmean
statistics.median
The list of items to be imported will definitely be expanded... Please, be patient.
Standard Python has many built-ins. Indie has only these:
None
, NoneType
, False
, True
, abs()
, bool()
, dict()
, float()
, int()
, len()
, list()
,
min()
, max()
, range()
, round()
, str()
, sum()
, tuple()
.
We run Indie code on our servers, that is why for the obvious reasons Indie's runtime is sandboxed. It means that it is very restricted in terms of what is allowed to do with the host system where code is being executed. For example file and socket I/O is not allowed, execution time and memory are limited too.