[PYTHON] Quantopian Tutorial LESSON 3

This is a continuation of Last time.

LESSON 3 Referencing Securities

This time, I will explain how to set the brand. Quantopian requires you to instantiate a stock instead of specifying the ticker symbol as a string. This instance contains various information such as stock name and SID, as well as exchange information.

sid() You can create an instance of the target brand by passing the SID as an argument of the sid () function. In the example below, an instance of Apple Inc. is created.

def initialize(context):
    print(sid(24))

You can specify the ticker symbol using the symbol described below, but the advantage of using sid () is that the ticker symbol can change, whereas the SID does not. The SID cannot be associated with the brand name, but it can be easily identified by setting it in the context object as shown below.

def initialize(context):
    context.aapl = sid(24)
    print(context.aapl)

symbol() Create an instance of the brand by specifying the ticker symbol as an argument. In the example below, an instance of Apple Inc. is created.

def initialize(context):
    print(symbol('AAPL'))

Different names may be output for stocks whose ticker symbol has been changed.

def initialize(context):
    print(symbol('UA'))
1970-01-01 09:00  PRINT Equity(27822 [UAA])
End of logs.

You can also use the set_symbol_lookup_date () function to reference the old name, but this is not recommended.

def initialize(context):
    set_symbol_lookup_date('2017-01-01')
    print(symbol('UAA'))

LESSON 1,2<-->LESSON4

Recommended Posts

Quantopian Tutorial LESSON 10
Quantopian Tutorial LESSON 8
Quantopian Tutorial LESSON 6
Quantopian Tutorial LESSON 9
Quantopian Tutorial LESSON 5
Quantopian Tutorial LESSON 3
Quantopian Tutorial LESSON 7
Quantopian Tutorial LESSON 4
Quantopian Tutorial LESSON 11
PyODE Tutorial 2
Python tutorial
PyODE Tutorial 1
TensorFlow tutorial tutorial