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

Fix/Cleanup Tradelog #35

Open
toirl opened this issue Aug 28, 2017 · 4 comments
Open

Fix/Cleanup Tradelog #35

toirl opened this issue Aug 28, 2017 · 4 comments

Comments

@toirl
Copy link
Owner

toirl commented Aug 28, 2017

Cointrader provides a Tradelog to log every trade made by a bot. This log is used while loading the bot to replay all trades and to set the current amount of coins and BTC.

I noticed some abnormalities when replaying the tradelog as BTC and LTC can become a negative value.
This is of course not possible and results in later errors when placing orders. ( E.g. in case the bot wants to sell a negativ amount of coins.)

It is currently unclear if the logging part, the replay part or both is broken.
So this Tradelog needs some work to do some investigation

This may result in

  • cleanup
  • better documentation
@bahelit
Copy link

bahelit commented Aug 30, 2017

I plan on analyzing the sqlite database and going through the code to fix this as soon as I can.

@toirl
Copy link
Owner Author

toirl commented Aug 30, 2017

This are great news!

Here are my current insights in the defect, maybe they help you:

I assume the defect in context of the tax calculation of poloniex. I initially implemented some naive tax handling (https://github.com/toirl/cointrader/blob/master/cointrader/exchange.py#L15) but I suspect this is a part of the problem, I currently tend to remove this completely.

Further look into the reponse from Poloniex for a buy or sell order leaves some questions to me. See the following example:

self.btc: 0.0001841

result: {u'orderNumber': u'101989044914',

u'resultingTrades': [{u'tradeID': u'10337554',

u'rate': u'0.01465099',

u'amount': u'0.01254339',

u'date': u'2017-08-28 20:30:46',

u'total': u'0.00018377',

u'type': u'buy'}]}

Remaining BTC = 0.00000033 ???

I placed an buy order with 0.0001841BTC. The response returned 0.00018377 BTC. I am not sure what this means. Does it mean that my order is only partially filled, or does it mean that poloniex put an internal tax on this and completely filled my order with 0.00018377?

Unfortunately the documentation of the API gives not detail on this. https://poloniex.com/support/api/
But maybe setting the killorfill option might help.

At last I think the current trade log is to complicated and can be reduced by the "tax" fields.

Let me know your findings!

@bahelit
Copy link

bahelit commented Aug 31, 2017

Well, think that the fee is 0.25 not 0.025.

Also in the database the tax field on the trades table is 0 for all entries.

Believe that the difference in your order and the response was the fee automatically removed. The function for fee should still exist and be used before placing an order to be sure it has enough after the fee to trade with.

@toirl
Copy link
Owner Author

toirl commented Aug 31, 2017

Well, think that the fee is 0.25 not 0.025.

Yes, you're right!

Also in the database the tax field on the trades table is 0 for all entries.

This looks like as it can be removed

The function for fee should still exist and be used before placing an order to be sure it has enough after the fee to trade with.

You mean If I want to place an order to buy 10 coins of X @ a rate of 0.1 BTC I actually must have at least 1BTC+0.25%? In the result we than expect the 1BTC total, right?

Another point to consider is: Polo differenciate between Taker and Maker Fees. (IIRC 0.25/0.15). But I think we would be on the safe side to always take the higher fee to make sure the order can be placed.

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

No branches or pull requests

2 participants