-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.xml
72 lines (66 loc) · 8 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>On the Road</title>
<link>https://stevexfliu.github.io/</link>
<description>Recent content on On the Road</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-US</language>
<managingEditor>[email protected] (Steve Liu)</managingEditor>
<webMaster>[email protected] (Steve Liu)</webMaster>
<lastBuildDate>Sat, 08 Apr 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://stevexfliu.github.io/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>A Testing Post</title>
<link>https://stevexfliu.github.io/post/test/</link>
<pubDate>Sat, 08 Apr 2023 00:00:00 +0000</pubDate>
<author>[email protected] (Steve Liu)</author>
<guid>https://stevexfliu.github.io/post/test/</guid>
<description><h2 id="1-introduction">1. Introduction</h2>
<p>We will test text, code, and $\LaTeX$ typesettings in this post.</p>
<h2 id="2-text-typesetting">2. Text Typesetting</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sit amet elit nec urna dignissim lobortis. Nulla sed orci et magna aliquam aliquam nec vel ex. Nulla malesuada mollis ex, at semper dui fringilla sit amet. Integer vestibulum, libero vel blandit varius, sem velit fringilla erat, et varius sem libero eu ligula. Donec sit amet lorem libero. Donec lobortis ullamcorper sem at maximus. Fusce lorem leo, pretium eget libero eget, cursus aliquam libero. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque sed nibh justo.</p>
<p>Nunc at ante bibendum, pharetra nunc quis, pretium quam. Sed quis cursus elit. Etiam pulvinar mi ultrices enim bibendum imperdiet. Maecenas consequat, odio ut ultrices consectetur, erat sem tempus nisi, et pharetra sem lacus vitae arcu. Phasellus at risus eget velit hendrerit dictum. Duis vitae vulputate metus, non lobortis justo. Nulla vulputate diam nisl, et ornare nulla euismod dapibus. Etiam sed nibh nisl.</p>
<h2 id="3-code-typesetting">3. Code Typesetting</h2>
<p>Let&rsquo;s backtest a simple strategy of hloding TSLA from 2022-01-01 to 2022-12-31:</p>
<div class="highlight"><pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#080;font-style:italic"># Import necessary libraries</span>
</span></span><span style="display:flex;"><span><span style="color:#a2f;font-weight:bold">import</span> <span style="color:#00f;font-weight:bold">yfinance</span> <span style="color:#a2f;font-weight:bold">as</span> <span style="color:#00f;font-weight:bold">yf</span>
</span></span><span style="display:flex;"><span><span style="color:#a2f;font-weight:bold">from</span> <span style="color:#00f;font-weight:bold">bt</span> <span style="color:#a2f;font-weight:bold">import</span> Backtest
</span></span><span style="display:flex;"><span><span style="color:#a2f;font-weight:bold">from</span> <span style="color:#00f;font-weight:bold">bt.algos</span> <span style="color:#a2f;font-weight:bold">import</span> BuyAndHold
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#080;font-style:italic"># Download the historical data for TSLA stock prices from Yahoo Finance</span>
</span></span><span style="display:flex;"><span>tsla <span style="color:#666">=</span> yf<span style="color:#666">.</span>Ticker(<span style="color:#b44">&#34;TSLA&#34;</span>)
</span></span><span style="display:flex;"><span>tsla_data <span style="color:#666">=</span> tsla<span style="color:#666">.</span>history(start<span style="color:#666">=</span><span style="color:#b44">&#34;2022-01-01&#34;</span>, end<span style="color:#666">=</span><span style="color:#b44">&#34;2022-12-31&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#080;font-style:italic"># Create a Backtest instance</span>
</span></span><span style="display:flex;"><span>bt <span style="color:#666">=</span> Backtest(
</span></span><span style="display:flex;"><span> data<span style="color:#666">=</span>tsla_data,
</span></span><span style="display:flex;"><span> algo<span style="color:#666">=</span>BuyAndHold,
</span></span><span style="display:flex;"><span> start<span style="color:#666">=</span><span style="color:#b44">&#34;2022-01-01&#34;</span>,
</span></span><span style="display:flex;"><span> end<span style="color:#666">=</span><span style="color:#b44">&#34;2022-12-31&#34;</span>
</span></span><span style="display:flex;"><span> cash<span style="color:#666">=</span><span style="color:#666">100000</span>
</span></span><span style="display:flex;"><span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#080;font-style:italic"># Run the backtest and print the result</span>
</span></span><span style="display:flex;"><span>bt<span style="color:#666">.</span>run()
</span></span><span style="display:flex;"><span><span style="color:#a2f">print</span>(bt<span style="color:#666">.</span>results)
</span></span></code></pre></div><h2 id="4-math-typesetting">4. Math Typesetting</h2>
<p>A normal distribution or Gaussian distribution is a type of continuous probability distribution for a real-valued random variable. The general form of its probability density function is
\begin{equation}
\tag{1}
f(x) = \cfrac{1}{\sigma\sqrt{2\pi}}e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}.
\end{equation}
The parameter $\mu$ in equation (1) is the mean or expectation of the distribution (and also its median and mode), while the parameter $\sigma$ is its standard deviation.</p>
</description>
</item>
<item>
<title>About</title>
<link>https://stevexfliu.github.io/about/</link>
<pubDate>Sat, 08 Apr 2023 00:00:00 +0000</pubDate>
<author>[email protected] (Steve Liu)</author>
<guid>https://stevexfliu.github.io/about/</guid>
<description><p>I am currently a part-time <em>Indie Quant</em> focusing on tradings of U.S. stocks and options. I develop my trading strategies with Python and R.</p>
<p>As you found, I am also a fan of $\LaTeX$ typesetting system, trying to (mis)use it everywhere.</p>
</description>
</item>
</channel>
</rss>