* WIP * end of day WIP started migration of trade history * added kline support to hitbtc huobi lbank * added exchangehistory to all supported exchanges started work on coinbase 300 candles/request method * end of day WIP * removed unused ta and misc changes to flag ready for review * yobit cleanup * revert coinbase changES * general code clean up and added zb support * poloniex support added * renamed method to FormatExchangeKlineInterval other misc fixes * linter fixes * linter fixes * removed verbose * fixed poloniex test coverage * revert poloniex mock data * regenerated poloniex mock data * a very verbose clean up * binance mock clean up * removed unneeded t.Log() * setting verbose to true to debug CI issue * first pass changes addressed * common.ErrNotYetImplemented implemented :D * comments added * WIP-addressed exchange requests and reverted previous GetExchangeHistory changes * WIP-addressed exchange requests and reverted previous GetExchangeHistory changes * increased test coverage added kraken support * OKGroup support completed started work on address GetExchangeHistory feedback and migrating to own PR under https://github.com/xtda/gocryptotrader/tree/exchange_history * convert zb ratelimits * gofmt run on okcoin * increased delay on rate limit * gofmt package * fixed panic with coinbene and bithumb if conversion fails * very broken end of day WIP * added support for GetHistoricCandlesEx to coinbase and binance * gofmt package * coinbase, btcmarkets, zb ex wrapper function added * added all exchange support for ex regenerated mock data * update bithumb to return wrapper method * gofmt package * end of day started work on changes * models created for exchange/asset/currency/currencypair, new seed system created * reworked test coverage added okgroup support general fixes/change requests addressed * Added OneMonth * limit checks on supportedexchanges * reverted getexchangehistory * started work on currency seeding and insertion * reworked binance tesT * added workaround for kraken panic * :D extremely broken WIP * renamed command to extended removed interval check on non-implemented commands * added wrapperconfig back * increased test coverage for FormatExchangeKlineInterval * WIP * increased test coverage for FormatExchangeKlineInterval bitfinex/gateio/huobi * linter fixes * zb kraken lbank coinbene btcmarkets support added * removed verbose * OK group support for other asset types added * swapped margin to use spot endpoint * index support added test coverage added for asset types * added asset type to okcoin test * gofmt * add asset to extended method * removed verbose * Very broken WIP models need to be regenerated * add support for coinbene swap increase test coverage * removed verbose * small clean up of okgroup wrapper functions * verbose to troubleshoot CI issues * removed verbose * added error check reverted coinbasechanges * attempting to fix broken model generation * readme updated * :D i broke so much * model regeneration fixed & complete * candle model filled out * removed unused start/finish started work on decoupling api requests from kline package * restructured coinbene, bithumb methods, added bitstamp support * kraken time fix * BTCMarkets restructure * typo fix * removed test for futures due to contact changing * removed test for futures due to contact changing * added start/end date to extended method over range * WIP * added sync option to candles * converted to assettranslator * removed verbose * removed verbose * removed invalid char * reverted incorrectly removed return * added import * further template updates * macos hates my keyboard :D * misc canges * started work on creating kline from databases eed * x -> i * removed verbose * updated fixCasing to allocate var before checks * sqlite3 supported work started * removed time conversion * further work on tets * sort all outgoing kline candles * fixCasing fix * after/before checks added * added parallel to test * logic check on BTCmarkets * removed unused param, used correct iterator * converted HitBTC to use time.Time * test update * add iszero false check to candle times * Seed exchange & OHCLV data for test usage * updated resultlimit to 5000 * new line added * added comment to exported const * move date forward * use configured ratelimit * fixed pair for test * panic fixed WIP on fixCasing * fixCasing rework, started work on readme docs * enable rate limiter for wrapper issues tool * docs updated * removed unused vars from tests * removed err from return and formatted currency * updated Yobit supported status * Updated HitBTC to use onehour candles due to test exeuction times * added further details to gctcli output * added link to docs * added link to tempalte * disable FTX websocket in config_example * fix poloneix * regenerated poloniex mock data * removed recording flag * format on package * moved exchange var outside of method scope * reworked seeding into package * verbose output improved * removed verbose from candles * Added comments to exported functions * removed verbose output * Reworking of tests * end of day commit * added SQLite migration for asset, test updates for exchange, added support for withdrawal for new exchange_name_id relation * regenerated database models * WIP * test rework, sqlite migration updates for withdrawal * Reworked error returns to stop duplications, format all output to UTC, changed gctscript OHLCV output to be unix timestmap, started work on seeding tool * gofmt * dbseed command for seeding exchanges added, removed seed from dbmigrate, LoadCSV method added for exchange * go mod tidy * added import candle from csv command to dbseed * Removed reset & duplicate migrate command from helper, renamed struct to Item/Candle over Candle/Tick, added test coverage to dbseed, improved withdraw tests * remove broken tests due to ORM generation of Fk, removed go unneeded goroutine for inserting records * removed t.Cleanup usage because appveyor * added test coverage to StoreInDatabase() * removed unneeded data from config for test * added new line * Added down migration support to candle/asset removal, return original error and display rollback error * removed unneeded err assignment, break out of loop on error * add err check to method for test * first pass changes * WIP * Updated migrations for both sqlite3 & postgres to create exchanges if any withdrawal_history records are found, removed migrate command * removed argusage as usage information is provided by flags * added inserted records return count and test coverage * new line added * Database: comment config details out to disable local postgresl testing by default * added asset support * Database: added error return when no exchanges are found, title exchange name across queries * Fixed test data * Database: removed migration bool from ConnectToDatabase(), removed empty line, insert asset on test * Database: verbose linter :D * Database/OHLCV: removed go module from dbseed command and reverted back to main module, converted interval to int64 to match other parts of code base, provided migrations to update database, poloniex fix to skip first candle * dbseed: add completed message to output * Database: added migration to add asset to uniq index for candle table * Database: database -> exchange * Database: add asset to upsert conflict * Poloneix: fix for invalid interval * regenerated poloniex mock data * Database: added down migration for candle interval update * OHCLV/Database: WIP * OHLCV/Datastore: added new ValidateKline() method to check that asset, pair, interval are enabled/supported by exchange and updated tests * revert configtest changes * OHCLV/Kline: pointer assignment to ErrorKline & format pairs on check * goimports * migration updates * Database/Candle: updated tests * revert configtest changes * ZB: updaed defaults to use uppercase pairs * ZB: updaed defaults to use uppercase pairs * revert pair formatting * Switch over to .Cotains() method from pairManagement * Added comment & ftx back 😆 * OHLCV/Datastore: (Candles): added not null to asset, (WithdrawalHistory): added not null to exchange_name_id), reworked KlineError return * set verbose to false * updated btc markets test * Updated readme * removed ability to have blank exchange name as indexing requires it * remove old usedb and empty exchange check, return error on no data instead * Updated kline test to match date range * Renamed candles.exchange_id column to candles.xchange_name_id to match withdrawal table, return err on unwrap, zb fix revert * regenerated sqlite3 models * force UTC for sqlite.... because sqlite * OHLCV/Datastore: upper case pairs on insert for consistency, remove unneeded rollback call on commit failure as it has no effect, move rollback outside of insertsqlite/insertpsql methods * add error check for no candles * nil length/cap is 0 in golang :D * OHLCV/Datastore: updated wording on examples, removed duplicate testfile * OHLCV/Datastore: updated README with links to dbseed * dbtool -> dbseed
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
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