public void Broadcast(ClientSocket srcSock) { Parallel.ForEach <ClientSocket>(portMap[srcSock].Clients, (dstSock, loopState) => { if (dstSock.SocketID == srcSock.SocketID) { loopState.Break(); } int mProcessId = GetProcessId(dstSock); if (mProcessId == -1) { loopState.Break(); } System.Net.Sockets.SocketInformation mInfomation = srcSock.cSocket.DuplicateAndClose(mProcessId); ExchangeObject mObject = new ExchangeObject { PackType = (int)Common.ECommand.SocketInfo, SerialNumber = 0, mData = Common.SerializeSocketInfo(mInfomation) }; mObject.PackLength = 12 + mObject.mData.Length; byte[] mBytes = mObject.ToBuffer(); server.SendData(dstSock.SocketID, mBytes); }); Logs.Create("根据映射配置,将" + srcSock.sRemoteIPAndPort.Replace(":", "_") + "的数据群发Broadcast到:" + portMap[srcSock].Clients.Count + "个客户端"); }
private void CloseTrades(int index) { Console.WriteLine("Closing trades........."); for (var iPos = index; iPos >= 0; iPos--) { this.FxStock = (ForexData)this.StockObject.TradeList[iPos]; if (this.FxStock.UnrealizedPL > 0.10m) { if (ExchangeObject.CloseTrade(this.FxStock, this.CurrentAccount.Id)) { this.FxStock.Cost = (this.FxStock.Count * this.FxStock.PriceBuy); this.FxStock.Revenue = (this.FxStock.Count * this.FxStock.PriceSell); this.FxStock.UserName = GetUserConfig(this.FxStock.Symbol).Name; //this.FxStock.ProfitnLoss = this.FxStock.ProfitnLoss + FxStock.FeeSell; Console.WriteLine("Sold " + this.FxStock.Count + " " + this.FxStock.Symbol + " with price " + this.FxStock.PriceSell + " and Profit = " + this.FxStock.ProfitnLoss + " at " + DateTime.Now); if (!dbManager.InsertEntity <ForexData>(this.FxStock)) { Console.WriteLine("Error while writing to DB"); } this.StockObject.TradeList.RemoveAt(iPos); thisAnalyzer.ClearAnalyzer(); } } } Console.WriteLine("...................................."); }
/// <summary> /// //查找上级流转对象逻辑 /// </summary> /// <param name="exchangeObject"></param> /// <param name="placeId"></param> /// <returns></returns> private async Task <CheckBarcodeModel> CheckParent(ExchangeObject exchangeObject, int placeId) { _logger.LogWarning($"循环判断上级流转对象在这有没有箱子"); var checkBarcodeModel = new CheckBarcodeModel(); while (exchangeObject.ParentId != null) { var o = exchangeObject; exchangeObject = await _objectRepository.GetQueryable().Where(a => a.Id == o.ParentId.Value) .FirstOrDefaultAsync(); var exchangeObject1 = exchangeObject; var boxs = await _boxObjectRepository.GetQueryable() .Where(a => a.Box.PlaceId == placeId && a.ExchangeObjectId == exchangeObject1.Id && a.Box.Enabled) .Select(a => a.Box).ToListAsync(); if (boxs.Count > 0) { checkBarcodeModel.Type = EnumCheckBarcodeType.唯一指定; checkBarcodeModel.Record = boxs.Select(a => new CheckedBarcodeRecord { FileCount = 1, Message = "", No = a.Id }).ToList(); return(checkBarcodeModel); } if (exchangeObject.IsVirtual) { return(await CheckVirtualObject(placeId, exchangeObject.Id)); } } return(checkBarcodeModel); }
void DoExitReceiveData(ClientSocket _client, List <byte> mBytesBuffer) { ExchangeObject mObject = new ExchangeObject(); while (mBytesBuffer.Count >= 12) { if (mObject.Format(mBytesBuffer)) { switch ((Common.ECommand)mObject.PackType) { case Common.ECommand.Data: Data data = new Data(); if (mObject.GetStruct <Data>(ref data)) { AddClientReceivePack(_client, data); //_client.SendData(mObject.ToBuffer<Data>(data, Common.ECommand.Data)); } else { Console.WriteLine("解析Data对象错误"); } break; } } else { mBytesBuffer.RemoveAt(0); } } }
private void TriggerQuickBuy(string symbol) { DateTime triggerTime = DateTime.Now; Order orderObject = null; if (this.CurrentAccount.Type == "Long") { orderObject = new Order(this.StockObject.Symbol, 10000, this.CurrentPrice, Constants.OrderAction.BUY, this.OrderType); } else if (this.CurrentAccount.Type == "Short") { orderObject = new Order(this.StockObject.Symbol, 10000, this.CurrentPrice, Constants.OrderAction.SELL, this.OrderType); } if (ExchangeObject.PlaceOrder(orderObject, this.CurrentAccount.Id)) //Service call 7 { if (orderObject.Status == "FILLED") { Console.WriteLine("Quick Buy " + this.CurrentAccount.Type + " -------- " + this.StockObject.Symbol + " at " + this.CurrentPrice.ToString()); } else if (orderObject.Status == "PENDING") { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.PENDING); } else if (orderObject.Status == "CANCELLED") { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.CANCELLED); } } else { Console.WriteLine("Buy more stocks failed - Please check"); } }
private void AddEnoughPositions() { Order orderObject = null; PositionConfig pConfig = null; try { IEnumerable <Quote> quoteList = ExchangeObject.GetQuoteList(null, this.CurrentAccount.Id); //Service call 3 - Initially once and whenever new position added to account based on Max pos count foreach (Quote q in quoteList) { if (!IsSymbolAlreadyAvailable(q.Symbol)) { pConfig = this.GetPositionConfig(q.Symbol); if (pConfig != null) { if (pConfig.InitialUnits > pConfig.MinQuantity) { if (this.CurrentAccount.Type == "Long") { orderObject = new Order(q.Symbol, pConfig.InitialUnits, q.LastBuyTradePrice, Constants.OrderAction.BUY, this.OrderType); } else if (this.CurrentAccount.Type == "Short") { orderObject = new Order(q.Symbol, pConfig.InitialUnits, q.LastSellTradePrice, Constants.OrderAction.SELL, this.OrderType); } if (ExchangeObject.PlaceOrder(orderObject, this.CurrentAccount.Id)) //Service call 4 { if (orderObject.Status == Constants.OrderState.FILLED) { DataAnalyzer dt = new DataAnalyzer(orderObject.Symbol, this.CurrentAccount.Id, this.CurrentAccount.Type); Thread newThread = new Thread(dt.SaveActiveTicker); newThread.Name = "AnalyzerAdd"; newThread.Start(); } else if (orderObject.Status == Constants.OrderState.PENDING) { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.PENDING); } else if (orderObject.Status == Constants.OrderState.CANCELLED) { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.CANCELLED); } if (((OandaAccount)this.CurrentAccount).PositionList.Count >= this.MaxPositionCount) { return; } } } } } } return; } catch (Exception ex) { throw; } }
private void Receive(Socket client) { var exchangeObject = new ExchangeObject { WorkSocket = client }; client.BeginReceive(exchangeObject.Buffer, 0, ExchangeObject.BufferSize, 0, ReceiveCallback, exchangeObject); }
private bool PlaceSellOrder() { bool rtnVal = false; Order orderObject = null; //Need short buy change /*if (this.OrderType == Constants.OrderType.MARKET) * orderObject = new Order(this.StockObject.Symbol, this.StockObject.TotalCount, this.CurrentPrice, Constants.OrderAction.SELL, this.OrderType); * else if (this.StockObject.StrategyData.OrderType == Constants.OrderType.LIMIT) * orderObject = new Order(this.StockObject.Symbol, this.StockObject.TotalCount, this.CurrentPrice, Constants.OrderAction.SELL, this.OrderType);*/ if (this.CurrentAccount.Type == "Long") { orderObject = new Order(this.StockObject.Symbol, this.StockObject.TotalCount, this.CurrentPrice, Constants.OrderAction.SELL, this.OrderType); } else if (this.CurrentAccount.Type == "Short") { orderObject = new Order(this.StockObject.Symbol, (this.StockObject.TotalCount * -1), this.CurrentPrice, Constants.OrderAction.BUY, this.OrderType); } if (ExchangeObject.PlaceOrder(orderObject, this.CurrentAccount.Id)) //Service call 5 { if (orderObject.Status == Constants.OrderState.FILLED) { //Do this in new thread.. this.StockObject.TotalCount = orderObject.Count; this.StockObject.SellPrice = orderObject.Price; this.StockObject.TotalRevenue = (orderObject.Count * orderObject.Price) + orderObject.Brokerage; this.StockObject.TotalSellFee = orderObject.Brokerage; this.StockObject.ProfitnLoss = orderObject.PnL; this.StockObject.ModifiedOn = orderObject.DoneAt; this.StockObject.UserName = GetUserConfig(this.StockObject.Symbol).Name; this.StockObject.Status = Constants.PositionState.CLOSED; if (UpdatePositionsForDataAnalysis()) { DataAnalyzer dt = new DataAnalyzer(orderObject.Symbol, this.CurrentAccount.Id, this.CurrentAccount.Type); Thread newThread = new Thread(dt.CloseActiveTicker); newThread.Name = "AnalyzerAdd"; newThread.Start(); } else { Console.WriteLine("Error while writing to DB"); } rtnVal = true; } else if (orderObject.Status == Constants.OrderState.PENDING) { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.PENDING); } else if (orderObject.Status == Constants.OrderState.CANCELLED) { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.CANCELLED); } } return(rtnVal); }
private static ExchangeObject[] ConfigureExchangeObjects(string[] objects) { ExchangeObject[] xobjs = new ExchangeObject[objects.Length]; for (int i = 0; i < objects.Length; i++) { xobjs[i] = new ExchangeObject(objects[i]); } return(xobjs); }
public void AcceptCallback(IAsyncResult ar) { synchronizer.Set(); var listener = (Socket)ar.AsyncState; Socket handler = listener.EndAccept(ar); var exchange = new ExchangeObject { WorkSocket = handler }; handler.BeginReceive(exchange.Buffer, 0, ExchangeObject.BufferSize, 0, ReadCallback, exchange); }
private void AddMoreStocks() { int count = 0; Order orderObject = null; if (((ForexPosition)this.StockObject).TradeList.Count < this.posConfig.ExtrapolateLevel) { count = Math.Abs(Convert.ToInt32(this.StockObject.TradeList[this.StockObject.TradeList.Count - 1].Count)) + 1; //*************************************************************************************** //Check enough margin available to buy this units decimal margin = ((OandaAccount)this.CurrentAccount).MarginAvailable; decimal expPrice = count * this.CurrentPrice; if (expPrice < margin) { //Need short buy change /* if (this.OrderType == Constants.OrderType.MARKET) * orderObject = new Order(this.StockObject.Symbol, count, this.CurrentPrice, Constants.OrderAction.BUY, this.OrderType); * else if (this.StockObject.StrategyData.OrderType == Constants.OrderType.LIMIT) * orderObject = new Order(this.StockObject.Symbol, count, this.CurrentPrice, Constants.OrderAction.BUY, this.OrderType);*/ if (this.CurrentAccount.Type == "Long") { orderObject = new Order(this.StockObject.Symbol, count, this.CurrentPrice, Constants.OrderAction.BUY, this.OrderType); } else if (this.CurrentAccount.Type == "Short") { orderObject = new Order(this.StockObject.Symbol, count, this.CurrentPrice, Constants.OrderAction.SELL, this.OrderType); } if (ExchangeObject.PlaceOrder(orderObject, CurrentAccount.Id)) //Service call 7 { if (orderObject.Status == "FILLED") { Console.WriteLine("Added More " + this.CurrentAccount.Type + " " + this.StockObject.Symbol + " at " + this.CurrentPrice.ToString()); } else if (orderObject.Status == "PENDING") { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.PENDING); } else if (orderObject.Status == "CANCELLED") { Console.WriteLine(DateTime.Now + " : Order status " + Constants.OrderState.CANCELLED); } } else { Console.WriteLine("Buy more stocks failed - Please check"); } } } }
void client_OnConnectEvent(object sender, ConnectEventArgs args) { SetStatus("连接服务器成功." + client.cSocket.RemoteEndPoint.ToString()); SetConencetStatus(true); //Task.Factory.StartNew(() => //{ int mProcessId = System.Diagnostics.Process.GetCurrentProcess().Id; ExchangeObject mObject = new ExchangeObject(); byte[] mBytes = mObject.ToBuffer <int>(mProcessId, Common.ECommand.Login); ((ClientSocket)sender).SendData(mBytes); Thread.Sleep(100); Send(null); //}); }
public void Send(byte[] data) { Task.Factory.StartNew(() => { int mSleepCount = (new Random((int)DateTime.Now.Ticks)).Next(10); ExchangeObject mObject = new ExchangeObject(); byte[] mBytes = mObject.ToBuffer <Data>(new Data { DataGuid = Guid.NewGuid(), Buffer = data }, Common.ECommand.Data); client.SendData(mBytes); Thread.Sleep(mSleepCount); }); }
private void UpdateAccountDetails() { DataAnalyzer dt = null; ExchangeObject.GetAccountChanges(this.CurrentAccount); //Service call 2 - Every Do-While loop delay thread sleep this.CurrentAccount.Type = GetAccountType(this.CurrentAccount.Id); if (((OandaAccount)this.CurrentAccount).OpenedTradesJson != null) { dt = new DataAnalyzer(string.Empty, this.CurrentAccount.Id, this.CurrentAccount.Type); dt.NewTrades = ((OandaAccount)this.CurrentAccount).OpenedTradesJson; Thread newThread = new Thread(dt.SaveNewTrades); newThread.Name = "AnalyzerExpSave"; newThread.Start(); } }
private void ProcessOffsetTrade() { this.StockObject.TradeList = ExchangeObject.GetOpenTrades(this.StockObject.Symbol, CurrentAccount.Id).ToList(); thisAnalyzer = GetStockAnalyzer(this.StockObject.Symbol); if (this.StockObject.TradeList.Count > 1) { if (thisAnalyzer.OffSetAnalyzer.IsSellOffsetMet) { int previousIndex = thisAnalyzer.OffSetAnalyzer.LastOffsetMetIndex; int currentIndex = GetOffsetIndexStatus(thisAnalyzer.OffSetAnalyzer.LastOffsetMetIndex); if (currentIndex < previousIndex) { this.FxStock = (ForexData)this.StockObject.TradeList[previousIndex]; if (this.FxStock.UnrealizedPL < 0.15m) { CloseTrades(thisAnalyzer.OffSetAnalyzer.LastOffsetMetIndex); } } } else { GetOffsetIndexStatus(0); } this.FxStock = (ForexData)this.StockObject.TradeList[0]; if (thisAnalyzer.OffSetAnalyzer.LastProfitValue > 0.10m) { if (this.FxStock.UnrealizedPL > 0.10m) { decimal diffIndex = thisAnalyzer.OffSetAnalyzer.LastProfitValue - this.FxStock.UnrealizedPL; if (diffIndex > 0.03m) { if (thisAnalyzer.OffSetAnalyzer.OffsetMetDiffIndex > 2 || thisAnalyzer.OffSetAnalyzer.LastTradeTimeDiff.Minutes > 30 || thisAnalyzer.OffSetAnalyzer.LastTradeTimeDiff.Hours >= 1) { CloseTrade(0); } else { thisAnalyzer.OffSetAnalyzer.OffsetMetDiffIndex++; } } } } thisAnalyzer.OffSetAnalyzer.LastProfitValue = this.FxStock.UnrealizedPL; } }
private bool IsReadyToAddMore() { bool rtnVal = false; decimal priceDiff = 0.0m; decimal lastPrice = 0.0m; string type = this.CurrentAccount.Type; if (posConfig.SellMode == Constants.TradeMode.FIXED) { //Need short buy change if (type == "Long") { this.CurrentPrice = ExchangeObject.GetCurrentPrice(this.StockObject.Symbol, Constants.OrderAction.BUY); //Service call 6 - every for loop } else if (type == "Short") { this.CurrentPrice = ExchangeObject.GetCurrentPrice(this.StockObject.Symbol, Constants.OrderAction.SELL); //Service call 6 - every for loop } lastPrice = this.StockObject.TradeList[this.StockObject.TradeList.Count - 1].PriceBuy; //thisAnalyzer = GetStockAnalyzer(this.StockObject.Symbol); //Provision for quick buy when process trade false if (type == "Long") { //if ((CurrentPrice-thisAnalyzer.QuickBuyAnalzer.LastLongPrice) > 0.00100m) //make it as quickbuythreshold in config //{ // //Provision for quick buy when process trade false //} priceDiff = lastPrice - CurrentPrice; } else if (type == "Short") { //if ((thisAnalyzer.QuickBuyAnalzer.LastShortPrice - CurrentPrice) > 0.00100m) //make it as quickbuythreshold in config //{ // //Provision for quick buy process trade false //} priceDiff = CurrentPrice - lastPrice; } if (priceDiff > posConfig.FixedBuyPriceValue) { rtnVal = true; } } else if (posConfig.SellMode == Constants.TradeMode.VARIABLE) { } return(rtnVal); }
private Account GetAccountDetails(string accountId) { Account accountInfo = null; accountInfo = ExchangeObject.GetAccountDetails(accountId); //Service call 1 - Once while starting app for (var iPos = ((OandaAccount)accountInfo).PositionList.Count - 1; iPos >= 0; --iPos) { DataAnalyzer dt = new DataAnalyzer(((OandaAccount)accountInfo).PositionList[iPos].Symbol, accountId, GetAccountType(accountId)); Thread newThread = new Thread(dt.SaveActiveTicker); newThread.Name = "AnalyzerAdd"; newThread.Start(); Console.WriteLine("Bought " + ((OandaAccount)accountInfo).PositionList[iPos].TotalCount + " " + ((OandaAccount)accountInfo).PositionList[iPos].Symbol); } return(accountInfo); }
public override IEnumerable <Quote> GetQuoteList(string[] tickerList, string accountId) { List <TDM_Instrument> instrList = null; List <Quote> result = new List <Quote>(); Quote q = null; if (tickerList == null) { tickerList = this.GetTickerList(); } for (int i = 0; i < tickerList.Length; i++) { instrList = ExchangeObject.GetSymbolPriceList(tickerList[i], DateTime.Now); InstrumentList.Add(tickerList[i], instrList); q = new Quote(); q.Symbol = tickerList[i]; q.LastTradePrice = instrList[0].BuyPrice; result.Add(q); } return(result); }
void client_OnReceiveEvent(object sender, ReceiveDataEventArgs args) { this.Invoke((MethodInvoker)(() => { ExchangeObject mObject = new ExchangeObject(); while (args.client.mBuffers.Count >= 12) { if (mObject.Format(args.client.mBuffers)) { switch ((Common.ECommand)mObject.PackType) { case Common.ECommand.Data: Data data = new Data(); if (mObject.GetStruct <Data>(ref data)) { toolStripStatusLabel1.Text = "收到"; textBox3.Text = Encoding.UTF8.GetString(data.Buffer); ObjectCount++; toolStripStatusLabel3.Text = "来自" + client.cSocket.LocalEndPoint.ToString() + "第" + ObjectCount + "个数据[" + data.DataGuid.ToString("N") + "]"; } else { Console.WriteLine("解析Data对象错误"); } break; case Common.ECommand.SocketInfo: SocketInformation mInfomation = Common.DeserializeSocketInfo(mObject.mData); CreateSocket(mInfomation); break; } } else { args.client.mBuffers.RemoveAt(0); } } })); }
/* It includes methods related to SampleEntity */ #endregion #region Methods public static List <ExchangeRate> GetExchangeRates() { try { HttpWebRequest request = DataService.CreateRequest(DataStatics.DomainForService, DataStatics.UserNameForService, DataStatics.PasswordForService, DataStatics.saportServiceURL(DataStatics.saportServiceGetLatestExchangeRates), true, true, "application/json; charset=UTF-8", "application/json; odata=verbose", "GET"); request.ContentLength = 0; WebResponse response = request.GetResponse(); string responseString = DataService.RestfulReader(response); response.Close(); var serializer = new JavaScriptSerializer(); ExchangeObject exchangeRateObj = serializer.Deserialize <ExchangeObject>(responseString); List <ExchangeRate> exchangeRates = exchangeRateObj.Data; return(exchangeRates); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public void ExchangeTransfer(ClientSocket srcSock, ClientSocket dstSock) { if (dstSock.SocketID == srcSock.SocketID) { return; } int mProcessId = GetProcessId(dstSock); if (mProcessId == -1) { return; } System.Net.Sockets.SocketInformation mInfomation = srcSock.cSocket.DuplicateAndClose(mProcessId); ExchangeObject mObject = new ExchangeObject { PackType = (int)Common.ECommand.SocketInfo, SerialNumber = 0, mData = Common.SerializeSocketInfo(mInfomation) }; mObject.PackLength = 12 + mObject.mData.Length; byte[] mBytes = mObject.ToBuffer(); server.SendData(dstSock.SocketID, mBytes); //Thread.Sleep(100); //ExchangeObject mObject2 = new ExchangeObject(); //byte[] mBytes2 = mObject2.ToBuffer<Data>(new Data //{ // DataGuid = Guid.NewGuid(), // Buffer = null //}, Common.ECommand.Data); //byte[] mBytes2 = mObject2.ToBuffer<int>(mProcessId, Common.ECommand.Login); //server.SendData(dstSock.SocketID, mBytes2); Logs.Create("根据映射配置,将" + srcSock.sRemoteIPAndPort.Replace(":", "_") + "的数据转发ExchangeTransfer到:" + dstSock.sRemoteIPAndPort); }
void server_OnReceiveClientDataEvent(object sender, ReceiveDataEventArgs args) { ExchangeObject mObject = new ExchangeObject(); while (args.client.mBuffers.Count >= 12) { if (mObject.Format(args.client.mBuffers)) { switch ((Common.ECommand)mObject.PackType) { case Common.ECommand.Data: Data data = new Data(); if (mObject.GetStruct <Data>(ref data)) { if (data.Buffer != null) { byte[] dat = mObject.ToBuffer <Data>(data, Common.ECommand.Data); //(sender as SocketServer).SendData(args.client.SocketID, dat);//转发回给源客户端 long id = DataManager.AddData(args.client.sRemoteIPAndPort, data.Buffer); if (id == 0) { Logs.Create("记录中转数据到数据库失败!数据来源[" + args.client.sRemoteIPAndPort + "],数据为[" + Encoding.UTF8.GetString(data.Buffer) + "]"); } } } else { Console.WriteLine("解析Data对象错误"); Logs.Create("解析Data对象错误"); //(sender as SocketServer).CloseClient(args.client.SocketID); } break; case Common.ECommand.Login: int mProcessId = 0; if (mObject.GetStruct <int>(ref mProcessId)) { SetClientProcessId(args.client, mProcessId); //int port = Convert.ToInt32(args.client.sRemoteIPAndPort.Split(':')[1]); foreach (ClientSocket f in portMap.Keys) { foreach (ClientSocket t in portMap[f].Clients) { ExchangeTransfer(f, t); } } } else { Console.WriteLine("解析ProcessId对象错误"); Logs.Create("解析ProcessId对象错误"); //(sender as SocketServer).CloseClient(args.client.SocketID); } break; } } else { Console.WriteLine("对象错误" + args.client.mBuffers.Count.ToString()); args.client.mBuffers.RemoveAt(0); } } }
private void ProcessTrade() { decimal profitVal = 0.0m; if (this.StockObject.TradeList.Count > 1) { for (var iPos = this.StockObject.TradeList.Count - 1; iPos > 0; iPos--) { this.FxStock = (ForexData)this.StockObject.TradeList[iPos]; if (posConfig.TradeProcessProfitMode == Constants.TradeMode.FIXED) { profitVal = posConfig.FixedTradeProcessProfitValue; } else if (posConfig.TradeProcessProfitMode == Constants.TradeMode.VARIABLE) { profitVal = posConfig.FixedTradeProcessProfitValue; } if (this.FxStock.UnrealizedPL >= (profitVal * 6)) //Move this to configuration { Thread newThread = null; //Quick buy 10K number and try closing soon, if soon not closed, enable flag and monitor daily. if (this.CurrentAccount.Type == "Long") { if (QuickBuyLongAccountInfo == null) { QuickBuyLongAccountInfo = GetAccountDetails(GetAccountId("Long")); } newThread = new Thread(() => this.TriggerQuickBuy(this.FxStock.Symbol)); } else if (this.CurrentAccount.Type == "Short") { if (QuickBuyShortAccountInfo == null) { QuickBuyShortAccountInfo = GetAccountDetails(GetAccountId("Short")); } newThread = new Thread(() => this.TriggerQuickBuy(this.FxStock.Symbol)); } newThread.Name = "QuickBuyTragger"; newThread.Start(); } else if (this.FxStock.UnrealizedPL >= profitVal) { if (ExchangeObject.CloseTrade(this.FxStock, this.CurrentAccount.Id)) { this.FxStock.Cost = (this.FxStock.Count * this.FxStock.PriceBuy); this.FxStock.Revenue = (this.FxStock.Count * this.FxStock.PriceSell); this.FxStock.UserName = GetUserConfig(this.FxStock.Symbol).Name; if (!dbManager.InsertEntity <ForexData>(this.FxStock)) { Console.WriteLine("Error while writing to DB"); } this.StockObject.TradeList.RemoveAt(iPos); } } else { break; } } } }
private string[] GetTickerList() { return(ExchangeObject.GetTickerList()); }