Giter Club home page Giter Club logo

finscript's Introduction

Finscript

Technical analysis domain specific language for creating reusable indicator calculator

Demo

Doc

Primitive types

  • Number:
a = 1
b = 2.3
  • Boolean
a = true
b = false
  • String
a = 'blah blah'
b = "blah blah"
c = '中文'
  • Object
a = {}
b = { a: 1, b: 2 }
c = { a, b }
d = { c, f: {} }
  • Array
a = [1, 2, 3]
b = [{ open: 10, close: 12 }, { open: 12, close: 14 }]
  • Color
a = #fff
b = #123456
c = #123456ff
  • Null
a = null

Comment

  • Single-line comment
// FIXME
  • Multi-line comment
/*
  blah
  blah
  blah
*/

Operator

  • Assign:=
  • Add:+
  • Subtract:-
  • Multiply:*
  • Divide:/
  • Modulus:%
  • Pow:^
  • Greater than:>
  • Less than:<
  • Greater than or equal:>=
  • Less than or equal:<=
  • Equal:==
  • Not equal:!==
  • And:and
  • Or:or
  • Not:not
  • Conditional operator: condition ? expression : expression

statement

  • if statement:
if a ==1 :
  // do something
else if a == 2:
  // do something
end
  • For loop:
for i in array:
  // do something
end
  • While loop:
while true:
  // do something
end

Function

  • Function declaration:
def print(a):
  Console.log(a)
end
  • Arrow function:
add = (a, b) => a + b
inc = a => a + 1
  • Function call:
Console.log(1)

Indicator operator

  • Open price:OPEN O

  • Close price:CLOSE C

  • High price:HIGH H

  • Low price:LOW L

  • Bar volume:VOLUME V VOL

  • Absolute value:ABS

ABS(O - C)
  • Arctangent:ATAN
ATAN(C)
  • Ceil: CEIL
CEIL(2.3) // 3 
  • Constant:CONST
CONST(1)
  • Cosine:COS
COS(C)
  • Count bars if condition is true:COUNT
COUNT(CLOSE > OPEN, 10)
  • Exponentially weighted moving average:EMA
EMA(C, 10)
  • Exponential Function: EXP
EXP(2) // e^2
  • Expmema: EXPMEMA
EXPMEMA(C, 10)
  • Floor: FLOOR
FLOOR(2.5) // 2
  • Max value of n bars:HHV
HHV(MAX(O, C), 60)
  • Min value of n bars:LLV
LLV(MIN(O, C), 60)
  • Natural logarithm:LN
LN(C)
  • Base-10 logarithmic:LOG
LOG(C)
  • Moving average:MA
MA(C, 60)
  • Greater of two or more values:MAX
MAX(O, C)
MAX(O, C, 100)
  • Smaller of two or more values:MIN
MIN(O, C)
MIN(O, C, 100, REF(C, 1))
  • Mathematical power function: POW
POW(C, 2)
  • Round: ROUND
ROUND(C)
  • Previous values :REF
REF(C, 10)
  • Sar:SAR
step = 2
  • Sine:COS
SIN(C)
  • Simple moving average:SMA
SMA(C, 10)
  • Square root :SQRT
SQRT(C)
  • Standard deviation:STD
STD(C, 10)
  • Sliding sum: SUM
SUM(C, 10)
  • Trigonometric tangent:TAN
TAN(C)

Creating new operator

prevClose = REF(C, 1)
prevLow = REF(L, 1)
true_range = MAX(H - L, H - prevLow, L - prevClose)

Indicator

Checkout demo

Built-in funciton

Number

  • Number.parseInt
  • Number.parseFloat
  • Number.prototype.toExponential
  • Number.prototype.toFixed
  • Number.prototype.toPrecision

Console

  • Console.log

finscript's People

Contributors

waisiukei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.