Exemplo n.º 1
0
 public static void SaveUserInfo(string user)
 {
     var record = new TraderMarkData()
     {
         Contract = "userinfo",
         Ticker = user,
         LastUpdated = DateTime.Now,
     };
     m_cache["userinfo"] = record;
     record.Changed = true;
     PersistChanged();
 }
Exemplo n.º 2
0
    public static TraderMarkData GetInstance(string contract_, string ticker_, string bond_, bool createIfNotThere_=true)
    {
      var key = getKey(contract_, ticker_, bond_);

      if(m_cache.ContainsKey(key)==false)
        lock(m_cache)
          if(m_cache.ContainsKey(key)==false)
          {
            var record = SI.DB.MongoDB.GetCollection<TraderMarkData>(MongoDBDetails.ServerReference, MongoDBDetails.DB, MongoDBDetails.TraderMarkRepoCollection)
              .Find(MongoDB.Driver.Builders<TraderMarkData>.Filter.Where(h => h.Contract == contract_ && h.Ticker == ticker_ && h.Bond == bond_))
              .FirstOrDefaultAsync().Result;

            if (record == null && createIfNotThere_)
            {
              record = new TraderMarkData
              {
                Contract = contract_,
                Ticker = ticker_,
                Bond = bond_,
                
              };
            }
            else if (record == null)
                return null;
            m_cache[key] = record;
          }

      return m_cache[key];
    }
Exemplo n.º 3
0
 public static void SaveDefaultRepo(double front, double back, double shift)
 {
     var record = new TraderMarkData()
     {
         Contract = "default",
         Ticker = "default",
         Bond = "default",
         FrontRepo = front,
         BackRepo = back,
         Shift = shift,
     };
     m_cache["default"] = record;
     record.Changed = true;
     PersistChanged();
 }