public void Save(Data.Asset entity) { try { this.Save(new List <Data.Asset>() { entity }); } catch { throw; } }
public void Insert(Data.Asset entity) { try { if (entity.ID == Guid.Empty) { entity.ID = Guid.NewGuid(); } this.Table.Add(entity); this.SubmitChanges(); } catch { throw; } }
public async Task <object> GetData_Daily(Data.Asset asset, int limit = 500) { try { IAlpacaDataClient data = null; if (!String.IsNullOrWhiteSpace(Settings.API_Alpaca_Live_Key) && !String.IsNullOrWhiteSpace(Settings.API_Alpaca_Live_Secret)) { data = Environments.Live.GetAlpacaDataClient(new SecretKey(Settings.API_Alpaca_Live_Key, Settings.API_Alpaca_Live_Secret)); } else if (!String.IsNullOrWhiteSpace(Settings.API_Alpaca_Paper_Key) && !String.IsNullOrWhiteSpace(Settings.API_Alpaca_Paper_Secret)) { data = Environments.Paper.GetAlpacaDataClient(new SecretKey(Settings.API_Alpaca_Paper_Key, Settings.API_Alpaca_Paper_Secret)); } else { return(new ArgumentNullException()); } // Maximum 1000 bars per API call var bars = await data.GetBarSetAsync(new BarSetRequest(asset.Symbol, TimeFrame.Day) { Limit = limit }); Data.Daily ds = new Data.Daily(); foreach (var bar in bars[asset.Symbol]) { if (bar.TimeUtc != null) { ds.Prices.Add(new Data.Daily.Price() { Date = bar.TimeUtc ?? new DateTime(), Open = bar.Open, High = bar.High, Low = bar.Low, Close = bar.Close, Volume = bar.Volume }); } } return(ds); } catch (Exception ex) { if (ex.Message != "Too Many Requests") // This is handled elsewhere- does not need to be error logged { await Log.Error($"{MethodBase.GetCurrentMethod().DeclaringType}: {MethodBase.GetCurrentMethod().Name}", ex); } return(ex.Message); } }
public void Delete(Data.Asset entity) { try { if (entity == null) { return; } this.Table.Remove(entity); this.SubmitChanges(); } catch { throw; } }
public async Task <object> GetData_Daily(Data.Asset asset, int limit = 500) { string output; output = await RequestData_Daily(asset.Symbol); if (output == "ERROR:INVALID" || output == "ERROR:INVALIDKEY" || output == "ERROR:EXCEEDEDCALLS" || output == "ERROR:EXCEPTION" || output.StartsWith("ERROR:WEBEXCEPTION:")) { return(output); } else { return(await ParseData_Daily(output, limit)); } }
private void BtnEdit_Click(object sender, RoutedEventArgs e) { try { if (DataGrid.SelectedValue == null) { throw new Exception(Localize.ex_no_record_selected); } Data.Asset asset = Business.GetAssetBusiness().GetById((DataGrid.SelectedValue as dynamic).Id); new FrmRegisterAssetEstablishment(asset.ID).ShowDialog(); SetDataGrid(); } catch (Exception ex) { AccountingKernel.Forms.Base.BaseWindow.ShowError(ex); } }
private void btnRegister_Click(object sender, RoutedEventArgs e) { try { var person = Business.GetPayrollPersonBusiness().GetByPPerson_Code(txtPerson.Text); if (person == null) { throw new Exception(Localize.ex_person_not_found); } var assetGood = Business.GetAssetGoodsBusiness().GetByCode(txtAssetGoods.Text); if (assetGood == null) { throw new Exception(Localize.ex_assetgood_not_found); } if (txtAmortizationRate.Text == string.Empty) { throw new Exception(Localize.ex_empty_amortizationrate); } if (cmbAmortizationMethod.SelectedIndex == -1) { throw new Exception(Localize.ex_amortizationmethod_not_selected); } if (txtDecay.Text == string.Empty) { throw new Exception(Localize.ex_empty_decay); } if (txtPrice.Text == string.Empty) { throw new Exception(Localize.ex_empty_price); } if (txtAsset_No.Text == string.Empty) { throw new Exception(Localize.ex_empty_assetno); } if (txtAsset_number.Text == string.Empty) { throw new Exception(Localize.ex_empty_assetnumber); } var asset = new Data.Asset(); if (AssetId.HasValue) { asset = Business.GetAssetBusiness().GetById(AssetId.Value); } asset.Idperson = person.id; asset.Idassetgoods = assetGood.ID; asset.assetdate = dtpAsset.Text; asset.asset_No = txtAsset_No.Text; asset.amortization_Rate = txtAmortizationRate.Text.ToDecimal(); asset.amortization_Method = cmbAmortizationMethod.SelectedValue.ToGUID(); asset.decay_value = txtDecay.Text.ToDecimal(); asset.Price = txtPrice.Text.ToDecimal(); asset.asset_number = txtAsset_number.Text.ToInt(); Business.GetAssetBusiness().Save(asset); this.Close(); } catch { throw; } }