private static Transaccion CreateSpotTrade(SpotWalletCsvRow row) { Transaccion transaccion = new Transaccion { Id = Guid.NewGuid(), Exchange = "crypto.com_exchange", Divisa_Comision = row.FeeCurrency, Cantidad_Comision = row.Fee, Fecha = row.TimestampUTC, Detalles = row.TradeId.ToString(), Alerta = false, Mensaje_Alerta = "", Tipo = "operacion" }; var divisas = row.Symbol.Split('_'); if (string.Equals(row.Side, "BUY")) { transaccion.Divisa_Compra = divisas[0]; transaccion.Cantidad_Compra = row.TradedQuantity; transaccion.Divisa_Venta = divisas[1]; transaccion.Cantidad_Venta = row.TradedQuantity * row.TradedPrice; } if (string.Equals(row.Side, "SELL")) { transaccion.Divisa_Venta = divisas[0]; transaccion.Cantidad_Venta = row.TradedQuantity; transaccion.Divisa_Compra = divisas[1]; transaccion.Cantidad_Compra = row.TradedQuantity * row.TradedPrice; } return(transaccion); }
public static SpotWalletCsvRow FromCsv(string csvLine) { string[] values = csvLine.Split(','); SpotWalletCsvRow csvRow = new SpotWalletCsvRow { AccountType = values[0], OrderId = Convert.ToInt64(values[1]), TradeId = Convert.ToInt64(values[2]), TimestampUTC = Convert.ToDateTime(values[3]), Symbol = values[4], Side = values[5], LiquidityIndicator = values[6], TradedPrice = Convert.ToDecimal(values[7], CultureInfo.InvariantCulture), TradedQuantity = Convert.ToDecimal(values[8], CultureInfo.InvariantCulture), Fee = Convert.ToDecimal(values[9], CultureInfo.InvariantCulture), FeeCurrency = values[10], }; return(csvRow); }
public static Transaccion GetSpotTrade(string line) { var row = SpotWalletCsvRow.FromCsv(line); return(CreateSpotTrade(row)); }