꿈꾸는 법을 가르쳐주세요

저자:네오1898, 창작: 2022-02-25 08:04:50, 업데이트: 2022-02-25 08:52:20

이 문서는 드림 총의 한 문장을 인용하여 오류가 발생하는 것을 발견했습니다: TypeError: cannot read property파일[553], 프로그램 종료로 인해, 사용자 정의 필드가 null로 인해 발생했는지, 또는 가격 정보로 인해 발생하지 않았는지, var pos = exchange.GetPosition (() 를 var pos = _C ((exchange.GetPosition (()) 로 변경하여 문제를 해결할 수 있는지 여부를 물어보십시오.

var currTotalEq = getTotalEquity()
var pos = _C(exchange.GetPosition())
//var pos = exchange.GetPosition()
if (currTotalEq && pos) {
                    // LogStatus(_D(), "当前总权益:", currTotalEq, "持仓:", pos)
                    var tblPos = {
                        "type" : "table",
                        "title" : "持仓",
                        "cols" : ["持仓数量", "持仓方向", "持仓均价", "持仓盈亏", "合约代码", "自定义字段 / " + SpecifyPosField],
                        "rows" : []
                    }
                    var descType = ["多头仓位", "空头仓位"]
                    for (var posIndex = 0 ; posIndex < pos.length ; posIndex++) {
                        tblPos.rows.push([pos[posIndex].Amount, descType[pos[posIndex].Type], pos[posIndex].Price, pos[posIndex].Profit, pos[posIndex].ContractType, SpecifyPosField == "" ? "--" : pos[posIndex].Info[SpecifyPosField]])
                    }
                    
                    var tbl = {
                        "type" : "table",
                        "title" : "数据",
                        "cols" : ["当前总权益", "实际盈亏", "当前价格", "买单价格/数量", "卖单价格/数量"],
                        "rows" : []
                    }
                    var buyOrder = null 
                    var sellOrder = null 
                    for (var orderIndex = 0 ; orderIndex < orders.length ; orderIndex++) {
                        if (orders[orderIndex].Type == ORDER_TYPE_BUY) {
                            buyOrder = orders[orderIndex]
                        } else {
                            sellOrder = orders[orderIndex]
                        }
                    }
                    var realProfit = currTotalEq - totalEq
                    if (exchange.GetName() == "Futures_Binance") {
                        _.each(pos, function(p) {
                            realProfit += parseFloat(p.Info.unRealizedProfit)
                        })                        
                    }
                    var t = exchange.GetTicker()
                    tbl.rows.push([currTotalEq, realProfit, t ? t.Last : "--", (buyOrder.Price + "/" + buyOrder.Amount), (sellOrder.Price + "/" + sellOrder.Amount)])

더 많은

네오1898var pos = exchange.GetPosition (() 를 var pos = _C ((exchange.GetPosition (()) 로 바꾸어 값이 내려갈 수 있는지 확인합니다.

네오1898553번 줄 근처의 번호는: var t = exchange.GetTicker ((() tbl.rows.push (([currTotalEq, realProfit, t? t.Last : "--", (buyOrder.Price + "/" + buyOrder.Amount), (sellOrder.Price + "/" + sellOrder.Amount))) 틱어 데이터가 없거나 var t = _C (exchange.GetTicker)) 로 변경하면 됩니다.

네오1898감사합니다, 드림!

작은 꿈`` tbl.rows.push (([currTotalEq, realProfit, t? t.Last : "--", (buyOrder? buyOrder.Price : "--") + "/" + (buyOrder? buyOrder.Amount :"--"), (sellOrder? sellOrder.Price "--") + "/" + (sellOrder? sellOrder.Amount : "--"))) `` 문제는, buyOrder가 null이 될 때, buyOrder.Amount 또는 buyOrder.Price에 접속하지 않으면 오류가 발생하지 않는다는 것입니다.

네오1898주문이 있을 때에도 가격은 수치입니다. 하지만 Amount는 항상 데이터도 없고 오류도 없습니다.

네오1898주문하지 않은 경우: 가격을 변경하고 금액을 변경해야하지만 시도했습니다. tbl.rows.push (([currTotalEq, realProfit, t? t.Last : "--", (buyOrder? buyOrder.Price : "--" + "/" + buyOrder? buyOrder.Amount :"--"), (sellOrder? sellOrder.Price "--" + "/" + sellOrder? sellOrder.Amount : "--") 또는 TypeError: cannot read property 'Amount' of null at main (__FILE__:554), 코드가 업데이트되지 않았습니까? 또는 오류가 있습니까?

작은 꿈가, 즉 접근. 어떤 변수의 속성을 판단할 때, 변수가 null인지, 아니면 접근하지 않으면 오류가 발생하지 않습니다.

네오1898tbl.rows.push (([currTotalEq, realProfit, t? t.Last : "--", (buyOrder? buyOrder.Price : "--" + "/" + buyOrder.Amount), (sellOrder? sellOrder.Price : "--" + "/" + sellOrder.Amount) ] 그리고 이것은 바로 위와 같습니다.

작은 꿈buyOrder?buyOrder.Price: "--" 이렇게 처리하면 됩니다.

작은 꿈빈 문자열을 전송할 수 있습니다.

네오1898네, 감사합니다. 몇 가지 단계에서는 주문을 하지 않았습니다. 그래서 주문 메시지는 null입니다. null을 입력하도록 허용해야 합니다.

가벼운 구름var t = _C (exchange.GetTicker)

가벼운 구름에러 허용 () 를 사용해서 설정할 수 없습니다. var pos = _C (exchange.GetPosition) 로 변경했습니다.

네오1898 tbl.rows.push,是这个不允许传入null值是吗?我有些步骤是没有下单的,所以订单信息为null,必须允许传入null,应该要怎么改呢,谢谢梦总!

네오1898다음으로, 제가 주문을 하지 않는데, 여기서 null가 허용되는지, 어디서 null로 허용되는지, 주문을 하지 않는지,

작은 꿈buyOrder 또는 sellOrder가 null로 인해 발생할 수 있습니다.