Exemplo n.º 1
0
        private void autobidButton_Click(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("Autobid Button Clicked ");
            Console.WriteLine("Configuration.getValue(test): " + Configuration.getValue("Configuration/Account/Branch"));
            OrderManager.Rules rules = new OrderManager.Rules();
            rules.MinTotalBidSizeTenCent       = Convert.ToInt32(minTotalBidSizeTenCentTextBox.Text);
            rules.MinTotalBidSizeFiveCent      = Convert.ToInt32(minTotalBidSizeFiveCentTextBox.Text);
            rules.MaxAskSizeBuyTriggerFiveCent = Convert.ToInt32(maxAskSizeBuyFiveCentTriggerTextBox.Text);
            rules.MaxAskSizeBuyTriggerTenCent  = Convert.ToInt32(maxAskSizeBuyTenCentTriggerTextBox.Text);
            rules.MaxAskPrice            = Convert.ToDouble(maxAskPriceTextBox.Text);
            rules.MinCoreExchangeBidSize = Convert.ToInt32(MinCoreExchangeBidSizeTextBox.Text);
            orderManager.rules           = rules;

            orderManager.AddWriteLineListeners(Terminal.OnWriteLine);
            Terminal.Clear();
            OrderDirections directions = new OrderDirections();
            XmlDataProvider xml        = (XmlDataProvider)FindName("Rule");

            Simulated            = Convert.ToBoolean(xml.Document.SelectSingleNode("Rule/Simulated").InnerText);
            directions.Simulated = Simulated;
            directions.Symbol    = optionSymbolComboBox.Text;
            directions.Route     = routeComboBox.Text;
            directions.Size      = Convert.ToInt32(sizeTextBox.Text);
            directions.Box       = boxCheckBox.IsChecked.Value;
            directions.Cbo       = cboCheckBox.IsChecked.Value;
            directions.Ise       = iseCheckBox.IsChecked.Value;
            directions.Ase       = aseCheckBox.IsChecked.Value;
            directions.Phs       = phsCheckBox.IsChecked.Value;

            orderManager.autobid(directions);

            orderManager.AutobidStatusListeners += UpdateTableStatus;
            recentSymbols.Add(optionSymbolComboBox.Text);
            optionSymbolComboBox.Items.Refresh();
        }
Exemplo n.º 2
0
        public static string ParseDirections(string result)
        {
            OrderDirections od = new OrderDirections();
            int             k  = 0;

            dynamic obj   = JsonConvert.DeserializeObject(result);
            dynamic route = obj.routes[0];

            for (int i = 0; i < route.legs.Count; i++)
            {
                dynamic leg = route.legs[i];
                for (int j = 0; j < leg.steps.Count; j++)
                {
                    Directions dir = new Directions(k, (leg.steps[j].end_location.lat).ToString(), (leg.steps[j].end_location.lng).ToString());
                    od.list.Add(dir);
                    if (od.next_id == -1)
                    {
                        od.next_id = k;
                    }
                    k++;
                }
            }

            return(JsonConvert.SerializeObject(od));
        }
        private Money?CalculateLimit(
            EquityInstrumentIntraDayTimeBar tick,
            OrderDirections buyOrSell,
            OrderTypes tradeOrderType)
        {
            if (tradeOrderType != OrderTypes.LIMIT)
            {
                return(null);
            }

            if (buyOrSell == OrderDirections.BUY)
            {
                var price         = (decimal)Normal.Sample((double)tick.SpreadTimeBar.Bid.Value, this._limitStandardDeviation);
                var adjustedPrice = Math.Max(0, Math.Round(price, 2));

                return(new Money(adjustedPrice, tick.SpreadTimeBar.Bid.Currency));
            }

            if (buyOrSell == OrderDirections.SELL)
            {
                var price         = (decimal)Normal.Sample((double)tick.SpreadTimeBar.Ask.Value, this._limitStandardDeviation);
                var adjustedPrice = Math.Max(0, Math.Round(price, 2));

                return(new Money(adjustedPrice, tick.SpreadTimeBar.Ask.Currency));
            }

            return(null);
        }
