Skip to content

Commit

Permalink
Update FAQs.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
edtechre committed Jul 5, 2023
1 parent 446519c commit 4666594
Showing 1 changed file with 72 additions and 87 deletions.
159 changes: 72 additions & 87 deletions docs/source/notebooks/FAQs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,7 @@
},
{
"cell_type": "markdown",
"id": "dfe7423b",
"id": "7607beb6",
"metadata": {},
"source": [
"### ... limit margin used for short sales?\n",
Expand All @@ -2037,7 +2037,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "22adb13a",
"id": "82b93739",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -2160,84 +2160,72 @@
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <th>2022-01-10</th>\n",
" <td>112472.56</td>\n",
" <td>112472.56</td>\n",
" <td>338302.00</td>\n",
" <td>103062.55</td>\n",
" <td>12472.56</td>\n",
" <td>-9410.01</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-12-23</th>\n",
" <td>188701.87</td>\n",
" <td>188701.87</td>\n",
" <th>2022-01-11</th>\n",
" <td>98536.05</td>\n",
" <td>98536.05</td>\n",
" <td>0.00</td>\n",
" <td>188701.87</td>\n",
" <td>88701.87</td>\n",
" <td>98536.05</td>\n",
" <td>-1463.95</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-12-27</th>\n",
" <td>188701.87</td>\n",
" <td>188701.87</td>\n",
" <td>540357.31</td>\n",
" <td>198742.08</td>\n",
" <td>88701.87</td>\n",
" <td>10040.21</td>\n",
" <th>2022-01-12</th>\n",
" <td>98536.05</td>\n",
" <td>98536.05</td>\n",
" <td>296592.41</td>\n",
" <td>99830.87</td>\n",
" <td>-1463.95</td>\n",
" <td>1294.82</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-12-28</th>\n",
" <td>201916.61</td>\n",
" <td>201916.61</td>\n",
" <th>2022-01-13</th>\n",
" <td>103550.41</td>\n",
" <td>103550.41</td>\n",
" <td>0.00</td>\n",
" <td>201916.61</td>\n",
" <td>101916.61</td>\n",
" <td>103550.41</td>\n",
" <td>3550.41</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-12-29</th>\n",
" <td>201916.61</td>\n",
" <td>201916.61</td>\n",
" <td>628715.51</td>\n",
" <td>195336.25</td>\n",
" <td>101916.61</td>\n",
" <td>-6580.36</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2022-12-30</th>\n",
" <td>203111.89</td>\n",
" <td>203111.89</td>\n",
" <td>0.00</td>\n",
" <td>203111.89</td>\n",
" <td>103111.89</td>\n",
" <td>0.00</td>\n",
" <th>2022-01-14</th>\n",
" <td>103550.41</td>\n",
" <td>103550.41</td>\n",
" <td>317490.89</td>\n",
" <td>99036.58</td>\n",
" <td>3550.41</td>\n",
" <td>-4513.83</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>251 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" cash equity margin market_value pnl \\\n",
"date \n",
"2022-01-03 100000.00 100000.00 0.00 100000.00 0.00 \n",
"2022-01-04 100000.00 100000.00 289702.46 102722.18 0.00 \n",
"2022-01-05 111667.90 111667.90 0.00 111667.90 11667.90 \n",
"2022-01-06 111667.90 111667.90 338321.57 107432.09 11667.90 \n",
"2022-01-07 112472.56 112472.56 0.00 112472.56 12472.56 \n",
"... ... ... ... ... ... \n",
"2022-12-23 188701.87 188701.87 0.00 188701.87 88701.87 \n",
"2022-12-27 188701.87 188701.87 540357.31 198742.08 88701.87 \n",
"2022-12-28 201916.61 201916.61 0.00 201916.61 101916.61 \n",
"2022-12-29 201916.61 201916.61 628715.51 195336.25 101916.61 \n",
"2022-12-30 203111.89 203111.89 0.00 203111.89 103111.89 \n",
" cash equity margin market_value pnl \\\n",
"date \n",
"2022-01-03 100000.00 100000.00 0.00 100000.00 0.00 \n",
"2022-01-04 100000.00 100000.00 289702.46 102722.18 0.00 \n",
"2022-01-05 111667.90 111667.90 0.00 111667.90 11667.90 \n",
"2022-01-06 111667.90 111667.90 338321.57 107432.09 11667.90 \n",
"2022-01-07 112472.56 112472.56 0.00 112472.56 12472.56 \n",
"2022-01-10 112472.56 112472.56 338302.00 103062.55 12472.56 \n",
"2022-01-11 98536.05 98536.05 0.00 98536.05 -1463.95 \n",
"2022-01-12 98536.05 98536.05 296592.41 99830.87 -1463.95 \n",
"2022-01-13 103550.41 103550.41 0.00 103550.41 3550.41 \n",
"2022-01-14 103550.41 103550.41 317490.89 99036.58 3550.41 \n",
"\n",
" unrealized_pnl fees \n",
"date \n",
Expand All @@ -2246,14 +2234,11 @@
"2022-01-05 0.00 0.0 \n",
"2022-01-06 -4235.81 0.0 \n",
"2022-01-07 0.00 0.0 \n",
"... ... ... \n",
"2022-12-23 0.00 0.0 \n",
"2022-12-27 10040.21 0.0 \n",
"2022-12-28 0.00 0.0 \n",
"2022-12-29 -6580.36 0.0 \n",
"2022-12-30 0.00 0.0 \n",
"\n",
"[251 rows x 7 columns]"
"2022-01-10 -9410.01 0.0 \n",
"2022-01-11 0.00 0.0 \n",
"2022-01-12 1294.82 0.0 \n",
"2022-01-13 0.00 0.0 \n",
"2022-01-14 -4513.83 0.0 "
]
},
"execution_count": 13,
Expand All @@ -2277,7 +2262,7 @@
"strategy = Strategy(YFinance(), start_date='1/1/2022', end_date='1/1/2023')\n",
"strategy.add_execution(short_fn, ['NVDA', 'AMD'])\n",
"result = strategy.backtest()\n",
"result.portfolio"
"result.portfolio.head(10)"
]
},
{
Expand Down Expand Up @@ -2405,7 +2390,7 @@
" <td>buy</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-02</td>\n",
" <td>95</td>\n",
" <td>98</td>\n",
" <td>NaN</td>\n",
" <td>435.65</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2415,7 +2400,7 @@
" <td>sell</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-03</td>\n",
" <td>95</td>\n",
" <td>98</td>\n",
" <td>NaN</td>\n",
" <td>437.45</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2425,7 +2410,7 @@
" <td>buy</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-04</td>\n",
" <td>95</td>\n",
" <td>98</td>\n",
" <td>NaN</td>\n",
" <td>430.62</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2435,7 +2420,7 @@
" <td>sell</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-07</td>\n",
" <td>95</td>\n",
" <td>98</td>\n",
" <td>NaN</td>\n",
" <td>425.83</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2445,7 +2430,7 @@
" <td>buy</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-08</td>\n",
" <td>95</td>\n",
" <td>98</td>\n",
" <td>NaN</td>\n",
" <td>421.16</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2455,7 +2440,7 @@
" <td>sell</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-09</td>\n",
" <td>95</td>\n",
" <td>98</td>\n",
" <td>NaN</td>\n",
" <td>426.17</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2465,7 +2450,7 @@
" <td>buy</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-10</td>\n",
" <td>96</td>\n",
" <td>97</td>\n",
" <td>NaN</td>\n",
" <td>423.43</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2475,7 +2460,7 @@
" <td>sell</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-11</td>\n",
" <td>96</td>\n",
" <td>97</td>\n",
" <td>NaN</td>\n",
" <td>424.15</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2485,7 +2470,7 @@
" <td>buy</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-14</td>\n",
" <td>95</td>\n",
" <td>97</td>\n",
" <td>NaN</td>\n",
" <td>420.17</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2495,7 +2480,7 @@
" <td>sell</td>\n",
" <td>SPY</td>\n",
" <td>2022-03-15</td>\n",
" <td>95</td>\n",
" <td>97</td>\n",
" <td>NaN</td>\n",
" <td>422.63</td>\n",
" <td>0.0</td>\n",
Expand All @@ -2507,16 +2492,16 @@
"text/plain": [
" type symbol date shares limit_price fill_price fees\n",
"id \n",
"1 buy SPY 2022-03-02 95 NaN 435.65 0.0\n",
"2 sell SPY 2022-03-03 95 NaN 437.45 0.0\n",
"3 buy SPY 2022-03-04 95 NaN 430.62 0.0\n",
"4 sell SPY 2022-03-07 95 NaN 425.83 0.0\n",
"5 buy SPY 2022-03-08 95 NaN 421.16 0.0\n",
"6 sell SPY 2022-03-09 95 NaN 426.17 0.0\n",
"7 buy SPY 2022-03-10 96 NaN 423.43 0.0\n",
"8 sell SPY 2022-03-11 96 NaN 424.15 0.0\n",
"9 buy SPY 2022-03-14 95 NaN 420.17 0.0\n",
"10 sell SPY 2022-03-15 95 NaN 422.63 0.0"
"1 buy SPY 2022-03-02 98 NaN 435.65 0.0\n",
"2 sell SPY 2022-03-03 98 NaN 437.45 0.0\n",
"3 buy SPY 2022-03-04 98 NaN 430.62 0.0\n",
"4 sell SPY 2022-03-07 98 NaN 425.83 0.0\n",
"5 buy SPY 2022-03-08 98 NaN 421.16 0.0\n",
"6 sell SPY 2022-03-09 98 NaN 426.17 0.0\n",
"7 buy SPY 2022-03-10 97 NaN 423.43 0.0\n",
"8 sell SPY 2022-03-11 97 NaN 424.15 0.0\n",
"9 buy SPY 2022-03-14 97 NaN 420.17 0.0\n",
"10 sell SPY 2022-03-15 97 NaN 422.63 0.0"
]
},
"execution_count": 15,
Expand Down

0 comments on commit 4666594

Please sign in to comment.