教えてもらいたい

作者: リン・ハーンネオ1898作成日: 2022-02-25 08:04:50,更新日: 2022-02-25 08:52:20

引用したコードの部分で,ある時点でエラーが表示される: TypeError: cannot read property Price of null at main (タイプエラー: cannot read property)ファイルプログラムが終了する原因は,カスタムフィールドが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)])

もっと

ネオ1898変えて,var pos = exchange.GetPosition (() をvar pos = _C ((exchange.GetPosition (()) にすると,この問題を解くことができるか,値を取って,さらに下に移動します.

ネオ1898553行近くのコードは: 変数 t = 交換.GetTicker tbl.rows.push (([currTotalEq, realProfit, t? t.Last : "--", (buyOrder.Price + "/" + buyOrder.Amount), (sellOrder.Price + "/" + sellOrder.Amount) ]) このリストは,このリストのリストのリストの1つに含まれています. ティッカーのデータが取れていない場合は,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アモウントはデータも報告もせず, 奇妙なことに,何が問題なのか?

ネオ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か,それとも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 (交換.GetTicker)

軽い雲誤差容認の内側が設定できないので,var pos = _C ((exchange.GetPosition) に変更しました.

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

ネオ1898命令番号はnullでなければなりません. 命令番号はnullでなければなりません. 命令番号はnullでなければなりません.

小さな夢buyOrder または sellOrder が null の結果になる可能性があります. プリントして確認してください.