private void SmartServerOnAddTick(string symbol, DateTime datetime, double price, double volume, string tradeno, StOrder_Action action) { Trade trade = new Trade(); trade.SecurityNameCode = symbol; trade.Price = Convert.ToDecimal(price); trade.Id = tradeno; trade.Time = datetime; trade.Volume = Convert.ToInt32(volume); if (action == StOrder_Action.StOrder_Action_Buy || action == StOrder_Action.StOrder_Action_Cover) { trade.Side = Side.Buy; } if (action == StOrder_Action.StOrder_Action_Sell || action == StOrder_Action.StOrder_Action_Short) { trade.Side = Side.Sell; } ServerTime = trade.Time; if (NewTradesEvent != null) { NewTradesEvent(trade); } }
public Order(string symbol, int cookie, string orderId, double volume, double filledVolume, double price, double stopPrice, StOrder_Action action, StOrder_Type type) { Symbol = symbol; Cookie = cookie; OrderId = orderId; Volume = (int)volume; FilledVolume = (int)filledVolume; Price = price; StopPrice = stopPrice; Action = Server.ActionCast(action); Type = Server.OrderTypeCast(type); }
private void OnAddTrade(string symbol, DateTime datetime, double price, double volume, string tradeno, StOrder_Action smartAction) { OnAddTrade(symbol, datetime, price, volume, tradeno, ToWrapper(smartAction)); }
private void SmartServerOnUpdateOrder(string portfolio, string symbol, StOrder_State state, StOrder_Action action, StOrder_Type type, StOrder_Validity validity, double price, double amount, double stop, double filled, DateTime datetime, string orderid, string orderno, int statusMask, int cookie, string description) { try { Order order = new Order(); order.NumberUser = cookie; order.NumberMarket = orderno; order.SecurityNameCode = symbol; order.Price = Convert.ToDecimal(price); order.Volume = Convert.ToInt32(amount); order.VolumeExecute = Convert.ToInt32(amount) - Convert.ToInt32(filled); order.NumberUser = cookie; order.Comment = orderid; order.PortfolioNumber = portfolio; if (_ordersWhithId.Find(o => o.Comment == order.Comment) == null) { _ordersWhithId.Add(order); } if (state == StOrder_State.StOrder_State_Open || state == StOrder_State.StOrder_State_Submited) { order.State = OrderStateType.Activ; order.TimeCallBack = datetime; _numsIncomeExecuteOrders.Add(cookie); } if (state == StOrder_State.StOrder_State_Pending) { order.TimeCallBack = datetime; order.State = OrderStateType.Pending; _numsIncomeExecuteOrders.Add(cookie); return; } if (state == StOrder_State.StOrder_State_Cancel || state == StOrder_State.StOrder_State_SystemCancel) { order.TimeCancel = datetime; order.State = OrderStateType.Cancel; _numsIncomeCancelOrders.Add(cookie); _numsIncomeExecuteOrders.Add(cookie); } if (state == StOrder_State.StOrder_State_SystemReject) { order.State = OrderStateType.Fail; order.VolumeExecute = 0; order.TimeCancel = datetime; order.TimeCallBack = datetime; _numsIncomeExecuteOrders.Add(cookie); _numsIncomeCancelOrders.Add(cookie); } if (state == StOrder_State.StOrder_State_Filled) { order.VolumeExecute = order.Volume; order.TimeCallBack = datetime; order.TimeDone = datetime; order.State = OrderStateType.Done; _numsIncomeExecuteOrders.Add(cookie); } if (state == StOrder_State.StOrder_State_Partial) { order.State = OrderStateType.Patrial; order.TimeCallBack = datetime; _numsIncomeExecuteOrders.Add(cookie); } if (action == StOrder_Action.StOrder_Action_Buy || action == StOrder_Action.StOrder_Action_Cover) { order.Side = Side.Buy; } else { order.Side = Side.Sell; } if (type == StOrder_Type.StOrder_Type_Limit) { order.TypeOrder = OrderPriceType.Limit; } else { order.TypeOrder = OrderPriceType.Market; } if (MyOrderEvent != null) { MyOrderEvent(order); } } catch (Exception error) { SendLogMessage(error.ToString(), LogMessageType.Error); } }
private void OnUpdateOrder(string portfolio, string symbol, StOrder_State smartState, StOrder_Action smartAction, StOrder_Type smartType, StOrder_Validity smartValidity, double price, double amount, double stop, double filled, DateTime datetime, string orderid, string orderno, int statusMask, int cookie) { SmartOrderState state; switch (smartState) { case StOrder_State.StOrder_State_ContragentReject: state = SmartOrderState.ContragentReject; break; case StOrder_State.StOrder_State_Submited: state = SmartOrderState.Submited; break; case StOrder_State.StOrder_State_Pending: state = SmartOrderState.Pending; break; case StOrder_State.StOrder_State_Open: state = SmartOrderState.Open; break; case StOrder_State.StOrder_State_Expired: state = SmartOrderState.Expired; break; case StOrder_State.StOrder_State_Cancel: state = SmartOrderState.Cancel; break; case StOrder_State.StOrder_State_Filled: state = SmartOrderState.Filled; break; case StOrder_State.StOrder_State_Partial: state = SmartOrderState.Partial; break; case StOrder_State.StOrder_State_ContragentCancel: state = SmartOrderState.ContragentReject; break; case StOrder_State.StOrder_State_SystemReject: state = SmartOrderState.SystemReject; break; case StOrder_State.StOrder_State_SystemCancel: state = SmartOrderState.SystemCancel; break; default: throw new ArgumentOutOfRangeException(nameof(smartState)); } SmartOrderType type; switch (smartType) { case StOrder_Type.StOrder_Type_Market: type = SmartOrderType.Market; break; case StOrder_Type.StOrder_Type_Limit: type = SmartOrderType.Limit; break; case StOrder_Type.StOrder_Type_Stop: type = SmartOrderType.Stop; break; case StOrder_Type.StOrder_Type_StopLimit: type = SmartOrderType.StopLimit; break; default: throw new ArgumentOutOfRangeException(nameof(smartType)); } SmartOrderValidity validity; switch (smartValidity) { case StOrder_Validity.StOrder_Validity_Day: validity = SmartOrderValidity.Day; break; case StOrder_Validity.StOrder_Validity_Gtc: validity = SmartOrderValidity.Gtc; break; default: throw new ArgumentOutOfRangeException(nameof(smartValidity)); } OnUpdateOrder(portfolio, symbol, state, ToWrapper(smartAction), type, validity, price, amount, stop, filled, datetime, orderid, orderno, statusMask, cookie); }
private void OnAddTradeHistory(int row, int nrows, string symbol, DateTime datetime, double price, double volume, string tradeno, StOrder_Action smartAction) { OnAddTradeHistory(row, nrows, symbol, datetime, price, volume, tradeno, ToWrapper(smartAction)); }
private void OnUpdateOrder(string portfolio, string symbol, StOrder_State state, StOrder_Action action, StOrder_Type type, StOrder_Validity validity, double price, double amount, double stop, double filled, DateTime datetime, string orderId, string orderStockId, int statusMask, int cookie, string description) { ProduceMessage( TopicName.UpdateOrder, JsonSerializer.Serialize( new UpdateOrder { Portfolio = portfolio, Symbol = symbol, State = state, Action = action, Type = type, Validity = validity, Price = price, Amount = amount, PriceStop = stop, FilledVolume = filled, DateTime = datetime, OrderId = orderId, StockOrderId = orderStockId, StatusMask = statusMask, UniqueId = cookie, Error = description } ) ); }
private void stServer_AddTick(string symbol, DateTime dateTime, double price, double volume, string tradeno, StOrder_Action action) { Tick Tick = new Tick { Symbol = symbol, DateTime = dateTime, Price = price, Volume = volume, TradeAction = MakeAction(action) }; this.logger.Log(String.Format("{0:dd/MM/yyyy H:mm:ss.fff}, {1}, получен Tick {2}, {3:dd/MM/yyyy H:mm:ss.fff}, {4}, {5}, {6}, {7}", BrokerDateTime.Make(DateTime.Now), this.GetType().Name, symbol, dateTime, price, volume, tradeno, action)); this.tradingData.Get <ObservableCollection <Tick> >().Add(Tick); }
void scom_SetMyOrder(int row, int nrows, string portfolio, string symbol, StOrder_State state, StOrder_Action action, StOrder_Type type, StOrder_Validity validity , double price, double amount, double stop, double filled, DateTime datetime, string id, string no, int cookie) { allClaims.AddOrderIdAndOrderNo(cookie, amount, action, id, no); string messageInf = DateTime.Now.ToString("HH:mm:ss:fff") + " SetMyOrders " + cookie; if (OnInformation != null) { OnInformation(InfoElement.logfile, messageInf); } }
void scom_AddTick(string symbol, DateTime datetime, double price, double volume, string tradeno, StOrder_Action action) { double v = 0; if (action == StOrder_Action.StOrder_Action_Buy) { v = volume; if (OnAddTick != null) { OnAddTick(datetime, price, volume, ActionGlassItem.buy); } } else if (action == StOrder_Action.StOrder_Action_Sell) { v = -volume; if (OnAddTick != null) { OnAddTick(datetime, price, volume, ActionGlassItem.sell); } } }
private void OnAddTick(string symbol, DateTime datetime, double price, double volume, string tradeno, StOrder_Action action) { lock (tickQueue) { tickQueue.Enqueue(new Tick(symbol, Datatype.LastTradePrice, datetime, price, volume)); } }
public void EmulateTickArrival(string symbol, DateTime date, double price, double volume, StOrder_Action action) { this.AddTick(symbol, date, price, volume, "8888888", action); }
public void PlaceOrder(string portfolio, string symbol, StOrder_Action action, StOrder_Type type, StOrder_Validity validity, double price, double amount, double stop, int cookie) { this.ordersPlaced++; }
private void SmartC_AddTick(string symbol, DateTime datetime, double price, double volume, string tradeno, StOrder_Action action) { SmartWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { } ); if (tablesnames["ticks"] == "") { return; } string a = "0"; switch (action) { case StOrder_Action.StOrder_Action_Buy: a = "1"; break; case StOrder_Action.StOrder_Action_Cover: break; case StOrder_Action.StOrder_Action_Sell: a = "2"; break; case StOrder_Action.StOrder_Action_Short: break; default: break; } new SqlCommand("INSERT INTO [" + tablesnames["ticks"] + "]" + " (dttick, price, volume, tradeno, idaction)" + " VALUES ('" + datetime.ToString() + "', " + price.ToString().Replace(',', '.') + ", " + volume.ToString().Replace(',', '.') + ", '" + tradeno + "', " + a + ")" , sqlconn).ExecuteNonQueryAsync(); }
private void SmartComServerTickAdded(string symbol, DateTime datetime, double price, double volume, string tradeno, StOrder_Action action) { //InformUser(datetime + ": " + symbol + ": " + price + " | " + volume); dbWriter.InsertTrade(symbol, datetime, price, volume); }