private void SaveSpreadOkexBinance() { CalculateSpread(() => { var btcBalance = 1; var usdOkexSell = btcBalance * btcOkex[0] * okexFee; var iotaOkexBuy = usdOkexSell / iotaOkex[1] * okexFee; var iotaBinanceSell = btcBalance / iotaBinance[0] * binanceFee; var spreadPercent = 100 - (iotaOkexBuy / iotaBinanceSell * 100); var iotaStep = 800; var iotaBinanceBuy = iotaStep * iotaBinance[0] * binanceFee; var usdOkexSell = iotaStep * iotaOkex[0] * okexFee; var iotaOkexSell = usdOkexSell / btcOkex[1]; var spread = iotaOkexSell - iotaBinanceBuy; var data = new DbSpread { Instrument1 = CurrencyName.IOTA, CreatedAt = DateTime.UtcNow, Exchange1 = ExchangeName.OkEx, Exchange2 = ExchangeName.Binance, SpreadPercent = Math.Round(spread, 8), // Math.Round(spreadPercent, 2), BidAltcUsd = iotaOkex[0], AskAltcUsd = iotaOkex[1], BidAltcInstr2 = iotaBinance[0], AskAltcInstr2 = iotaBinance[1], BidUsd1 = btcOkex[0], AskUsd1 = btcOkex[1], BidUsd2 = btcBinance[0], AskUsd2 = btcBinance[1] }; _dbRepo.SaveSpread(data); }); }
private void SaveSpread() { CalculateSpread(() => { var btcBalance = 0.5; var buyAltc1 = btcBalance / iotaBtc[1] * tradingFee; var buyUsd = btcBalance / btc[1] * tradingFee; var buyAltc2 = buyUsd / iotaUsd[0] * tradingFee; var data = new DbSpread { Instrument1 = CurrencyName.IOTA, CreatedAt = DateTime.UtcNow, Exchange1 = ExchangeName.OkEx, Exchange2 = ExchangeName.OkEx, SpreadPercent = Math.Round(buyAltc2 - buyAltc1, 2) }; _dbRepo.SaveSpread(data); }); }
public void SaveSpread(DbSpread data) { _dbRepo.SaveSpread(data); }