Skip to content

Commit

Permalink
Merge pull request #17 from linkpoolio/feature/result-key
Browse files Browse the repository at this point in the history
Return a `result` key for Fluxmonitor support
  • Loading branch information
jleeh authored Apr 26, 2020
2 parents 6e26297 + 0c95118 commit 9102b1b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 126 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build
on: [push, pull_request]

jobs:
test:
name: Test
runs-on: ubuntu-latest
container:
image: golang:1.13.8
steps:
- uses: actions/checkout@master
- run: go get
- run: go test ./... -coverprofile=coverage.txt
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Asset Price External Adaptor ![Travis-CI](https://travis-ci.org/linkpoolio/asset-price-cl-ea.svg?branch=master) [![codecov](https://codecov.io/gh/linkpoolio/asset-price-cl-ea/branch/master/graph/badge.svg)](https://codecov.io/gh/linkpoolio/asset-price-cl-ea)
# Asset Price External Adaptor ![Build](https://github.com/linkpoolio/asset-price-cl-ea/workflows/Build/badge.svg) [![codecov](https://codecov.io/gh/linkpoolio/asset-price-cl-ea/branch/master/graph/badge.svg)](https://codecov.io/gh/linkpoolio/asset-price-cl-ea)
External Adaptor for Chainlink which aggregates prices of crypto assets from multiple exchanges based on a weighted average of their volume.

This adaptor is built using the bridges framework: https://github.com/linkpoolio/bridges
Expand All @@ -7,11 +7,10 @@ This adaptor is built using the bridges framework: https://github.com/linkpoolio

- Binance
- Bitfinex
- Bitstamp (Highly rate limited)
- Bitstamp (highly rate limited)
- Bittrex
- Coinall
- Coinbase Pro
- COSS
- HitBTC
- Huobi Pro
- Kraken
Expand Down Expand Up @@ -87,6 +86,7 @@ Should return something similar to:
"base": "BTC",
"quote": "USD",
"id": "BTC-USD",
"result": 3836.4042305857843,
"price": "3836.4042305857843",
"volume": "131747894.87525243",
"usdPrice": "3836.4042305857843",
Expand Down Expand Up @@ -115,6 +115,7 @@ curl -X POST -H 'Content-Type: application/json' -d '{ "jobRunId": "1234", "data
"base": "LINK",
"quote": "ETH",
"id": "LINK-ETH",
"result": 0.0031786459052877327,
"price": "0.0031786459052877327",
"volume": "797.6642187877999",
"usdPrice": "0.43956635389465454",
Expand Down
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type Output struct {
ID string `json:"id"`
Result float64 `json:"result"`
Price string `json:"price"`
Volume string `json:"volume"`
USDPrice null.String `json:"usdPrice"`
Expand All @@ -34,6 +35,7 @@ func GetPrice(base, quote string) (*Output, error) {
}

p, v := aggregateResponses(responses)
output.Result = p
output.Price = formatFloat(p)
output.Volume = formatFloat(v)

Expand Down
8 changes: 3 additions & 5 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
"time"
)

var c *Config

func init() {
c = NewConfig()
StartPairsTicker(c)
StartPairsTicker(&Config{TickerInterval: time.Minute})
}

func TestBTCUSD(t *testing.T) {
Expand All @@ -37,7 +35,7 @@ func TestETHEUR(t *testing.T) {
assert.True(t, r.Price != "0", "price returned from API is 0")
assert.True(t, r.Volume != "0", "volume returned from API is 0")
assert.True(t, len(r.Exchanges) > 1, "exchanges returned from API is less than 2")
assert.Equal(t, r.USDPrice.String, "", "usd price returned from API is 0")
assert.True(t, r.USDPrice.String != "0", "usd price returned from API is 0")
assert.Equal(t, r.ID, "ETH-EUR", "id of trading pair isn't correct")
}

Expand Down
73 changes: 0 additions & 73 deletions app/exchange/coss.go

This file was deleted.

26 changes: 0 additions & 26 deletions app/exchange/coss_test.go

This file was deleted.

1 change: 0 additions & 1 deletion app/exchange/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var (
//&Bitstamp{}, (Extreme rate limit)
&Bittrex{},
&Coinall{},
&COSS{},
&Coinbase{},
&Gemini{},
&Huobi{},
Expand Down
20 changes: 2 additions & 18 deletions app/go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/aws/aws-lambda-go v1.10.0/go.mod h1:zUsUQhAUjYzR8AuduJPCfhBuKWUaDbQiPOG+ouzmE1A=
github.com/aws/aws-lambda-go v1.13.2 h1:8lYuRVn6rESoUNZXdbCmtGB4bBk4vcVYojiHjE4mMrM=
github.com/aws/aws-lambda-go v1.13.2/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/beldur/kraken-go-api-client v0.0.0-20190315074429-1bcd7922cada/go.mod h1:NtR1i+x0BHgyscUkgG1FlAokpIxNDKgLO3301OLxWt0=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5/go.mod h1:0YZ2wQSuwviXXXGUiK6zXzskyBLAbLXhamxzcFHSLoM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/linkpoolio/asset-price-cl-ea v0.5.1 h1:Xjf9a2jdG2p+e3emwMbYC6Bsmv/umTTJlvxSv0ytrXk=
github.com/linkpoolio/asset-price-cl-ea v0.5.1/go.mod h1:ucF3qfss8mtguPR/VXHYnmTIdQbLSI4T+cgU1i1Y6Pk=
github.com/linkpoolio/bridges v0.0.0-20190531150643-66a80e9d4bdd/go.mod h1:B5Z/PmGOb1EDqm81hkXp3C2FV7G2VGmh5/CwWE4jsGM=
github.com/linkpoolio/bridges v0.0.0-20191025104425-88bd7b263478 h1:q1OaqixLPBagppubJelUeMSJfuV0W/qXUPYGtkzpRfg=
github.com/linkpoolio/bridges v0.0.0-20191025104425-88bd7b263478/go.mod h1:DInZAD65BIbStcCB8bvXqCeG2qJ1YXsdEsX7RdtSvkE=
github.com/montanaflynn/stats v0.5.0/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
Expand All @@ -22,34 +17,23 @@ github.com/preichenberger/go-gdax v0.0.0-20171211025541-77508b321c97 h1:nKHQTmdb
github.com/preichenberger/go-gdax v0.0.0-20171211025541-77508b321c97/go.mod h1:couLd4kMp3zNIXEnhqnIcRB4+1WC0/fo/Ytn2w/Fzag=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/tidwall/gjson v1.2.1/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA=
github.com/tidwall/gjson v1.3.2 h1:+7p3qQFaH3fOMXAJSrdZwGKcOO/lYdGS0HqGhPqDdTI=
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
github.com/tidwall/pretty v0.0.0-20190325153808-1166b9ac2b65/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/utahta/go-openuri v0.1.0/go.mod h1:wg5kOkfgUWHGFacyyH+FsrEzB++WPpFyKrwDSeo69Ng=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190415154727-2b5498619ef1/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/guregu/null.v3 v3.4.0 h1:AOpMtZ85uElRhQjEDsFx21BkXqFPwA7uoJukd4KErIs=
gopkg.in/guregu/null.v3 v3.4.0/go.mod h1:E4tX2Qe3h7QdL+uZ3a0vqvYwKQsRSQKM5V4YltdgH9Y=
Expand Down

0 comments on commit 9102b1b

Please sign in to comment.