Let's develop an investment algorithm with Python 1

Introduction

Note how to use the platform called Smart Trade to invest in stocks in Python.

What is Smart Trade

top.png

Smart Trade provides engineers with a state-of-the-art stock investment system trading environment, basically free of charge. The algorithms you develop will be available for sale in your own trades or on the Smart Trade marketplace.

https://beta.smarttrade.co.jp/

The functions that can be used in the beta version are still limited, but now they are all released for free. Will it be like the App Store in the future?

2018/1/11 postscript: Official URL for developers https://quantx.io/developer

What can i do?

You can analyze past stock price data of Japan and China with Python. If there is a timing when it seems okay to buy or sell, you can simulate how much profit you made by ordering using the Smart Trade API (this is called "backtesting"). Masu).

In addition, since it has a simple BI tool-like function, you can simply display the stock price on a chart, check the values of various technical indicators calculated, and visually check what the actual trading timing was. You can check.

How do you analyze it?

The analysis is written in Python. Since WebIDE is prepared, you can check the result as it is by writing and executing the program on the browser.

Various data are prepared on the Smart Trade platform, so you can easily use it just by declaring the data you want to use. Since pandas is used for the actual data manipulation, I think that anyone who can use pandas can try it relatively easily.

Hello System Trade!

First, let's display the stock price of 9984 (Softbank) on the chart like Hello World. On the Python Coding screen, write the following code and execute it.

def initialize(ctx):
    #Algorithm settings
    ctx.configure(
      target="jp.stock.daily",    #Algorithm for daily stocks of Japanese stocks
      channels={
        "jp.stock": {
          "symbols": [
            "jp.stock.9984",      #Use SoftBank data
          ],
          "columns": [
            "close_price",        #closing price
            "close_price_adj",    #closing price(After stock split adjustment)
          ]
        }
      }
    )

def handle_signals(ctx, date, current):
    '''
    current: pd.DataFrame
    '''
    pass

When you run

summary.png

The chart came out. There is no unevenness, but this means that the assets have not changed at all because we are not buying or selling. Looking at the details of the brand,

detail.png

It's coming out properly!

Next time, I will display the moving average.

Reference information

2018/1/11 postscript Official version URL:

Recommended Posts

Let's develop an investment algorithm with Python 1
Let's write FizzBuzz with an error: Python Version
Let's run Excel with Python
Creating an egg with python
[Python3] Dijkstra's algorithm with 14 lines
Let's write python with cinema4d.
Let's build git-cat with Python
Let's get started with Python ~ Building an environment on Windows 10 ~
Cut out an image with python
Let's make a GUI with python.
Create an Excel file with Python3
I sent an SMS with Python
Let's play with Excel with Python [Beginner]
Let's do image scraping with Python
Let's make a graph with python! !!
Draw an illustration with Python + OpenCV
[Python] Send an email with outlook
Let's analyze voice with Python # 1 FFT
Python algorithm
Efficiently develop Azure Python apps with CI/CD
System trading starting with Python3: long-term investment
[Python] Building an environment with Anaconda [Mac]
Algorithm learned with Python 10th: Binary search
Algorithm learned with Python 5th: Fibonacci sequence
Let's make a shiritori game with Python
Algorithm learned with Python 9th: Linear search
Algorithm learned with Python 7th: Year conversion
Note when creating an environment with python
Algorithm learned with Python 8th: Evaluation of algorithm
Let's create a free group with Python
Algorithm learned with Python 4th: Prime numbers
Search the maze with the python A * algorithm
[Introduction to Python] Let's use foreach with Python
Let's read the RINEX file with Python ①
Algorithm learned with Python 2nd: Vending machine
Algorithm learned with Python 19th: Sorting (heapsort)
Develop Windows apps with Python 3 + Tkinter (Preparation)
[Python] Let's make matplotlib compatible with Japanese
Algorithm learned with Python 6th: Leap year
[Python] Quickly create an API with Flask
Scraping from an authenticated site with python
Let's do MySQL data manipulation with Python
Create an English word app with python
Let's make a web framework with Python! (1)
Send an email with Amazon SES + Python
Join an online judge with Python 3.x
Algorithm learned with Python 3rd: Radix conversion
Algorithm learned with Python 12th: Maze search
Let's get along with Python # 0 (Environment construction)
Let's make a web framework with Python! (2)
Algorithm learned with Python 11th: Tree structure
[Blender x Python] Let's get started with Blender Python !!
[What is an algorithm? Introduction to Search Algorithm] ~ Python ~
Python hand play (let's get started with AtCoder?)
Let's explain the asset allocation by the Black-Litterman model (with an execution example by Python)
Statistics with python
Let's solve simultaneous linear equations with Python sympy!
Create an app that guesses students with python
[Python] Make a game with Pyxel-Use an editor-
Python memorandum (algorithm)
Algorithm learned with Python 13th: Tower of Hanoi