@Kevin - HTML and CSS are page description languages - they describe what a page should have and what it should look like. You need a good grasp of an imperative programming language - one that tells the computer what to do. Quantopian uses Python 2.
First, you need to study Python, and bring yourself to a level that allows you to express what you want. Many professional traders who work with other languages, or spreadsheets, but know little or nothing about Python, come to Quantopian, write embarrassingly incorrect code, and take up a lot of their own and others' time asking embarrassing questions. Don't be one of them.
You don't have to master all of Python to write Quantopian algorithms. You have to have good knowledge of a few simple concepts:
- variable
- type
- predefined simple types and operations on them:
int
, float
, str
, bool
- especially integer division: how much is
1/2
?
- optionally, implicit conversion to
bool
, which simplifies writing conditions
- functions: when and how they're executed; how to define one
- object: how to read and set a member variable of an object, call a member function, but not how to define object types (classes)
- predefined Python container object types:
list
, dict
(it helps if you know arrays from other languages, perhaps JavaScript)
- statements: assignment,
if
, for
, function call
- comments: learn to use them early and often, and keep them up to date
If Python is your first imperative programming language, you'd better take a class, or have lessons with a private tutor. If you already know another (eg. JavaScript), or you're really bright and have good math and reasoning skills, you can read good books or watch good videos, and reproduce code examples.
Then you can start learning the Quantopian programming interface. At a minimum, you will need to know:
- how to make your algorithms watch certain securities (stocks or ETFs):
symbols
, symbol
, or sid
- how to find out the current price of a security (currently, a stock or ETF trading on major US exchanges)
sec
you're watching: data[sec].price
- how to send an order to buy or sell
n
shares of security sec
(positive n
to buy, negative to sell or short): order(sec, n)
- how to find out how much cash you have available:
context.portfolio.cash
- how to find out how many shares of security
sec
you have or are short: context.portfolio.positions[sec]
- how to find out if you have any open orders that haven't been filled yet (and better don't trade if you do):
get_open_orders()
- how to find out what commissions per trade and per share you're being charged:
0.0
and 0.03
USD respectively by default (unless Quantopian relents and makes get_commission
available)
Read the relevant portions of the Quantopian help page at https://www.quantopian.com/help to learn more about those. Always try to find the answer there before posting a question on the forum.
Sooner or later, it will greatly help you to know and use the pandas
library. If you're running Windows, the best way to get Pandas is to download and install Enthought Canopy, which comes with pandas
, numpy
, statsmodels
, and other libraries available from the Quantopian platform.