mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 15:10:44 +00:00
Update to GCT script library (#496)
* * Adds script link to GCT logger package * Adds ability to save data as csv via script * addr nits * go mod tidy * add glorious suggestion * rm unused function * fix linter issues * clean up some issues * Add in configuration fields to object for reflection to the csv file * RM line :D * address nits * update to check for target already being set and add more test coverage * force usage of .csv file extention && append date to client filename as to not overwrite file if collision occurs * fix whoopsie * linter issues * purge getter methods * Added glorious suggestion * go mod tidy after merge * niterinos
This commit is contained in:
28
gctscript/examples/csv.gct
Normal file
28
gctscript/examples/csv.gct
Normal file
@@ -0,0 +1,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()
|
||||
@@ -7,7 +7,7 @@ load := func() {
|
||||
// retrieve account information from exchange and store in info variable
|
||||
info := exch.accountinfo("BTC Markets")
|
||||
// print out info
|
||||
fmt.print(info)
|
||||
fmt.println(info)
|
||||
}
|
||||
|
||||
load()
|
||||
|
||||
@@ -3,7 +3,7 @@ exch := import("exchange")
|
||||
|
||||
load := func() {
|
||||
info := exch.pairs("BTC Markets", false, "SPOT")
|
||||
fmt.print(info)
|
||||
fmt.println(info)
|
||||
}
|
||||
|
||||
load()
|
||||
|
||||
@@ -3,7 +3,7 @@ exch := import("exchange")
|
||||
|
||||
load := func() {
|
||||
info := exch.orderquery("BTC Markets", "4491600698")
|
||||
fmt.print(info)
|
||||
fmt.println(info)
|
||||
}
|
||||
|
||||
load()
|
||||
|
||||
@@ -3,7 +3,7 @@ exch := import("exchange")
|
||||
|
||||
load := func() {
|
||||
info := exch.ordersubmit("BTC Markets","BTC-AUD","-","LIMIT","SELL",1000000, 1,"")
|
||||
fmt.print(info)
|
||||
fmt.println(info)
|
||||
}
|
||||
|
||||
load()
|
||||
|
||||
@@ -19,7 +19,7 @@ load := func() {
|
||||
// submit request to withdraw funds
|
||||
info := exch.withdrawfiat("BTC Markets", "AUD", "hello", 1, "-")
|
||||
// print out info
|
||||
fmt.print(info)
|
||||
fmt.println(info)
|
||||
}
|
||||
|
||||
load()
|
||||
|
||||
@@ -18,7 +18,7 @@ load := func() {
|
||||
|
||||
info := exch.withdrawcrypto("BTC Markets","BTC", "1234562362", "1231", 1.0, 0.0, "","" )
|
||||
// print out info
|
||||
fmt.print(info)
|
||||
fmt.println(info)
|
||||
}
|
||||
|
||||
load()
|
||||
|
||||
Reference in New Issue
Block a user