public static int BrokerLogin(string user, string pwd, string type, StringBuilder accounts) { oAurhConfiguration = new SpotwareConnectConfiguration(); oAuthClient = new SpotwareConnectClient(oAurhConfiguration); accessToken = GetToken(); connected = accessToken != null; if (connected) { accountsAPI = new AccountsAPI(ACCOUNTS_API_HOST_URL, accessToken); tradingAccounts = accountsAPI.getTradingAccounts(); foreach (TradingAccountJson account in tradingAccounts) { if (accounts.Length > 0) { accounts.Append('\0'); } accounts.Append(account.AccountId); } return(1); } return(0); }
public static void Start() { AccountsAPI accountsAPI = new AccountsAPI(); Boolean toPostMasterData = Convert.ToBoolean(ConfigurationManager.AppSettings["PostMasterData"].ToString()); if (toPostMasterData) { //string currenttime = Util.Util.GetServerDateTime().ToString("dd-MMM-yyy HH:mm:ss.fff"); Logger.WriteLog("Master Data Started..."); try { accountsAPI.Main(); } catch (Exception ex) { Logger.WriteLog("Exception in Master Data: " + ex.Message); } Logger.WriteLog("Master Data Ended..."); } Logger.WriteLog("Started1..."); Boolean toPostTransactionData = Convert.ToBoolean(ConfigurationManager.AppSettings["PostTransactionData"].ToString()); if (toPostTransactionData) { Boolean toPostBookedAgentVouchers = Convert.ToBoolean(ConfigurationManager.AppSettings["PostBookedAgentVouchers"].ToString()); if (toPostBookedAgentVouchers) { Logger.WriteLog("Konduskar Booked Agent Vouchers Started..."); try { accountsAPI.PostAgentVouchers(); } catch (Exception ex) { Logger.WriteLog("Konduskar Exception in Booked Agent Vouchers: " + ex.Message); } Logger.WriteLog("Konduskar Agent Vouchers Ended..."); } Boolean toPostBookedAgentVouchersUpdate = Convert.ToBoolean(ConfigurationManager.AppSettings["PostBookedAgentVouchersUpdate"].ToString()); if (toPostBookedAgentVouchersUpdate) { Logger.WriteLog("Konduskar Booked Agent Vouchers Update Started..."); try { accountsAPI.UpdateAgentVouchers(); } catch (Exception ex) { Logger.WriteLog("Konduskar Exception in Booked Agent Vouchers Updation: " + ex.Message); } Logger.WriteLog("Konduskar Agent Vouchers Update Ended..."); } Boolean toPostCancelledAgentVouchers = Convert.ToBoolean(ConfigurationManager.AppSettings["PostCancelledAgentVouchers"].ToString()); if (toPostCancelledAgentVouchers) { Logger.WriteLog("Konduskar Cancelled Agent Vouchers Credit Note Started..."); try { accountsAPI.PostAgentVouchersCancellation(); } catch (Exception ex) { Logger.WriteLog("Konduskar Exception in Cancelled Agent Vouchers Credit Note: " + ex.Message); } Logger.WriteLog("Konduskar Agent Vouchers Cancelletion Ended..."); } Boolean toPostBranchBookings = Convert.ToBoolean(ConfigurationManager.AppSettings["PostBranchBookings"].ToString()); if (toPostBranchBookings) { Logger.WriteLog("konduskar Bookings Started..."); try { accountsAPI.PostBranchSalesEntry(); } catch (Exception ex) { Logger.WriteLog("Exception in Bookings_konduskar: " + ex.Message); } Logger.WriteLog("konduskar Bookings Ended..."); } Boolean toPostBranchBookingsUpdate = Convert.ToBoolean(ConfigurationManager.AppSettings["PostBranchBookingsUpdate"].ToString()); if (toPostBranchBookingsUpdate) { Logger.WriteLog("konduskar Bookings Updation Started..."); try { accountsAPI.UpdateBranchSalesEntry(); } catch (Exception ex) { Logger.WriteLog("Exception in Bookings_konduskar Updation: " + ex.Message); } Logger.WriteLog("konduskar Bookings Updation Ended..."); } Boolean toPostBranchCancellation = Convert.ToBoolean(ConfigurationManager.AppSettings["PostBranchCancellation"].ToString()); if (toPostBranchCancellation) { Logger.WriteLog("konduskar Branch Cancellation Started..."); try { accountsAPI.PostBranchRefundReceiptEntry(); } catch (Exception ex) { Logger.WriteLog("Exception in Cancellations_konduskar: " + ex.Message); } Logger.WriteLog("konduskar Cancellation Ended..."); } Boolean toPostBookedFranchiseVouchers = Convert.ToBoolean(ConfigurationManager.AppSettings["PostBookedFranchiseVouchers"].ToString()); if (toPostBookedFranchiseVouchers) { Logger.WriteLog("Konduskar Booked Franchise Vouchers Started..."); try { accountsAPI.PostFranchiseVouchers(); } catch (Exception ex) { Logger.WriteLog("Konduskar Exception in Booked Franchise Vouchers: " + ex.Message); } Logger.WriteLog("Konduskar Franchise Vouchers Ended..."); } Boolean toCheckQBConnection = Convert.ToBoolean(ConfigurationManager.AppSettings["CheckQBConnection"].ToString()); if (toCheckQBConnection) { Logger.WriteLog("Check Qb Posting..."); try { accountsAPI.CheckPostingInQB(); } catch (Exception ex) { Logger.WriteLog("Check Qb Posting: " + ex.Message); } Logger.WriteLog("Check Qb Posting..."); } } }
public MainPage() { this.plotView = createChartPanel(); this.buyButton = new TradingButton("Buy"); this.sellButton = new TradingButton("Sell"); this.Content = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Children = { createTopPanel(), this.plotView, createBottomPanel() } }; // Using messaging center to ensure that content only gets loaded once authentication is successful. // Once Xamarin.Forms adds more support for view life cycle events, this kind of thing won't be as necessary. // The OnAppearing() and OnDisappearing() overrides just don't quite cut the mustard yet, nor do the Appearing and Disappearing delegates. MessagingCenter.Subscribe <App> (this, "Authenticated", (sender) => { accountsAPI = new AccountsAPI(App.ACCOUNTS_API_HOST_URL, App.Instance.Token); tradingAPI = new TradingAPI(App.TRADING_API_HOST, App.TRADING_API_PORT, App.Instance.Token, App.CLIENT_ID, App.CLIENT_SECRET); fillAccounts(); fillSymbols(); refreshPlotView(); tradingAPI.Start(); tradingAPI.ExecutionEvent += (executionEvent) => { Device.BeginInvokeOnMainThread(() => { String filledTitle = "Order Filled at {0}"; String filledMessage = "Your request to {0} {1} of {2} was filled at VWAP {3}"; if (executionEvent.executionType == ProtoOAExecutionType.OA_ORDER_FILLED) { ProtoOAOrder order = executionEvent.order; string title = String.Format(filledTitle, order.executionPrice); string message = String.Format(filledMessage, order.tradeSide, order.requestedVolume / 100, order.symbolName, order.executionPrice); DisplayAlert(title, message, "Close"); } }); }; tradingAPI.SpotEvent += (spotEvent) => { if (spotEvent.symbolName.Equals(currentSymbol.SymbolName)) { if (spotEvent.askPriceSpecified) { LineAnnotation annotation = (LineAnnotation)plotView.Model.Annotations[0]; annotation.Y = spotEvent.askPrice; annotation.Text = spotEvent.askPrice.ToString(); } Device.BeginInvokeOnMainThread(() => { if (spotEvent.askPriceSpecified) { buyButton.setPrice(spotEvent.askPrice); plotView.Model.InvalidatePlot(true); } if (spotEvent.bidPriceSpecified) { sellButton.setPrice(spotEvent.bidPrice); } }); } }; tradingAPI.SendSubscribeForTradingEventsRequest(currentTradingAccount.AccountId); tradingAPI.SendSubscribeForSpotsRequest(currentTradingAccount.AccountId, currentSymbol.SymbolName); }); }