Ejemplo n.º 1
0
        public InfoRecord[] GetInfoRecords(ITranslationManager tm)
        {
            const string tg      = "Statistics";
            var          records = new List <InfoRecord>
            {
                new InfoRecord
                {
                    Name  = tm.T(tg, "Type"),
                    Value = InstrType.ToString()
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Comment"),
                    Value = Comment
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Digits"),
                    Value = Digits.ToString(CultureInfo.InvariantCulture)
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Point value"),
                    Value = Point.ToString("0.#####")
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Lot size"),
                    Value = LotSize.ToString(CultureInfo.InvariantCulture)
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Spread"),
                    Value = Spread.ToString("F2") + " " + tm.T(tg, "points")
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Swap long"),
                    Value = SwapLong.ToString("F2") + " " + tm.T(tg, SwapType.ToString().ToLower())
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Swap short"),
                    Value = SwapShort.ToString("F2") + " " + tm.T(tg, SwapType.ToString().ToLower())
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Commission"),
                    Value = Commission.ToString("F2") + " " + tm.T(tg, CommissionType.ToString().ToLower())
                },
                new InfoRecord
                {
                    Name  = tm.T(tg, "Slippage"),
                    Value = Slippage.ToString("F2") + " " + tm.T(tg, "points")
                }
            };

            return(records.ToArray());
        }
