Commit Graph

953 Commits

Author SHA1 Message Date
Ryan O'Hara-Reid
35b94268e0 Update request.go to fix concurrency nonce issues (#285)
* Updates nonce generation to adhere to fifo channel buffer before request executes by routine

* removed unused variables, lns etc

* Fix requested changes and added in timer that disengages lock if out of scope error occurs

* Fixed woopsy daisy issue

* Add benchmark, reduce time in force to unlock before stack insertion, add nil check for edge case

* Remove unusued waitgroup field

* use return nonce.Value and method, rm redundant nonce code, fix tests.

* Fix linter issue: unnecessary conversion
2019-05-06 13:46:34 +10:00
Vadim Zhuk
1967507d40 Fix bugs with unmarshaling on ZB and OKGroup (#290)
* Replace nonce increment with mutex to atomic incrementation
* Fix ZB order unmarshaling
* Fix CancelSpotOrderResponse unmarshaling on OKGroup
2019-05-03 20:38:14 +10:00
Adrian Gallagher
f19cf37752 Add AppVeyor support (#289)
Add AppVeyor support
2019-05-03 13:09:01 +10:00
Adrian Gallagher
5ea82f163a OKGroup: Fix unmarshalling issues after API update (#288) 2019-05-02 12:10:29 +10:00
Ryan O'Hara-Reid
6e2cba566f Add in routine that checks internet connectivity for bot services (#287)
* Add in routine that checks internet connectivity for bot services

* Packaged connection checker
2019-05-02 10:14:42 +10:00
Ryan O'Hara-Reid
2f1405ead4 Add OS X CI Matrix support to Travis (#284)
Add OS X CI Matrix support to Travis
2019-04-30 15:27:16 +10:00
Ryan O'Hara-Reid
88bc17a17f ZB: GetOrderbook out of range fix (#286)
ZB: GetOrderbook out of range fix
2019-04-29 17:27:03 +10:00
Adrian Gallagher
47152c87e3 Update CONTRIBUTORS and doc templates 2019-04-26 17:36:41 +10:00
Adrian Gallagher
9bdcc22ae1 Relax case sensitive string comparisons in various parts of GCT 2019-04-23 14:22:00 +10:00
Adrian Gallagher
32e4dcb63d Bitmex: Fix UpdateTicker/UpdateOrderbook wrappers
UpdateTicker: drop need for start timestamp as the latest entry will always be returned by default
UpdateOrderbook: fix string comparison so that orderbook entries will actually be appended

NOTE: As of this time, Bitmex doesn't support a ticker API endpoint so the only two options are a) last trade for an asset (which GCT uses) or b) orderbook data query
Fixes issue: https://github.com/thrasher-/gocryptotrader/issues/282
2019-04-23 11:02:30 +10:00
Vadim Zhuk
b02d03da8b Fix order issues on GateIo, Huobi, OkGroup and Poloniex (#280)
* fix balance responce

* Fixed OrderHistory unmarshalling on the GateIo

* fix int convertation in the GetOrderHistory function

* fix issue on order submit : Binance exchange raw response: {"code":-1102,"msg":"Mandatory parameter 'timeInForce' was not sent, was empty/null, or malformed."}

* Okgroup: fix issue on empty notional GetSpotOrderResponse

* Okgroup: fix issue with empty order status. order start is required for orderHistory request

* HUOBU: fix order currency mapping in GetActiveOrders method

* OKGroup: fix currency name on GetAccountInfo

* ZB: fixed wrong error code on order send method

* OKGroup: add missing fields to GetActiveOrders mapping

* huobi: add missing fields to GetActiveOrders/GetOrderHistory response mapping

* gateio: add order status field to GetActiveOrders response

* gateio: fix orderId on SubmitOrder response

* - poloniex: fix 422 on private API call
- poloniex: fix empty order history

* - poloniex: fix 422 on private API call (revert)

* GateIo: Fix unmarshalling issue

* Huobi: removing redundant breaks

* Huobi: fix rangeValCopy in GetActiveOrders/GetOrderHistory methods
2019-04-18 17:38:47 +10:00
Andrew Jackson
c449568f6d Fix incorrect variable usage (err -> errNTP) 2019-04-18 10:23:19 +10:00
Andrew
071f4f68a8 New NTP Client (#277)
* WIP

* Added check for time out of sync

* merged upstream/master

* added tests

* Increased configuration options for NTPclient and test coverage

* removed unneeded config save at end of ntp update

* Added test for empty response to confirm it will loop

* formatting correction

* converted to pointer to allow for default allowance settings to be checked

* added readme for NTP server

* corrected some formatting

* updated configtest negativedifference value

* gofmt config_test.go for correct import order

* corrected typo value in test

* bugfix for windows newline and changes based on PR feedback

* added minus sign to output

* fixed negative number input

* Fixed spelling mistakes and removed redundant test

* reverted back to a positive number in the config instead of negative for allowednegativedifference

* restructured code for cleaner output
2019-04-18 10:08:19 +10:00
Adam
400c1cc84d Improved test coverage and functions in common.go (#266)
Improved directory creation, including permissions and expanded test coverage
2019-04-17 17:33:40 +10:00
Vadim Zhuk
ca344bad51 ZB: Fix SendAuthenticatedHTTPRequest error code handling (#278)
* fix balance responce

* Fixed OrderHistory unmarshalling on the GateIo

* fix int convertation in the GetOrderHistory function

* fix issue on order submit : Binance exchange raw response: {"code":-1102,"msg":"Mandatory parameter 'timeInForce' was not sent, was empty/null, or malformed."}

* Okgroup: fix issue on empty notional GetSpotOrderResponse

* Okgroup: fix issue with empty order status. order start is required for orderHistory request

* HUOBU: fix order currency mapping in GetActiveOrders method

* OKGroup: fix currency name on GetAccountInfo

* ZB: fixed wrong error code on order send method
2019-04-17 09:25:06 +10:00
Harry Ma
6ebebf1b16 Fix the unsuitable definition of a function (#279) 2019-04-17 09:20:46 +10:00
Adrian Gallagher
388d160f2b BTSE: Fix JSONDecode error upon successful websocket connection
BTSE updated their websocket API to send a "connect success" message upon a successful connection
2019-04-15 14:53:38 +10:00
Adrian Gallagher
5a42a4162b Improve currency pair handling code
Fixes these happy little accidents:
1) Config: Actually use enabled pairs for config.GetEnabledPairs
2) Pair format: Handle edge case for pairs DASHKRW vs DSHKRW and improve testing
2019-04-15 14:49:46 +10:00
Scott
32b43387fd Kraken websocket orderbook buffer (#276)
* Adds a orderbook buffer to prevent out of order issues with WS orderbooks. Internalises latest orderbook for comparisons sake as getorderbookex is unreliable due to REST updates

* Adds a basic rate limiter for WS requests. Updates buffer to support multiple channels

* Uses earliest buffer 'lastupdate' to compate to existing orderbook's 'lastupdate' instead of last

* Adds WS test for buffer use

* Adds out of order test

* Fixes blocking bid updates, fixes issue where orderbook processing occured in wrong area, adds detailed verbose debugging, uses pointer for channelData use

* Updates test to adapt to buffer limits, reduces kraken buffer to 3

* Change websocket connection check in tests. Change error handling. Implement requestID in data responses for WS. Change test to prevent default subscriptions from preventing test execution with extra data. Updates orderbook tests to call correct functions to prevent resubscriptions. Removes resubscribe on subscription status failure

* Fixes linting issues

* Fixes error handling
2019-04-12 09:21:37 +10:00
Adrian Gallagher
7ac8854c43 Specifically set dist to xenial to avoid go linker build issue 2019-04-11 08:11:05 +10:00
Adam
d69713f59d Fix rangeValCopy linter issues (#275)
* first pass of linter fixes for range val

* fixed the remaining issues for pointers

* changed as requested
2019-04-10 17:04:32 +10:00
Scott
e56fc26d93 Offline worst case trade fees (#274)
* Really basic getSimulated fee function everywhere

* Worst case fees for all exchanges

* Adds tests, fixes comment spacing. Adds wrapper logic. Makes test api key var name consistent. Removes some okcoin ETT tests

* Removes redundant functions

* linting issues. Fixes introduces huobi issues

* More linting

* Stops trying to hide ETT problems, uses iota

* Skips ETT tests for now
2019-04-09 19:38:31 +10:00
Andrew
eeda97bbaf Binance websocket fixes for #271 & #270 (#272)
* Fixes bug reported in #271 switch statement

* Time conversion fix for timestamp

* remove debug statement

* reverted back to CurrDayClose
2019-04-07 05:41:47 +10:00
Adrian Gallagher
8251fdd6ae CoinbasePro: Fix websocket ticker inconsistency
Addresses issue: https://github.com/thrasher-/gocryptotrader/issues/270
2019-04-06 15:08:06 +11:00
Vadim Zhuk
3956613831 OKGroup: fix currency name on GetAccountInfo (#273)
OKGroup: fix currency name on GetAccountInfo
2019-04-06 11:42:07 +11:00
Andrew
6c8f8ff66b Fixes DNS rebinding vulnerability in router by explicitly passing Host parameter based off config listenaddress (#209) 2019-04-04 17:41:13 +11:00
Andrew
ca55f2f965 Optimisation: Large struct pointer conversion (final part) (#265)
Completes large struct pointer optomisations over the entire codebase and enables hugeParams linter by default
2019-04-04 15:31:49 +11:00
Scott
107cf76373 Kraken websocket support (#264)
* Initial commit. Adds ticker, candle and trade, subscription support

* Adds support for spread and orderbooks

* Adds new currency pair delimiter ("/"), Adds dedicated websocket Connected channel handler, Updates Kraken websocket capability definition, Refines websocket tests to connect and disconnect without freezing, separates WebsocketUnsubscribeEventRequest ChannelID into its own struct WebsocketUnsubscribeByChannelIDEventRequest to prevent bad json WS requests, Adds asset type to orderbook, Kraken WS handles connection better

* Removes duplicate type, reverts config value

* Addresses error returns and changes writeToWebsocket to use byte array. Removes deferred funcs in tests. Increases test listening limit for rare cases

* Fixes verbose log. Rearranges WS Connect async ordering. Fixes DATA RACE. Fixes random okex tests. Ensures Kraken WS tests only connect once
2019-04-04 10:21:44 +11:00
Andrew
a0e291097e Fix CoinbasePro websocket bug introduced in PR #262 (#269) 2019-04-04 10:19:48 +11:00
Vadim Zhuk
866efd069d Fix issues (#263)
OKGroup/Huobi: Fix order history/active orders issues
2019-03-28 13:06:42 +11:00
Adrian Gallagher
b048539f4c Expose GetFeeByType exchange wrapper 2019-03-27 16:13:05 +11:00
Adrian Gallagher
fbc9b0aa97 Bugfix: OKCoin/OKEX SetRealOrderDefaults 2019-03-26 16:53:38 +11:00
Vadim Zhuk
286436de76 Okgroup: fix empy notional (#261)
OKGroup: GetSpotOrderResponse fix empty notional
2019-03-26 16:42:01 +11:00
Andrew
dc236c251e Optimisation: large structs/huge param fixes (part 2) (#262)
* updated golangci config to enable hugeparam linter

* ModifyOrder struct usage converted to a pointer

* OrderBook conversion to struct

* More conversion of large structs to pointers

* updated golangci config to enable hugeparam linter

* ModifyOrder struct usage converted to a pointer

* OrderBook conversion to struct

* More conversion of large structs to pointers

* disabled hugeParam check for golang again

* changed based on suggested feedback and fix for no default provider

* fixed typing
2019-03-26 15:40:46 +11:00
Adrian Gallagher
5683fdd917 BTSE: Drop need to check for commas after REST update 2019-03-26 09:51:38 +11:00
Adrian Gallagher
5d891e70e9 Cleanup: rm/adjust non-needed println's/warnings 2019-03-26 09:50:22 +11:00
Ryan O'Hara-Reid
c49cf18677 OKEX websocket: Fix test race condition (#258) 2019-03-25 16:16:19 +11:00
Adrian Gallagher
052b5c2f28 bugfix: improve orderbook/ticker and currency logic 2019-03-23 17:36:17 +11:00
Vadim Zhuk
9c6c8f3341 Binance: fix issue on order submit (#259)
fix issue on order submit : Binance exchange raw response: {"code":-1102,"msg":"Mandatory parameter 'timeInForce' was not sent, was empty/null, or malformed."}
2019-03-23 16:56:01 +11:00
Andrew
76ac98830e optimisation: large structs/huge param fixes (#257)
* Updated SetAPIURL() & UpdateConfig() to use pointers

* Withdraw functions now take a pointer to withdrawrequest struct

* Fund Withdraw is now a pointer

* Moved GetFee functions to use a pointer due to large size of feebuilder struct

* OrderCancellation usage converted to pointer due to size of struct

* merged up upstream/master and changes made to OKgroup code

* GetOrdersRequest usage converted to a pointer

* okgroup pointer migration

* reverted golangci config back to master

* removed old anx benchmark typo
2019-03-21 16:36:06 +11:00
Vadim Zhuk
2cb2413131 GateIO: Fixed OrderHistory unmarshalling (#255)
* Fixed OrderHistory unmarshalling on the GateIo
2019-03-19 23:21:58 +11:00
Ryan O'Hara-Reid
0990f9d118 Currency package update (#247)
* Initial currency overhaul before service system implementation

* Remove redundant currency string in orderbook.Base
Unexport lastupdated field in orderbook.Base as it was being instantiated multiple times
Add error handling for process orderbook

*  Remove redundant currency string in ticker.Price
 Unexport lastupdated field in ticker.Price
 Add error handling for process ticker function and fix tests

* Phase Two Update

* Update translations to use map type - thankyou to kempeng for spotting this

* Change pair method name from Display -> Format for better readability

* Fixes misspelling and tests

* Implement requested changes from GloriousCode

* Remove reduntant function and streamlined return in currency_translation.go

* Revert pair method naming conventions

* Change currency naming conventions

* Changed code type to exported Item type with underlying string to reduce complexity

* Added interim orderbook process method to orderbook.Base type

* Changed feebuilder struct field to currency.Pair

* Adds fall over system for backup fx providers

* deprecate function and children and fix linter issue with btcmarkets

* Fixed requested changes

* Fix bug and move mtx for rates

* Fixed after rebase oopsies

* Fix linter issues

* Fixes race conditions in testing functions

* Final phase coinmarketcap update

* fix linter issues

* Implement requested changes

* Adds configuration variables to increase/decrease time durations between updating currency file and fetching new currency rates

* Add a collection of tests to improve codecov

* After rebase oopsy fixes for btse

* Fix requested changes

* fix after rebase oopsies and add more efficient comparison checks within currency pair

* Fix linter issues
2019-03-19 11:49:05 +11:00
Adrian Gallagher
ed760e184e OKEX/OKCoin fix unauthenticated endpoints 2019-03-18 16:04:46 +11:00
Scott
6a15ecc65c OKEX/OKCoin API combine via OKGroup (#252)
* Initial commit

* Successful authenticated request implementation.

* Removes data from okcoin, okex. Implements some account okgroup endpoints. Adds tests

* Finishes account API endpoint implementations.

* Implements and adds tests for the following okgroup v3 API endpoints: GetSpotTradingAccounts, GetSpotTradingAccountForCurrency, GetSpotBillDetailsForCurrency, PlaceSpotOrder, PlaceMultipleSpotOrders, CancelSpotOrder, CancelMultipleSpotOrders, GetSpotOrders, GetSpotOpenOrders, GetSpotOrder, GetSpotTransactionDetails, GetSpotTokenPairDetails, GetSpotOrderBook, GetSpotAllTokenPairsInformation, GetSpotAllTokenPairsInformationForCurrency, GetSpotFilledOrdersInformation, GetSpotMarketData

* Implements and adds tests for all margin api endpoints: GetMarginTradingAccounts, GetMarginTradingAccountsForCurrency, GetMarginBillDetails, GetMarginAccountSettings, GetMarginLoanHistory, OpenMarginLoan, RepayMarginLoan, PlaceMarginOrder, PlaceMultipleMarginOrders, CancelMarginOrder, CancelMultipleMarginOrders, GetMarginOrders, GetMarginOpenOrders, GetMarginOrder, GetMarginTransactionDetails. Simplifies some Spot endpoints combining ForCurrency funcs where possible

* Adds all 29 Futures endpoints with tests. Updates comments and naming conventions. Adds standard realordertest func. Adds ability to make public API requests. Adds test purpose comments

* Adds 29 endpoints for SWAP API support. Adds tests for each endpoint. Declares response variables in function declaration. Simplifies URL parameter formatting

* Adds all ETT endpoints with tests

* Creates OKCoin and OKEX struct types. Moves okgroup tests to okcoin and okex exchanges. Updates withdraw fee calculation. Updates exchange.go exchange declaration to point to new types. Streamlines wrapper tests. Begins websocket integration

* Rebase fixes

* Deletes okcoin_types.go, okcoin_wrapper.go, okex_types.go, okex_wrapper.go. Combines okex,okcoin wrappers in okgroup_wrapper.go. Removes boilerplate url.values with new request struct type parsing. Adds github.com/google/go-querystring to go modules. Replaces USDT with USD for OKCoin tests. Moves OKEX specific endpoints (futures, swap & ett) to okex.go. Fixes recieving receiving again

* Maps the wrapper

* Parses json into time.Time instead of string + conversion

* Renames websocket.SetEnabled to websocket.SetWsStatusAndConnection. Maps main spot websocket functions for okgroup. Adds some basic ws tests

* Updates websocket default URLS, adds checksum tests, removes setdefaults from okgroup, adds WebsocketDataWrapper to wrap all okgroup websocket data responses, handles spot, swap, index and futures ticker, candle, trade, orderbook, funding fee websocket responses. Partially implements checksum validation on orderbook data. Fixes all linting issues

* Handles the calculation of okgroup websocket checksums. Adds tests

* Now all orderbook checksums are validated. Cleans up implementations and removes invalid checksum calculator functions. Adds function to parse ordertype. Puts verbose logs behind verbose check

* Removes parallel from okgroup tests. Removes unused code. Adds GetWsChannelWithoutOrderType. Improves handling of WS data types. Adds types for more ws channels. Simplifies update orderbook handling

* updates btse func name

* linting

* Fixes websocket connection issue with tests. Removes test verbosity

* Updates checksum calculation to handle more than 7 decimal places. Adds rate limiters. Uses != "" instead of len > 0. Adds new test to handle checksum calculation with 8 decimal places.

* Removes logging. Fixes orderbook wrapper references

* Adds slightly more robust resubscribe func. Adds websocket tests that can detect websocket errors

* Fixes linting issues

* Adds new WS func IsConnected() to expose ws status. Tests protect against channel timeout

* Adds test comments. Fixes parallel issues for futures tests

* Fixes error output for wrapper function
2019-03-18 15:18:36 +11:00
Vadim Zhuk
b915edd278 GateIO: Account info - fix balance response (#254)
GateIO: Account info - fix balance response
2019-03-16 14:20:55 +11:00
Andrew
58bd0a301b Added config option to enable pprof (#253)
* Added config option to enable pprof

* fixed typo in Makefile
2019-03-14 14:56:30 +11:00
Adrian Gallagher
6cb356cd7a configs: periodic update of available pairs
NOTE: Yobit and Bitflyer dynamic support is enabled in the engine branch
2019-03-13 11:45:42 +11:00
Adrian Gallagher
3ac8b7746f Add REST and websocket support for BTSE (#250)
* Add REST and websocket support for BTSE exchange

TO-DO: Finish wrappers and expand test coverage

* Fill out wrapper funcs and expand test coverage
2019-03-08 16:33:10 +11:00
Adrian Gallagher
6d6b0ae067 gofmt exchanges/coinut.go 2019-03-02 02:22:13 -08:00
Adrian Gallagher
7dcb1ab553 Migrate from gometalinter.v2 to golangci-lint (#249)
* Migrate from gometalinter.v2 to golangci-lint
2019-03-01 16:10:29 +11:00