Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Bittrex Exchange Hybrid Backfilling / Error handling / Products update #1221

Closed
wants to merge 16 commits into from
Closed

Bittrex Exchange Hybrid Backfilling / Error handling / Products update #1221

wants to merge 16 commits into from

Conversation

station384
Copy link
Contributor

@station384 station384 commented Jan 25, 2018

Address issue #1218 making URL request error a recoverable error.
Correct generation of bittrex products.json. min size is now taken into account.
Addresses Issues #499,#816, and my own personal annoyance with its inability to back-fill.

Back-filling is accomplished by using the candle api and the
marketHistory

Candle api
1 minute interval
max history of about 10 days
mapping to
size: total volume traded in 1 min
price: closing price for the 1 min period
side: forced as sell as there is no way to tell since this is a sum of
both buy and sells in the 1 minute period

marketHistory
is directly mapped but only has the last 100 trades

Back-filling is accomplished by using the candle api and the
marketHistory

Candle api
1 minute interval
max history of about 10 days
mapping to
size: total volume traded in 1 min
price: closing price for the 1 min period
side: forced as sell as there is no way to tell since this is a sum of
both buy and sells in the 1 minute period

marketHistory
is directly mapped but only has the last 100 trades
@station384
Copy link
Contributor Author

station384 commented Jan 25, 2018

This does accomplish the backfill, but it does save "imaginary" trades, each one of the imaginary ones is the sum of all the trades for 1m or what ever the gap is from the previous one.

All imaginary trades buy/sell is guessed.

I figure the buy/sell for this doesn't really matter for what were looking for here, what were really after is the price and the time of that price, and the volume traded so we can calculate velocity.

any calculations that take into the account number of past trades of buy/sell orders a may be incorrect.

@station384 station384 closed this Jan 25, 2018
@station384 station384 reopened this Jan 25, 2018
Bittrex retrieves all back data at once,
I figure if the price was higher then it was a buy.
but not sure, since were dealing with groups of trades in this part,
and not a single filled order.
if the close price is higher there should be been more buys so mark the
buySell as buy
@station384
Copy link
Contributor Author

Done poking at it.
Still unsure what to mark the buy/sell as on the long term back-fills, but i'm guessing using this logic.
If the price is higher than the last price, then there should have been more buys to push the closing price higher. therefore mark the trade as a buy.

The confusion comes from the perspective. looking at the marker trend this is the correct view. looking at as a trader, this is incorrect, because if the price is higher. I would have sold.

allows for correct calculation of minimums, and increments
as a recoverable error.
see issue #1218
@station384
Copy link
Contributor Author

Okay really done poking at it.

@station384 station384 changed the title Bittrex Hybrid Backfilling Bittrex Exchange Hybrid Backfilling / Error handling / Products update Jan 25, 2018
@station384
Copy link
Contributor Author

@DeviaVir, I'm Done with bittrex. on to getting hitbtc to work.

@XarImoR
Copy link

XarImoR commented Jan 26, 2018

The only error i'm getting now on bittrex is this:

/home/ubuntu/zenbot-watcher/extensions/exchanges/bittrex/exchange.js:233
market: joinProduct(opts.product_id)
^
TypeError: Cannot read property 'product_id' of undefined
at Object.getQuote (/home/ubuntu/zenbot-watcher/extensions/exchanges/bittrex/exchange.js:233:34)
at Timeout._onTimeout (/home/ubuntu/zenbot-watcher/extensions/exchanges/bittrex/exchange.js:42:24)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)

Any idea to solve this?
@station384:
By the way... really good job repairing Bittrex

Parameters :
./zenbot.sh trade bittrex.WINGS-ETH --strategy ta_macd ---buy_pct 10 --buy_max_amt 0.33 --order_type maker

(error with other coins as well -- ADT-ETH/DGB-ETH/STRAT-ETH/WAVES-ETH/SNT-ETH/FUN-ETH )

@station384
Copy link
Contributor Author

what are the parameters you are sending in so I can try and reproduce this error. Its one that I havn't seen yet.

@station384
Copy link
Contributor Author

They only way I was able to reproduce it was to delete the item out of the products.json.
You may try updating it by executing extensions/exchanges/bittrex/update-products.sh

note: you need to be in the extensions/exchanges/bittrex/ directory when executing so it will save the products.json in that directory.

correct a mistake in increment I made due to misunderstanding of how
increment works.
@station384
Copy link
Contributor Author

@XarImoR I finally got this error to reproduce while the coin combo was in the products list. It only seems to be on the the ETH market, I am still trying to figure out what the error is caused by, but is taking awhile as it happens only under rare conditions for me.

@station384
Copy link
Contributor Author

I have received
"Cannot read property 'product_id' of undefined" 2x on ETH market, havn't seen it on the BTC or USDT. So far I have not been able to track it down the cause due to the infrequency of the occurrence.

"Error during syncing balance. Please check your API-Key" -- this I still get, but is treated now as a recoverable error, it shouldn't crash the program. If your version is crashing on this, you my not have some of the updates I included in this pull after the first post.

I have not received
"Cannot read property 'Bid' of null", this looks like during a buy or a sell operation, but unsure

I suspect these are all related to cloudfare interfering, and they are all the same error just showing up as different because of where it is happening in the code. All of them can be caused by the API not responding for one reason or other. 1-2 is when the api doesn't respond with the data we think it should have.

1 and 2 has to do with error handing. I just need to catch it, or log it some how when it happens (need the JSON of the error object that is returned, do figure out conditions)
I've just run out of time to implement the code to catch this right now.

  1. I can't do anything about. it will happen, it is there API not accepting the keys because of some reason or another. The only thing I can do is retry the command after a few seconds, which I have implemented.

Stack trace was not returning enuf information to diagnose some errors
returned by the api.
# Conflicts:
#	extensions/exchanges/bittrex/products.json
@station384
Copy link
Contributor Author

I've added extra logging to any errors that occur when calling the API. Try and get to the bottom of this errors.

@station384
Copy link
Contributor Author

Do not post an unedited debug result. It will contain API key as it seems it is returned by the API results. Going to close down this pull till I figure out these errors.

@station384 station384 closed this Jan 29, 2018
@XarImoR
Copy link

XarImoR commented Jan 29, 2018

thanks for the warning...but this is a text copy from a other machine...but i will delete the comment

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

Successfully merging this pull request may close these issues.

None yet

2 participants