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 BittrexTradeManager(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)); } }
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 BittrexTradeManager(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); } }