-
Notifications
You must be signed in to change notification settings - Fork 820
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
exchanges: Update Poloniex exchange API #1351
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. just skimmed across changes and found some basic things. Nice work!
exchanges/mock/common.go
Outdated
if err != nil { | ||
return vals, err | ||
if strings.EqualFold(err.Error(), "json: cannot unmarshal array into Go value of type map[string]interface {}") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please have a valid test case for this?
exchanges/mock/common.go
Outdated
intermediary := make(map[string]interface{}) | ||
err := json.Unmarshal(payload, &intermediary) | ||
intermediary := make([]map[string]interface{}, 1, 5) | ||
intermediary[0] = make(map[string]interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be allocated with the json call so can RM this.
@@ -181,12 +181,14 @@ func HTTPRecord(res *http.Response, service string, respContents []byte) error { | |||
if jErr != nil { | |||
return jErr | |||
} | |||
|
|||
if MatchURLVals(reqVals, mockVals) { | |||
found = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please have a test case for this?
|
||
// MatchBatchAndGetResponse matches a batch of incoming request values with mockdata response | ||
// values and returns the payload | ||
func MatchBatchAndGetResponse(mockData []HTTPResponse, requestVals []url.Values) (json.RawMessage, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs tests
exchanges/poloniex/poloniex.go
Outdated
var resp []SymbolDetail | ||
path := "/markets" | ||
if !symbol.IsEmpty() { | ||
path = fmt.Sprintf("%s/%s", path, symbol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use concatenation instead of fmt.Sprintf across this PR.
sort.Sort(trade.ByDate(resp)) | ||
return resp, nil | ||
} | ||
|
||
// -------------------------------------------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
} | ||
return s.DeriveSubmitResponse(sOrder.ID) | ||
} | ||
var response *PlaceOrderResponse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be shifted above smart order and used in all requests.
} | ||
return nil, err | ||
smartOrder = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just do a length check on smartOrders
QuoteAmount: resp.Amount.Float64(), | ||
ExecutedAmount: resp.FilledQuantity.Float64(), | ||
RemainingAmount: resp.Quantity.Float64() - resp.FilledAmount.Float64(), | ||
Cost: resp.Quantity.Float64() * resp.AvgPrice.Float64(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resp.Quantity.Float64()
-> resp.FilledQuantity.Float64()
maybe there is a partial fill?
exchanges/request/request.go
Outdated
@@ -237,6 +237,7 @@ func (r *Requester) doRequest(ctx context.Context, endpoint EndpointLimit, newRe | |||
if err != nil { | |||
return err | |||
} | |||
println(string(contents)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👁️
…r functions, and types
…dling for v3 websocket connections
PR Description
This pull request included a Poloniex exchange code implementation with REST and WebSocket capabilities. The Wrapper and Web-socket functions have all undergone testing. My code conforms to the GCT style standards used by other exchanges.
golangci-lint was used to fix a few mistakes. For future use, endpoint methods that the GCT wrapper does not support are also implemented.
The PR included implementations for REST for trading and other endpoint methods, Web-socket streaming, and Trading through the web socket stream.
Fixes # (issue)
Type of change
Please delete options that are not relevant and add an
x
in[]
as the item is complete.How has this been tested
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.
Checklist