public void fetchBook(JToken msg) { bidState = STATE.PROCESSING; askState = STATE.PROCESSING; JObject[] arrOffer = msg["offers"].ToObject <JObject[]>(); dtBid = new DS.BidDataTable(); dtAsk = new DS.AskDataTable(); foreach (JObject j in arrOffer) { double takerPaysXRP; double takerGetsXRP; string takerPayCCY; string takerGetCCY; if (Double.TryParse(j["taker_pays"].ToString(), out takerPaysXRP)) { takerGetCCY = j["taker_gets"]["currency"].ToString(); if (CCY1 == "XRP" && takerGetCCY == CCY2) { dtBid.AddBidRow(RConfig.MILLION * j["taker_gets"]["value"].ToObject <double>() / takerPaysXRP, takerPaysXRP / RConfig.MILLION); } } else if (Double.TryParse(j["taker_gets"].ToString(), out takerGetsXRP)) { takerPayCCY = j["taker_pays"]["currency"].ToString(); if (CCY1 == "XRP" && takerPayCCY == CCY2) { dtAsk.AddAskRow(RConfig.MILLION * j["taker_pays"]["value"].ToObject <double>() / takerGetsXRP, takerGetsXRP / RConfig.MILLION); } } else { takerPayCCY = j["taker_pays"]["currency"].ToString(); takerGetCCY = j["taker_gets"]["currency"].ToString(); if (takerPayCCY == CCY1 && takerGetCCY == CCY2) { dtBid.AddBidRow(j["taker_gets"]["value"].ToObject <double>() / j["taker_pays"]["value"].ToObject <double>(), j["taker_pays"]["value"].ToObject <double>()); } else if (takerPayCCY == CCY2 && takerGetCCY == CCY1) { dtAsk.AddAskRow(j["taker_pays"]["value"].ToObject <double>() / j["taker_gets"]["value"].ToObject <double>(), j["taker_gets"]["value"].ToObject <double>()); } } } bidState = STATE.READY; askState = STATE.READY; }
public void fetchBookBid(JToken msg) { JObject[] arrBid = msg["offers"].ToObject <JObject[]>(); dtBid = new DS.BidDataTable(); if (CCY1 == "XRP" || CCY2 == "XRP") { foreach (JObject j in arrBid) { if (j["taker_pays_funded"] == null) { dtBid.AddBidRow(RConfig.MILLION / j["quality"].ToObject <double>(), j["TakerPays"].ToObject <double>() / RConfig.MILLION); } else { dtBid.AddBidRow(RConfig.MILLION / j["quality"].ToObject <double>(), j["taker_pays_funded"].ToObject <double>() / RConfig.MILLION); } } } else { foreach (JObject j in arrBid) { if (j["taker_pays_funded"] == null) { dtBid.AddBidRow(1.0 / j["quality"].ToObject <double>(), j["TakerPays"]["value"].ToObject <double>()); } else { dtBid.AddBidRow(1.0 / j["quality"].ToObject <double>(), j["taker_pays_funded"]["value"].ToObject <double>()); } } } bestBid = dtBid[0].Bid; bestBidQty = dtBid[0].BidQty; bidState = STATE.READY; }