Exemplo n.º 4
0
        public static string UpdateNextLoc(string directions)
        {
            OrderDirections obj = JsonConvert.DeserializeObject <OrderDirections>(directions);

            obj.last_id = obj.next_id;
            obj.next_id++;
            return(JsonConvert.SerializeObject(obj));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the order direction in string format.
        /// </summary>
        /// <param name="Dir">The order direction.</param>
        /// <returns>The order direction in string format</returns>
        private string _GetOrderDirection(OrderDirections Dir)
        {
            switch (Dir)
            {
            case OrderDirections.Asc:
                return("ASC");

            case OrderDirections.Desc:
                return("DESC");

            default:
                return("ASC");
            }
        }
Exemplo n.º 6
0
        public static DbGeography GetNextLoc(string directions)
        {
            OrderDirections obj = JsonConvert.DeserializeObject <OrderDirections>(directions);

            if (obj.last_id == obj.list.Count)
            {
                return(null);
            }
            else
            {
                string      lat   = obj.list.Where(x => x.id == obj.next_id).First().lat;
                string      lon   = obj.list.Where(x => x.id == obj.next_id).First().lon;
                var         point = string.Format("POINT({1} {0})", lat, lon);
                DbGeography loc   = DbGeography.FromText(point);

                return(loc);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Adds an expression/s to the ORDER BY clause.
 /// </summary>
 /// <param name="Direction">The order direction of the expression/s.</param>
 /// <param name="Expressions">The expression to be ordered.</param>
 /// <returns>The current instance of this class.</returns>
 public SelectCountQuery SetOrderBy(OrderDirections Direction, params string[] Expressions)
 {
     if (Expressions != null & Expressions.Length > 0)
     {
         List <string> lstExpression = new List <string>();
         foreach (var strExpression in Expressions)
         {
             if (strExpression.IsNullOrWhiteSpace())
             {
                 continue;
             }
             lstExpression.Add(this._EncloseBackTick(strExpression));
         }
         if (lstExpression.Count > 0)
         {
             this._Orders.Add(String.Format("{0} {1}", String.Join(", ", lstExpression.ToArray()), this._GetOrderDirection(Direction)));
         }
     }
     return(this);
 }
 /// <summary>
 /// Adds an expression/s to the ORDER BY clause.
 /// </summary>
 /// <param name="Direction">The order direction of the expression/s.</param>
 /// <param name="Expressions">The expression to be ordered.</param>
 /// <returns>The current instance of this class.</returns>
 public OracleSqlBuilderSelect SetOrderBy(OrderDirections Direction, params string[] Expressions)
 {
     if (Expressions != null & Expressions.Length > 0)
     {
         List <string> lstExpression = new List <string>();
         foreach (string strExpression in Expressions)
         {
             if (String.IsNullOrWhiteSpace(strExpression))
             {
                 continue;
             }
             if (!this._IsValidExpression(strExpression))
             {
                 throw new ArgumentException(String.Format("Expression '{0}' is not a valid format.", strExpression));
             }
             lstExpression.Add(this._Name(strExpression));
         }
         if (lstExpression.Count > 0)
         {
             this._Orders.Add(String.Format("{0} {1}", String.Join(", ", lstExpression.ToArray()), this._GetOrderDirection(Direction)));
         }
     }
     return(this);
 }
Exemplo n.º 9
0
 public OrderClause(string propertyName, OrderDirections order)
 {
     PropertyName = propertyName;
     Order = order;
 }
Exemplo n.º 10
0
        public DealerOrder(
            IFinancialInstrument instrument,
            string reddeerTradeId,
            string tradeId,
            DateTime?placedDate,
            DateTime?bookedDate,
            DateTime?amendedDate,
            DateTime?rejectedDate,
            DateTime?cancelledDate,
            DateTime?filledDate,
            DateTime?createdDate,
            string traderId,
            string dealerName,
            string notes,
            string tradeCounterParty,
            OrderTypes orderType,
            OrderDirections orderDirection,
            Currency currency,
            Currency settlementCurrency,
            OrderCleanDirty cleanDirty,
            decimal?accumulatedInterest,
            string dealerOrderVersion,
            string dealerOrderVersionLinkId,
            string dealerOrderGroupId,
            Money?limitPrice,
            Money?averageFillPrice,
            decimal?orderedVolume,
            decimal?filledVolume,
            decimal?optionStrikePrice,
            DateTime?optionExpirationDate,
            OptionEuropeanAmerican tradeOptionEuropeanAmerican)
            : base(placedDate, bookedDate, amendedDate, rejectedDate, cancelledDate, filledDate)
        {
            this.Instrument           = instrument ?? throw new ArgumentNullException(nameof(instrument));
            this.ReddeerDealerOrderId = reddeerTradeId ?? string.Empty;
            this.DealerOrderId        = tradeId ?? string.Empty;

            this.CreatedDate = createdDate;

            this.DealerId            = traderId ?? string.Empty;
            this.DealerName          = dealerName ?? string.Empty;
            this.Notes               = notes ?? string.Empty;
            this.DealerCounterParty  = tradeCounterParty ?? string.Empty;
            this.OrderType           = orderType;
            this.OrderDirection      = orderDirection;
            this.Currency            = currency;
            this.SettlementCurrency  = settlementCurrency;
            this.CleanDirty          = cleanDirty;
            this.AccumulatedInterest = accumulatedInterest;

            this.DealerOrderVersion       = dealerOrderVersion;
            this.DealerOrderVersionLinkId = dealerOrderVersionLinkId;
            this.DealerOrderGroupId       = dealerOrderGroupId;

            this.LimitPrice             = limitPrice;
            this.AverageFillPrice       = averageFillPrice;
            this.OrderedVolume          = orderedVolume;
            this.FilledVolume           = filledVolume;
            this.OptionStrikePrice      = optionStrikePrice;
            this.OptionExpirationDate   = optionExpirationDate;
            this.OptionEuropeanAmerican = tradeOptionEuropeanAmerican;
        }
Exemplo n.º 11
0
        public Order(
            FinancialInstrument instrument,
            Market market,
            int?reddeerOrderId,
            string orderId,
            DateTime?created,
            string orderVersion,
            string orderVersionLinkId,
            string orderGroupId,
            DateTime?placedDate,
            DateTime?bookedDate,
            DateTime?amendedDate,
            DateTime?rejectedDate,
            DateTime?cancelledDate,
            DateTime?filledDate,
            OrderTypes orderType,
            OrderDirections orderDirection,
            Currency orderCurrency,
            Currency?orderSettlementCurrency,
            OrderCleanDirty orderCleanDirty,
            decimal?orderAccumulatedInterest,
            Money?orderLimitPrice,
            Money?orderAverageFillPrice,
            decimal?orderOrderedVolume,
            decimal?orderFilledVolume,
            string orderTraderId,
            string orderTraderName,
            string orderClearingAgent,
            string orderDealingInstructions,
            IOrderBroker orderBroker,
            Money?orderOptionStrikePrice,
            DateTime?orderOptionExpirationDate,
            OptionEuropeanAmerican orderOptionEuropeanAmerican,
            IReadOnlyCollection <DealerOrder> trades)
            : base(placedDate, bookedDate, amendedDate, rejectedDate, cancelledDate, filledDate)
        {
            // keys
            this.Instrument     = instrument ?? throw new ArgumentNullException(nameof(instrument));
            this.Market         = market ?? throw new ArgumentNullException(nameof(market));
            this.ReddeerOrderId = reddeerOrderId;
            this.OrderId        = orderId ?? string.Empty;

            // versioning
            this.OrderVersion       = orderVersion ?? string.Empty;
            this.OrderVersionLinkId = orderVersionLinkId ?? string.Empty;
            this.OrderGroupId       = orderGroupId ?? string.Empty;

            // dates
            this.CreatedDate = created;

            // order fundamentals
            this.OrderType                = orderType;
            this.OrderDirection           = orderDirection;
            this.OrderCurrency            = orderCurrency;
            this.OrderSettlementCurrency  = orderSettlementCurrency;
            this.OrderCleanDirty          = orderCleanDirty;
            this.OrderAccumulatedInterest = orderAccumulatedInterest;
            this.OrderLimitPrice          = orderLimitPrice;
            this.OrderAverageFillPrice    = orderAverageFillPrice;
            this.OrderOrderedVolume       = orderOrderedVolume;
            this.OrderFilledVolume        = orderFilledVolume;
            this.OrderBroker              = orderBroker;

            // order trader and post trade
            this.OrderTraderId            = orderTraderId ?? string.Empty;
            this.OrderTraderName          = orderTraderName ?? string.Empty;
            this.OrderClearingAgent       = orderClearingAgent ?? string.Empty;
            this.OrderDealingInstructions = orderDealingInstructions ?? string.Empty;

            // options
            this.OrderOptionStrikePrice      = orderOptionStrikePrice;
            this.OrderOptionExpirationDate   = orderOptionExpirationDate;
            this.OrderOptionEuropeanAmerican = orderOptionEuropeanAmerican;

            // associated dealer orders
            this.DealerOrders = trades ?? new DealerOrder[0];
        }
Exemplo n.º 12
0
        public static async Task <PagedResult <TItem> > ToPagedResultAsync <TItem, TSortField>(this IQueryable <TItem> items, GetListQuery query, Expression <Func <TItem, TSortField> > sort = null, OrderDirections direction = OrderDirections.Asc) where TItem : class
        {
            var result = new PagedResult <TItem> {
                Count = await items.CountAsync()
            };

            if (result.Count == 0)
            {
                result.Items = new TItem[] { };
                return(result);
            }

            if (sort != null)
            {
                items = direction == OrderDirections.Desc
                    ? items.OrderByDescending(sort)
                    : items.OrderBy(sort);
            }

            result.Items = await items.Skip(query.Offset).Take(query.Limit).ToListAsync();

            return(result);
        }