public void Buy2330ByFuture()//下跌買進2330 { Future.FuturePossibility Fp = new Future.FuturePossibility(); BuyAndSell BuySell = new BuyAndSell(); company = "2330"; GetData(); Fp.startDate = this.startDate; Fp.endDate = this.endDate; Fp.getData(); bool HasBuy = false; double AccDrop = 0; double AccRise = 0; double countDrop = 0; double countRise = 0; double stCountRise = 3; for (int i = 0; i < ClosePrice.Count; i++) { if (double.Parse(RewardRatio[i][1]) < 0) { AccDrop += double.Parse(RewardRatio[i][1]); AccRise = 0; countDrop++; countRise = 0; } else if (double.Parse(RewardRatio[i][1]) > 0) { AccDrop = 0; AccRise = double.Parse(RewardRatio[i][1]); countRise++; countDrop = 0; } if (AccRise > 5) { stCountRise++; } if (HasBuy && (AccDrop < 0 || countRise == stCountRise)) { stCountRise = 3; sp.SellStock(2330, double.Parse(ClosePrice[i][1]), ClosePrice[i][0]); HasBuy = false; } if ((AccDrop < -3.5 || countDrop == 3) && !HasBuy) { sp.BuyStock(2330, double.Parse(ClosePrice[i][1]), ClosePrice[i][0]); AccDrop = 0; HasBuy = true; } } double poss = 0; sp.ProfitAndLoss(ref poss); }
async void sellListView_ItemTapped(object sender, ItemTappedEventArgs e) { BuyAndSell bs = (BuyAndSell)e.Item; await Navigation.PushAsync(new DetailSellP(bs, this)); //Navigation.RemovePage(this); ((ListView)sender).SelectedItem = null; }
public DetailBuyP(BuyAndSell bs, Page page) { InitializeComponent(); bsGlobal = bs; this.page = page; Title = "Detalle de la Compra"; productName.Text = bsGlobal.ProductName; factura.Text = bsGlobal.Factura.ToString(); dateProduct.Text = bsGlobal.Date.Month + "/" + bsGlobal.Date.Day + "/" + bsGlobal.Date.Year; double t = bsGlobal.Price; neto.Text = Utilities.GetNeto(t); iva.Text = Utilities.GetIva(t); total.Text = Utilities.GetTotal(t); eliminarButton.Clicked += eliminarButton_Clicked; }
public async void okButton_Clicked(object sender, EventArgs e) { if (string.IsNullOrEmpty(priceEntry.Text)) { await DisplayAlert("Error", "Debe ingresar un monto", "Aceptar"); priceEntry.Focus(); } else { int facturaTemp = 0; if (!string.IsNullOrEmpty(facturaEntry.Text)) { facturaTemp = Int32.Parse(facturaEntry.Text); } BuyAndSell bs = new BuyAndSell { Price = Double.Parse(priceEntry.Text), Date = dateEntry.Date, isBuy = true, ProductName = nameEntry.Text.Replace("\n", ""), Factura = facturaTemp, User = Utilities.usuario }; using (var databse = new BuyAndSellDatabase()) { databse.InsertBuySell(bs); //limpia los campos facturaEntry.Text = ""; nameEntry.Text = ""; priceEntry.Text = ""; await Navigation.PushAsync(new ResumeBuysP()); Navigation.RemovePage(page); Navigation.RemovePage(this); } } }