Exemplo n.º 1
0
 public ApiManager(EntityManager entityManager, BinanceRestClient binanceRestClient)
 {
     this.entityManager = entityManager;
     exchangeClients    = new Dictionary <string, IExchangeRestClient> {
         { Constant.Binance, binanceRestClient }
     };
 }
Exemplo n.º 2
0
        public static async Task Main(string[] args)
        {
            const string token = "ETHBTC";

            IBinanceRestClient binanceRestClient = new BinanceRestClient(new BinanceClientConfiguration
            {
                ApiKey    = "<your_api_key>",
                SecretKey = "<your_secret_key>"
            });


            var marketDepth = new MarketDepth(token);

            await TestConnection(binanceRestClient);

            marketDepth.MarketDepthChanged += (sender, e) =>
            {
                int n = 20;

                System.Console.Clear();

                System.Console.WriteLine("Price : Volume");
                System.Console.WriteLine(
                    JsonConvert.SerializeObject(
                        new
                {
                    LastUpdate = e.UpdateTime,
                    Asks       = e.Asks.Take(n).Reverse().Select(s => $"{s.Price} : {s.Volume}"),
                    Bids       = e.Bids.Take(n).Select(s => $"{s.Price} : {s.Volume}")
                },
                        Formatting.Indented));

                System.Console.WriteLine("Press Enter to stop streaming market depth...");

                System.Console.SetCursorPosition(0, 0);
            };


            var marketDepthManager = new MarketDepthManager(binanceRestClient, new BinanceWebSocketClient(binanceRestClient, Logger));

            // build order book
            await marketDepthManager.BuildAsync(marketDepth);

            // stream order book updates
            marketDepthManager.StreamUpdates(marketDepth);


            System.Console.WriteLine("Press Enter to exit...");
            System.Console.ReadLine();
        }
Exemplo n.º 3
0
        public static async Task Main(string[] args)
        {
            // set bot settings
            const string token = "ETHBTC";

            IBinanceRestClient binanceRestClient = new BinanceRestClient(new BinanceClientConfiguration
            {
                ApiKey    = "<your_api_key>",
                SecretKey = "<your_secret_key>"
            });

            var strategyConfig = new MarketStrategyConfiguration
            {
                MinOrderVolume             = 1.0M,
                MaxOrderVolume             = 50.0M,
                TradeWhenSpreadGreaterThan = .02M
            };


            // create bot
            IMarketBot bot = new MarketMakerBot(
                token,
                new NaiveMarketMakerStrategy(strategyConfig, Logger),
                binanceRestClient,
                new BinanceWebSocketClient(binanceRestClient, Logger),
                Logger);


            // start bot
            try
            {
                await bot.RunAsync();

                System.Console.WriteLine("Press Enter to stop bot...");
                System.Console.ReadLine();
            }
            finally
            {
                bot.Stop();
            }

            System.Console.WriteLine("Press Enter to exit...");
            System.Console.ReadLine();
        }