mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +00:00
exchanges: Remove FTX implementation and fix minor test issues (#1100)
* exchanges: Start removal of FTX * Get tests happy again * okx: improve logic and add basic coverage * Fix linterino * Round 2 plus rm useless assignment in test * Fix exchange_wrapper_issues test error * Fix nitters * Address nitters
This commit is contained in:
@@ -34,7 +34,6 @@ const (
|
||||
htmlScrape = "HTML String Check"
|
||||
pathBinance = "https://binance-docs.github.io/apidocs/spot/en/#change-log"
|
||||
pathOkCoin = "https://www.okcoin.com/docs/en/#change-change"
|
||||
pathFTX = "https://github.com/ftexchange/ftx"
|
||||
pathBTSE = "https://www.btse.com/apiexplorer/spot/#btse-spot-api"
|
||||
pathBitfinex = "https://docs.bitfinex.com/docs/changelog"
|
||||
pathBitmex = "https://www.bitmex.com/static/md/en-US/apiChangelog"
|
||||
@@ -463,8 +462,6 @@ func checkChangeLog(htmlData *HTMLScrapingData) (string, error) {
|
||||
dataStrings, err = htmlScrapeBinance(htmlData)
|
||||
case pathBTSE:
|
||||
dataStrings, err = htmlScrapeBTSE(htmlData)
|
||||
case pathFTX:
|
||||
dataStrings, err = htmlScrapeFTX(htmlData)
|
||||
case pathBitfinex:
|
||||
dataStrings, err = htmlScrapeBitfinex(htmlData)
|
||||
case pathBitmex:
|
||||
@@ -1596,95 +1593,6 @@ loop:
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// htmlScrapeFTX gets the check string for FTX exchange
|
||||
func htmlScrapeFTX(htmlData *HTMLScrapingData) ([]string, error) {
|
||||
temp, err := sendHTTPGetRequest(htmlData.Path, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer temp.Body.Close()
|
||||
a := temp.Body
|
||||
tokenizer := html.NewTokenizer(a)
|
||||
var respStr string
|
||||
loop:
|
||||
for {
|
||||
next := tokenizer.Next()
|
||||
switch next {
|
||||
case html.ErrorToken:
|
||||
break loop
|
||||
case html.StartTagToken:
|
||||
token := tokenizer.Token()
|
||||
if token.Data == htmlData.TokenData {
|
||||
for _, a := range token.Attr {
|
||||
if a.Key == htmlData.Key && a.Val == htmlData.Val {
|
||||
loop2:
|
||||
for {
|
||||
anotherToken := tokenizer.Next()
|
||||
switch anotherToken {
|
||||
case html.StartTagToken:
|
||||
z := tokenizer.Token()
|
||||
if z.Data == "a" {
|
||||
for _, m := range z.Attr {
|
||||
if m.Key == "title" {
|
||||
switch m.Val {
|
||||
case "rest":
|
||||
loop3:
|
||||
for {
|
||||
nextToken := tokenizer.Next()
|
||||
switch nextToken {
|
||||
case html.StartTagToken:
|
||||
f := tokenizer.Token()
|
||||
if f.Data == "time-ago" {
|
||||
for _, b := range f.Attr {
|
||||
if b.Key == "datetime" {
|
||||
respStr += b.Val
|
||||
}
|
||||
}
|
||||
}
|
||||
case html.EndTagToken:
|
||||
tk := tokenizer.Token()
|
||||
if tk.Data == htmlData.TokenDataEnd {
|
||||
break loop3
|
||||
}
|
||||
}
|
||||
}
|
||||
case "websocket":
|
||||
loop4:
|
||||
for {
|
||||
nextToken := tokenizer.Next()
|
||||
switch nextToken {
|
||||
case html.StartTagToken:
|
||||
f := tokenizer.Token()
|
||||
if f.Data == "time-ago" {
|
||||
for _, b := range f.Attr {
|
||||
if b.Key == "datetime" {
|
||||
respStr += b.Val
|
||||
}
|
||||
}
|
||||
}
|
||||
case html.EndTagToken:
|
||||
tk := tokenizer.Token()
|
||||
if tk.Data == htmlData.TokenDataEnd {
|
||||
break loop4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case html.ErrorToken:
|
||||
break loop2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return []string{respStr}, nil
|
||||
}
|
||||
|
||||
// htmlScrapeBitfinex gets the check string for Bitfinex exchange
|
||||
func htmlScrapeBitfinex(htmlData *HTMLScrapingData) ([]string, error) {
|
||||
temp, err := sendHTTPGetRequest(htmlData.Path, nil)
|
||||
|
||||
@@ -660,19 +660,6 @@ func TestTrelloDeleteCheckItems(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTMLScrapeFTX(t *testing.T) {
|
||||
data := HTMLScrapingData{
|
||||
TokenData: "span",
|
||||
Key: "class",
|
||||
Val: "css-truncate css-truncate-target d-block width-fit",
|
||||
TokenDataEnd: "svg",
|
||||
Path: "https://github.com/ftexchange/ftx"}
|
||||
a, err := htmlScrapeFTX(&data)
|
||||
if err != nil || len(a) != 1 {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTMLScrapeBinance(t *testing.T) {
|
||||
data := HTMLScrapingData{
|
||||
TokenData: "h1",
|
||||
|
||||
@@ -375,20 +375,6 @@
|
||||
}
|
||||
},
|
||||
"Disabled": false
|
||||
},
|
||||
{
|
||||
"Name": "FTX",
|
||||
"CheckType": "HTML String Check",
|
||||
"Data": {
|
||||
"HTMLData": {
|
||||
"Key": "class",
|
||||
"Val": "css-truncate css-truncate-target",
|
||||
"TokenDataEnd": "td",
|
||||
"CheckString": "65e8800b5c6800aad896f888b2a62afc-d29c4f140f6ca068db9970054076ba63e51a9e96bf56d570e62cdb573c86b18526296117-1c388b9ec24e52ca4537240db3f48025ec9fca7a",
|
||||
"Path": "https://github.com/ftexchange/ftx"
|
||||
}
|
||||
},
|
||||
"Disabled": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -375,20 +375,6 @@
|
||||
}
|
||||
},
|
||||
"Disabled": false
|
||||
},
|
||||
{
|
||||
"Name": "FTX",
|
||||
"CheckType": "HTML String Check",
|
||||
"Data": {
|
||||
"HTMLData": {
|
||||
"Key": "class",
|
||||
"Val": "css-truncate css-truncate-target",
|
||||
"TokenDataEnd": "td",
|
||||
"CheckString": "65e8800b5c6800aad896f888b2a62afc-d29c4f140f6ca068db9970054076ba63e51a9e96bf56d570e62cdb573c86b18526296117-1c388b9ec24e52ca4537240db3f48025ec9fca7a",
|
||||
"Path": "https://github.com/ftexchange/ftx"
|
||||
}
|
||||
},
|
||||
"Disabled": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -98,7 +98,6 @@ exchange
|
||||
An example of this is:
|
||||
```
|
||||
binance,
|
||||
ftx,
|
||||
btc markets,
|
||||
```
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ The following is a screenshot of the relationship between relevant data history
|
||||
| created | The date the job was created | `2020-01-01T13:33:37Z` |
|
||||
| conversion_interval | When converting data as a job, this determines the resulting interval | `86400000000000` |
|
||||
| overwrite_data | If data already exists, the setting allows you to overwrite it | `true` |
|
||||
| secondary_exchange_id | For a `secondaryvalidatecandles` job, the exchange id of the exchange to compare data to | `ftx` |
|
||||
| secondary_exchange_id | For a `secondaryvalidatecandles` job, the exchange id of the exchange to compare data to | `bybit` |
|
||||
| decimal_place_comparison | When validating API candles, this will round the data to the supplied decimal point to check for equality | `3` |
|
||||
| replace_on_issue | When there is an issue validating candles for a `validatecandles` job, the API data will overwrite the existing candle data | `false` |
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ _b in this context is an `IBotExchange` implemented struct_
|
||||
| CoinbasePro | Yes | Yes | No|
|
||||
| COINUT | Yes | Yes | No |
|
||||
| Exmo | Yes | NA | No |
|
||||
| FTX | Yes | Yes | Yes |
|
||||
| GateIO | Yes | Yes | No |
|
||||
| Gemini | Yes | Yes | Yes |
|
||||
| HitBTC | Yes | Yes | Yes |
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
{{define "exchanges ftx" -}}
|
||||
{{template "header" .}}
|
||||
## FTX Exchange
|
||||
|
||||
### Current Features
|
||||
|
||||
+ REST Support
|
||||
+ Websocket Support
|
||||
|
||||
### How to enable
|
||||
|
||||
+ [Enable via configuration](https://github.com/thrasher-corp/gocryptotrader/tree/master/config#enable-exchange-via-config-example)
|
||||
|
||||
+ Individual package example below:
|
||||
|
||||
```go
|
||||
// Exchanges will be abstracted out in further updates and examples will be
|
||||
// supplied then
|
||||
```
|
||||
|
||||
### How to do REST public/private calls
|
||||
|
||||
+ If enabled via "configuration".json file the exchange will be added to the
|
||||
IBotExchange array in the ```go var bot Bot``` and you will only be able to use
|
||||
the wrapper interface functions for accessing exchange data. View routines.go
|
||||
for an example of integration usage with GoCryptoTrader. Rudimentary example
|
||||
below:
|
||||
|
||||
main.go
|
||||
```go
|
||||
var f exchange.IBotExchange
|
||||
|
||||
for i := range bot.Exchanges {
|
||||
if bot.Exchanges[i].GetName() == "FTX" {
|
||||
f = bot.Exchanges[i]
|
||||
}
|
||||
}
|
||||
|
||||
// Public calls - wrapper functions
|
||||
|
||||
// Fetches current ticker information
|
||||
tick, err := f.FetchTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := f.FetchOrderbook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - wrapper functions - make sure your APIKEY and APISECRET are
|
||||
// set and AuthenticatedAPISupport is set to true
|
||||
|
||||
// Fetches current account information
|
||||
accountInfo, err := f.GetAccountInfo()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
+ If enabled via individually importing package, rudimentary example below:
|
||||
|
||||
```go
|
||||
// Public calls
|
||||
|
||||
// Fetches current ticker information
|
||||
ticker, err := f.GetTicker()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Fetches current orderbook information
|
||||
ob, err := f.GetOrderBook()
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Private calls - make sure your APIKEY and APISECRET are set and
|
||||
// AuthenticatedAPISupport is set to true
|
||||
|
||||
// GetUserInfo returns account info
|
||||
accountInfo, err := f.GetUserInfo(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
|
||||
// Submits an order and the exchange and returns its tradeID
|
||||
tradeID, err := f.Trade(...)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
```
|
||||
|
||||
### Please click GoDocs chevron above to view current GoDoc information for this package
|
||||
{{template "contributions"}}
|
||||
{{template "donations" .}}
|
||||
{{end}}
|
||||
@@ -34,7 +34,6 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
|
||||
| CoinbasePro | Yes | Yes | No|
|
||||
| COINUT | Yes | Yes | NA |
|
||||
| Exmo | Yes | NA | NA |
|
||||
| FTX | Yes | Yes | No |
|
||||
| GateIO | Yes | Yes | NA |
|
||||
| Gemini | Yes | Yes | No |
|
||||
| HitBTC | Yes | Yes | No |
|
||||
|
||||
@@ -12,7 +12,7 @@ func TestDisruptFormatting(t *testing.T) {
|
||||
t.Fatal("error cannot be nil")
|
||||
}
|
||||
|
||||
_, err = disruptFormatting(currency.Pair{Base: currency.BTC})
|
||||
_, err = disruptFormatting(currency.Pair{Quote: currency.BTC})
|
||||
if err == nil {
|
||||
t.Fatal("error cannot be nil")
|
||||
}
|
||||
|
||||
@@ -106,11 +106,6 @@
|
||||
"secret": "Secret",
|
||||
"otpSecret": "-"
|
||||
},
|
||||
"ftx": {
|
||||
"key": "Key",
|
||||
"secret": "Secret",
|
||||
"otpSecret": "-"
|
||||
},
|
||||
"gateio": {
|
||||
"key": "Key",
|
||||
"secret": "Secret",
|
||||
|
||||
Reference in New Issue
Block a user