Skip to content

Instantly share code, notes, and snippets.

@chuckremes
Created January 19, 2010 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuckremes/281102 to your computer and use it in GitHub Desktop.
Save chuckremes/281102 to your computer and use it in GitHub Desktop.
> contracts.find({full_name: /CLE/})
{ "_id" : ObjectId("4b55c962870d490f80000001"), "month" : "F", "exchange_name" : "NYMEX on Globex", "expiration_date" : "2010/12/20 00:00:00", "exchange_id" : 67, "symbol" : "F.US.CLEF11", "scale" : 2, "type" : "future", "description" : "Crude Light (Globex), Jan 11", "year" : "2011", "tick_size" : 0.01, "tick_value" : 10, "contract_id" : 265126, "full_name" : "F.US.CLEF11", "currency" : "USD" }
{ "_id" : ObjectId("4b55c963870d490f80000002"), "month" : "F", "exchange_name" : "NYMEX on Globex", "expiration_date" : "2011/12/20 00:00:00", "exchange_id" : 67, "symbol" : "F.US.CLEF12", "scale" : 2, "type" : "future", "description" : "Crude Light (Globex), Jan 12", "year" : "2012", "tick_size" : 0.01, "tick_value" : 10, "contract_id" : 284201, "full_name" : "F.US.CLEF12", "currency" : "USD" }
{ "_id" : ObjectId("4b55c964870d490f80000003"), "month" : "F", "exchange_name" : "NYMEX on Globex", "expiration_date" : "2012/12/19 00:00:00", "exchange_id" : 67, "symbol" : "F.US.CLEF13", "scale" : 2, "type" : "future", "description" : "Crude Light (Globex), Jan 13", "year" : "2013", "tick_size" : 0.01, "tick_value" : 10, "contract_id" : 324765, "full_name" : "F.US.CLEF13", "currency" : "USD" }
# and now the ruby...
>> def ts symbol
>> @mongo = Mongo::Connection.new("10.126.128.23").db("market_data")
>>
?> @contract_collection = @mongo.collection "contracts"
>> @contracts = @contract_collection.find({'symbol' => /symbol/}).to_a
>> p @contracts
>> end
=> nil
>> ts 'F.US.CLE'
[]
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment