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

problem creating new orders: error in filters #31

Open
pietervandessel opened this issue Feb 18, 2023 · 3 comments
Open

problem creating new orders: error in filters #31

pietervandessel opened this issue Feb 18, 2023 · 3 comments

Comments

@pietervandessel
Copy link

Hi,
I get the following error when creating a new order (e.g.: binance_new_order("XRPUSDT", side = "BUY", type = "LIMIT", price=0.32, quantity = 60, time_in_force = "GTC", test=F):

"Error in if (filters[filterType == "PERCENT_PRICE", avgPriceMins] == 0) { :
argument is of length zero"

If I run: filters <- binance_filters("XRPUSDT"), I can see that filterType has the value PERCENT_PRICE_BY_SIDE but not PERCENT_PRICE

@r-heller
Copy link

r-heller commented Mar 18, 2023

Hi,

Thank you for the great package.

I received the same error - binance changed the "PERCENT_PRICE" filter into "PERCENT_PRICE_BY SIDE". Rerun the formula by replacing the term turned into the following error:

"Error in [.data.table(filters, filterType == "PERCENT_PRICE_BY_SIDE", :
j (the 2nd argument inside [...]) is a single symbol but column name 'multiplierDown' is not found. Perhaps you intended DT[, ..multiplierDown]. This difference to data.frame is deliberate and explained in FAQ 1.1."

Most probably this is due to the second change in the API:
multiplierUp was divided into: bidMultiplierUp, askMultiplierUp, and
multiplierDown was divided into: bidMultiplierDown, askMultiplierDown

Interestingly, manual change of the formula with respect to the changes above did not affect the error mentioned by @pietervandessel.

Even removing manually all "stopifnot" statements and testing a BUY LIMIT path did not affect the result:

"Error in if (filters[filterType == "PERCENT_PRICE", avgPriceMins] == 0) { :
argument is of length zero"

It seems like another part of the package is pointing at the filterType == "PERCENT_PRICE".

Test-changes to the formula are given below:

"f_binance_new_order <- function (symbol
, side = c("BUY", "SELL")
, type = c("LIMIT", "MARKET", "STOP_LOSS", "STOP_LOSS_LIMIT", "TAKE_PROFIT", "TAKE_PROFIT_LIMIT", "LIMIT_MAKER")
, time_in_force = c("GTC", "IOC", "FOK")
, quantity
, price
, stop_price
, iceberg_qty
, test = TRUE)
{
filterType <- minQty <- maxQty <- stepSize <- applyToMarket <- avgPriceMins <- limit <- NULL
minNotional <- minPrice <- maxPrice <- tickSize <- bidMultiplierDown <- bidMultiplierUp <- askMultiplierDown <- askMultiplierUp <- NULL
side <- match.arg(side)
type <- match.arg(type)

params <- list(symbol = symbol, side = side, type = type, quantity = quantity, price = price)

if (isTRUE(test)) {
message("TEST")
ord <- binance_query(endpoint = "api/v3/order/test", method = "POST", params = params, sign = TRUE)
if (is.list(ord) & length(ord) == 0) {
ord <- "OK"
}
}
else {
ord <- binance_query(endpoint = "api/v3/order", method = "POST", params = params, sign = TRUE)
ord$fills <- NULL
ord <- as.data.table(ord)
for (v in c("price", "origQty", "executedQty", "cummulativeQuoteQty")) {
ord[, :=((v), as.numeric(get(v)))]
}
for (v in c("transactTime")) {
ord[, :=((v), as.POSIXct(get(v)/1000, origin = "1970-01-01"))]
}
setnames(ord, to_snake_case(names(ord)))
}
data.table(ord)
}

environment(f_binance_new_order) <- asNamespace('binancer')
assignInNamespace("binance_new_order", f_binance_new_order, ns = "binancer")"

@daroczig Any idea on how to fix this issue otherwise? Thank you very much in advance!

@daroczig
Copy link
Owner

I've just saw @stanyip's PR at #32 that might fix the above -- can you folks pls check and report back?

@r-heller
Copy link

Thank you! Problem solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants