@if (!ViewContext.ModelState.IsValid)
{
}
@if (Model.ShowScripting)
{
The script language is composed of several rules composed of a currency pair and a mathematical expression. The example below will use kraken
for both LTC_USD
and BTC_USD
pairs.
LTC_USD = kraken(LTC_USD);
BTC_USD = kraken(BTC_USD);
However, explicitely setting specific pairs like this can be a bit difficult. Instead, you can define a rule X_X
which will match any currency pair. The following example will use kraken
for getting the rate of any currency pair.
X_X = kraken(X_X);
However, kraken
does not support the BTC_CAD
pair. For this reason you can add a rule mapping all X_CAD
to ndax
, a Canadian exchange.
X_CAD = ndax(X_CAD);
X_X = kraken(X_X);
A given currency pair match the most specific rule. If two rules are matching and are as specific, the first rule will be chosen.
But now, what if you want to support DOGE
? The problem with DOGE
is that most exchange do not have any pair for it. But bitpay
has a DOGE_BTC
pair.
Luckily, the rule engine allow you to reference rules:
DOGE_X = bitpay(DOGE_BTC) * BTC_X;
X_CAD = ndax(X_CAD);
X_X = kraken(X_X);
With DOGE_USD
will be expanded to bitpay(DOGE_BTC) * kraken(BTC_USD)
. And DOGE_CAD
will be expanded to bitpay(DOGE_BTC) * ndax(BTC_CAD)
.
However, we advise you to write it that way to increase coverage so that DOGE_BTC
is also supported:
DOGE_X = DOGE_BTC * BTC_X;
DOGE_BTC = bitpay(DOGE_BTC);
X_CAD = ndax(X_CAD);
X_X = kraken(X_X);
It is worth noting that the inverses of those pairs are automatically supported as well.
It means that the rule USD_DOGE = 1 / DOGE_USD
implicitly exists.