public static SimpleArbitrage CreateFrom( decimal estimatedProfits, string baseCurrency, string quoteCurrency, int buyFrom, decimal buyPrice, decimal buyAmounts, int sellTo, decimal sellPrice, decimal sellAmounts, StopLossSetting buyStopLossSetting, StopLossSetting sellStopLossSetting) { var arbitrageId = Guid.NewGuid().ToString(); //無條件捨去至 N 位 //It seems Binance only support max to 6. int roundedNumber = 6; decimal pow = (decimal)Math.Pow(10, roundedNumber); decimal roundedBuyAmounts = Math.Floor(buyAmounts * (pow)) / pow; decimal roundedSellAmounts = Math.Floor(sellAmounts * (pow)) / pow; var buySlipPrice = buyStopLossSetting.GetSlipPrice(buyPrice, baseCurrency, quoteCurrency); var buyOrder = new ArbitrageBuyOrder( Guid.NewGuid().ToString(), buyFrom, baseCurrency, quoteCurrency, buyPrice, roundedBuyAmounts, buySlipPrice ); var sellSlipPrice = sellStopLossSetting.GetSlipPrice(sellPrice, baseCurrency, quoteCurrency); var sellOrder = new ArbitrageSellOrder( Guid.NewGuid().ToString(), sellTo, baseCurrency, quoteCurrency, sellPrice, roundedSellAmounts, sellSlipPrice ); var arbitrageData = ArbitrageData.FromSimpleArbitrageOpened(buyOrder, sellOrder); return(new SimpleArbitrage( arbitrageId, buyOrder, sellOrder, estimatedProfits, arbitrageData, SimpleArbitrageStatus.Opened )); }
public void Update(StopLossSetting stopLossSetting) { _context.Entry(stopLossSetting).State = EntityState.Modified; }
public StopLossSetting Add(StopLossSetting stopLossSetting) { return(_context.StopLossSettings.Add(stopLossSetting).Entity); }