Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LBank exchange support #327

Merged
merged 26 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
const (
// Default number of enabled exchanges. Modify this whenever an exchange is
// added or removed
defaultEnabledExchanges = 27
defaultEnabledExchanges = 28
)

func TestGetCurrencyConfig(t *testing.T) {
Expand Down Expand Up @@ -479,7 +479,7 @@ func TestCountEnabledExchanges(t *testing.T) {
}
enabledExch := GetConfigEnabledExchanges.CountEnabledExchanges()
if enabledExch != defaultEnabledExchanges {
t.Error("Test failed. GetConfigEnabledExchanges is wrong")
t.Errorf("Test failed. Expected %v, Received %v", defaultEnabledExchanges, enabledExch)
}
}

Expand Down
42 changes: 42 additions & 0 deletions config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,48 @@
}
]
},
{
"name": "LBank",
"enabled": true,
"verbose": false,
"websocket": false,
"useSandbox": false,
"restPollingDelay": 10,
"httpTimeout": 15000000000,
"httpUserAgent": "",
"httpDebugging": false,
"authenticatedApiSupport": false,
"apiKey": "Key",
"apiSecret": "Secret",
"apiUrl": "NON_DEFAULT_HTTP_LINK_TO_EXCHANGE_API",
"apiUrlSecondary": "NON_DEFAULT_HTTP_LINK_TO_EXCHANGE_API",
"proxyAddress": "",
"websocketUrl": "NON_DEFAULT_HTTP_LINK_TO_WEBSOCKET_EXCHANGE_API",
"availablePairs": "fbc_usdt,hds_usdt,galt_usdt,dxn_usdt,iog_usdt,ioex_usdt,vollar_usdt,oath_usdt,bloc_usdt,btc_lbcn,eth_lbcn,usdt_lbcn,btc_usdt,eth_usdt,eth_btc,abbc_btc,bzky_eth,onot_eth,kisc_eth,bxa_usdt,atp_usdt,mat_usdt,sky_btc,sky_lbcn,rnt_usdt,vena_usdt,grin_usdt,ida_usdt,pnt_usdt,bsv_btc,bsv_usdt,opx_usdt,tena_eth,seer_lbcn,vet_lbcn,vtho_btc,vnx_lbcn,vnx_btc,amo_eth,ubex_btc,eos_btc,ubex_usdt,tns_lbcn,tns_btc,ali_eth,sdc_eth,sait_eth,artcn_usdt,dax_btc,dax_eth,dali_usdt,vet_usdt,ten_usdt,bch_usdt,neo_usdt,qtum_usdt,zec_usdt,vet_btc,pai_btc,pnt_btc,bch_btc,ltc_btc,neo_btc,dash_btc,etc_btc,qtum_btc,zec_btc,sc_btc,bts_btc,cpx_btc,xwc_btc,fil6_btc,fil12_btc,fil36_btc,eos_usdt,ut_eth,ela_eth,vet_eth,vtho_eth,pai_eth,bfdt_eth,her_eth,ptt_eth,tac_eth,idhub_eth,ssc_eth,skm_eth,iic_eth,ply_eth,ext_eth,eos_eth,yoyow_eth,trx_eth,qtum_eth,zec_eth,bts_eth,btm_eth,mith_eth,nas_eth,man_eth,dbc_eth,bto_eth,ddd_eth,cpx_eth,cs_eth,iht_eth,tky_eth,ocn_eth,dct_eth,zpt_eth,eko_eth,mda_eth,pst_eth,xwc_eth,put_eth,pnt_eth,aac_eth,fil6_eth,fil12_eth,fil36_eth,uip_eth,seer_eth,bsb_eth,cdc_eth,grams_eth,ddmx_eth,eai_eth,inc_eth,bnb_usdt,ht_usdt,bot_eth,kbc_btc,kbc_usdt,mai_usdt,phv_usdt,hnb_usdt,gt_usdt,b91_usdt,voken_usdt,cye_usdt,brc_usdt,btc_ausd",
"enabledPairs": "btc_usdt",
"baseCurrencies": "USD",
"assetTypes": "SPOT",
"supportsAutoPairUpdates": true,
"configCurrencyPairFormat": {
"uppercase": false,
"delimiter": "_"
},
"requestCurrencyPairFormat": {
"uppercase": false,
"delimiter": "_"
},
"bankAccounts": [
{
"bankName": "",
"bankAddress": "",
"accountName": "",
"accountNumber": "",
"swiftCode": "",
"iban": "",
"supportedCurrencies": ""
}
]
},
{
"name": "LocalBitcoins",
"enabled": true,
Expand Down
3 changes: 3 additions & 0 deletions exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/itbit"
"github.com/thrasher-corp/gocryptotrader/exchanges/kraken"
"github.com/thrasher-corp/gocryptotrader/exchanges/lakebtc"
"github.com/thrasher-corp/gocryptotrader/exchanges/lbank"
"github.com/thrasher-corp/gocryptotrader/exchanges/localbitcoins"
"github.com/thrasher-corp/gocryptotrader/exchanges/okcoin"
"github.com/thrasher-corp/gocryptotrader/exchanges/okex"
Expand Down Expand Up @@ -173,6 +174,8 @@ func LoadExchange(name string, useWG bool, wg *sync.WaitGroup) error {
exch = new(kraken.Kraken)
case "lakebtc":
exch = new(lakebtc.LakeBTC)
case "lbank":
exch = new(lbank.Lbank)
case "localbitcoins":
exch = new(localbitcoins.LocalBitcoins)
case "okcoin international":
Expand Down
13 changes: 13 additions & 0 deletions exchanges/anx/anx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,16 @@ func TestGetDepositAddress(t *testing.T) {
}
}
}

