'بھاگنا' مارکیٹ کی حکمت عملی بن گئی

مصنف:صفر، تاریخ: 2014-08-06 00:12:12
ٹیگز:ہائی فریکوئنسیمارکیٹ بنانے والا

اس کے علاوہ ، آپ کو اس بات کا یقین کرنے کی ضرورت ہے کہ آپ کے کاروبار میں بہت زیادہ سرمایہ کاری کرنے کی ضرورت ہے ، لہذا آپ کو اس کی ضرورت نہیں ہے۔



function CancelPendingOrders(orderType) {
    while (true) {
        var orders = _C(exchange.GetOrders);
        var count = 0;
        if (typeof(orderType) != 'undefined') {
            for (var i = 0; i < orders.length; i++) {
                if (orders[i].Type == orderType) {
                    count++;
                }
            }
        } else {
            count = orders.length;
        }
        if (count == 0) {
            return;
        }

        for (var j = 0; j < orders.length; j++) {
            if (typeof(orderType) == 'undefined' || (orderType == orders[j].Type)) {
                exchange.CancelOrder(orders[j].Id, orders[j]);
                if (j < (orders.length-1)) {
                    Sleep(Interval);
                }
            }
        }
    }
}


function updateProfit(accountInit, accountNow, ticker) {
    var netNow = accountNow.Balance + accountNow.FrozenBalance + ((accountNow.Stocks + accountNow.FrozenStocks) * ticker.Buy);
    var netInit = accountInit.Balance + accountInit.FrozenBalance + ((accountInit.Stocks + accountInit.FrozenStocks) * ticker.Buy);
    LogProfit(netNow - netInit);
}

var InitAccount = null;
var LastBuyPrice = 0;
var LastSellPrice = 0;

function onTick() {
    var ticker = _C(exchange.GetTicker);
    var BuyPrice = ticker.Buy + SlidePrice;
    var SellPrice = ticker.Sell - SlidePrice;

    // 利润消失
    if ((SellPrice - BuyPrice) <= MaxDiff) {
        CancelPendingOrders();
        return;
    }
  
    var cancelType = null;
    
    if (LastBuyPrice > 0 && (ticker.Buy - LastBuyPrice) > SlidePrice) {
        cancelType = ORDER_TYPE_BUY;
    }
    
    if (LastSellPrice > 0 && (LastSellPrice - ticker.Sell) > SlidePrice) {
        if (cancelType == null) {
            cancelType = ORDER_TYPE_SELL;
        } else {
            cancelType = -1;
        }
    }
    
    if (cancelType == -1) {
        CancelPendingOrders();
    } else if (cancelType != null) {
        CancelPendingOrders(cancelType);
    }

    var orders = _C(exchange.GetOrders);
    if (orders.length == 2) {
        return;
    }
    var account = _C(exchange.GetAccount);
    var amountBuy = _N(Math.min(account.Balance / BuyPrice, Lot));
    var amountSell = Math.min(account.Stocks, Lot);

    if (amountBuy >= MinStock) {
        if (orders.length == 0 || orders[0].Type == ORDER_TYPE_SELL) {
            if (orders.length > 0) {
                updateProfit(InitAccount, account, ticker);
            }
            exchange.Buy(BuyPrice, amountBuy);
            LastBuyPrice = BuyPrice;
        }
    }
    if (amountSell >= MinStock) {
        if (orders.length == 0 || orders[0].Type == ORDER_TYPE_BUY) {
            if (orders.length > 0) {
                updateProfit(InitAccount, account, ticker);
            }
            exchange.Sell(SellPrice, amountSell);
            LastSellPrice = SellPrice;
        }
    }
}

function onexit() {
    CancelPendingOrders();
}

function main() {
    InitAccount = _C(exchange.GetAccount);
    Log(InitAccount);
    SetErrorFilter("502:|503:|unexpected|network|timeout|WSARecv|Connect|GetAddr|no such|reset|received|EOF");
    exchange.SetRate(1);
    LoopInterval = Math.max(LoopInterval, 1);
    Lot = Math.max(MinStock, Lot);
    while (true) {
        onTick();
        Sleep(LoopInterval * 1000);
    }
}


متعلقہ

مزید

ہنس0621ہم کس طرح کرنسی کا تعین کرتے ہیں؟

بی بیشکریہ شیئر کرنے کے لیے، کوشش کر رہا ہوں، کچھ جگہوں پر تو سمجھ میں نہیں آرہا، کچھ تبصرے کیے ہیں، شکریہ شیئر کرنے کے لیے۔ https://dn-filebox.qbox.me/ae3dba6b345db61fdb04694f11f5a089969c523f.png https://dn-filebox.qbox.me/7425baf156815b000d4aeb26c74669b8f08dff04.png https://dn-filebox.qbox.me/ad115b10c27f20434f27f8eaa4dd319341abdbf3.png

رُستِپِنگif (orders.length == 0 ordres[0].Type == ORDER_TYPE_SELL) { براہ کرم اس آرڈر [0].Type == ORDER_TYPE_SELL] پر فیصلہ کرنے کی ضرورت کیوں ہے؟

ڈینیاورینتبصرے کے لئے شکریہ