private bool Compare(IExchange exchange1, IExchange exchange2)
        {
            var quote1 = exchange1.GetLastQuote();
            var quote2 = exchange2.GetLastQuote();

            if (quote1 == null || quote2 == null)
                return false;

            if (quote1.Bid <= quote2.Ask)
                return false;

            #region -- Prepare --

            string desc = string.Format("Arb detected, buy {1} sell {0}", quote1.SourceExchange, quote2.SourceExchange);
            Console.WriteLine(desc);

            decimal qty = 1; //Determine this based on how much cash is left

            #endregion

            #region -- Execution --

            var trade = new Trade(desc);

            /*
            trade.Transactions.Add(new MarketOrderBuyBTCTransaction(exchange1, qty, quote1.Bid));
            trade.Transactions.Add(new MarketOrderSellBTCTransaction(exchange2, qty, quote1.Bid));
            */
            //notificationEngine.TradeSignal(quote1, quote2);
            notificationEngine.TradeSignal(trade);

            #endregion

            return true;
        }
Beispiel #2
0
        public void TradeSignal(Trade trade)
        {
            string subject = string.Format("Botcoin - Trade signal");

            string table = "";

            foreach (var transaction in trade.Transactions)
            {
                table += string.Format(
            @"
            <tr>
            <td>
            {0}
            </td>
            <td>
            </td>
            </tr>
            ",
             transaction.ToString()
                    );
            }

            string body = string.Format(
            @"
            Botcoin trade signal: {0}</b>!<br>
            <br>

            <table>
            <tr>
            <th>Trade</th>
            <th></th>
            </tr>
            {1}
            </table>
            "
            , table
            );

            smtpProvider.Send(subject, body);
        }
        private bool Compare(CurrencyWalletPair exchange1, CurrencyWalletPair exchange2)
        {
            var quote1 = exchange1.LastTick();
            var quote2 = exchange2.LastTick();

            if (quote1 == null || quote2 == null)
                return false;

            string desc = string.Format("Arb detected, buy {1} sell {0}", quote1.SourceExchange, quote2.SourceExchange);

            CurrencyWalletPair ltcRebalance = new CurrencyWalletPair(exchange1.destinationWallet, exchange2.destinationWallet
                , dataStore);
            CurrencyWalletPair btcRebalance = new CurrencyWalletPair(exchange1.sourceWallet, exchange2.sourceWallet
                , dataStore);

            #region -- Execution --

            var trade = new Trade(desc);

            trade.Transactions.Add(new Transaction(exchange1));
            trade.Transactions.Add(new Transaction(exchange2));
            trade.Transactions.Add(new Transaction(ltcRebalance));
            trade.Transactions.Add(new Transaction(btcRebalance));

            var result = trade.Execute(1);

            if (result <= 1)
                return false; //Loses money

            //notificationEngine.TradeSignal(quote1, quote2);
            notificationEngine.TradeSignal(trade);

            #endregion

            return true;
        }
 public void TradeSignal(Shared.Models.Trade trade)
 {
     //DO nothing, used for debugging without spamming the recipients
 }