question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poloniex order fees

See original GitHub issue

fetch_order() on the poloniex service returns 'fee': None and doesn’t otherwise account for the fees.

Thus doing a buy/then sell gives an insufficient funds error from the exchange. Basically what I am doing is something like this:

uuid = polo.create_limit_buy_order("BCH/BTC", 0.00303204, rate)['id']
time.sleep(10)
order = polo.fetch_order(uuid)

# later on, sell it:
amount = order['filled']   # equals 0.00303204 as all was filled
polo.create_limit_sell_order("BCH/BTC", amount, rate)

When I sell, I get an insufficient funds error because I don’t have that much because Polo deducts the fees in BCH after buying it.

I would need to sell amount - fee, but don’t have access to fee. Could you include it?

Really in addition to returning the fees, to me it would make more sense to directly include fields in the Order Structure that tell you how much you have as a result of the order. In the above example, I don’t really have 0.00303204 units of BCH, I only have 0.00302446 as a result of the buy and thats all I care about. It would be nice if CCXT did the filled - fee calculation already otherwise I have to check fee structure and only deduct fee from filled if the fee currency is the destination one. In other words, the only thing I really care about is exactly how much more BCH is in my account and exactly how much less BTC is in my account.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:25 (15 by maintainers)

github_iconTop GitHub Comments

3reactions
nmiculiniccommented, Nov 25, 2017

As for multiple API call, you may add option (in unified API for example), full/short which would tell you should you only make the most basic API call, or multiple API calls as needed.

2reactions
stonemonkcommented, Nov 15, 2017

I will be offline for next 2 weeks and then very busy the following 2 weeks, but if you haven’t make progress on this issue by then, maybe I can help. I was just a bit hesitant because I haven’t worked with JS in about 10 years so I am very rusty with it.

I just pulled up my old Polo code I wrote prior to using CCXT. Indeed I was caching the total quantity from the original buy/sell request by returning it as part of the ID (My ID was a tuple to encode quantity and orderID, etc so I didn’t have to cache it internally by the my Exchange class).

Additionally, I had found the only proper way to calculate the fee was to iterate each trade in the order, callulate the fee and round it down to 8 decimal places, and only then sum them together. Example:

    def get_order(self, uuid):
        order_id = uuid[0]
        trades = self.service.returnOrderTrades(order_id)
        if trades:
            symbol = uuid[1]
            kind = uuid[2]
            quantity = uuid[3]
            total_price = Decimal(0)
            filled = Decimal(0)
            fee = Decimal(0)

            for trade in trades:
                assert trade["type"] == kind
                assert trade["currencyPair"] == symbol

                amount = Decimal(trade["amount"])
                total = Decimal(trade["total"])
                fee_percent = Decimal(trade["fee"])
                if kind == "buy":
                    fee += (fee_percent * amount).quantize(Decimal('.00000001'), rounding=ROUND_DOWN)
                else:
                    fee += (fee_percent * total).quantize(Decimal('.00000001'), rounding=ROUND_DOWN)
                total_price += total
                filled += amount

            info = {
                "unit_price": total_price / filled,
                "total_price": total_price,
                "total_quantity": quantity,
                "filled_quantity": filled,
                "resultant_quantity": filled - fee,
                "remaining_quantity": quantity - filled
            }
            
            return info
        return None
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fee Structure - Poloniex Support
Fee Structure ; 3. $50K - $1M · ≥$0. 0.1050% / 0.1200%. 0.0735% / 0.0840% ; 4. $1M - $10M · ≥$0. 0.0700%...
Read more >
Poloniex Trading, Deposit & Withdrawal Fees (2022 Update)
Poloniex trading fees ; 3, $50K – $1M · N/A ; 4, $1m – $10m, N/A ; 5, $10m – $50m, N/A ;...
Read more >
Poloniex Deposit, Trading & Withdrawal fees - CryptoFeeSaver
Deposit, Trading & Withdrawal fees of Poloniex exchange. Compare the top cryptocurrency exchanges fees and start saving money now!
Read more >
Poloniex Review 2022 - Investopedia
Poloniex's fees are just 0.145% or 0.155% at the highest tier. Coinbase's fees range from 0.00% to 0.60% depending on trade volume. Poloniex...
Read more >
Poloniex Launches the Lowest Futures Trading Fees in the ...
Starting today, the Maker and Taker fee rates for trading USDT-collateralized perpetual contracts on Poloniex are 0.01% and 0.04% respectively, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found