Bitfinex securities trading

Author: 7meter, Date: 2017-10-14 17:20:59
Tags: Extent-APIBitfinex


var bitfinexIndex = 0;
var basecurrency;
var quotecurrency;

function init(){
    for(var i = 0;i<exchanges.length;i++){
        if(exchanges[i].GetName() == "Bitfinex"){
            bitfinexIndex = i
        }
    }
    var st = exchanges[bitfinexIndex].GetCurrency().split("_")
    basecurrency = st[0]
    quotecurrency = st[1]
}

$.bitfinexSell = function(price, amount){
    var message = "symbol=" + basecurrency + quotecurrency + "&amount=" + amount.toString() + "&price=" + price.toString() + "&side=sell" + "&type=limit"
    id = exchanges[bitfinexIndex].IO("api", "POST", "/v1/order/new", message)
    return id.order_id
}

$.bitfinexBuy = function(price, amount){
    var message = "symbol=" + basecurrency + quotecurrency + "&amount=" + amount.toString() + "&price=" + price.toString() + "&side=buy" + "&type=fill-or-kill"
    var id = exchanges[bitfinexIndex].IO("api", "POST", "/v1/order/new", message)
    return id.order_id
}

$.bitfinexGetPosition = function(){
    var position = exchanges[bitfinexIndex].IO("api", "POST", "/v1/positions")
    return position
}

//直接使用exchange.GetOrder(id)就可以了,不需要调用模板
$.bitfinexGetOrder = function(order_id){
    var order = exchanges[bitfinexIndex].IO("api", "POST", "/v1/order/status", "order_id=", parseInt(order_id))
    return order
}

//直接用exchange.CancelOrder(id)就可以取消订单,不需要调用模板
$.bitfinexCancelOrder = function(order_id){
    //var result = exchanges[bitfinexIndex].IO("api", "POST", "/v1/order/cancel", "order_id=", parseInt(order_id))
    //return order
}

//返回margin钱包一共可以交易多少USD(虚拟币会换成美元加入计算)
$.marginBalance = function(){
    var balance = exchanges[bitfinexIndex].IO("api", "POST", "/v1/margin_infos")
    return balance[0].tradable_balance;
}

Related

More

The SeahawksThis is a list of all the different ways Dn-filebox.qbox.me/7f0380fdc97b1d9955e7a69f48c45725856d28d9.png is credited in the database. After hundreds of attempts to trade Bitfinex securities in the past week, I still encountered obstacle reporting errors, and I don't know if the author has a solution.

louis+ "&type=fill-or-kill" + "&side=buy" + "&type=fill-or-kill" Why is the type of payment = fill-or-kill different from the sales order?

wangwlbAlso, the concept of the IOT is not very clear, can you please provide a description or explanation of the IOT on our website?

wangwlbI'm not sure what the basic concept is, so I'm going to have to ask you again, thank you very much: Your link provides a template, please tell me how to link to the current policy (which is a non-security trading strategy that works well on bitfinex)? just link this template under the policy? and how to retest? Thank you.

7meterThis is how the exchange API is defined, and you can go to the bitfinex API description interface to see it.

wangwlbI think so too, thank you again!

7meterNo, I've tested it on a hard drive, and it should be fine, and you can test it on a very small number of people.

wangwlbThank you. Thank you. Is there a possibility of a re-test on the platform?

7meterYou can delete the original, and then you can refer to it again. Note that I changed the function name.

wangwlbThank you. There is already a template in the original strategy: the template for the digital currency spot market library (updated) The name of the buy function looks the same, how does it recognize itself? Also, if you're trading securities, I see that there's a security ratio on bitfinex, how do you set it up in the policy? The problem is somewhat childish and laughable due to the lack of basic knowledge.

7meterYou can quote my template in the policy, and put a dot in the dash, and then in the policy, you can buy with $.Buy (price, quantity) on the exchange with collateral.