Пример #1
0
        private static async Task TradeReader(ApiTrader api, MarketManager trader)
        {
            while (true)
            {
                try
                {
                    var tradeStream = api.Client.PrivateApi.GetTradeUpdates(new Empty());

                    while (await tradeStream.ResponseStream.MoveNext())
                    {
                        foreach (var trade in tradeStream.ResponseStream.Current.Trades)
                        {
                            Console.WriteLine(
                                $"TRADE: orderId: {trade.OrderId}, size: {trade.BaseVolume}, role: {trade.Role}");
                            await trader.HandleTrade(trade.OrderId, decimal.Parse(trade.BaseVolume));
                        }

                        await trader.PlaceToMarketAsync();
                    }

                    tradeStream.Dispose();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error on stream read:");
                    Console.WriteLine(ex);
                }
            }
        }
Пример #2
0
        static async Task Main(string[] args)
        {
            var key = Environment.GetEnvironmentVariable("HFT_API_KEY");
            var api = new ApiTrader("https://hft-apiv2-grpc.lykke.com", key);

            var trader = new MarketManager(api, "ETHUSD");

            await trader.ResetMarke(350, 0.001m, 1, 50,
                                    0.1m, 4,
                                    0m, 0);

            await trader.PlaceToMarketAsync();

            var tradeReader = TradeReader(api, trader);

            var pulser = Pulser(trader);

            var cmd = Console.ReadLine();

            while (cmd != "exit")
            {
                cmd = Console.ReadLine();
            }
        }