Exemplo n.º 1
0
            protected override State <Config> Run(TradingProvider trading, DataProvider data)
            {
                OrderUpdate buyOrder =
                    trading.ExecuteFullMarketOrderBuy(AlgorithmConfiguration.TradingPairs.First());
                Portfolio portfolio = trading.GetPortfolio();

                _limitSell = trading.PlaceLimitOrderSell(
                    AlgorithmConfiguration.TradingPairs.First(),
                    portfolio.GetAllocation(AlgorithmConfiguration.TradingPairs.First().Left).Free,
                    buyOrder.AverageFilledPrice * AlgorithmConfiguration.TakeProfit);
                SetTimer(TimeSpan.FromHours(AlgorithmConfiguration.StopTime));
                return(new NothingState <Config>());
            }
Exemplo n.º 2
0
            protected override State <Config> Run(TradingProvider trading, DataProvider data)
            {
                decimal allocation = trading.GetPortfolio().GetAllocation(
                    AlgorithmConfiguration.BaseCurrency).Free
                                     *
                                     0.5M
                                     /
                                     data.GetCurrentPriceLastTrade(FirstPair);

                // If the Filter and CrossoverSMA signal the trade, we buy at market.
                trading.ExecuteMarketOrderBuy(FirstPair, allocation);
                if (_stoploss != null)
                {
                    return(new CancelStopState(_stoploss, _pyramid));
                }
                else
                {
                    return(new SetStopState(_pyramid));
                }
            }
Exemplo n.º 3
0
 protected override State <Config> Run(TradingProvider trading, DataProvider data)
 {
     Logger.LogInformation($"Total btc {trading.GetPortfolio().GetAllocation(new Currency("BTC"))}");
     SetTimer(TimeSpan.FromMinutes(AlgorithmConfiguration.WaitTime));
     return(new NothingState <Config>());
 }