public static Order ToOrder(jsonOrder _Order) { Order tmp = new Order { Base = decimal.Parse(_Order.@base, System.Globalization.NumberFormatInfo.InvariantInfo), FeeBase = decimal.Parse(_Order.fee_base, System.Globalization.NumberFormatInfo.InvariantInfo), CompletedTime = JSON.FromEpoch(_Order.completed_timestamp), Counter = decimal.Parse(_Order.counter, System.Globalization.NumberFormatInfo.InvariantInfo), CreationTime = JSON.FromEpoch(_Order.creation_timestamp), ExpirationTime = JSON.FromEpoch(_Order.expiration_timestamp), FeeCounter = decimal.Parse(_Order.fee_counter, System.Globalization.NumberFormatInfo.InvariantInfo), LimitPrice = decimal.Parse(_Order.limit_price, System.Globalization.NumberFormatInfo.InvariantInfo), LimitVolume = decimal.Parse(_Order.limit_volume, System.Globalization.NumberFormatInfo.InvariantInfo), OrderID = _Order.order_id }; tmp.State = (_Order.state.ToLower() == "pending" ? OrderStates.Pending : _Order.state.ToLower() == "completed" ? OrderStates.Complete : OrderStates.Cancelled); tmp.Type = _Order.type.ToLower() == "ask" ? OrderTypes.Ask : OrderTypes.Bid; foreach (jsonTrade t in _Order.trades) { tmp.Trades.Add(t.ToTrade()); } return(tmp); }
public static jsonOrder FromOrder(Order _Order) { List <jsonTrade> Trades = new List <jsonTrade>(); foreach (Trade t in _Order.Trades) { Trades.Add(t.ToJsonTrade()); } jsonOrder tmpOrder = new jsonOrder { @base = _Order.Base.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), completed_timestamp = JSON.ToEpoch(_Order.CompletedTime), counter = _Order.Counter.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), creation_timestamp = JSON.ToEpoch(_Order.CreationTime), expiration_timestamp = JSON.ToEpoch(_Order.ExpirationTime), fee_base = _Order.FeeBase.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), fee_counter = _Order.FeeCounter.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), limit_price = _Order.LimitPrice.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), limit_volume = _Order.LimitVolume.ToString(System.Globalization.NumberFormatInfo.InvariantInfo), order_id = _Order.OrderID, state = _Order.State.ToString().ToUpper(), trades = Trades.ToArray(), type = _Order.Type.ToString().ToUpper() }; return(tmpOrder); }
public static Order FromJsonOrder(jsonOrder _Order) { return(_Order.ToOrder()); }