func TestUpdateOrderbook(t *testing.T) {
shazbert marked this conversation as resolved.
Show resolved Hide resolved
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every exported function in a program should have a doc comment. The first sentence should be a summary that starts with the name (TestUpdateOrderbook) being declared.
From effective go.

a.SetDefaults()
q := currency.Pair{
Delimiter: "_",
Base: currency.BTC,
Quote: currency.USD}

_, err := a.UpdateOrderbook(q, "spot")
if err != nil {
t.Fatalf("Update for orderbook failed: %v", err)
}
}
7 changes: 3 additions & 4 deletions exchanges/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ func (e *Base) UpdateCurrencies(exchangeProducts currency.Pairs, enabled, force
log.Debugf("%s Updating pairs - Removed: %s.\n", e.Name, removedPairs)
}
}

if enabled {
exch.EnabledPairs = products
e.EnabledPairs = products
Expand Down Expand Up @@ -829,7 +828,7 @@ type Format struct {
OrderSide map[string]string
}

// CancelAllOrdersResponse returns the status from attempting to cancel all orders on an exchagne
// CancelAllOrdersResponse returns the status from attempting to cancel all orders on an exchange
type CancelAllOrdersResponse struct {
OrderStatus map[string]string
}
Expand All @@ -853,7 +852,7 @@ const (

// ToString changes the ordertype to the exchange standard and returns a string
func (o OrderType) ToString() string {
return fmt.Sprintf("%v", o)
return string(o)
}

// OrderSide enforces a standard for OrderSides across the code base
Expand All @@ -870,7 +869,7 @@ const (

// ToString changes the ordertype to the exchange standard and returns a string
func (o OrderSide) ToString() string {
return fmt.Sprintf("%v", o)
return string(o)
}

// SetAPIURL sets configuration API URL for an exchange
Expand Down
32 changes: 32 additions & 0 deletions exchanges/lbank/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

# GoCryptoTrader Lbank Exchange Wrapper

<img src="https://github.com/thrasher-corp/gocryptotrader/blob/master/web/src/assets/page-logo.png?raw=true" width="350px" height="350px" hspace="70">

An exchange interface wrapper for the GoCryptoTrader application.

## This is still in active development

You can track ideas, planned features and what's in progresss on this Trello board: [https://trello.com/b/ZAhMhpOy/gocryptotrader](https://trello.com/b/ZAhMhpOy/gocryptotrader).

## Current Lbank Exchange Features

+ REST Support
+ Websocket Support is currently not supported

+ Can be used as a package

## Notes

+ Please add notes here with any production issues
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add notes here with any production issues

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example; Websocket implementation not completed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

+ Please provide link to exchange website and API documentation
MadCozBadd marked this conversation as resolved.
Show resolved Hide resolved

https://github.com/LBank-exchange/lbank-official-api-docs/tree/master/API-For-Spot-EN

## Contributors

+ Please add your information
MadCozBadd marked this conversation as resolved.
Show resolved Hide resolved

|Name|Github|Contribution|
|--|--|--|
|MadCozBadd|https://github.com/madcozbadd |Initial REST and Wrapper Implementation|
Loading