Dim serialized = Newtonsoft.Json.JsonConvert.SerializeObject(gridOrderNewState)
Dim gridOrderNewstate2 = Newtonsoft.Json.JsonConvert.DeserializeObject(Of gridTradingState)(serialized)
结果几乎是空版本gridOrderNewstate2
这就是序列化后的值
{
"bidInBase":0.99055,
"askInBase":0.99333,
"high":0.99448,
"low":0.97528,
"dateSinceLastTransactions":"2022-11-14T21:04:34.0103292+07:00",
"suggestedLow":0.0,
"suggestedhigh":0.0,
"Orders":[
{
"time":"2022-11-14T13:09:54",
"id":"227286807874",
"customIdentifier":"t-FraxTest",
"amountOfQuoteCurrencyBeingOrdered":6.25,
"priceInBasecoin":1.0,
"marketString":"gate",
"Base":"USDT",
"Quote":"FRAX",
"isSellingInsteadOfBuying":true,
"marketURL":"https://gate.io/trade/frax_usdt"
},
{
"time":"2022-11-14T13:09:54",
"id":"227286807867",
"customIdentifier":"t-FraxTest",
"amountOfQuoteCurrencyBeingOrdered":6.263,
"priceInBasecoin":0.99778,
"marketString":"gate",
"Base":"USDT",
"Quote":"FRAX",
"isSellingInsteadOfBuying":true,
"marketURL":"https://gate.io/trade/frax_usdt"
},
{
"time":"2022-11-14T13:09:54",
"id":"227286807859",
"customIdentifier":"t-FraxTest",
"amountOfQuoteCurrencyBeingOrdered":6.277,
"priceInBasecoin":0.99556,
"marketString":"gate",
"Base":"USDT",
"Quote":"FRAX",
"isSellingInsteadOfBuying":true,
"marketURL":"https://gate.io/trade/frax_usdt"
},
{
"time":"2022-11-14T13:09:54",
"id":"227286807851",
"customIdentifier":"t-FraxTest",
"amountOfQuoteCurrencyBeingOrdered":6.291,
"priceInBasecoin":0.99333,
"marketString":"gate",
"Base":"USDT",
"Quote":"FRAX",
"isSellingInsteadOfBuying":true,
"marketURL":"https://gate.io/trade/frax_usdt"
},
{
"time":"2022-11-14T13:09:54",
"id":"227286807835",
"customIdentifier":"t-FraxTest",
"amountOfQuoteCurrencyBeingOrdered":6.334,
"priceInBasecoin":0.98667,
"marketString":"gate",
"Base":"USDT",
"Quote":"FRAX",
"isSellingInsteadOfBuying":false,
"marketURL":"https://gate.io/trade/frax_usdt"
},
{
"time":"2022-11-14T13:09:54",
"id":"227286807823",
"customIdentifier":"t-FraxTest",
"amountOfQuoteCurrencyBeingOrdered":6.348,
"priceInBasecoin":0.98444,
"marketString":"gate",
"Base":"USDT",
"Quote":"FRAX",
"isSellingInsteadOfBuying":false,
"marketURL":"https://gate.io/trade/frax_usdt"
},
{
"time":"2022-11-14T13:09:54",
"id":"227286807816",
"customIdentifier":"t-FraxTest",
"amountOfQuoteCurrencyBeingOrdered":6.363,
"priceInBasecoin":0.98222,
"marketString":"gate",
"Base":"USDT",
"Quote":"FRAX",
"isSellingInsteadOfBuying":false,
"marketURL":"https://gate.io/trade/frax_usdt"
},
{
"time":"2022-11-14T13:09:54",
"id":"227286807762",
"customIdentifier":"t-FraxTest",
"amountOfQuoteCurrencyBeingOrdered":6.377,
"priceInBasecoin":0.98,
"marketString":"gate",
"Base":"USDT",
"Quote":"FRAX",
"isSellingInsteadOfBuying":false,
"marketURL":"https://gate.io/trade/frax_usdt"
}
]
}
很明显有些东西在那里。
但我无法反序列化为同一个对象类。
顺便说一句,这是班级
Class gridTradingState
ReadOnly Property bidInBase As Decimal
ReadOnly Property askInBase As Decimal
ReadOnly Property high As Decimal
ReadOnly Property low As Decimal
ReadOnly Property dateSinceLastTransactions As Date
ReadOnly Property suggestedLow As Decimal
ReadOnly Property suggestedhigh As Decimal
ReadOnly Property Orders As OrderAlreadyPlacedAtanExchange()
Public Shared Function creategridTradingOldState(market As MarketPairInanExchange, ordersInp As OrderAlreadyPlacedAtanExchange()) As gridTradingState
Dim currentState = New gridTradingState
'currentState._bidInBase = market.askbidInBase(False)
'currentState._askInBase = market.askbidInBase(True)
currentState._bidInBase = market.bidInBaseCoin
currentState._askInBase = market.askInBaseCoin
currentState._high = market.highInBaseCoin
currentState._low = market.lowInBaseCoin
currentState._Orders = ordersInp
currentState._dateSinceLastTransactions = Now
Return currentState
End Function
Public Sub updateSuggestedLowandHigh(suggestedLowNew As Decimal, suggestedHighNew As Decimal)
_suggestedLow = suggestedLowNew
_suggestedhigh = suggestedHighNew
End Sub
End Class
有人要求提供最低限度可重复的样本。我删除订单。序列化的内容变成
{
"bidInBase": 0.98735,
"askInBase": 0.9918,
"high": 0.99448,
"low": 0.97528,
"dateSinceLastTransactions": "2022-11-14T22:47:47.5532599+07:00",
"suggestedLow": 0.0,
"suggestedhigh": 0.0
}
问题依然存在。看来 dbc 正在做某事