protected ApiFund MapFund(IFund fund)
 {
     return(new ApiFund()
     {
         Name = fund.Name,
         DisplayName = fund.DisplayName,
         Category = fund.Category,
         Description = fund.Description,
         Token = new ApiToken()
         {
             Symbol = fund.Token.Symbol,
             Decimals = fund.Token.Decimals,
             Address = fund.Token.ContractAddress.Address
         },
         CirculatingSupply = fund.CirculatingSupply,
         Nav = new ApiNav()
         {
             Value = fund.Nav.Value,
             ValuePerToken = fund.Nav.ValuePerToken,
             DiffDaily = fund.Nav.DiffDaily,
             DiffWeekly = fund.Nav.DiffWeekly,
             DiffMonthly = fund.Nav.DiffMonthly
         },
         Market = MapMarket(fund.Market),
         Assets = fund.Assets
                  .Select(a => new ApiAsset()
         {
             Holding = new ApiHolding()
             {
                 Name = a.Holding.Name,
                 IsCoin = a.Holding.IsCoin,
                 Symbol = a.Holding.Symbol ?? "-",
                 ContractAddress = a.Holding.ContractAddress?.Address,
                 HexColour = a.Holding.HexColour,
                 Decimals = a.Holding.Decimals,
                 Links = new ApiHoldingLinks()
                 {
                     [nameof(ApiHoldingLinks.Link)] = a.Holding.Link,
                     [nameof(ApiHoldingLinks.ImageLink)] = a.Holding.ImageLink,
                     [nameof(ApiHoldingLinks.MarketLink)] = a.Holding.MarketLink,
                 }
             },
             PricePerToken = a.PricePerToken,
             Quantity = a.Quantity,
             Total = a.Total,
             Share = a.Share
         })
                  .ToList(),
         Links = new ApiFundLinks()
         {
             [nameof(ApiFundLinks.Self)] = new Uri(AppSettings.HostUrl.OriginalString.TrimEnd('/') + $"/api/v1/funds/{fund.Token.Symbol}", UriKind.Absolute),
             ["Lite"] = fund.LitepaperUri,
             [nameof(ApiFundLinks.Fact)] = fund.FactSheetUri,
             [nameof(ApiFundLinks.External)] = fund.InvictusUri
         }
     });
 }
示例#2
0
 public decimal GetTotalFundValuation(IFund fund)
 {
     try
     {
         return(Math.Round(_fund.CurrentValuation, 2));
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#3
0
        public static FundModel ToFundModel(this IFund fund)
        {
            var result = new FundModel(
                fund.Id,
                fund.Name,
                fund.ShortName,
                fund.Ticker
                );

            return(result);
        }
示例#4
0
        static void Main(string[] args)
        {
            string market    = Properties.Settings.Default.Market;
            string className = $"AbstractFactory.{market}Factory";

            IFactory factory = (IFactory)Assembly.Load("AbstractFactory").CreateInstance(className);
            IStock   stock   = factory.CreateStock();

            stock.Buy();
            stock.Sell();
            IFund fund = factory.CreateFund();

            fund.Buy();
            fund.Sell();

            Console.Read();
        }
示例#5
0
        public IFund CreateFund(string fundName, IRepo <IStockPosition> fundRepo, IRepo <IBenchmark> benchmarkRepo, ILogger logger = null)
        {
            if (fundRepo == null)
            {
                throw new Exception("fund repository is not inilialised");
            }

            if (logger != null)
            {
                _logger = logger;
            }
            try
            {
                _fund          = new Fund(fundName, fundRepo);
                _benchmarkRepo = benchmarkRepo;
                return(_fund);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#6
0
        // ***************************************************************************************************************************
        // ****************************************************     METHODS   ********************************************************
        // ***************************************************************************************************************************

        /// <summary>
        /// Gets the control number.
        /// </summary>
        /// <param name = "fund" >
        /// The fund.
        /// </param>
        /// <param name = "fy" >
        /// The fy.
        /// </param>
        /// <returns>
        /// </returns>
        private IControlNumber GetControlNumber(IFund fund, IBudgetFiscalYear fy)
        {
            if (fund != null &&
                fy != null)
            {
                try
                {
                    var connection = new ConnectionBuilder(Source.ControlNumbers, Provider.SQLite);

                    var args = new Dictionary <string, object>
                    {
                        [$"{Field.FundCode}"] = fund.GetCode(),
                        [$"{Field.BFY}"]      = BFY.GetFirstYear(),
                        [$"{Field.RcCode}"]   = RC.GetCode()
                    };

                    var sqlstatement = new SqlStatement(connection, args, SQL.SELECT);
                    var query        = new Query(connection, sqlstatement);
                    return(new ControlNumber(query));
                }
                catch (Exception ex)
                {
                    Fail(ex);
                    return(default);
示例#7
0
        public void AddFund(StockType stock, double quantity, double price)
        {
            IFund fund = CreateFund(stock, quantity, price);

            MyFund.Add(fund);
        }
示例#8
0
 public void Resolve(IFund fund)
 {
     this.Result = fund.ToFundModel();
 }
示例#9
0
 public FundViewModel(IFundFactory fundFactory)
 {
     _fund = fundFactory.GetFund();
 }
示例#10
0
 public FundManager(IFund fund, IRepo <IBenchmark> benchmarkRepo)
 {
     _fund          = fund;
     _benchmarkRepo = benchmarkRepo;
 }
示例#11
0
 public FundManager(IFund fund)
 {
     _fund = fund;
 }
示例#12
0
 public SpotTradeService(IOrder om, IFund fm)
 {
     _apiOrder = om;
     _fund     = fm;
 }
示例#13
0
 public OrderBuilder WithFund(IFund fund)
 {
     _editableData.Fund = fund;
     return(this);
 }