Ejemplo n.º 2
0
        public void TestALotSize()
        {
            IDbMasterDataCache dbMasterDataCache =
                ZppConfiguration.CacheManager.GetMasterDataCache();

            LotSize lotSize = new LotSize(new Quantity(6),
                                          dbMasterDataCache.M_ArticleGetAll()[0].GetId());

            foreach (var quantity in lotSize.GetLotSizes())
            {
                Assert.True(quantity.GetValue() == TestConfiguration.LotSize, $"Quantity ({quantity}) is not correct.");
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FxRiskManagment"/> class.
 /// </summary>
 /// <param name="portfolio">The QCAlgorithm Portfolio.</param>
 /// <param name="riskPerTrade">The max risk per trade.</param>
 /// <param name="maxExposurePerTrade">The maximum exposure per trade.</param>
 /// <param name="maxExposure">The maximum exposure in all trades.</param>
 /// <param name="lotsize">The minimum quantity to trade.</param>
 /// <exception cref="System.NotImplementedException">The pairs should be added to the algorithm before initialize the risk manager.</exception>
 public FxRiskManagment(SecurityPortfolioManager portfolio, decimal riskPerTrade, decimal maxExposurePerTrade,
                        decimal maxExposure, LotSize lotsize = LotSize.Micro, int minQuantity = 5)
 {
     _portfolio = portfolio;
     if (_portfolio.Securities.Count == 0)
     {
         throw new NotImplementedException("The pairs should be added to the algorithm before initialize the risk manager.");
     }
     this._riskPerTrade   = riskPerTrade;
     _maxExposurePerTrade = maxExposurePerTrade;
     this._maxExposure    = maxExposure;
     _lotSize             = (int)lotsize;
     _minQuantity         = minQuantity;
 }
Ejemplo n.º 4
0
        //int newSizeW = 0;
        //int newSizeH = 0;
        //int newSizeL = 0;
        //int newPeaces = 0;
        //decimal newPrice = 0m;
        public Window1()
        {
            InitializeComponent();
            // ================================= Fields =======

            string[] materialType = { "Buk", "Dub", "Yavor", "Yasen" };
            this.MaterialType.SelectedValue = materialType[0];

            LotSize newSise = new LotSize(0, 0, 0);

            // =================================
            this.NewID.Text = IdGenerator.GetId().ToString();
            this.MaterialType.ItemsSource = materialType;
        }
Ejemplo n.º 5
0
        /**
         * Initialize the db:
         * - deletes current
         * - creates db according to given configuration
         */
        private void InitDb(string testConfiguration,
                            ProductionDomainContext productionDomainContext, bool InitData)
        {
            if (ZppConfiguration.CacheManager.GetTestConfiguration() == null)
            {
                ReadInTestConfiguration(testConfiguration);
            }

            if (Constants.IsLocalDb)
            {
                bool isDeleted = productionDomainContext.Database.EnsureDeleted();
                if (!isDeleted)
                {
                    // pass
                }
            }

            /*
             * // random name currently, this doesn't work on linux/unix anyway
             * else if(Constants.IsLocalDb == false && Constants.IsWindows)
             * {
             *  bool wasDropped = Dbms.DropDatabase(
             *      Constants.GetDbName(),
             *      Constants.GetConnectionString(Constants.DefaultDbName));
             *  if (wasDropped == false)
             *  {
             *      // pass
             *  }
             * }*/

            if (InitData)
            {
                Type dbSetInitializer = Type.GetType(_testConfiguration.DbSetInitializer);
                dbSetInitializer.GetMethod("DbInitialize").Invoke(null, new[]
                {
                    productionDomainContext
                });
            }
            else
            {
                productionDomainContext.Database.EnsureCreated();
            }

            LotSize.SetDefaultLotSize(new Quantity(_testConfiguration.LotSize));
            LotSize.SetLotSizeType(_testConfiguration.LotSizeType);
        }
        public async Task <List <LotSize> > GetLotSizes()
        {
            List <LotSize> result = new List <LotSize>();
            JObject        query  = await _apiClient.CallAsync <JObject>(ApiMethod.GET, EndPoints.ExchangeInfo, false);

            JToken tmp = query["symbols"];

            foreach (JToken t in tmp)
            {
                var jArray  = t.SelectToken("filters").ToArray();
                var lotSize = jArray.First(x => x["filterType"].Value <string>() == "LOT_SIZE");

                LotSize lotsize = JsonConvert.DeserializeObject <LotSize>(lotSize.ToString());
                lotsize.Symbol = t.SelectToken("symbol").ToString();

                result.Add(lotsize);
            }
            return(result);
        }
            public static double GetPipValue(string instrument, LotSize lot, double tickSize, double askPrice)
            {
                if (instrument.EndsWith("USD"))
                {
                    return(tickSize * (double)lot);
                }

                if (instrument.StartsWith("USD"))
                {
                    return(tickSize * (double)lot / askPrice);
                }


                RelatedPairs.RelatedPair relPair = RelatedPairs.GetRelatedPairs()[instrument];
                if (relPair.Instrument.StartsWith("USD"))
                {
                    return(tickSize * (double)lot / relPair.Rate);
                }


                throw new Exception("GetPipValue: The relative pair instrument or rate could not be determined (probably GBPUSD or other where USD is quote currency");
            }
Ejemplo n.º 8
0
        private Lot LotParser()
        {
            Wood    wood       = (Wood)WoodComboBox.SelectedItem;
            int     tempW      = int.Parse(NewWidthTextBox.Text);
            int     tempH      = int.Parse(NewHeightTextBox.Text);
            int     tempL      = int.Parse(NewLengthTextBox.Text);
            int     tempPieces = int.Parse(NewPiecesTextBox.Text);
            decimal tempPrice  = decimal.Parse(NewPriceTextBox.Text);
            LotSize tempSize   = new LotSize(tempW, tempH, tempL);

            switch (wood)
            {
            case Wood.Buk: return(new BukLot(tempSize, tempPieces, tempPrice));

            case Wood.Dub: return(new DubLot(tempSize, tempPieces, tempPrice));

            case Wood.Yavor: return(new YavorLot(tempSize, tempPieces, tempPrice));

            case Wood.Yasen: return(new YasenLot(tempSize, tempPieces, tempPrice));

            default: throw new ArgumentException("Invalid wood type");
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = (StockExchange != null
                                 ? StockExchange.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (TradeSector != null
                                 ? TradeSector.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (SecurityCode != null
                                 ? SecurityCode.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (SecurityName != null
                                 ? SecurityName.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (SecurityClass != null
                                 ? SecurityClass.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ HasOptions.GetHashCode();
         hashCode = (hashCode * 397) ^ (SecurityStatus != null
                                 ? SecurityStatus.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (Currency != null
                                 ? Currency.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ LimitUpPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ LimitDownPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ LotSize.GetHashCode();
         hashCode = (hashCode * 397) ^ (LotFlag != null
                                 ? LotFlag.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (SuspendedFlag != null
                                 ? SuspendedFlag.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (SecuritySubClass != null
                                 ? SecuritySubClass.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (UnderlyinSecurityCode != null
                                 ? UnderlyinSecurityCode.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ (SecurityLevel != null
                                 ? SecurityLevel.GetHashCode()
                                 : 0);
         hashCode = (hashCode * 397) ^ PreviousClose.GetHashCode();
         hashCode = (hashCode * 397) ^ OpenPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ Turnover.GetHashCode();
         hashCode = (hashCode * 397) ^ HighPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ LowPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ LastPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ CurrentBidPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ CurrentAskPrice.GetHashCode();
         hashCode = (hashCode * 397) ^ Volume.GetHashCode();
         hashCode = (hashCode * 397) ^ PERatio.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyVolume1.GetHashCode();
         hashCode = (hashCode * 397) ^ SellVolume1.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyPrice2.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyVolume2.GetHashCode();
         hashCode = (hashCode * 397) ^ SellPrice2.GetHashCode();
         hashCode = (hashCode * 397) ^ SellVolume2.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyPrice3.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyVolume3.GetHashCode();
         hashCode = (hashCode * 397) ^ SellPrice3.GetHashCode();
         hashCode = (hashCode * 397) ^ SellVolume3.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyPrice4.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyVolume4.GetHashCode();
         hashCode = (hashCode * 397) ^ SellPrice4.GetHashCode();
         hashCode = (hashCode * 397) ^ SellVolume4.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyPrice5.GetHashCode();
         hashCode = (hashCode * 397) ^ BuyVolume5.GetHashCode();
         hashCode = (hashCode * 397) ^ SellPrice5.GetHashCode();
         hashCode = (hashCode * 397) ^ SellVolume5.GetHashCode();
         return(hashCode);
     }
 }