public IEnumerable <Transaction> GetAllTransaction() { using (var db = new TradingContext()) { return(db.TransactionHistory.AsEnumerable <Transaction>().ToList()); } }
public IQueryable <Transaction> GetQueryableTransactions() { using (var db = new TradingContext()) { return(db.TransactionHistory); } }
public decimal GetSharePrice(int shareID) { using (var db = new TradingContext()) { return(db.Shares.Where(s => s.ShareID == shareID).FirstOrDefault().Price); } }
public void RecreateCombinationResults() { using (var Context = new TradingContext()) { new CombinationResultsInitalizer().Initalize(Context); } }
public int GetClientShareAmount(int clientID, int shareID) { using (var db = new TradingContext()) { return(db.BlockOfSharesTable.Where(b => b.ShareID == shareID && b.ClientID == clientID).FirstOrDefault().Amount); } }
public IEnumerable <BlockOfShares> GetAllBlockOfShares() { using (var db = new TradingContext()) { return(db.BlockOfSharesTable.OrderBy(b => b.ClientID).AsEnumerable <BlockOfShares>().ToList()); } }
public bool IsClientHasShareType(int clientID, int shareID) { using (var db = new TradingContext()) { return(db.BlockOfSharesTable.Where(b => b.ShareID == shareID && b.ClientID == clientID).FirstOrDefault() != null); } }
public int GetNumberOfShares() { using (var db = new TradingContext()) { return(db.Shares.Count()); } }
public int GetNumberOfClients() { using (var db = new TradingContext()) { return(db.Clients.Count()); } }
public bool IsShareExist(int shareID) { using (var db = new TradingContext()) { return(db.Shares.Where(s => s.ShareID == shareID).FirstOrDefault() != null); } }
public string GetClientName(int clientID) { using (var db = new TradingContext()) { return(db.Clients.Where(c => c.ClientID == clientID).FirstOrDefault().Name); } }
public int GetClientID(string clientName) { using (var db = new TradingContext()) { return(db.Clients.Where(c => c.Name == clientName).FirstOrDefault().ClientID); } }
public bool IsClientExist(int clientID) { using (var db = new TradingContext()) { return(db.Clients.Where(c => c.ClientID == clientID).FirstOrDefault() != null); } }
public IEnumerable <Client> GetAllClients() { using (var db = new TradingContext()) { return(db.Clients.OrderBy(c => c.Name).AsEnumerable <Client>().ToList()); } }
public bool IsShareExist(string shareType) { using (var db = new TradingContext()) { return(db.Shares.Where(c => c.ShareType == shareType).FirstOrDefault() != null); } }
public async Task <TradingContext> Build(ExchangeCode exchangeCode, string symbol) { ITradingStrategy strategy = null; IEnumerable <ICandle> candles = null; return(await WithConnection(async (connection, transaction) => { Strategy strategyInfo = await _strategyManager.Get(exchangeCode, symbol, connection); if (!strategyInfo.IsEnabled) { return null; } Type type = Type.GetType(strategyInfo.TypeName, true, true); strategy = (ITradingStrategy)Activator.CreateInstance(type); // TODO: Add Strategy preset support //strategy.Preset = strategyInfo.Preset; candles = await _candlesManager.GetLastCandles(exchangeCode, symbol, strategy.OptimalTimeframe.Code, strategy.MinNumberOfCandles, connection, transaction); TradingContext context = new TradingContext(exchangeCode, symbol, strategy, candles); return context; })); }
public IEnumerable <Share> GetAllShares() { using (var db = new TradingContext()) { return(db.Shares.OrderBy(s => s.ShareType).AsEnumerable <Share>().ToList()); } }
public IEnumerable <BlockOfShares> GetClientShares(int clientID) { using (var db = new TradingContext()) { return(db.BlockOfSharesTable.Where(b => b.ClientID == clientID).AsEnumerable().ToList()); } }
public decimal GetClientBalance(int clientID) { using (var db = new TradingContext()) { return(db.Clients.Where(c => c.ClientID == clientID).FirstOrDefault().Balance); } }
static void Main(string[] args) { using (var db = new TradingContext()) { var trade = new Trade { Instrument = InstrumentType.Common, Price = 1, Quantity = 200, Side = TradeSide.Buy, Ticker = "KMI", MarkToMarket = 12, TransactionUtc = new DateTime(2016, 11, 10).ToUniversalTime() }; var position = new Position { Ticker = "KMI" }; position.Trades.Add(trade); db.Positions.Add(position); db.SaveChanges(); var query = from p in db.Positions select p; foreach (var p in query) { Console.WriteLine(JsonConvert.SerializeObject(p)); Console.WriteLine(); } Console.ReadLine(); } }
public int GetShareID(string shareType) { using (var db = new TradingContext()) { return(db.Shares.Where(c => c.ShareType == shareType).FirstOrDefault().ShareID); } }
public string GetShareType(int shareID) { using (var db = new TradingContext()) { return(db.Shares.Where(s => s.ShareID == shareID).FirstOrDefault().ShareType); } }
public bool IsClientExist(string clientName) { using (var db = new TradingContext()) { return(db.Clients.Where(c => c.Name == clientName).FirstOrDefault() != null); } }
static void Main(string[] args) { using (TradingContext context = new TradingContext()) { dataBase = context; ordersContoller = new OrdersContoller(); if (dataBase.traders.ToList().Count == 0) { InitializeDb(); } else { player = dataBase.traders.First(tr => tr.name == "Player"); } MainForm form = new MainForm(); form.ShowDialog(); // Application.Run(); } }
public void Insert(BlockOfShares blockOfShares) { using (var db = new TradingContext()) { db.BlockOfSharesTable.Add(blockOfShares); db.SaveChanges(); } }
public void Insert(Transaction transaction) { using (var db = new TradingContext()) { db.TransactionHistory.Add(transaction); db.SaveChanges(); } }
public void Remove(Client client) { using (var db = new TradingContext()) { var clientToDelete = db.Clients.Where(c => c.Name == client.Name).FirstOrDefault(); db.Clients.Remove(clientToDelete); db.SaveChanges(); } }
public bool Insert(Share share) { using (var db = new TradingContext()) { db.Shares.Add(share); db.SaveChanges(); return(true); } }
public bool Insert(Client client) { using (var db = new TradingContext()) { db.Clients.Add(client); db.SaveChanges(); return(true); } }
public static void ImportFromBorsaItaliana(string startFrom) { List <string> tickers = getTickers(startFrom); int index = 0; var borsaItalianaService = new BorsaItalianaService(); foreach (var ticker in tickers) { var quote = borsaItalianaService.GetDailyQuotesLastThreeMonths(ticker); quote = GetEndOfMonthQuotes(quote); if (quote.Any()) { using (var context = new TradingContext()) { var quoteEsistenti = context.Quote.Where(q => q.Ticker == ticker).ToList(); foreach (var quota in quote) { var quotaEsistente = quoteEsistenti.SingleOrDefault(q => q.Data.ToString("MMyyyy") == quota.Data.ToString("MMyyyy")); if (quotaEsistente == null) { context.Quote.Add(quota); } else if (quotaEsistente.Chiusura != quota.Chiusura || quotaEsistente.Volumi != quota.Volumi) { context.Update(quotaEsistente); quotaEsistente.Chiusura = quota.Chiusura; quotaEsistente.Volumi = quota.Volumi; } } var records = context.SaveChanges(); Console.WriteLine($"{++index} {ticker}: {records} record(s) affected"); } } else { Console.WriteLine($"{++index} {ticker}: ERROR no data returned from web service"); } } using (var context = new TradingContext()) { var etfService = new EtfService(null, new EtfRepository(context)); var counter = etfService.AggiornaQuoteMeseSuccessivo(); Console.WriteLine($"Quote mese successivo: {counter} record(s) affected"); var portfolioService = new PortfolioService(borsaItalianaService, null, null, new PortfolioRepository(context)); counter = portfolioService.AggiornaQuotePortfolio(); Console.WriteLine($"Quote portafoglio: {counter} record(s) affected"); } Console.WriteLine("Done!"); }