private async Task SyncLimitOrderAsync() { // RemoveListener is here only to override previous ExecutionReport handler. There is no need to use it every time before Listen(). _wsClient.RemoveListener <ExecutionReport>(); var orderLock = new SemaphoreSlim(0, 1); var clOrdId = CommonFuncs.NewClOrdId("limit-1"); var filledQty = "0"; _wsClient.Listen <ExecutionReport>((client, er) => { _logger.LogInformation($"Received execution report1: {er}"); if (er.ExecType == ExecType.Trade && er.ClOrdId == clOrdId) { filledQty = er.LastQty; orderLock.Release(); } return(Task.CompletedTask); }); await _wsClient.NewLimitOrderAsync(clOrdId, "BTC/USDT", Side.Buy, 0.01M, SpotAccountId, 10000).ConfigureAwait(false); // Wait until order is filled await orderLock.WaitAsync().ConfigureAwait(false); _logger.LogInformation($"Order filled for {filledQty}"); }
private async Task OrderMassCancelAsync() { _wsClient.Listen <OrderMassCancelReport>((client, report) => { _logger.LogInformation($"Order mass cancel report: {report}"); return(Task.CompletedTask); }); // cancel orders that will open positions for specific symbol and side await _wsClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-1"), "XBTUSD", Side.Buy, PositionEffect.Open).ConfigureAwait(false); // cancel all orders for specific symbol and side await _wsClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-2"), "XBTUSD", Side.Buy).ConfigureAwait(false); // cancel all orders for specific symbol await _wsClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-3"), "XBTUSD") .ConfigureAwait(false); // cancel all order for account await _wsClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-4")) .ConfigureAwait(false); await Task.Delay(100).ConfigureAwait(false); }
private OperationReturn Follow() { OperationReturn optReturn = new OperationReturn(); optReturn.Result = true; optReturn.Code = Defines.RET_SUCCESS; try { List <UpdateFollow> lstFollows = App.updateInfo.ListFollows; if (lstFollows.Count > 0) { foreach (UpdateFollow item in lstFollows) { switch (item.Key) { case 101: if (App.dicAppInstalled.Keys.Contains(ConstDefines.UMP)) { optReturn = CommonFuncs.StartMAMT(App.dicAppInstalled[ConstDefines.UMP].AppInstallPath); } break; } } } } catch (Exception ex) { return(optReturn); } return(optReturn); }
private async Task TakeProfitForExistingPositionAsync() { var command = OrderExtensions.NewLimitOrder(CommonFuncs.NewClOrdId("stop-order"), "XBTUSD", Side.Sell, 1M, MarginAccountId, 10000); command.ForPosition(12345); await _wsClient.SendCommandAsync(command).ConfigureAwait(false); }
private async Task StopOrderAsync() { await _wsClient.NewStopOrderAsync(CommonFuncs.NewClOrdId("stop-order"), "BTC/USDT", Side.Sell, 0.01M, SpotAccountId, 9500).ConfigureAwait(false); var command = OrderExtensions.NewStopOrder(CommonFuncs.NewClOrdId("stop-order"), "BTC/USDT", Side.Sell, 0.01M, SpotAccountId, 9500); await _wsClient.SendCommandAsync(command).ConfigureAwait(false); }
private async Task MassCancelAsync(CancellationToken cancellationToken) { // cancel orders that will open positions for specific symbol and side var report = await _restClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-1"), "XBTUSD", Side.Buy, PositionEffect.Open).ConfigureAwait(false); _logger.LogInformation($"Order mass cancel report 1: {report}"); // cancel all orders for specific symbol and side report = await _restClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-2"), "XBTUSD", Side.Buy).ConfigureAwait(false); _logger.LogInformation($"Order mass cancel report 2: {report}"); // cancel all orders for specific symbol report = await _restClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-3"), "XBTUSD").ConfigureAwait(false); _logger.LogInformation($"Order mass cancel report 3: {report}"); // cancel all order for account report = await _restClient.OrderMassCancelAsync(MarginAccountId, CommonFuncs.NewClOrdId("mass-cancel-4")) .ConfigureAwait(false); _logger.LogInformation($"Order mass cancel report 4: {report}"); }
private async Task LimitOrderPostOnlyAsync(CancellationToken cancellationToken) { var executionReport = await _restClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit-order"), "BTC/USDT", Side.Buy, 0.01M, SpotAccountId, 10000, execInst : new[] { ExecInst.StayOnOfferSide }, cancellationToken : cancellationToken) .ConfigureAwait(false); HandleOrderReport(executionReport); executionReport = await _restClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit-order"), "BTC/USDT", Side.Buy, 0.01M, SpotAccountId, 10000, execInst : new[] { ExecInst.PegToOfferSide }, cancellationToken : cancellationToken) .ConfigureAwait(false); HandleOrderReport(executionReport); }
/// <summary> /// 确定添加宿舍日常信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { //检查时间 DateTime dtManagementTime = new DateTime(1900, 1, 1); if (txtManagementTime.Text.Trim() != "") { if (!DateTime.TryParse(txtManagementTime.Text.Trim(), out dtManagementTime)) { CommonFuncs.ShowMsg(this.Page, "入住时间格式不正确,请改正"); txtManagementTime.Focus(); return; } } Management man = new Management(); man.dormitoryID = int.Parse(drtxtDorID.SelectedItem.Value); man.Hygiene = droHygiene.SelectedItem.Value; man.Inspectors = ((Administrator)Session["Administrator"]).AdminID; man.ManagementTime = DateTime.Parse(txtManagementTime.Text.Trim()); man.Explain = txtExplains.Text.Trim(); if (new ManagementBLL().InsertManagementBLL(man) == 1) { CommonFuncs.ShowMsg(this.Page, "添加宿舍日常管理信息成功"); } else { CommonFuncs.ShowMsg(this.Page, "添加宿舍日常管理信息失败!\\n\\n请检查各个输入是否合法,\\n宿舍日常管理ID是否已经存在,\\n或者请管理员查看系统日志。"); } }
private async Task SltpGroupAsync(CancellationToken cancellationToken) { var id = CommonFuncs.NewClOrdId("limit-sltp-1"); var command = OrderExtensions.NewLimitOrder(id, "XBTUSD", Side.Sell, 1M, MarginAccountId, 10600); command.AddTrailingStopLoss(500); command.AddTakeProfit(10000); var executionReport = await _restClient.NewOrderAsync(command, cancellationToken).ConfigureAwait(false); HandleOrderReport(executionReport); // OR executionReport = await _restClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit-sltp-2"), "XBTUSD", Side.Sell, 1M, MarginAccountId, 10600, trailingOffset : 500, takeProfitPrice : 10000, cancellationToken : cancellationToken).ConfigureAwait(false); HandleOrderReport(executionReport); }
/// <summary> /// 获得打补丁之前 各个服务的状态 /// </summary> private void GetServiceStatus() { App.dicAllServiceStatus.Clear(); OperationReturn optReturn = null; for (int i = 0; i < App.lstAllServiceNames.Count; i++) { optReturn = CommonFuncs.GetComputerServiceStatus(App.lstAllServiceNames[i]); if (!optReturn.Result) { App.WriteLog("Service " + App.lstAllServiceNames[i] + " not installed"); App.WriteLog(optReturn.Message); } else { ServiceEnty service = optReturn.Data as ServiceEnty; App.dicAllServiceStatus.Add(App.lstAllServiceNames[i], service); switch (service.ServiceStatus) { case (int)ServiceStatusType.Not_Exit: App.WriteLog("Service " + App.lstAllServiceNames[i] + " not installed"); break; case (int)ServiceStatusType.Started: App.WriteLog("Service " + App.lstAllServiceNames[i] + " installed and started"); break; case (int)ServiceStatusType.Stoped: App.WriteLog("Service " + App.lstAllServiceNames[i] + " installed and stoped"); break; } } } }
private async Task CancelOrdersAsync(CancellationToken cancellationToken) { for (var i = 0; i < 3; i++) { var executionReport = await _restClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId($"limit-{i}"), "BTC/USDT", Side.Buy, 0.01M, SpotAccountId, 10000, cancellationToken : cancellationToken) .ConfigureAwait(false); if (executionReport.ExecType != ExecType.NewExec) { continue; } switch (i) { case 0: var cancelResponse1 = await _restClient.CancelOrderByOrderIdAsync( CommonFuncs.NewClOrdId("cancel-1"), executionReport.OrderId, "BTC/USDT", Side.Buy, SpotAccountId, cancellationToken : cancellationToken).ConfigureAwait(false); HandleOrderReport(cancelResponse1); break; case 1: // Actually it is possible to cancel order by client id at any time. No need to wait for ExecutionReport confirmation. var cancelResponse2 = await _restClient.CancelOrderByClOrdIdAsync( CommonFuncs.NewClOrdId("cancel-2"), executionReport.ClOrdId, "BTC/USDT", Side.Buy, SpotAccountId, cancellationToken : cancellationToken).ConfigureAwait(false); HandleOrderReport(cancelResponse2); break; case 2: var cancelCommand = executionReport.ToOrderCancelRequest(CommonFuncs.NewClOrdId("cancel-3")); var cancelResponse3 = await _restClient.CancelOrderAsync(cancelCommand, cancellationToken) .ConfigureAwait(false); HandleOrderReport(cancelResponse3); break; } } }
private async Task CollapsePositionsAsync(CancellationToken cancellationToken) { var report = await _restClient.CollapsePositionsAsync( CommonFuncs.NewClOrdId("collapse"), MarginAccountId, "XBTUSD", cancellationToken).ConfigureAwait(false); _logger.LogInformation($"Position maintenance report: {report}"); }
private async Task TakeProfitForExistingPositionAsync(CancellationToken cancellationToken) { var id = CommonFuncs.NewClOrdId("stop-order"); var command = OrderExtensions.NewLimitOrder(id, "XBTUSD", Side.Sell, 1M, MarginAccountId, 10000); command.ForPosition(12345); var executionReport = await _restClient.NewOrderAsync(command, cancellationToken).ConfigureAwait(false); HandleOrderReport(executionReport); }
private async Task MarketOrderAsync(CancellationToken cancellationToken) { var executionReport = await _restClient.NewMarketOrderAsync( CommonFuncs.NewClOrdId("market-order"), "BTC/USDT", Side.Sell, 0.01M, SpotAccountId, cancellationToken : cancellationToken).ConfigureAwait(false); HandleOrderReport(executionReport); }
private async Task GetAllOrdersAndCancelAsync() { // RemoveListener is here only to override previous ExecutionReport handler. There is no need to use it every time before Listen(). _wsClient.RemoveListener <ExecutionReport>(); ExecutionReport[] orders = null; var ordersReceivedLock = new SemaphoreSlim(0, 1); _wsClient.RemoveListener <OrderMassStatusResponse>(); _wsClient.Listen <OrderMassStatusResponse>((client, response) => { _logger.LogInformation($"Received order mass status response {response.MassStatusReqId} " + $"with {response.ExecutionReports.Count.ToString()} orders"); orders = response.ExecutionReports.ToArray(); ordersReceivedLock.Release(); return(Task.CompletedTask); }); await _wsClient.GetOrdersAndFillsAsync(MarginAccountId, Guid.NewGuid().ToString()).ConfigureAwait(false); await ordersReceivedLock.WaitAsync().ConfigureAwait(false); if (orders.Length == 0) { _logger.LogWarning("No orders to cancel"); return; } var ordersCanceledLock = new SemaphoreSlim(0, 1); var canceledCount = 0; _wsClient.Listen <ExecutionReport>((client, er) => { _logger.LogInformation($"Received ER for {er.ClOrdId}: {er.ExecType}"); if (er.ExecType == ExecType.CanceledExec && orders.Any(o => o.OrderId == er.OrderId)) { if (++canceledCount == orders.Length) { ordersCanceledLock.Release(); } } return(Task.CompletedTask); }); foreach (var order in orders) { await _wsClient.SendCommandAsync(order.ToOrderCancelRequest(CommonFuncs.NewClOrdId("cancel"))).ConfigureAwait(false); } await ordersCanceledLock.WaitAsync().ConfigureAwait(false); }
public object this[string name] { get { var index = CommonFuncs.GetExcelColumnIndex(name); return(this[index]); } set { var index = CommonFuncs.GetExcelColumnIndex(name); this[index] = value; } }
private async Task LimitOrderAsync(CancellationToken cancellationToken) { var executionReport = await _restClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit-order"), "BTC/USDT", Side.Sell, 0.01M, SpotAccountId, 10500, text : "order comment 1", cancellationToken : cancellationToken).ConfigureAwait(false); HandleOrderReport(executionReport); }
static void Main(string[] args) { ILog log = LogManager.GetLogger("MyLog"); try { SelfUpdateHandler updateHandler = new SelfUpdateHandler(log); updateHandler.CleanUpdateFileIfNeeded(args); Configuration conf; DAL dal; if (ConfigurationFileExists()) { log.Info("Loading configuration."); conf = Configuration.DeSerialize(); dal = new DAL(GetDbOfflineFilePath(), conf.Id); } else { dal = new DAL(GetDbOfflineFilePath()); // Exit only when DB is down and no configuration found (meaning - first run). if (dal.IsDbOffline(true)) { throw new Exception("### DB is Offline! ###"); } log.Info("First run - creating configuration."); conf = new Configuration { Id = dal.GenerateClientId() }; Configuration.Serialize(conf); } log.Info("Got ID => " + conf.Id); CommonFuncs.RegisterAtStartup(); new MissionsManager(log, updateHandler, dal, conf).Run(); // Block thread. WaitHandle waitHandle = new AutoResetEvent(false); waitHandle.WaitOne(); } catch (Exception ex) { log.Error(ex); } }
/// <summary> /// 确定增加维修信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { DateTime dtRepairtime = new DateTime(1900, 1, 1); if (txtRepairtime.Text.Trim() != "") { if (!DateTime.TryParse(txtRepairtime.Text.Trim(), out dtRepairtime)) { CommonFuncs.ShowMsg(this.Page, "报修时间格式不正确,请改正"); txtRepairtime.Focus(); return; } } DateTime dtHandletime = new DateTime(1900, 1, 1); if (txtHandletime.Text.Trim() != "") { if (!DateTime.TryParse(txtHandletime.Text.Trim(), out dtHandletime)) { CommonFuncs.ShowMsg(this.Page, "处理时间格式不正确,请改正"); txtHandletime.Focus(); return; } } Repair rep = new Repair(); rep.dormitoryID = int.Parse(drtxtDorID.SelectedItem.Value); rep.RepairPerso = txtRepairPerso.Text.Trim(); rep.RepairName = txtRepairName.Text.Trim(); rep.RepairTime = DateTime.Parse(txtRepairtime.Text.Trim()); rep.HandleTime = DateTime.Parse(txtHandletime.Text.Trim()); rep.Count = int.Parse(txtCount.Text.Trim()); rep.HandlePerso = txtHandlePerso.Text.Trim(); rep.Explain = txtExplains.Text.Trim(); if (new RepairBLL().InsertRepairBLL(rep) == 1) { CommonFuncs.ShowMsg(this.Page, "添加维修信息成功"); } else { CommonFuncs.ShowMsg(this.Page, "添加维修信息失败!\\n\\n请检查各个输入是否合法,\\n维修信息ID是否已经存在,\\n或者请管理员查看系统日志。"); } }
private async Task SltpGroupAsync() { var command = OrderExtensions.NewLimitOrder(CommonFuncs.NewClOrdId("limit-sltp"), "XBTUSD", Side.Sell, 1M, MarginAccountId, 10600); command.AddTrailingStopLoss(500); command.AddTakeProfit(10000); await _wsClient.SendCommandAsync(command).ConfigureAwait(false); await _wsClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit-sltp"), "XBTUSD", Side.Sell, 1M, MarginAccountId, 10600, trailingOffset : 500, takeProfitPrice : 10000).ConfigureAwait(false); }
/// <summary> /// 确定增加来访信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { //来访时间 DateTime dtAccommodationtime = new DateTime(1900, 1, 1); if (txtVisitingTime.Text.Trim() != "") { if (!DateTime.TryParse(txtVisitingTime.Text.Trim(), out dtAccommodationtime)) { CommonFuncs.ShowMsg(this.Page, "来访时间格式不正确,请改正"); txtVisitingTime.Focus(); return; } } //离开时间 DateTime dtleavetime = new DateTime(1900, 1, 1); if (txtLikaiTime.Text.Trim() != "") { if (!DateTime.TryParse(txtLikaiTime.Text.Trim(), out dtleavetime)) { CommonFuncs.ShowMsg(this.Page, "离开时间格式不正确,请改正"); txtLikaiTime.Focus(); return; } } Visiting vi = new Visiting(); vi.dormitoryID = int.Parse(drtxtVist.SelectedItem.Value); vi.VisitingName = txtVisitingName.Text.Trim(); vi.VisitingTime = DateTime.Parse(txtVisitingTime.Text.Trim()); vi.LikaiTime = DateTime.Parse(txtLikaiTime.Text.Trim()); if (new VisitingBLL().InsertVisitingBLL(vi) == 1) { CommonFuncs.ShowMsg(this.Page, "添加来访信息成功"); } else { CommonFuncs.ShowMsg(this.Page, "添加来访信息失败!\\n\\n请检查各个输入是否合法,\\n来访信息ID是否已经存在,\\n或者请管理员查看系统日志。"); } }
/// <summary> /// 结束会话 /// </summary> /// <param name="session"></param> /// <param name="lstParams"> /// lstParams[0] : CookieID /// </param> /// <returns></returns> public static OperationReturn EndCookie(SessionInfo session, List <string> lstParams) { OperationReturn optReturn = new OperationReturn(); try { //LogOperation.WriteLog("End cookie "); string strToken = session.RentInfo.Token; long lCookieID = long.Parse(lstParams[0]); long now = 0; CommonFuncs.DateTimeToNumber(DateTime.Now, ref now); long nowUtc = 0; CommonFuncs.DateTimeToNumber(DateTime.Now.ToUniversalTime(), ref nowUtc); string strSql = string.Empty; switch (session.DBType) { case 2: strSql = "update t_16_001_{0} set C004 = {1} ,C005 = {2} where C001 = {3}"; strSql = string.Format(strSql, strToken, now, nowUtc, lCookieID); optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql); break; case 3: strSql = "update t_16_001_{0} set C004 = {1} ,C005 = {2} where C001 = {3}"; strSql = string.Format(strSql, strToken, now, nowUtc, lCookieID); optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql); break; } if (!optReturn.Result) { //LogOperation.WriteLog("EndCookie failed : " + optReturn.Message); return(optReturn); } optReturn.Result = true; } catch (Exception ex) { //LogOperation.WriteLog("EndCookie exception : " + ex.Message); optReturn.Result = false; } return(optReturn); }
private async Task ReplaceAsync(CancellationToken cancellationToken) { var executionReport = await _restClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit"), "XBTUSD", Side.Buy, 1M, MarginAccountId, 10000, cancellationToken : cancellationToken).ConfigureAwait(false); var replaceCommand = executionReport.ToOrderCancelReplaceRequest(CommonFuncs.NewClOrdId("replace")); replaceCommand.OrderQty = 2M.ToFixString(); var replaceResponse = await _restClient.ReplaceOrderAsync(replaceCommand, cancellationToken) .ConfigureAwait(false); HandleOrderReport(replaceResponse); }
/// <summary> /// 确定添加宿舍 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { Model.Dormitory dor = new Model.Dormitory(); // dor.dormitoryID = int.Parse(txtdormitoryID.Text.Trim()); dor.DormitoryBoos = txtBossName.Text.Trim(); dor.beds = txtbeds.Text.Trim(); dor.ISBN = txtISBN.Text.Trim(); dor.dormitoryPrice = int.Parse(txtPrice.Text.Trim()); dor.dormitoryGrade = txtdormitoryGrade.Text.Trim(); dor.dormitoryPerso = int.Parse(txtPerso.Text.Trim()); dor.Explain = txtExplains.Text.Trim(); if (new DormitoryBLL().InsertDormitoryBLL(dor) == 1) { CommonFuncs.ShowMsg(this.Page, "添加宿舍信息成功"); } else { CommonFuncs.ShowMsg(this.Page, "添加宿舍信息失败!\\n\\n请检查各个输入是否合法,\\n学生ID是否已经存在,\\n或者请管理员查看系统日志。 "); } }
private async Task ReplaceAsync() { // RemoveListener is here only to override previous ExecutionReport handler. There is no need to use it every time before Listen(). _wsClient.RemoveListener <ExecutionReport>(); var clOrdId = CommonFuncs.NewClOrdId("limit"); _wsClient.Listen <ExecutionReport>(async(client, er) => { _logger.LogInformation($"Received ER for {er.ClOrdId}: {er.ExecType}"); if (er.ExecType == ExecType.NewExec && er.ClOrdId == clOrdId) { var command = er.ToOrderCancelReplaceRequest(CommonFuncs.NewClOrdId("replace")); command.OrderQty = 2M.ToFixString(); await client.CancelReplaceOrderAsync(command).ConfigureAwait(false); } }); await _wsClient.NewLimitOrderAsync(clOrdId, "XBTUSD", Side.Buy, 1M, MarginAccountId, 10000).ConfigureAwait(false); }
private async Task InfinitePlaceCancelAsync() { _wsClient.RemoveListener <ExecutionReport>(); _wsClient.RemoveListener <BalanceIncrementalRefresh>(); var placeInterval = TimeSpan.FromMilliseconds(500); _wsClient.Listen <ExecutionReport>(async(client, er) => { _logger.LogInformation($"ER {er.ClOrdId} ExecType {er.ExecType}"); if (er.ExecType != ExecType.NewExec) { return; } var cancelCommand = er.ToOrderCancelRequest(CommonFuncs.NewClOrdId("cancel-order")); try { await client.SendCommandAsync(cancelCommand).ConfigureAwait(false); } catch (Exception ex) { _logger.LogError($"Failed to cancel order {er.ClOrdId}: {ex.Message}"); } }); while (true) { var limitCommand = OrderExtensions.NewLimitOrder(CommonFuncs.NewClOrdId("limit-order"), "BTC/USDT", Side.Sell, 0.01M, SpotAccountId, 10500); try { await _wsClient.SendCommandAsync(limitCommand).ConfigureAwait(false); } catch (Exception ex) { _logger.LogError($"Failed to place limit order: {ex.Message}"); } await Task.Delay(placeInterval).ConfigureAwait(false); } }
private async Task LimitOrderPostOnlyAsync() { await _wsClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit-order"), "BTC/USDT", Side.Buy, 0.01M, SpotAccountId, 10000, execInst : new[] { ExecInst.StayOnOfferSide }) .ConfigureAwait(false); await _wsClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit-order"), "BTC/USDT", Side.Buy, 0.01M, SpotAccountId, 10000, execInst : new[] { ExecInst.PegToOfferSide }) .ConfigureAwait(false); }
private void Application_Exit(object sender, ExitEventArgs e) { if (bIsUpgrageSuccess) { List <string> lstServices = App.lstServicesToStart; if (lstServices.Count > 0) { OperationReturn optReturn = new OperationReturn(); optReturn.Result = true; optReturn.Code = Defines.RET_SUCCESS; for (int i = 0; i < lstServices.Count; i++) { optReturn = CommonFuncs.StartServiceByNmae(lstServices[i]); if (!optReturn.Result) { App.WriteLog("Start service " + lstServices[i] + " failed. " + optReturn.Message); } else { App.WriteLog("Start service " + lstServices[i] + " success. "); } } } } //删掉解压出来的文件 if (Directory.Exists(App.gStrUpdateFolderTempPath)) { try { Directory.Delete(gStrUpdateFolderTempPath, true); } catch (Exception ex) { App.WriteLog("Delete " + gStrUpdateFolderTempPath + " failed. " + ex.Message); } } }
private async Task LimitOrderAsync() { await _wsClient.NewLimitOrderAsync( CommonFuncs.NewClOrdId("limit-order"), "BTC/USDT", Side.Sell, 0.01M, SpotAccountId, 10500, text : "order comment 1") .ConfigureAwait(false); var command = OrderExtensions.NewLimitOrder( CommonFuncs.NewClOrdId("limit-order"), "BTC/USDT", Side.Sell, 0.01M, SpotAccountId, 10500, text: "order comment 2"); await _wsClient.SendCommandAsync(command).ConfigureAwait(false); }
private async Task StopLossForExistingPositionAsync(CancellationToken cancellationToken) { var id = CommonFuncs.NewClOrdId("stop-order-1"); var command = OrderExtensions.NewStopOrder(id, "XBTUSD", Side.Sell, 1M, MarginAccountId, 9500); command.ForPosition(12345); var executionReport = await _restClient.NewOrderAsync(command, cancellationToken).ConfigureAwait(false); HandleOrderReport(executionReport); // OR executionReport = await _restClient.NewStopOrderAsync( CommonFuncs.NewClOrdId("stop-order-2"), "XBTUSD", Side.Sell, 1M, MarginAccountId, 9500, positionId : 12345, cancellationToken : cancellationToken) .ConfigureAwait(false); HandleOrderReport(executionReport); }