Ejemplo n.º 1
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = "orders")] HttpRequestMessage req, TraceWriter log)
        {
            try
            {
                //read json object from request body
                var content     = req.Content;
                var jsonContent = content.ReadAsStringAsync().Result;
                var order       = JsonConvert.DeserializeObject <TradeDto>(jsonContent);

                var tradeTable = await ConnectionManager.GetTableConnection(Constants.OrderTableName, Constants.IsDryRunning);

                var activeTrade = tradeTable.CreateQuery <Trade>().Where(x => x.RowKey == order.Uuid).FirstOrDefault();

                // Directly sell it off.
                var tradeManager = new GenericTradeManager(new BittrexApi(Constants.IsDryRunning), null, new PushNotificationManager(), (a) => log.Info(a));
                await tradeManager.DirectSell(activeTrade);

                tradeTable.Execute(TableOperation.Replace(activeTrade));

                return(req.CreateResponse(HttpStatusCode.OK, true));
            }
            catch (Exception ex)
            {
                return(req.CreateResponse(HttpStatusCode.OK, false));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called by the <see cref="IScheduler" /> when a
        /// <see cref="ITrigger" /> fires that is associated with
        /// the <see cref="IJob" />.
        /// </summary>
        public virtual Task Execute(IJobExecutionContext context)
        {
            log.Info($"Ready to shuffle your g0ldz!");

            // Call the Bittrex Trade manager with the strategy of our choosing.
            var manager = new GenericTradeManager(new BittrexApi(), new BigThree(), null, (a) => log.Info(a));

            // Call the process method to start processing the current situation.
            manager.CheckStrategySignals().GetAwaiter().GetResult();

            return(Task.FromResult(true));
        }
Ejemplo n.º 3
0
        public static async Task Run([TimerTrigger("10 0 * * * *")] TimerInfo myTimer, TraceWriter log)
        {
            try
            {
                log.Info("Starting processing...");

                // Call the Bittrex Trade manager with the strategy of our choosing.
                var manager = new GenericTradeManager(new BittrexApi(Constants.IsDryRunning), new BigThree(), new PushNotificationManager(), (a) => log.Info(a));

                // Call the process method to start processing the current situation.
                await manager.Process();
            }
            catch (Exception ex)
            {
                // If anything goes wrong log an error to Azure.
                log.Error(ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 4
0
        public static async Task Run([TimerTrigger("0 * * * * *")] TimerInfo myTimer, TraceWriter log)
        {
            try
            {
                log.Info("Starting processing...");

                // Call the Bittrex Trade manager with the strategy of our choosing.
                var manager = new GenericTradeManager(
                    new BinanceApi(),
                    new TheScalper(),
                    null, (a) => log.Info(a)
                    );

                // Call the process method to start processing the current situation.
                await manager.UpdateRunningTrades();

                log.Info("Done...");
            }
            catch (Exception ex)
            {
                // If anything goes wrong log an error to Azure.
                log.Error(ex.Message + ex.StackTrace);
            }
        }