12
집중하다
3
수행원

멩씨에게 물어보세요

만든 날짜: 2022-02-25 08:04:50, 업데이트 날짜: 2022-02-25 08:52:20
comments   16
hits   949

멘의 코드에 인용하여, 어떤 시점에서 오류가 발생한다는 것을 알게 되었습니다. TypeError: cannot read property ‘Price’ of null at main (FILE[553], 프로그램 퇴출을 일으켰고, DreamCatcher에게, 사용자 정의 필드가 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)])