Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7186385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:37:12+00:00 2026-05-28T18:37:12+00:00

This is a sample document holding OHLC stock data, truncated (via python print). {

  • 0

This is a sample document holding OHLC stock data, truncated (via python print).

{
   "_id":ObjectId("4f1c567d60de7d0908000000"),
   "ticker" : "msft"
   "pricing":[
      {
         "Volume":"2094300",
         "Adj Close":"85.87",
         "High":"88.11",
         "Low":"87.45",
         "Date":         ISODate("2011-01-14T00:00:00         Z"),
         "Close":"88.10",
         "Open":"87.74"
      },
      {
         "Volume":"2351900",
         "Adj Close":"85.81",
         "High":"88.87",
         "Low":"87.76",
         "Date":         ISODate("2011-01-13T00:00:00         Z"),
         "Close":"88.04",
         "Open":"88.47"
      },
      {
         "Volume":"2732900",
         "Adj Close":"86.42",
         "High":"88.76",
         "Low":"87.92",
         "Date":         ISODate("2011-01-12T00:00:00         Z"),
         "Close":"88.66",
         "Open":"88.02"
      }

Couple questions about this:

  1. Is there any way to index things within a document and not within a collection? I want to be able to easily look up data by date, maybe there is a better way to organize the data?

  2. I am confused as to how to retrieve or update a specific pricing data, I tried to push in the new pricing data using:

    var = collection.find({ ‘ticker’ : ticker}) //Find the correct document

    var[0].update( { ‘$push’ : { ‘pricing’ : newpricingdata } }) //update that companies values

but it doesnt work. Find works fine, update doesnt.

newpricingdata looks like (python print):

[
   {
      'Volume':'3522600',
      'Adj Close':'85.65',
      'High':'85.70',
      'Low':'84.96',
      'Date':datetime.datetime(2012,1,20,0,0),
      'Close':'85.65',
      'Open':'85.45'
   },
   {
      'Volume':'3413700',
      'Adj Close':'85.80',
      'High':'86.23',
      'Low':'84.92',
      'Date':datetime.datetime(2012,1,19,0,0),
      'Close':'85.80',
      'Open':'85.10'
   },

]
  1. How would you retrieve the price of ticker msft on say 1/20/2012 via python? The mongodb documentation doesnt really give good examples of subtree operations…
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:37:13+00:00Added an answer on May 28, 2026 at 6:37 pm

    If you want to query by date then:

    collection.ensureIndex({"pricing.Date" : 1}) 
    

    To update pricing data, you have to call the update() method on collection, just as you call find() on the same collection, and you want $pushAll since newpricingdata is an array:

    collection.update({ "_id" : ObjectId("4f1c567d60de7d0908000000")}, { '$pushAll' : { 'pricing' : newpricingdata } }, false, false); 
    

    Question:

    How would you retrieve the price of ticker msft on say 1/20/2012 via
    python? The mongodb documentation doesnt really give good examples of
    subtree operations…

    It’s not possible to query and return only matching elements of an array, mongodb will give you the whole array. Which means you’ll have to extract that element in python.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written this sample code to print the length of x. But for some
I have this function (sample here: http://jsbin.com/emabe4/ ) var a=[]; var log = document.getElementById('log');
I tried some thing like this, <script> function sample(image){ document.write('<img src=photo/'+image+' width=200 height=200/>'); //document.open(photo/+image);
Consider this simple XML document. The serialized XML shown here is the result of
Imagine this sample java class: class A { void addListener(Listener obj); void removeListener(Listener obj);
Consider this sample code: <div class=containter id=ControlGroupDiv> <input onbeforeupdate=alert('bingo 0'); return false; onclick=alert('click 0');return
Consider this sample class, class TargetClass { private static String SENSITIVE_DATA = sw0rdfish; private
In this sample code the URL of the app seems to be determined by
in this sample method/message: -(void) setNumerator:(int) n { numerator = n; } What does
Take this sample class as an example: [AttributeUsage(AttributeTargets.All, AllowMultiple=true)] public class BugFixAttribute : System.Attribute

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.