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.

Bitfinex margin orders

See original GitHub issue

I noticed that for Bitfinex you do this to “type”:

let order = {
            'symbol': this.marketId (market),
            'amount': amount.toString (),
            'side': side,
            'type': 'exchange ' + type,
            'ocoorder': false,
            'buy_price_oco': 0,
            'sell_price_oco': 0,
        };

thus allowing only exchange orders (and not margin orders). Is there a reason for this? I didn’t check, but I think that “type” is exchange-specific anyway, so why not just let use margin types or exchange types using the corresponding string?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
danmaz74commented, Aug 20, 2017

HI @kroitor Thanks for the answer, it’s clear now, but I would NEVER have guessed it. I just created a pull request with a suggestion to document this feature (didn’t test it though…)

1reaction
kroitorcommented, Aug 20, 2017

Hi, @danmaz74 !

Thanks for your question!

Here’s the answer: we use that by default, but we allow you to override the type and trade with margin orders as well. Notice, there’s the last argument to the createOrder named params = {}. Also notice, that below that code you copied here, there’s a line doing this.extend (order, params):

    async createOrder (market, type, side, amount, price = undefined, params = {}) {
        await this.loadMarkets ();
        let order = {
            'symbol': this.marketId (market),
            'amount': amount.toString (),
            'side': side,
            'type': 'exchange ' + type,
            'ocoorder': false,
            'buy_price_oco': 0,
            'sell_price_oco': 0,
        };
        if (type == 'market') {
            order['price'] = this.nonce ().toString ();
        } else {
            order['price'] = price.toString ();
        }
        //                                             ↓↓↓↓ THIS LINE ↓↓↓↓
        let result = await this.privatePostOrderNew (this.extend (order, params));
        return {
            'info': result,
            'id': result['order_id'].toString (),
        };
    },

The params object is empty by default, but you can use it to set the type as you want it, like so:

bitfinex.createOrder('BTC/USD', 'limit', 'sell', 1, 4100, { 'type': 'marginOrderOrAnyOtherType' })

The params argument is supported by all methods for order placement, including, createMarketSellOrder, createLimitBuyOrder, etc…

Is that ok for an answer? ) If so, please, close this issue, and if not, I’m waiting for your further questions ) Thx!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to open/close a margin position at Bitfinex
1. When trading on margin, firstly, make sure that your funds are in your Margin wallet. · 2. Next, go to the Trading...
Read more >
Features - Bitfinex
Bitfinex allows users to trade with up to 10x leverage by receiving funding from the peer to peer margin funding platform. Users can...
Read more >
What is Margin Funding – Bitfinex Help Center
Funding fees would be 15.0% of the fees generated by the Margin Funding order, or 18.0% if the funding offer was a hidden...
Read more >
How to claim a margin position on Bitfinex
1. Firstly, find the position you would like to claim in your Positions widget. · 2. Check your wallets to ensure that you...
Read more >
Margin Funding on Bitfinex
How to use Bitfinex Margin Funding · Step 1: Make a deposit · Step 2: Move funds to Funding Wallet · Step 3:...
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