* Modifications for a smoother live run * Fixes data appending * Successfully allows multi-currency live trading. Adds multiple currencies to live DCA strategy * Attempting to get cash and carry working * Poor attempts at sorting out data and appending it properly with USD in mind * =designs new live data handler * Updates cash and carry strat to work * adds test coverage. begins closeallpositions function * Updates cash and carry to work live * New kline.Event type. Cancels orders on close. Rn types * =Fixes USD funding issue * =fixes tests * fixes tests AGAIN * adds coverage to close all orders * crummy tests, should override * more tests * more tests * more coverage * removes scourge of currency.Pair maps. More tests * missed currency stuff * Fixes USD data issue & collateral issue. Needs to close ALL orders * Now triggers updates on the very first data entry * All my problems are solved now???? * fixes tests, extends coverage * there is some really funky candle stuff going on * my brain is melting * better shutdown management, fixes freezing bug * fixes data duplication issues, adds retries to requests * reduces logging, adds verbose options * expands coverage over all new functionality * fixes fun bug from curr == curr to curr.Equal(curr) * fixes setup issues and tests * starts adding external wallet amounts for funding * more setup for assets * setup live fund calcs and placing orders * successfully performs automated cash and carry * merge fixes * funding properly set at all times * fixes some bugs, need to address currencystatistics still * adds 'appeneded' trait, attempts to fix some stats * fixes stat bugs, adds cool new fetchfees feature * fixes terrible processing bugs * tightens realorder stats, sadly loses some live stats * this actually sets everything correctly for bothcd ..cd ..cd ..cd ..cd ..! * fix tests * coverage * beautiful new test coverage * docs * adds new fee getter delayer * commits from the correct directory * Lint * adds verbose to fund manager * Fix bug in t2b2 strat. Update dca live config. Docs * go mod tidy * update buf * buf + test improvement * Post merge fixes * fixes surprise offset bug * fix sizing restrictions for cash and carry * fix server lints * merge fixes * test fixesss * lintle fixles * slowloris * rn run to task, bug fixes, close all on close * rpc lint and fixes * bugfix: order manager not processing orders properly * somewhat addresses nits * absolutely broken end of day commit * absolutely massive knockon effects from nits * massive knockon effects continue * fixes things * address remaining nits * jk now fixes things * addresses the easier nits * more nit fixers * more niterinos addressederinos * refactors holdings and does some nits * so buf * addresses some nits, fixes holdings bugs * cleanup * attempts to fix alert chans to prevent many chans waiting? * terrible code, will revert * to be reviewed in detail tomorrow * Fixes up channel system * smashes those nits * fixes extra candles, fixes collateral bug, tests * fixes data races, introduces reflection * more checks n tests * Fixes cash and carry issues. Fixes more cool bugs * fixes ~typer~ typo * replace spot strats from ftx to binance * fixes all the tests I just destroyed * removes example path, rm verbose * 1) what 2) removes FTX references from the Backtester * renamed, non-working strategies * Removes FTX references almost as fast as sbf removes funds * regen docs, add contrib names,sort contrib names * fixes merge renamings * Addresses nits. Fixes setting API credentials. Fixes Binance limit retrieval * Fixes live order bugs with real orders and without * Apply suggestions from code review Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update backtester/engine/live.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update backtester/engine/live.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update backtester/config/strategyconfigbuilder/main.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * updates docs * even better docs Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
GoCryptoTrader package gctscript
This gctscript package is part of the GoCryptoTrader codebase.
This is still in active development
You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.
Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack
Current Features for gctscript package
- Execute scripts
- Terminate scripts
- Autoload scripts on bot startup
- Current Exchange features supported:
- Enabled Exchanges
- Enabled currency pairs
- Account information
- Query Order
- Submit Order
- Cancel Order
- Ticker
- Orderbook
How to use
Prerequisites
To Enable database logging support you must have an active migrated database by following the database setup guide
Syntax Highlighting
To enable syntax highlighting for vscode download extension graphman65/vscode-tengo then add ".gct" to vscode-tengo package.json settings to enable highlighting of our files.
Configuration
The gctscript configuration struct is currently:
type Config struct {
Enabled bool `json:"enabled"`
ScriptTimeout time.Duration `json:"timeout"`
AllowImports bool `json:"allow_imports"`
AutoLoad []string `json:"auto_load"`
Verbose bool `json:"Verbose"`
}
With an example configuration being:
"gctscript": {
"enabled": true,
"timeout": 600000000,
"allow_imports": true,
"auto_load": [],
"debug": false
},
Script Control
-
You can autoload scripts on bot start up by placing their name in the "auto_load" config entry
"auto_load": ["one","two"]This will look in your GoCryptoTrader data directory in a folder called "scripts" for files one.gct and two.gct and autoload them
-
Manual control of scripts can be done via the gctcli command with support for the following:
- Enable/Disable GCTScript:
gctcli enablesubsystem "gctscript" gctcli disablesubsystem "gctscript"- Start/Execute:
gctcli script execute <scriptname> <pathoverride> gctcli script execute "timer.gct" "~/gctscript" { "status": "ok", "data": "timer.gct executed" }- Stop:
gctcli script stop <uuid> gctcli script stop 821bd73e-02b1-4974-9463-874cb49f130d { "status": "ok", "data": "821bd73e-02b1-4974-9463-874cb49f130d terminated" }- Status:
gctcli script status { "status": "ok", "scripts": [ { "uuid": "821bd73e-02b1-4974-9463-874cb49f130d", "name": "timer.gct", "next_run": "2019-11-14 13:11:40.224919456 +1100 AEDT m=+91.062103259" } ] }- Read file:
gctcli script read <filename> gctcli script read "timer.gct" { "status": "ok", "script": { "name": "timer.gct", "path": "/home/x/.gocryptotrader/scripts" }, "data": "fmt := import(\"fmt\")\nt := import(\"times\")\n\nname := \"run\"\ntimer := \"5s\"\n\nload := func() {\n\tfmt.printf(\"5s %s\\n\",t.now())\n}\n\nload()\n" }- Query running script:
gctcli script query <uuid> gctcli script query 821bd73e-02b1-4974-9463-874cb49f130d { "status": "ok", "script": { "UUID": "bf692e2d-fa1e-4d95-92fd-33d7634d3d77", "name": "timer.gct", "path": "/home/x/.gocryptotrader/scripts", "next_run": "2019-12-12 07:44:19.747572406 +1100 AEDT m=+16.782773385" }, "data": "fmt := import(\"fmt\")\nt := import(\"times\")\n\nname := \"run\"\ntimer := \"5s\"\n\nload := func() {\n\tfmt.printf(\"5s %s\\n\",t.now())\n}\n\nload()\n" } load()- Add script to autoload:
gctcli script autoload add timer { "status": "success", "data": "script timer added to autoload list" }- Remove script from autoload:
gctcli script autoload remove timer { "status": "success", "data": "script timer removed from autoload list" }
Scripting & Extending modules
The scripting engine utilises tengo an intro tutorial for it can be found here
Modules have been written so far linking up common exchange features including
- Orderbook
- Ticker
- Order Management
- Account information
- Withdraw funds
- Get Deposit Addresses
Extending or creating new modules:
Extending an existing module the exchange module for example is simple
- Open required module
- Add to exchangeModule map
- Define function with signature
(args ...objects.Object) (ret objects.Object, err error)
Similar steps can be taken to add a new module with a few adjustments
- Open required GCT
- Add module name to GCTModules map
GCT module methods
Current supported methods added and exposed to scripts are as follows:
accountinfo
-> exchange:string
depositaddress
-> exchange:string
-> currency:string
orderbook
-> exchange:string
-> currency pair:string
-> delimiter:string
-> asset:string
ticker
-> exchange:string
-> currency pair:string
-> delimiter:string
-> asset:string
pairs
-> exchange:string
-> enabled only:bool
-> asset:string
queryorder
-> exchange:string
-> order id:string
submitorder
-> exchange:string
-> currency pair:string
-> delimiter:string
-> order type:string
-> order side:string
-> price:float64
-> amount:float64
-> client_id:string
withdrawfiat
-> exchange:string
-> currency:string
-> description:string
-> amount:float64
-> bank id:string
withdrawcrypto
-> exchange:string
-> currency:string
-> address:string
-> address tag:string
-> amount:float64
-> fee:float64
-> description:string
Contribution
Please feel free to submit any pull requests or suggest any desired features to be added.
When submitting a PR, please abide by our coding guidelines:
- Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
- Code must be documented adhering to the official Go commentary guidelines.
- Code must adhere to our coding style.
- Pull requests need to be based on and opened against the
masterbranch.
Donations
If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:
bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc