forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csv.gct
28 lines (23 loc) · 908 Bytes
/
csv.gct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
exch := import("exchange")
t := import("times")
// Import all the indicators you want
atr := import("indicator/atr")
sma := import("indicator/sma")
ema := import("indicator/ema")
common := import("common")
load := func() {
// define your start and end within reason.
start := t.date(2017, 8 , 17, 0 , 0 , 0, 0)
end := t.add_date(start, 0, 6 , 0)
// This fetches the ohlcv
ohlcvData := exch.ohlcv("binance", "BTC-USDT", "-", "SPOT", start, end, "1d")
// construct ta values
avgtr := atr.calculate(ohlcvData.candles, 14)
simma := sma.calculate(ohlcvData.candles, 9)
expma := ema.calculate(ohlcvData.candles, 9)
// 'ctx' is already defined when we construct our bytecode from file.
// It contains script ID and shortname of file as save details to default
// script output directory.
common.writeascsv(ctx, ohlcvData, avgtr, simma, expma)
}
load()