CatPtain commited on
Commit
013b837
·
verified ·
1 Parent(s): 77abdcb

Upload 55 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. assets/README.md +5 -0
  3. assets/extensions/obbject.json +7 -0
  4. assets/extensions/provider.json +316 -0
  5. assets/extensions/router.json +72 -0
  6. assets/scripts/generate_extension_data.py +126 -0
  7. build/conda/README.md +38 -0
  8. build/conda/environments/constructor.yml +10 -0
  9. build/conda/installer/README.md +246 -0
  10. build/conda/installer/assets/Installer_horizontal.bmp +0 -0
  11. build/conda/installer/assets/Installer_horizontal2.png +0 -0
  12. build/conda/installer/assets/Installer_vertical2.bmp +3 -0
  13. build/conda/installer/assets/create_shortcut.vbs +70 -0
  14. build/conda/installer/assets/custom_conclusion.nsi +86 -0
  15. build/conda/installer/assets/custom_welcome.nsi +41 -0
  16. build/conda/installer/assets/dmg_volume.icns +3 -0
  17. build/conda/installer/assets/examples/README.md +40 -0
  18. build/conda/installer/assets/examples/empty_obbject/README.md +9 -0
  19. build/conda/installer/assets/examples/empty_obbject/empty_obbject/__init__.py +30 -0
  20. build/conda/installer/assets/examples/empty_obbject/pyproject.toml +18 -0
  21. build/conda/installer/assets/examples/empty_provider/README.md +9 -0
  22. build/conda/installer/assets/examples/empty_provider/empty_provider/__init__.py +21 -0
  23. build/conda/installer/assets/examples/empty_provider/empty_provider/models/__init__.py +1 -0
  24. build/conda/installer/assets/examples/empty_provider/empty_provider/models/empty_model.py +93 -0
  25. build/conda/installer/assets/examples/empty_provider/empty_provider/utils/__init__.py +1 -0
  26. build/conda/installer/assets/examples/empty_provider/pyproject.toml +18 -0
  27. build/conda/installer/assets/examples/empty_router/README.md +9 -0
  28. build/conda/installer/assets/examples/empty_router/empty_router/__init__.py +1 -0
  29. build/conda/installer/assets/examples/empty_router/empty_router/empty_router.py +69 -0
  30. build/conda/installer/assets/examples/empty_router/empty_router/empty_views.py +29 -0
  31. build/conda/installer/assets/examples/empty_router/pyproject.toml +18 -0
  32. build/conda/installer/assets/examples/install_examples.py +48 -0
  33. build/conda/installer/assets/examples/python_basics.ipynb +3848 -0
  34. build/conda/installer/assets/header_win.png +0 -0
  35. build/conda/installer/assets/installer.nsi +264 -0
  36. build/conda/installer/assets/installer_conclusion.txt +12 -0
  37. build/conda/installer/assets/installer_license.txt +661 -0
  38. build/conda/installer/assets/installer_readme.txt +19 -0
  39. build/conda/installer/assets/installer_welcome.txt +8 -0
  40. build/conda/installer/assets/openbb.icns +0 -0
  41. build/conda/installer/assets/openbb_icon.ico +0 -0
  42. build/conda/installer/assets/openbb_osx.png +0 -0
  43. build/conda/installer/assets/openbb_platform_installer/README.md +48 -0
  44. build/conda/installer/assets/openbb_platform_installer/obb-env.yml +5 -0
  45. build/conda/installer/assets/openbb_platform_installer/openbb_platform_installer/__init__.py +3 -0
  46. build/conda/installer/assets/openbb_platform_installer/openbb_platform_installer/update.py +30 -0
  47. build/conda/installer/assets/openbb_platform_installer/pyproject.toml +40 -0
  48. build/conda/installer/assets/openbb_win.png +0 -0
  49. build/conda/installer/construct.yaml +95 -0
  50. build/conda/installer/post_install.bat +61 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ build/conda/installer/assets/dmg_volume.icns filter=lfs diff=lfs merge=lfs -text
37
+ build/conda/installer/assets/Installer_vertical2.bmp filter=lfs diff=lfs merge=lfs -text
assets/README.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Assets
2
+
3
+ This folder should hold assets read by OpenBB applications, such as OpenBB Hub or marketing website.
4
+
5
+ The goal is to be more explicit about which assets are being used externally and cannot be deleted before checking where they are used.
assets/extensions/obbject.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "packageName": "openbb-charting",
4
+ "optional": true,
5
+ "description": "Create custom charts from OBBject data."
6
+ }
7
+ ]
assets/extensions/provider.json ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "packageName": "openbb-alpha-vantage",
4
+ "optional": true,
5
+ "reprName": "Alpha Vantage",
6
+ "description": "Alpha Vantage provides realtime and historical\nfinancial market data through a set of powerful and developer-friendly data APIs\nand spreadsheets. From traditional asset classes (e.g., stocks, ETFs, mutual funds)\nto economic indicators, from foreign exchange rates to commodities,\nfrom fundamental data to technical indicators, Alpha Vantage\nis your one-stop-shop for enterprise-grade global market data delivered through\ncloud-based APIs, Excel, and Google Sheets. ",
7
+ "credentials": [
8
+ "alpha_vantage_api_key"
9
+ ],
10
+ "deprecatedCredentials": {
11
+ "API_KEY_ALPHAVANTAGE": "alpha_vantage_api_key"
12
+ },
13
+ "website": "https://www.alphavantage.co",
14
+ "instructions": "Go to: https://www.alphavantage.co/support/#api-key\n\n![AlphaVantage](https://user-images.githubusercontent.com/46355364/207820936-46c2ba00-81ff-4cd3-98a4-4fa44412996f.png)\n\nFill out the form, pass Captcha, and click on, \"GET FREE API KEY\"."
15
+ },
16
+ {
17
+ "packageName": "openbb-benzinga",
18
+ "optional": false,
19
+ "reprName": "Benzinga",
20
+ "description": "Benzinga is a financial data provider that offers an API\nfocused on information that moves the market.",
21
+ "credentials": [
22
+ "benzinga_api_key"
23
+ ],
24
+ "website": "https://www.benzinga.com"
25
+ },
26
+ {
27
+ "packageName": "openbb-biztoc",
28
+ "optional": true,
29
+ "reprName": "BizToc",
30
+ "description": "BizToc uses Rapid API for its REST API.\nYou may sign up for your free account at https://rapidapi.com/thma/api/biztoc.\n\nThe Base URL for all requests is:\n\n https://biztoc.p.rapidapi.com/\n\nIf you're not a developer but would still like to use Biztoc outside of the main website,\nwe've partnered with OpenBB, allowing you to pull in BizToc's news stream in their Terminal.",
31
+ "credentials": [
32
+ "biztoc_api_key"
33
+ ],
34
+ "deprecatedCredentials": {
35
+ "API_BIZTOC_TOKEN": "biztoc_api_key"
36
+ },
37
+ "website": "https://api.biztoc.com",
38
+ "instructions": "The BizToc API is hosted on RapidAPI. To set up, go to: https://rapidapi.com/thma/api/biztoc.\n\n![biztoc0](https://github.com/marban/OpenBBTerminal/assets/18151143/04cdd423-f65e-4ad8-ad5a-4a59b0f5ddda)\n\nIn the top right, select 'Sign Up'. After answering some questions, you will be prompted to select one of their plans.\n\n![biztoc1](https://github.com/marban/OpenBBTerminal/assets/18151143/9f3b72ea-ded7-48c5-aa33-bec5c0de8422)\n\nAfter signing up, navigate back to https://rapidapi.com/thma/api/biztoc. If you are logged in, you will see a header called X-RapidAPI-Key.\n\n![biztoc2](https://github.com/marban/OpenBBTerminal/assets/18151143/0f3b6c91-07e0-447a-90cd-a9e23522929f)"
39
+ },
40
+ {
41
+ "packageName": "openbb-bls",
42
+ "optional": false,
43
+ "reprName": "Bureau of Labor Statistics' (BLS) Public Data API",
44
+ "description": "The Bureau of Labor Statistics' (BLS) Public Data Application Programming Interface (API) gives the public access to economic data from all BLS programs. It is the Bureau's hope that talented developers and programmers will use the BLS Public Data API to create original, inventive applications with published BLS data.",
45
+ "credentials": [
46
+ "bls_api_key"
47
+ ],
48
+ "website": "https://www.bls.gov/developers/api_signature_v2.htm",
49
+ "instructions": "Sign up for a free API key here: https://data.bls.gov/registrationEngine/"
50
+ },
51
+ {
52
+ "packageName": "openbb-cboe",
53
+ "optional": true,
54
+ "reprName": "Chicago Board Options Exchange (CBOE)",
55
+ "description": "Cboe is the world's go-to derivatives and exchange network,\ndelivering cutting-edge trading, clearing and investment solutions to people\naround the world.",
56
+ "credentials": [],
57
+ "website": "https://www.cboe.com"
58
+ },
59
+ {
60
+ "packageName": "openbb-cftc",
61
+ "optional": false,
62
+ "reprName": "Commodity Futures Trading Commission (CFTC) Public Reporting API",
63
+ "description": "The mission of the Commodity Futures Trading Commission (CFTC) is to promote the integrity,\n resilience, and vibrancy of the U.S. derivatives markets through sound regulation.",
64
+ "credentials": [
65
+ "cftc_app_token"
66
+ ],
67
+ "website": "https://cftc.gov/",
68
+ "instructions": "Credentials are not required, but your IP address may be subject to throttling limits.\n API requests made using an application token are not throttled.\n Create an account here: https://evergreen.data.socrata.com/signup\n and then generate the app_token by signing in with the credentials\n here: https://publicreporting.cftc.gov/profile/edit/developer_settings."
69
+ },
70
+ {
71
+ "packageName": "openbb-deribit",
72
+ "optional": true,
73
+ "reprName": "Deribit Public Data",
74
+ "description": "Unofficial Python client for public data published by Deribit.",
75
+ "credentials": [],
76
+ "website": "https://deribit.com/",
77
+ "instructions": "This provider does not require any credentials and is not meant for trading."
78
+ },
79
+ {
80
+ "packageName": "openbb-ecb",
81
+ "optional": true,
82
+ "reprName": "European Central Bank (ECB)",
83
+ "description": "The ECB Data Portal provides access to all official ECB statistics.\nThe portal also provides options to download data and comprehensive metadata for each dataset.\nStatistical publications and dashboards offer a compilation of key data on selected topics.",
84
+ "credentials": [],
85
+ "website": "https://data.ecb.europa.eu"
86
+ },
87
+ {
88
+ "packageName": "openbb-econdb",
89
+ "optional": false,
90
+ "reprName": "EconDB",
91
+ "description": "The mission of the company is to process information in ways that\nfacilitate understanding of the economic situation at different granularity levels.\n\nThe sources of data include official statistics agencies and so-called alternative\ndata sources where we collect direct observations of the market and generate\naggregate statistics.",
92
+ "credentials": [
93
+ "econdb_api_key"
94
+ ],
95
+ "website": "https://econdb.com"
96
+ },
97
+ {
98
+ "packageName": "openbb-federal-reserve",
99
+ "optional": false,
100
+ "reprName": "Federal Reserve (FED)",
101
+ "description": "Access data provided by the Federal Reserve System, the Central Bank of the United States.",
102
+ "credentials": [],
103
+ "website": "https://www.federalreserve.gov/data.htm"
104
+ },
105
+ {
106
+ "packageName": "openbb-finra",
107
+ "optional": true,
108
+ "reprName": "Financial Industry Regulatory Authority (FINRA)",
109
+ "description": "FINRA Data provides centralized access to the abundance of data FINRA\nmakes available to the public, media, researchers and member firms.",
110
+ "credentials": [],
111
+ "website": "https://www.finra.org/finra-data"
112
+ },
113
+ {
114
+ "packageName": "openbb-finviz",
115
+ "optional": true,
116
+ "reprName": "FinViz",
117
+ "description": "Unofficial Finviz API - https://github.com/lit26/finvizfinance/releases",
118
+ "credentials": [],
119
+ "website": "https://finviz.com"
120
+ },
121
+ {
122
+ "packageName": "openbb-fmp",
123
+ "optional": false,
124
+ "reprName": "Financial Modeling Prep (FMP)",
125
+ "description": "Financial Modeling Prep is a new concept that informs you about\nstock market information (news, currencies, and stock prices).",
126
+ "credentials": [
127
+ "fmp_api_key"
128
+ ],
129
+ "deprecatedCredentials": {
130
+ "API_KEY_FINANCIALMODELINGPREP": "fmp_api_key"
131
+ },
132
+ "website": "https://financialmodelingprep.com",
133
+ "instructions": "Go to: https://site.financialmodelingprep.com/developer/docs\n\n![FinancialModelingPrep](https://user-images.githubusercontent.com/46355364/207821920-64553d05-d461-4984-b0fe-be0368c71186.png)\n\nClick on, \"Get my API KEY here\", and sign up for a free account.\n\n![FinancialModelingPrep](https://user-images.githubusercontent.com/46355364/207822184-a723092e-ef42-4f87-8c55-db150f09741b.png)\n\nWith an account created, sign in and navigate to the Dashboard, which shows the assigned token. by pressing the \"Dashboard\" button which will show the API key.\n\n![FinancialModelingPrep](https://user-images.githubusercontent.com/46355364/207823170-dd8191db-e125-44e5-b4f3-2df0e115c91d.png)"
134
+ },
135
+ {
136
+ "packageName": "openbb-fred",
137
+ "optional": false,
138
+ "reprName": "Federal Reserve Economic Data | St. Louis FED (FRED)",
139
+ "description": "Federal Reserve Economic Data is a database maintained by the\nResearch division of the Federal Reserve Bank of St. Louis that has more than\n816,000 economic time series from various sources.",
140
+ "credentials": [
141
+ "fred_api_key"
142
+ ],
143
+ "deprecatedCredentials": {
144
+ "API_FRED_KEY": "fred_api_key"
145
+ },
146
+ "website": "https://fred.stlouisfed.org",
147
+ "instructions": "Go to: https://fred.stlouisfed.org\n\n![FRED](https://user-images.githubusercontent.com/46355364/207827137-d143ba4c-72cb-467d-a7f4-5cc27c597aec.png)\n\nClick on, \"My Account\", create a new account or sign in with Google:\n\n![FRED](https://user-images.githubusercontent.com/46355364/207827011-65cdd501-27e3-436f-bd9d-b0d8381d46a7.png)\n\nAfter completing the sign-up, go to \"My Account\", and select \"API Keys\". Then, click on, \"Request API Key\".\n\n![FRED](https://user-images.githubusercontent.com/46355364/207827577-c869f989-4ef4-4949-ab57-6f3931f2ae9d.png)\n\nFill in the box for information about the use-case for FRED, and by clicking, \"Request API key\", at the bottom of the page, the API key will be issued.\n\n![FRED](https://user-images.githubusercontent.com/46355364/207828032-0a32d3b8-1378-4db2-9064-aa1eb2111632.png)"
148
+ },
149
+ {
150
+ "packageName": "openbb-government-us",
151
+ "optional": true,
152
+ "reprName": "Data.gov | United States Government",
153
+ "description": "Data.gov is the United States government's open data website.\nIt provides access to datasets published by agencies across the federal government.\nData.gov is intended to provide access to government open data to the public, achieve\nagency missions, drive innovation, fuel economic activity, and uphold the ideals of\nan open and transparent government.",
154
+ "credentials": [],
155
+ "website": "https://data.gov"
156
+ },
157
+ {
158
+ "packageName": "openbb-imf",
159
+ "optional": false,
160
+ "reprName": "International Monetary Fund (IMF) Public Data API",
161
+ "description": "This provider allows you to access International Monetary Fund data through the IMF Public Data API.",
162
+ "credentials": [],
163
+ "website": "https://datahelp.imf.org/knowledgebase/articles/667681-using-json-restful-web-service"
164
+ },
165
+ {
166
+ "packageName": "openbb-intrinio",
167
+ "optional": false,
168
+ "reprName": "Intrinio",
169
+ "description": "Intrinio is a financial data platform that provides real-time and\nhistorical financial market data to businesses and developers through an API.",
170
+ "credentials": [
171
+ "intrinio_api_key"
172
+ ],
173
+ "deprecatedCredentials": {
174
+ "API_INTRINIO_KEY": "intrinio_api_key"
175
+ },
176
+ "website": "https://intrinio.com",
177
+ "instructions": "Go to: https://intrinio.com/starter-plan\n\n![Intrinio](https://user-images.githubusercontent.com/85772166/219207556-fcfee614-59f1-46ae-bff4-c63dd2f6991d.png)\n\nAn API key will be issued with a subscription. Find the token value within the account dashboard."
178
+ },
179
+ {
180
+ "packageName": "openbb-multpl",
181
+ "optional": true,
182
+ "description": "Public broad-market data published to https://multpl.com.",
183
+ "credentials": [],
184
+ "website": "https://www.multpl.com/"
185
+ },
186
+ {
187
+ "packageName": "openbb-nasdaq",
188
+ "optional": true,
189
+ "reprName": "NASDAQ",
190
+ "description": "Positioned at the nexus of technology and the capital markets, Nasdaq\nprovides premier platforms and services for global capital markets and beyond with\nunmatched technology, insights and markets expertise.",
191
+ "credentials": [
192
+ "nasdaq_api_key"
193
+ ],
194
+ "deprecatedCredentials": {
195
+ "API_KEY_QUANDL": "nasdaq_api_key"
196
+ },
197
+ "website": "https://data.nasdaq.com",
198
+ "instructions": "Go to: https://www.quandl.com\n\n![Quandl](https://user-images.githubusercontent.com/46355364/207823899-208a3952-f557-4b73-aee6-64ac00faedb7.png)\n\nClick on, \"Sign Up\", and register a new account.\n\n![Quandl](https://user-images.githubusercontent.com/46355364/207824214-4b6b2b74-e709-4ed4-adf2-14803e6f3568.png)\n\nFollow the sign-up instructions, and upon completion the API key will be assigned.\n\n![Quandl](https://user-images.githubusercontent.com/46355364/207824664-3c82befb-9c69-42df-8a82-510d85c19a97.png)"
199
+ },
200
+ {
201
+ "packageName": "openbb-oecd",
202
+ "optional": false,
203
+ "reprName": "Organization for Economic Co-operation and Development (OECD)",
204
+ "description": "OECD Data Explorer includes data and metadata for OECD countries and selected\nnon-member economies.",
205
+ "credentials": [],
206
+ "website": "https://data-explorer.oecd.org/"
207
+ },
208
+ {
209
+ "packageName": "openbb-polygon",
210
+ "optional": false,
211
+ "reprName": "Polygon.io",
212
+ "description": "The Polygon.io Stocks API provides REST endpoints that let you query\nthe latest market data from all US stock exchanges. You can also find data on\ncompany financials, stock market holidays, corporate actions, and more.",
213
+ "credentials": [
214
+ "polygon_api_key"
215
+ ],
216
+ "deprecatedCredentials": {
217
+ "API_POLYGON_KEY": "polygon_api_key"
218
+ },
219
+ "website": "https://polygon.io",
220
+ "instructions": "Go to: https://polygon.io\n\n![Polygon](https://user-images.githubusercontent.com/46355364/207825623-fcd7f0a3-131a-4294-808c-754c13e38e2a.png)\n\nClick on, \"Get your Free API Key\".\n\n![Polygon](https://user-images.githubusercontent.com/46355364/207825952-ca5540ec-6ed2-4cef-a0ed-bb50b813932c.png)\n\nAfter signing up, the API Key is found at the bottom of the account dashboard page.\n\n![Polygon](https://user-images.githubusercontent.com/46355364/207826258-b1f318fa-fd9c-41d9-bf5c-fe16722e6601.png)"
221
+ },
222
+ {
223
+ "packageName": "openbb-sec",
224
+ "optional": false,
225
+ "reprName": "Securities and Exchange Commission (SEC)",
226
+ "description": "SEC is the public listings regulatory body for the United States.",
227
+ "credentials": [],
228
+ "website": "https://www.sec.gov/data"
229
+ },
230
+ {
231
+ "packageName": "openbb-seeking-alpha",
232
+ "optional": true,
233
+ "reprName": "Seeking Alpha",
234
+ "description": "Seeking Alpha is a data provider with access to news, analysis, and\nreal-time alerts on stocks.",
235
+ "credentials": [],
236
+ "website": "https://seekingalpha.com"
237
+ },
238
+ {
239
+ "packageName": "openbb-stockgrid",
240
+ "optional": true,
241
+ "reprName": "Stockgrid",
242
+ "description": "Stockgrid gives you a detailed view of what smart money is doing.\nGet in depth data about large option blocks being traded, including\nthe sentiment score, size, volume and order type. Stop guessing and\nbuild a strategy around the number 1 factor moving the market: money.",
243
+ "credentials": [],
244
+ "website": "https://www.stockgrid.io"
245
+ },
246
+ {
247
+ "packageName": "openbb-tiingo",
248
+ "optional": false,
249
+ "reprName": "Tiingo",
250
+ "description": "A Reliable, Enterprise-Grade Financial Markets API. Tiingo's APIs\npower hedge funds, tech companies, and individuals.",
251
+ "credentials": [
252
+ "tiingo_token"
253
+ ],
254
+ "website": "https://tiingo.com"
255
+ },
256
+ {
257
+ "packageName": "openbb-tmx",
258
+ "optional": true,
259
+ "reprName": "TMX",
260
+ "description": "Unofficial TMX Data Provider Extension\n TMX Group Companies\n - Toronto Stock Exchange\n - TSX Venture Exchange\n - TSX Trust\n - Montr\u00e9al Exchange\n - TSX Alpha Exchange\n - Shorcan\n - CDCC\n - CDS\n - TMX Datalinx\n - Trayport\n ",
261
+ "credentials": [],
262
+ "website": "https://www.tmx.com"
263
+ },
264
+ {
265
+ "packageName": "openbb-tradier",
266
+ "optional": true,
267
+ "reprName": "Tradier",
268
+ "description": "Tradier provides a full range of services in a scalable, secure,\nand easy-to-use REST-based API for businesses and individual developers.\nFast, secure, simple. Start in minutes.\nGet access to trading, account management, and market-data for\nTradier Brokerage accounts through our APIs.",
269
+ "credentials": [
270
+ "tradier_api_key",
271
+ "tradier_account_type"
272
+ ],
273
+ "deprecatedCredentials": {
274
+ "API_TRADIER_TOKEN": "tradier_api_key"
275
+ },
276
+ "website": "https://tradier.com",
277
+ "instructions": "Go to: https://documentation.tradier.com\n\n![Tradier](https://user-images.githubusercontent.com/46355364/207829178-a8bba770-f2ea-4480-b28e-efd81cf30980.png)\n\nClick on, \"Open Account\", to start the sign-up process. After the account has been setup, navigate to [Tradier Broker Dash](https://dash.tradier.com/login?redirect=settings.api) and create the application. Request a sandbox access token."
278
+ },
279
+ {
280
+ "packageName": "openbb-tradingeconomics",
281
+ "optional": false,
282
+ "reprName": "Trading Economics",
283
+ "description": "Trading Economics provides its users with accurate information for\n196 countries including historical data and forecasts for more than 20 million economic\nindicators, exchange rates, stock market indexes, government bond yields and commodity\nprices. Our data for economic indicators is based on official sources, not third party\ndata providers, and our facts are regularly checked for inconsistencies.\nTrading Economics has received nearly 2 billion page views from all around the\nworld.",
284
+ "credentials": [
285
+ "tradingeconomics_api_key"
286
+ ],
287
+ "website": "https://tradingeconomics.com"
288
+ },
289
+ {
290
+ "packageName": "openbb-us-eia",
291
+ "optional": false,
292
+ "reprName": "U.S. Energy Information Administration (EIA) Open Data and API",
293
+ "description": "The U.S. Energy Information Administration is committed to its free and open data by making it available through an Application Programming Interface (API) and its open data tools. See https://www.eia.gov/opendata/ for more information.",
294
+ "credentials": [
295
+ "eia_api_key"
296
+ ],
297
+ "website": "https://eia.gov/",
298
+ "instructions": "Credentials are required for functions calling the EIA's API.\n Register for a free key here: https://www.eia.gov/opendata/register.php"
299
+ },
300
+ {
301
+ "packageName": "openbb-wsj",
302
+ "optional": true,
303
+ "reprName": "Wall Street Journal (WSJ)",
304
+ "description": "WSJ (Wall Street Journal) is a business-focused, English-language\ninternational daily newspaper based in New York City. The Journal is published six\ndays a week by Dow Jones & Company, a division of News Corp, along with its Asian\nand European editions. The newspaper is published in the broadsheet format and\nonline. The Journal has been printed continuously since its inception on\nJuly 8, 1889, by Charles Dow, Edward Jones, and Charles Bergstresser.\nThe WSJ is the largest newspaper in the United States, by circulation.\n ",
305
+ "credentials": [],
306
+ "website": "https://www.wsj.com"
307
+ },
308
+ {
309
+ "packageName": "openbb-yfinance",
310
+ "optional": false,
311
+ "reprName": "Yahoo Finance",
312
+ "description": "Yahoo! Finance is a web-based platform that offers financial news,\ndata, and tools for investors and individuals interested in tracking and analyzing\nfinancial markets and assets.",
313
+ "credentials": [],
314
+ "website": "https://finance.yahoo.com"
315
+ }
316
+ ]
assets/extensions/router.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "packageName": "openbb-commodity",
4
+ "optional": false,
5
+ "description": "Commodity market data."
6
+ },
7
+ {
8
+ "packageName": "openbb-crypto",
9
+ "optional": false,
10
+ "description": "Cryptocurrency market data."
11
+ },
12
+ {
13
+ "packageName": "openbb-currency",
14
+ "optional": false,
15
+ "description": "Foreign exchange (FX) market data."
16
+ },
17
+ {
18
+ "packageName": "openbb-derivatives",
19
+ "optional": false,
20
+ "description": "Derivatives market data."
21
+ },
22
+ {
23
+ "packageName": "openbb-econometrics",
24
+ "optional": true,
25
+ "description": "Econometrics analysis tools."
26
+ },
27
+ {
28
+ "packageName": "openbb-economy",
29
+ "optional": false,
30
+ "description": "Economic data."
31
+ },
32
+ {
33
+ "packageName": "openbb-equity",
34
+ "optional": false,
35
+ "description": "Equity market data."
36
+ },
37
+ {
38
+ "packageName": "openbb-etf",
39
+ "optional": false,
40
+ "description": "Exchange Traded Funds market data."
41
+ },
42
+ {
43
+ "packageName": "openbb-fixedincome",
44
+ "optional": false,
45
+ "description": "Fixed Income market data."
46
+ },
47
+ {
48
+ "packageName": "openbb-index",
49
+ "optional": false,
50
+ "description": "Indices data."
51
+ },
52
+ {
53
+ "packageName": "openbb-news",
54
+ "optional": false,
55
+ "description": "Financial market news data."
56
+ },
57
+ {
58
+ "packageName": "openbb-quantitative",
59
+ "optional": true,
60
+ "description": "Quantitative analysis tools."
61
+ },
62
+ {
63
+ "packageName": "openbb-regulators",
64
+ "optional": false,
65
+ "description": "Financial market regulators data."
66
+ },
67
+ {
68
+ "packageName": "openbb-technical",
69
+ "optional": true,
70
+ "description": "Technical Analysis tools."
71
+ }
72
+ ]
assets/scripts/generate_extension_data.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generate assets from modules."""
2
+
3
+ from importlib import import_module
4
+ from json import dump
5
+ from pathlib import Path
6
+ from typing import Any, Dict, List
7
+
8
+ from poetry.core.pyproject.toml import PyProjectTOML
9
+
10
+ THIS_DIR = Path(__file__).parent
11
+ OPENBB_PLATFORM_PATH = Path(THIS_DIR, "..", "..", "openbb_platform")
12
+ PROVIDERS_PATH = OPENBB_PLATFORM_PATH / "providers"
13
+ EXTENSIONS_PATH = OPENBB_PLATFORM_PATH / "extensions"
14
+ OBBJECT_EXTENSIONS_PATH = OPENBB_PLATFORM_PATH / "obbject_extensions"
15
+
16
+ OPENBB_PLATFORM_TOML = PyProjectTOML(OPENBB_PLATFORM_PATH / "pyproject.toml")
17
+
18
+
19
+ def to_title(string: str) -> str:
20
+ """Format string to title."""
21
+ return " ".join(string.split("_")).title()
22
+
23
+
24
+ def get_packages(path: Path, plugin_key: str) -> Dict[str, Any]:
25
+ """Get packages."""
26
+ SKIP = ["tests", "__pycache__"]
27
+ folders = [f for f in path.glob("*") if f.is_dir() and f.stem not in SKIP]
28
+ packages: Dict[str, Any] = {}
29
+ for f in folders:
30
+ pyproject = PyProjectTOML(Path(f, "pyproject.toml"))
31
+
32
+ if not pyproject.data:
33
+ continue
34
+
35
+ poetry = pyproject.data["tool"]["poetry"]
36
+ name = poetry["name"]
37
+ plugin = poetry.get("plugins", {}).get(plugin_key)
38
+ packages[name] = {"plugin": list(plugin.values())[0] if plugin else ""}
39
+ return packages
40
+
41
+
42
+ def write(filename: str, data: Any):
43
+ """Write to json."""
44
+ with open(Path(THIS_DIR, "..", "extensions", f"{filename}.json"), "w") as json_file:
45
+ dump(data, json_file, indent=4)
46
+
47
+
48
+ def to_camel(string: str):
49
+ """Convert string to camel case."""
50
+ components = string.split("_")
51
+ return components[0] + "".join(x.title() for x in components[1:])
52
+
53
+
54
+ def create_item(package_name: str, obj: object, obj_attrs: List[str]) -> Dict[str, Any]:
55
+ """Create dictionary item from object attributes."""
56
+ pkg_spec = OPENBB_PLATFORM_TOML.data["tool"]["poetry"]["dependencies"].get(
57
+ package_name
58
+ )
59
+ optional = pkg_spec.get("optional", False) if isinstance(pkg_spec, dict) else False
60
+ item = {"packageName": package_name, "optional": optional}
61
+ item.update(
62
+ {to_camel(a): getattr(obj, a) for a in obj_attrs if getattr(obj, a) is not None}
63
+ )
64
+ return item
65
+
66
+
67
+ def generate_provider_extensions() -> None:
68
+ """Generate providers_extensions.json."""
69
+ packages = get_packages(PROVIDERS_PATH, "openbb_provider_extension")
70
+ data: List[Dict[str, Any]] = []
71
+ obj_attrs = [
72
+ "repr_name",
73
+ "description",
74
+ "credentials",
75
+ "deprecated_credentials",
76
+ "website",
77
+ "instructions",
78
+ ]
79
+
80
+ for pkg_name, details in sorted(packages.items()):
81
+ plugin = details.get("plugin", "")
82
+ file_obj = plugin.split(":")
83
+ if len(file_obj) == 2:
84
+ file, obj = file_obj[0], file_obj[1]
85
+ module = import_module(file)
86
+ provider_obj = getattr(module, obj)
87
+ data.append(create_item(pkg_name, provider_obj, obj_attrs))
88
+ write("provider", data)
89
+
90
+
91
+ def generate_router_extensions() -> None:
92
+ """Generate router_extensions.json."""
93
+ packages = get_packages(EXTENSIONS_PATH, "openbb_core_extension")
94
+ data: List[Dict[str, Any]] = []
95
+ obj_attrs = ["description"]
96
+ for pkg_name, details in sorted(packages.items()):
97
+ plugin = details.get("plugin", "")
98
+ file_obj = plugin.split(":")
99
+ if len(file_obj) == 2:
100
+ file, obj = file_obj[0], file_obj[1]
101
+ module = import_module(file)
102
+ router_obj = getattr(module, obj)
103
+ data.append(create_item(pkg_name, router_obj, obj_attrs))
104
+ write("router", data)
105
+
106
+
107
+ def generate_obbject_extensions() -> None:
108
+ """Generate obbject_extensions.json."""
109
+ packages = get_packages(OBBJECT_EXTENSIONS_PATH, "openbb_obbject_extension")
110
+ data: List[Dict[str, Any]] = []
111
+ obj_attrs = ["description"]
112
+ for pkg_name, details in sorted(packages.items()):
113
+ plugin = details.get("plugin", "")
114
+ file_obj = plugin.split(":")
115
+ if len(file_obj) == 2:
116
+ file, obj = file_obj[0], file_obj[1]
117
+ module = import_module(file)
118
+ ext_obj = getattr(module, obj)
119
+ data.append(create_item(pkg_name, ext_obj, obj_attrs))
120
+ write("obbject", data)
121
+
122
+
123
+ if __name__ == "__main__":
124
+ generate_provider_extensions()
125
+ generate_router_extensions()
126
+ generate_obbject_extensions()
build/conda/README.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenBB Platform Installer
2
+
3
+ The code in this folder creates a packaged installer for the OpenBB Platform, using Conda Constructor.
4
+
5
+ The installers can be created for Windows (.exe), macOS (.pkg).
6
+
7
+ The installer is distributed with a Conda environment that contains Python and package management tools.
8
+
9
+ The dependencies required to run the application are installed from PyPI by the constructor's post_install script. They are installed by poetry and are defined in the `installer/assets/openbb_platform_installer/pyproject.toml` file.
10
+
11
+ The version of Python is defined in the `construct.yaml` file. It is set for 3.12.
12
+
13
+ ## Build Instructions
14
+
15
+ **In order to build the installer, conda should be already installed and initialized your current shell profile.**
16
+
17
+ Navigate into the `build/conda` folder and then begin.
18
+
19
+ 1. Create the Conda environment.
20
+ - `conda env create --file environments/constructor.yml`
21
+ 2. Activate the environment.
22
+ - `conda activate constructor`
23
+ 3. Build the installer.
24
+ - `constructor installer/.`
25
+
26
+ ## For when we have a full NSIS
27
+
28
+ To check nsis file - run
29
+
30
+ ```batch
31
+ miniconda3\envs\constructor\NSIS\makensis.exe /V2 assets\installer.nsi
32
+ ```
33
+
34
+ gives better output for errors
35
+
36
+ ```batch
37
+ miniconda3\envs\constructor\NSIS\makensis.exe /V4 assets\installer.nsi
38
+ ```
build/conda/environments/constructor.yml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ name: constructor
2
+ channels:
3
+ - conda-forge
4
+ - defaults
5
+ dependencies:
6
+ - conda-build
7
+ - constructor>=3.9.3
8
+ - six
9
+ - urllib3
10
+ - requests
build/conda/installer/README.md ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenBB Platform
2
+
3
+ Thanks for installing the OpenBB Platform. To get the most out of your experience, we recommend reviewing the contents of this document.
4
+
5
+ If you have never used Python before, don't worry, your first time is just a double-click away. The sections below outline everything you need to know for getting started.
6
+
7
+ ## What Did I Install?
8
+
9
+ This is a kitted out development container for Pythonic, open source, financial research. It has everything you need to get started immediately.
10
+
11
+ Included is a complete installation of the OpenBB Platform and CLI, along with Conda and Jupyter Notebook, in an isolated Python 3.12 Conda environment.
12
+
13
+ If you already have an installation of Conda or Anaconda, the version in this folder will not rely on, interfere, or share base environment paths with, existing versions.
14
+
15
+ Tools for managing, updating, and building environments allow you to take full control of your installation, as well as quickly spin up new containers within this project folder.
16
+
17
+ Follow the quick start steps below to get started using right away; or, open one of the shortcuts described below.
18
+
19
+ If you want to build your own endpoints, connections, and features, try installing the [example extensions](#examples)
20
+
21
+ ## OpenBB Workspace Quick Start
22
+
23
+ - Login to the [OpenBB Hub](https://my.openbb.co)
24
+ - Optionally, add API keys for remote authorization on the page [here](https://my.openbb.dev/app/platform/credentials).
25
+ - If credentials have been added, from the sidebar, click on 'Personal Access Token'.
26
+ - Generate a token and copy the value to the clipboard.
27
+ - Optionally, from the sidebar, click on 'Widgets' to filter out any provider extensions or endpoints you wish to exclude.
28
+ - Without filtering, there will be well over 300 individual widgets. This will narrow the field and focus on only what you need.
29
+ - After configuring, download the file ("widget_settings.json") and save it to, `~/.openbb_platform`. The "Settings" shortcut takes you there.
30
+ - Double-click on the `openbb-api` shortcut.
31
+ - If you generated a personal access token, paste the values that were copied to the clipboard and hit the return key.
32
+ - Enter y/n to persist the downloaded credentials on the local machine for future sessions.
33
+
34
+ - By default, the server will be running on: [http://127.0.0.1:6900](http://127.0.0.1:6900)
35
+
36
+ - Login to OpenBB Workspace [here](https://pro.openbb.co)
37
+ - From the sidebar, click on, "Data Connectors".
38
+ - Then click on the button, "Add Data".
39
+ - In the pop-up menu, select "Custom Backend".
40
+ - Enter a name for the connection - i.e, "OpenBB Platform"
41
+ - Enter the address the server is running on - i.e, "http://127.0.0.1:6900"
42
+ - **Ensure that "Validate Widgets" is set to "No".**
43
+ - Click on the "Test" button.
44
+ - Finally, click on the "Add" button.
45
+
46
+ The OpenBB Platform API widgets can now be added to any dashboard. For a more detailed version of these instructions, see the documentation page [here](https://docs.openbb.co/pro/custom-backend)
47
+
48
+ ## Shortcuts
49
+
50
+ At the root of the installation folder (where this document is) are shortcuts for launchers and to key file locations.
51
+
52
+ - Bash (Windows: CMD): Opens a command line shell with the base Conda environment activated. Activate the OpenBB environment with:
53
+ - Mac/Linux: `source activate obb`
54
+ - Windows: `conda activate obb`
55
+ - Environments: Shortcut to the root "envs" folder, where the `obb` and any created environments are stored.
56
+ - "widgets.json" is located in the "assets" subdirectory.
57
+ - openbb-api: Opens a Terminal window and launches the OpenBB API, with optional prompts to login with your OpenBB Hub PAT.
58
+ - openbb-cli: Opens a Terminal window and launches the OpenBB CLI (formerly OpenBB Terminal).
59
+ - openbb-ipython: Opens a Terminal window and starts an IPython session with the OpenBB Platform package imported.
60
+ - openbb-notebook: Opens a Terminal window, starts the Jupyter development server, and opens a browser window with the Notebook application.
61
+ - OpenBBUserData: Shortcut to the OpenBBUserData folder. Files exported from CLI are saved here.
62
+ - Settings: Shortcut to the `~/.openbb_platform` location where `.env` files and `user_settings.json` are stored.
63
+ - If you cannot see the ".env" file, set Finder/Explorer to display hidden/system files.
64
+ - Update: Opens a Terminal window and updates the OpenBB Platform environment (obb) and packages.
65
+
66
+ ## Command Line Entry Points
67
+
68
+ There are several command line entry points available when either:
69
+ - The OpenBB Platform environment (obb) is active.
70
+ - The "openbb_platform_installer" package has been installed in the active Python environment.
71
+
72
+ ### OpenBB Entry Points
73
+
74
+ - openbb: Launches the OpenBB CLI.
75
+ - openbb-api: Launches the API and accepts select arguments.
76
+ - All args/kwargs available to `uvicorn run` are exposed.
77
+ - `--login`: True/False. Defeats the login prompt when False.
78
+ - `--no-build`: Skips building "widgets.json"
79
+ - openbb-build: Runs the build script that generates the static assets for the OpenBB Python interface.
80
+ - Run this after installing/uninstalling/updating OpenBB extensions
81
+ - Automatically run when `openbb-update` is run.
82
+ - openbb-update: Updates the environment packages defined in `pyproject.toml` and `poetry.lock` and rebuilds the OpenBB Python interface.
83
+ - Location of Poetry files: "/extensions/openbb_platform_installer"
84
+ - Passes all args/kwargs to `poetry install`.
85
+
86
+ ### Starting The OpenBB Platform API With Optional Arguments
87
+
88
+ 1. Open the `Bash` (`CMD` on Windows) shortcut.
89
+ 2. Activate the `obb` environment
90
+ - Unix: `source activate obb`
91
+ - Windows: `conda activate obb`
92
+ 3. Run `openbb-api` with `--parameter value` to add any `uvicorn.run` parameter.
93
+
94
+ ### OpenBB Platform API Over HTTPS
95
+
96
+ To run the API over the HTTPS protocol, you must first create a self-signed certificate and the associated key. After steps 1 & 2 above, you can generate the files by entering this to the command line:
97
+
98
+ ```sh
99
+ openssl req -x509 -days 3650 -out localhost.crt -keyout localhost.key -newkey rsa:4096 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config <( \
100
+ printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
101
+ ```
102
+
103
+ Two files will be created, in the current working directory, that are passed as keyword arguments to the `openbb-api` entry point.
104
+
105
+ ```sh
106
+ openbb-api --ssl_keyfile localhost.key --ssl_certfile localhost.crt
107
+ ```
108
+
109
+ **Note**: Adjust the command to include the full path to the file if the current working directory is not where they are located.
110
+
111
+
112
+ The certificate - `localhost.crt` - will need to be added to system's trust store. The process for this will depend on the operating system and the user account privilege.
113
+
114
+ A quick solution is to visit the server's URL, show the details of the warning, and choose to continue anyways.
115
+
116
+ Contact the system administrator if you are using a work device and require additional permissions to complete the configuration.
117
+
118
+ ![This Connection Is Not Private](https://in.norton.com/content/dam/blogs/images/norton/am/this_connection_not_is_private.png)
119
+
120
+ ## Installed Folder Structure
121
+
122
+ At the root of the installation (where this document is), there will be three folders:
123
+
124
+ - conda (Windows: This is named after the last folder path if the default was not used)
125
+ - extensions
126
+ - notebooks
127
+
128
+ ### Conda
129
+
130
+ This is the folder where Conda is installed and all environment data (site-packages, etc.) is stored. The "Environments" shortcuts takes you to the root of the "envs" folder.
131
+
132
+ ### Extensions
133
+
134
+ This folder contains two subfolders:
135
+
136
+ ### Notebooks
137
+
138
+ This folder contains tutorial notebooks with examples for getting started with Python and the OpenBB Platform. They can be opened by launching the `openbb-notebook` shortcut.
139
+
140
+ #### examples
141
+
142
+ Contains empty example extensions for the three types of OpenBB Platform extensions:
143
+
144
+ - Router
145
+ - Provider
146
+ - OBBject
147
+
148
+ To install all three examples in the OpenBB Platform environment, open the Bash/CMD shortcut and enter:
149
+
150
+ ```console
151
+ source activate obb # CMD: conda activate obb
152
+ cd extensions/examples
153
+ python install_examples.py
154
+ ```
155
+
156
+ #### openbb_platform_installer
157
+
158
+ This is a meta package for installing and managing OpenBB Platform installation within any Python environment.
159
+ Poetry is used to update and resolve any dependencies that are defined in the `pyproject.toml` file.
160
+
161
+ The `poetry.lock` file is updated every time the `Update` shortcut is run.
162
+
163
+ There are several configurations available, via combinations of `--with`, `--without`, and `--only` parameters, when running `poetry install`.
164
+
165
+ Choices are:
166
+
167
+ - main
168
+ - openbb-all
169
+ - cli
170
+ - notebook
171
+
172
+ Each parameter will accept multiple items, but `--without` takes priority for solving for the environment.
173
+
174
+ ## Uninstallation
175
+
176
+ Mac/Linux users can uninstall by deleting the folder, while Windows users can run the Uninstall shortcut.
177
+
178
+ The leftover artifacts will include:
179
+
180
+ - Global configuration files stored by Poetry, PIP, Conda, and Jupyter.
181
+ - Third-party Python package caches and `.env` files.
182
+ - Folders:
183
+ - ~/.openbb_platform
184
+ - ~/OpenBBUserData
185
+
186
+ Windows users will also need to remove the parent folder where it was originally installed, after running Uninstall.
187
+
188
+ Your OpenBB Hub account can be deleted, along with all associated data, from the Account page in [my.openbb.co](https://my.openbb.co)
189
+
190
+ ## Additional Information
191
+
192
+ ### Conda Install vs. PIP Install vs. Poetry Install
193
+
194
+ The three ways to install packages may appear to accomplish the same objectives - installing Python packages - but each has a distinctly different purpose.
195
+
196
+ An easy way to think about the difference is, both `pip` and `poetry` require an existing Python installation; `conda` installs Python so that you can run `pip install poetry`.
197
+
198
+ In general, you use:
199
+
200
+ - `conda`
201
+ - When a new environment has been created. Packages here can be included in the creation command, `conda create`.
202
+ - When the specific package is only distributed through Conda or the `conda-forge` channel.
203
+ - When changing the version of Python used within the environment.
204
+ - For interactions with the machine code layer of the system - e.g., compilers, and bridges to "outside of Python" land.
205
+ - `pip`
206
+ - When installing/uninstalling packages to the activated Python environment.
207
+ - Resort to `conda install` when packages fail to install, or wheels cannot be built, from PyPI.
208
+ - `poetry`
209
+ - Installing a local Python package.
210
+ - Syncing all package dependencies according to provided specs in `pyproject.toml` and `poetry.lock` files.
211
+ - Building and distributing Python packages.
212
+
213
+ Conda is for container management and machine code level operations, Poetry resolves the project's dependencies and provides build/distribution tools within the current Python environment, while `pip` is for installing Python packages - typically from [PyPI](https://pypi.org).
214
+
215
+ ### Documentation Resources
216
+
217
+ ### OpenBB
218
+ - [OpenBB Pro](https://docs.openbb.co/pro)
219
+ - [OpenBB Pro Data Connectors](https://docs.openbb.co/pro/data-connector)
220
+ - [widgets.json](https://docs.openbb.co/pro/custom-backend/widgets.json)
221
+ - [OpenBB Platform](https://docs.openbb.co/platform)
222
+ - [OpenBB Platform Quickstart](https://docs.openbb.co/platform/getting_started/quickstart)
223
+ - [OpenBB CLI](https://docs.openbb.co/cli)
224
+ - [OpenBB User Settings](https://docs.openbb.co/platform/user_guides/settings_and_environment_variables)
225
+ - [API Keys and Authorization](https://docs.openbb.co/platform/getting_started/api_keys)
226
+ - [REST API Requests](https://docs.openbb.co/platform/getting_started/api_requests)
227
+ - [OpenBB Platform Architecture Overview](https://docs.openbb.co/platform/developer_guide/architecture_overview)
228
+ - [Create A New Router Extension](https://docs.openbb.co/platform/getting_started/create_new_router_extension)
229
+ - [OpenBB Charting](https://github.com/OpenBB-finance/OpenBB/tree/develop/openbb_platform/obbject_extensions/charting#readme)
230
+ - [PyWry](https://github.com/OpenBB-finance/pywry)
231
+
232
+ ### External
233
+
234
+ - [python](https://docs.python.org/3/)
235
+ - [conda create](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#managing-environments)
236
+ - [pyproject.toml](https://python-poetry.org/docs/pyproject/)
237
+ - [requirements.txt](https://pip.pypa.io/en/stable/reference/requirements-file-format/)
238
+ - [pip](https://pip.pypa.io/en/stable/)
239
+ - [poetry config](https://python-poetry.org/docs/configuration)
240
+ - [pydantic](https://docs.pydantic.dev/latest/)
241
+ - [uvicorn](https://www.uvicorn.org/)
242
+ - [fastapi](https://fastapi.tiangolo.com/)
243
+ - [jupyter](https://docs.jupyter.org/en/latest/)
244
+ - [pandas](https://pandas.pydata.org/docs/)
245
+ - [numpy](https://numpy.org/doc/)
246
+ - [Plotly Graph Objects](https://plotly.com/python/graph-objects/)
build/conda/installer/assets/Installer_horizontal.bmp ADDED
build/conda/installer/assets/Installer_horizontal2.png ADDED
build/conda/installer/assets/Installer_vertical2.bmp ADDED

Git LFS Details

  • SHA256: 47b558253268762d87b97e358a103db267e54f9f54a5805d82fcdafaa3093bf3
  • Pointer size: 131 Bytes
  • Size of remote file: 357 kB
build/conda/installer/assets/create_shortcut.vbs ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Set objShell = CreateObject("WScript.Shell")
2
+ sdesktopPath = objShell.SpecialFolders("Desktop")
3
+
4
+ Set fso = CreateObject("Scripting.FileSystemObject")
5
+ prefixPath = objShell.ExpandEnvironmentStrings("%PREFIX%")
6
+ userProfilePath = objShell.ExpandEnvironmentStrings("%USERPROFILE%")
7
+ currentPath = fso.GetAbsolutePathName(prefixPath)
8
+ parentFolder = fso.GetParentFolderName(currentPath)
9
+ shortcutFolder = parentFolder
10
+
11
+ Set objFSO = CreateObject("Scripting.FileSystemObject")
12
+ If Not objFSO.FolderExists(shortcutFolder) Then
13
+ objFSO.CreateFolder(shortcutFolder)
14
+ End If
15
+
16
+ If prefixPath = "%PREFIX%" Or userProfilePath = "%USERPROFILE%" Then
17
+ WScript.Echo "Environment variables %PREFIX% or %USERPROFILE% are not set correctly."
18
+ WScript.Quit 1
19
+ End If
20
+
21
+ Sub CreateShortcut(name, targetPath, iconPath)
22
+ Set objShell = CreateObject("WScript.Shell")
23
+ Set objShortcut = objShell.CreateShortcut(shortcutFolder & "\" & name & ".lnk")
24
+ objShortcut.TargetPath = objShell.ExpandEnvironmentStrings(targetPath)
25
+ objShortcut.IconLocation = objShell.ExpandEnvironmentStrings(iconPath)
26
+ objShortcut.Description = name
27
+ objShortcut.Save
28
+ End Sub
29
+
30
+ CreateShortcut "openbb-cli", "C:\Windows\System32\cmd.exe", prefixPath & "\assets\openbb_icon.ico"
31
+ CreateShortcut "openbb-api", "C:\Windows\System32\cmd.exe", prefixPath & "\assets\openbb_icon.ico"
32
+ CreateShortcut "openbb-notebook", "C:\Windows\System32\cmd.exe", prefixPath & "\assets\openbb_icon.ico"
33
+ CreateShortcut "openbb-ipython", "C:\Windows\System32\cmd.exe", prefixPath & "\assets\openbb_icon.ico"
34
+ CreateShortcut "Update", "C:\Windows\System32\cmd.exe", prefixPath & "\assets\openbb_icon.ico"
35
+ CreateShortcut "CMD", "C:\Windows\System32\cmd.exe", prefixPath & "\assets\openbb_icon.ico"
36
+ CreateShortcut "Environments", prefixPath & "\envs", prefixPath & "\assets\openbb_icon.ico"
37
+ CreateShortcut "Settings", userProfilePath & "\.openbb_platform", prefixPath & "\assets\openbb_icon.ico"
38
+ CreateShortcut "OpenBBUserData", userProfilePath & "\OpenBBUserData", prefixPath & "\assets\openbb_icon.ico"
39
+ CreateShortcut "Uninstall", prefixPath & "\Uninstall-OpenBB.exe", prefixPath & "\assets\openbb_icon.ico"
40
+
41
+ Set objShortcut = objShell.CreateShortcut(shortcutFolder & "\openbb-notebook.lnk")
42
+ objShortcut.Arguments = "/k PATH " & prefixPath & ";" & prefixPath & "\Scripts;" & prefixPath & "\Library\bin;%PATH% && activate " & prefixPath & "\envs\obb && cd " & shortcutFolder & " && jupyter-notebook && exit"
43
+ objShortcut.WorkingDirectory = shortcutFolder
44
+ objShortcut.Save
45
+
46
+ Set objShortcut = objShell.CreateShortcut(shortcutFolder & "\openbb-ipython.lnk")
47
+ objShortcut.Arguments = "/k PATH " & prefixPath & ";" & prefixPath & "\Scripts;" & prefixPath & "\Library\bin;%PATH% && activate " & prefixPath & "\envs\obb && ipython -c ""from openbb import obb;obb"" -i"
48
+ objShortcut.WorkingDirectory = prefixPath
49
+ objShortcut.Save
50
+
51
+ Set objShortcut = objShell.CreateShortcut(shortcutFolder & "\openbb-api.lnk")
52
+ objShortcut.Arguments = "/k PATH " & prefixPath & ";" & prefixPath & "\Scripts;" & prefixPath & "\Library\bin;%PATH% && activate " & prefixPath & "\envs\obb && call openbb-api --login && exit"
53
+ objShortcut.WorkingDirectory = prefixPath
54
+ objShortcut.Save
55
+
56
+
57
+ Set objShortcut = objShell.CreateShortcut(shortcutFolder & "\Update.lnk")
58
+ objShortcut.Arguments = "/k PATH " & prefixPath & ";" & prefixPath & "\Scripts;" & prefixPath & "\Library\bin;%PATH% && activate " & prefixPath & "\envs\obb && call openbb-update && exit"
59
+ objShortcut.WorkingDirectory = prefixPath
60
+ objShortcut.Save
61
+
62
+ Set objShortcut = objShell.CreateShortcut(shortcutFolder & "\CMD.lnk")
63
+ objShortcut.Arguments = "/k PATH " & prefixPath & ";" & prefixPath & "\Scripts;" & prefixPath & "\Library\bin;%PATH% && activate base && echo Conda base environment is active. Use this shell to create new environments. && echo To activate the OpenBB environment, run 'conda activate obb'."
64
+ objShortcut.WorkingDirectory = shortcutFolder
65
+ objShortcut.Save
66
+
67
+ Set objShortcut = objShell.CreateShortcut(shortcutFolder & "\openbb-cli.lnk")
68
+ objShortcut.Arguments = "/k PATH " & prefixPath & ";" & prefixPath & "\Scripts;" & prefixPath & "\Library\bin;%PATH% && activate " & prefixPath & "\envs\obb && call openbb && exit"
69
+ objShortcut.WorkingDirectory = prefixPath
70
+ objShortcut.Save
build/conda/installer/assets/custom_conclusion.nsi ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ Page Custom muiExtraPages_Create
4
+
5
+ !include "FileFunc.nsh"
6
+
7
+ var IntroText
8
+ var InstallationLink
9
+ var ExampleImg
10
+ var ExampleImgCtl
11
+ var PARENTDIR
12
+
13
+ Function muiExtraPages_Create
14
+ Push $0
15
+
16
+ !insertmacro MUI_HEADER_TEXT_PAGE \
17
+ "${PRODUCT_NAME}" \
18
+ "Installation Successfully Complete"
19
+
20
+ ${GetParent} "$INSTDIR" $PARENTDIR
21
+
22
+ nsDialogs::Create /NOUNLOAD 1018
23
+ ${NSD_CreateLabel} 10u 10u 280u 40u "Click the link below to open the installation folder:"
24
+ Pop $IntroText
25
+
26
+ ${NSD_CreateLink} 10u 55u 200u 10u $PARENTDIR
27
+ Pop $InstallationLink
28
+ ${NSD_OnClick} $InstallationLink LaunchLinkOne
29
+
30
+ nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP}|${SS_REALSIZECONTROL} 0 10u 90u 280u 40u ""
31
+ Pop $ExampleImgCtl
32
+ StrCpy $0 $PLUGINSDIR\openbb_win.png
33
+ System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}|${LR_LOADTRANSPARENT}|${LR_LOADMAP3DCOLORS}) i.s'
34
+ Pop $ExampleImg
35
+ SendMessage $ExampleImgCtl ${STM_SETIMAGE} ${IMAGE_BITMAP} $ExampleImg
36
+
37
+ nsDialogs::Show
38
+
39
+ System::Call 'gdi32:DeleteObject(i $ExampleImg)'
40
+
41
+ Pop $0
42
+ FunctionEnd
43
+
44
+ !define MUI_FINISHPAGE_TEXT "Select a resource to open.$\r$\n$\r$\n"
45
+ !define MUI_FINISHPAGE_RUN
46
+ !define MUI_FINISHPAGE_RUN_TEXT "OpenBB Platform Documentation"
47
+ !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLinkTwo"
48
+ !define MUI_PAGE_CUSTOMFUNCTION_SHOW MyFinishShow
49
+ !define MUI_PAGE_CUSTOMFUNCTION_LEAVE MyFinishLeave
50
+
51
+ var CheckboxLinkThree
52
+ var CheckboxLinkFour
53
+
54
+ Function LaunchLinkOne
55
+ ExecShell "open" "$PARENTDIR"
56
+ FunctionEnd
57
+
58
+ Function LaunchLinkTwo
59
+ ExecShell "open" "https://docs.openbb.co/platform"
60
+ FunctionEnd
61
+
62
+ Function MyFinishShow
63
+ ${NSD_CreateCheckbox} 120u 110u 100% 10u "OpenBB CLI Documentation"
64
+ Pop $CheckboxLinkThree
65
+ ${NSD_Check} $CheckboxLinkThree
66
+ SetCtlColors $CheckboxLinkThree "" "ffffff"
67
+
68
+ ${NSD_CreateCheckbox} 120u 130u 100% 10u "OpenBB Pro Documentation"
69
+ Pop $CheckboxLinkFour
70
+ ${NSD_Check} $CheckboxLinkFour
71
+ SetCtlColors $CheckboxLinkFour "" "ffffff"
72
+ FunctionEnd
73
+
74
+ Function MyFinishLeave
75
+ ${NSD_GetState} $CheckboxLinkThree $0
76
+ ${If} $0 <> 0
77
+ ExecShell "open" "https://docs.openbb.co/cli"
78
+ ${EndIf}
79
+
80
+ ${NSD_GetState} $CheckboxLinkFour $0
81
+ ${If} $0 <> 0
82
+ ExecShell "open" "https://docs.openbb.co/pro"
83
+ ${EndIf}
84
+ FunctionEnd
85
+
86
+ !insertmacro MUI_PAGE_FINISH
build/conda/installer/assets/custom_welcome.nsi ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Below is an example of creating multiple pages after the welcome page of the installer.
2
+ #
3
+ # This file contains code that is inserted where the @CUSTOM_WELCOME_FILE@ is located
4
+ # in the main.nsi.tmpl. The main mechanism for extra pages occurs with the
5
+ # "Page Custom muiExtraPagesAfterWelcome_Create" line, which
6
+ # references the function "muiExtraPagesAfterWelcome_Create" for page creation.
7
+
8
+ !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipPageIfUACInnerInstance
9
+ !insertmacro MUI_PAGE_WELCOME
10
+
11
+ Page Custom muiExtraPagesAfterWelcome_Create
12
+
13
+ var IntroAfterWelcomeText
14
+ var InstallationAfterWelcomeLink
15
+ var ExampleAfterWelcomeImg
16
+ var ExampleImgAfterWelcomeCtl
17
+
18
+ Function muiExtraPagesAfterWelcome_Create
19
+ Push $0
20
+
21
+ !insertmacro MUI_HEADER_TEXT_PAGE \
22
+ "${PRODUCT_NAME}" \
23
+ "Welcome to OpenBB Platform Installer"
24
+
25
+ nsDialogs::Create /NOUNLOAD 1018
26
+ ${NSD_CreateLabel} 10u 10u 280u 120u "Welcome to the OpenBB Platform Installer.$\r$\n$\r$\nThis application will install the latest version of the OpenBB Platform on your computer as a self-contained, Python 3.12, Conda environment.$\r$\n$\r$\nIn order to install you need access to the Internet.$\r$\n$\r$\nInstallation requires between 1-2 GB of storage space, with a minimum of 4GB RAM.$\r$\n$\r$\nWhen a non-default installation path is chosen, it requires a depth of two - i.e, User/MyUserAccount/OpenBB/conda, where OpenBB is the target folder, and conda is the name of the folder where Conda and the installed environments live. The path, including username, should not contain any spaces."
27
+ Pop $IntroAfterWelcomeText
28
+
29
+ nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP}|${SS_REALSIZECONTROL} 0 10u 90u 280u 40u ""
30
+ Pop $ExampleImgAfterWelcomeCtl
31
+ StrCpy $0 $PLUGINSDIR\openbb_win.png
32
+ System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}|${LR_LOADTRANSPARENT}|${LR_LOADMAP3DCOLORS}) i.s'
33
+ Pop $ExampleAfterWelcomeImg
34
+ SendMessage $ExampleImgAfterWelcomeCtl ${STM_SETIMAGE} ${IMAGE_BITMAP} $ExampleAfterWelcomeImg
35
+
36
+ nsDialogs::Show
37
+
38
+ System::Call 'gdi32:DeleteObject(i $ExampleAfterWelcomeImg)'
39
+
40
+ Pop $0
41
+ FunctionEnd
build/conda/installer/assets/dmg_volume.icns ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e103259cce429d278e0dc98359e215d4cabfc7911fa8feffa42e5c16dbbb0d6
3
+ size 674218
build/conda/installer/assets/examples/README.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Example Extension Templates
2
+
3
+ The extensions in this folder represent starting points for creating your own OpenBB extensions. The types of extensions that can be created are:
4
+
5
+ - Router
6
+ - Create a new router path and define the functions for the app.
7
+ - Provider
8
+ - Add a new data provider source.
9
+ - OBBject
10
+ - Extend the response object returned by every command.
11
+
12
+ ## Installation
13
+
14
+ ### All Examples
15
+
16
+ To install all example extensions, activate the environment, then run:
17
+
18
+ ```sh
19
+ python install_examples.py
20
+ ```
21
+
22
+ ### Individual Example
23
+
24
+ To install an individual extension to the existing OpenBB environment, activate it, then navigate into the folder of the desired extension and enter:
25
+
26
+ ```sh
27
+ poetry install --only-root
28
+ ```
29
+
30
+ Then, rebuild the OpenBB Python interface with:
31
+
32
+ ```sh
33
+ openbb-build
34
+ ```
35
+
36
+ The new extension(s) will be available by importing the OpenBB package.
37
+
38
+ ```python
39
+ from openbb import obb
40
+ ```
build/conda/installer/assets/examples/empty_obbject/README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Empty OBBject Extension
2
+
3
+ This is an empty OpenBB Platform OBBJECT (Response Object) Extension.
4
+
5
+ Install this extension locally with:
6
+
7
+ ```console
8
+ poetry install --only-root
9
+ ```
build/conda/installer/assets/examples/empty_obbject/empty_obbject/__init__.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Empty OBBject extension."""
2
+
3
+ import warnings
4
+
5
+ from openbb_core.app.model.extension import Extension
6
+ from openbb_core.app.model.obbject import OBBject
7
+
8
+ warnings.filterwarnings(
9
+ "ignore", lineno=0
10
+ ) # This suppresses a warning you might see with IPython and OBBject Extensions on import and initialize.
11
+
12
+ ext = Extension(name="empty")
13
+
14
+ # OBBject Accessors are used to extend the functionality of the OBBject class.
15
+ # The name given to the Extension creates a new namespace in every output object of the Router.
16
+ # This is useful for formatting/processing the output of the function calls, where universal application is desired.
17
+
18
+
19
+ @ext.obbject_accessor
20
+ class Empty:
21
+ """An Empty OBBject extension."""
22
+
23
+ def __init__(self, obbject):
24
+ """Creates an instance of the Empty OBBject extension."""
25
+ self._obbject: OBBject = obbject
26
+
27
+ @staticmethod
28
+ def hello():
29
+ """Print a greeting message."""
30
+ print("Hello from the Empty OBBject extension!") # noqa: T201
build/conda/installer/assets/examples/empty_obbject/pyproject.toml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "empty-obbject"
3
+ version = "0.0.1"
4
+ description = "An empty OBBject extension"
5
+ authors = ["OpenBB Team <hello@openbb.co>"]
6
+ readme = "README.md"
7
+ packages = [{ include = "empty_obbject" }]
8
+
9
+ [tool.poetry.dependencies]
10
+ python = "^3.9.21,<3.13"
11
+ openbb-core = "^1.4.6"
12
+
13
+ [build-system]
14
+ requires = ["poetry-core"]
15
+ build-backend = "poetry.core.masonry.api"
16
+
17
+ [tool.poetry.plugins."openbb_obbject_extension"]
18
+ empty = "empty_obbject:ext"
build/conda/installer/assets/examples/empty_provider/README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Empty Provider Extension
2
+
3
+ This is an empty OpenBB Platform Provider Extension.
4
+
5
+ Install this extension locally with:
6
+
7
+ ```console
8
+ poetry install --only-root
9
+ ```
build/conda/installer/assets/examples/empty_provider/empty_provider/__init__.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Empty Provider Module."""
2
+
3
+ # Import the fetchers from each model.
4
+ from openbb_core.provider.abstract.provider import Provider
5
+
6
+ from empty_provider.models.empty_model import EmptyFetcher
7
+
8
+ empty_provider = Provider(
9
+ name="empty",
10
+ website="http://empty.io",
11
+ description="""The empty provider is a supplier of promises.""",
12
+ # credentials=["api_key"], # Credentials added here are mapped to `user_settings.json` in the `credentials` key.
13
+ fetcher_dict={
14
+ "Empty": EmptyFetcher # The key is the name of the model defined in the @router decorator.
15
+ },
16
+ )
17
+
18
+ # Every provider follows this same pattern, so it is possible to import the fetchers from other providers
19
+ # and map them to the fetcher_dict above.
20
+ # from openbb_yfinance import yfinance_provider
21
+ # yfinance_fetchers = yfinance_provider.fetcher_dict.copy()
build/conda/installer/assets/examples/empty_provider/empty_provider/models/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Empty Provider Models."""
build/conda/installer/assets/examples/empty_provider/empty_provider/models/empty_model.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Empty Fetcher Model. This model is used in conjunction with the 'empty_router' extension."""
2
+
3
+ # pylint: disable=unused-import
4
+ # flake8: noqa: F401
5
+
6
+ from datetime import (
7
+ date as dateType,
8
+ datetime,
9
+ )
10
+ from typing import Any, Dict, Optional
11
+
12
+ from openbb_core.provider.abstract.data import Data
13
+ from openbb_core.provider.abstract.fetcher import Fetcher
14
+ from openbb_core.provider.abstract.query_params import QueryParams
15
+ from pydantic import Field
16
+
17
+
18
+ class EmptyQueryParams(QueryParams):
19
+ """Empty Query Params"""
20
+
21
+ some_param: Optional[str] = Field(
22
+ default=None,
23
+ description="Some param",
24
+ )
25
+
26
+
27
+ class EmptyData(Data):
28
+ """Empty Data"""
29
+
30
+ date: Optional[dateType] = Field(
31
+ default=None,
32
+ description="Date of the data.",
33
+ )
34
+ title: Optional[str] = Field(
35
+ default=None,
36
+ description="Title of the data.",
37
+ )
38
+
39
+
40
+ class EmptyFetcher(
41
+ Fetcher[
42
+ EmptyQueryParams,
43
+ EmptyData, # Change the Typing when returning a list of models - i.e, records.
44
+ ]
45
+ ):
46
+ """Empty Fetcher."""
47
+
48
+ @staticmethod
49
+ def transform_query(params: Dict[str, Any]) -> EmptyQueryParams:
50
+ """Transform query params."""
51
+ transformed_params = params.copy()
52
+ # if transformed_params.get("some_param"):
53
+ # do something
54
+ #
55
+ # This is where you can set default values for query parameters.
56
+ # Essentially, `@model_validate(mode='before')`.
57
+ return EmptyQueryParams(**transformed_params)
58
+
59
+ @staticmethod
60
+ async def aextract_data(
61
+ query: EmptyQueryParams,
62
+ credentials: Optional[Dict[str, str]],
63
+ **kwargs: Any,
64
+ ) -> Dict: # Typing here should match the 'data' input of 'transform_data'.
65
+ """Extract data."""
66
+ # pylint: disable=import-outside-toplevel
67
+ # from openbb_core.provider.utils.helpers import (
68
+ # make_request,
69
+ # amake_request,
70
+ # amake_requests,
71
+ # get_querystring,
72
+ # ) Use these to make HTTP requests.
73
+
74
+ # We import here so that items are imported on execution, not on initialization.
75
+ # Critical for modules that introduce a heavy load on the system.
76
+ # Generally, any module required for data retrieval and parsing should be 'lazy' imported.
77
+ # This is to ensure that the module is only imported when needed.
78
+
79
+ print(query.some_param) # noqa: T201
80
+ results = {
81
+ "date": datetime.now().date(),
82
+ "title": "Hello from the Empty Provider extension!",
83
+ }
84
+ return results
85
+
86
+ @staticmethod
87
+ def transform_data(
88
+ query: EmptyQueryParams,
89
+ data: Dict, # Typing here matches the output of '(a)extract_data'.
90
+ **kwargs: Any,
91
+ ) -> EmptyData: # Typing here matches the Fetcher's definition.
92
+ """Transform data."""
93
+ return EmptyData.model_validate(data)
build/conda/installer/assets/examples/empty_provider/empty_provider/utils/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Utilities and Helpers."""
build/conda/installer/assets/examples/empty_provider/pyproject.toml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "empty-provider"
3
+ version = "0.0.1"
4
+ description = "Empty provider extension for OpenBB"
5
+ authors = ["OpenBB Team <hello@openbb.co>"]
6
+ readme = "README.md"
7
+ packages = [{ include = "empty_provider" }]
8
+
9
+ [tool.poetry.dependencies]
10
+ python = "^3.9.21,<3.13"
11
+ openbb-core = "^1.4.6"
12
+
13
+ [build-system]
14
+ requires = ["poetry-core"]
15
+ build-backend = "poetry.core.masonry.api"
16
+
17
+ [tool.poetry.plugins."openbb_provider_extension"]
18
+ empty = "empty_provider:empty_provider"
build/conda/installer/assets/examples/empty_router/README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Empty Router Extension
2
+
3
+ This is an empty OpenBB Platform Router Extension.
4
+
5
+ Install this extension locally with:
6
+
7
+ ```console
8
+ poetry install --only-root
9
+ ```
build/conda/installer/assets/examples/empty_router/empty_router/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """An Empty OpenBB Router extension."""
build/conda/installer/assets/examples/empty_router/empty_router/empty_router.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Empty Router Extenision for OpenBB Platform."""
2
+
3
+ from datetime import datetime
4
+
5
+ from openbb_core.app.model.command_context import CommandContext
6
+ from openbb_core.app.model.example import APIEx, PythonEx
7
+ from openbb_core.app.model.obbject import OBBject
8
+ from openbb_core.app.provider_interface import (
9
+ ExtraParams,
10
+ ProviderChoices,
11
+ StandardParams,
12
+ )
13
+ from openbb_core.app.query import Query
14
+ from openbb_core.app.router import Router
15
+ from openbb_core.provider.abstract.data import Data
16
+
17
+ router = Router(prefix="", description="An Empty OpenBB Router Extension.")
18
+
19
+ # The first function call will take longer than the rest, as modules are loaded on the first call.
20
+
21
+ # Note that all routers must return an instance of `OBBject`, where the output is the `results` attribute.
22
+
23
+
24
+ # This is a standard router "get" command.
25
+ @router.command(
26
+ methods=["GET"],
27
+ examples=[
28
+ PythonEx(
29
+ description="Say Hello.",
30
+ code=[
31
+ "result = obb.empty.hello()",
32
+ ],
33
+ ),
34
+ ],
35
+ )
36
+ async def hello() -> (
37
+ OBBject[dict]
38
+ ): # The output of every router command must be an instance of `OBBject`.
39
+ """OpenBB Hello World."""
40
+ return OBBject(
41
+ results={
42
+ datetime.now().strftime(
43
+ "%Y-%m-%d"
44
+ ): "Hello from the Empty Router extension!"
45
+ }
46
+ )
47
+
48
+
49
+ # This uses the Provider Interface to call the empty provider fetcher.
50
+ @router.command(
51
+ model="Empty",
52
+ examples=[
53
+ APIEx(parameters={"provider": "empty"}),
54
+ PythonEx(
55
+ description="Say Hello.",
56
+ code=[
57
+ "result = obb.empty.empty_function()",
58
+ ],
59
+ ),
60
+ ],
61
+ )
62
+ async def empty_function(
63
+ cc: CommandContext,
64
+ provider_choices: ProviderChoices,
65
+ standard_params: StandardParams,
66
+ extra_params: ExtraParams,
67
+ ) -> OBBject[Data]:
68
+ """An empty function using the Provider Interface."""
69
+ return await OBBject.from_query(Query(**locals()))
build/conda/installer/assets/examples/empty_router/empty_router/empty_views.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Views for the Empty Extension."""
2
+
3
+ # pylint: disable=unused-import
4
+ # flake8: noqa: F401
5
+
6
+ from typing import TYPE_CHECKING, Any, Dict, Tuple
7
+
8
+ if TYPE_CHECKING:
9
+ from openbb_charting.core.openbb_figure import OpenBBFigure
10
+
11
+ # If `openbb-charting` was installed, this will be used to create a chart.
12
+ # Process the data by accessing, "kwargs["obbject_item"]", the function results.
13
+ # The return is a Tuple of the OpenBBFigure and a Dict of the data, so it can be
14
+ # returned to the Fast API endpoint. Use `fig.to_plotly_json()` to convert the
15
+ # OpenBBFigure to a JSON serializable object.
16
+
17
+
18
+ class EmptyViews:
19
+ """Empty Views."""
20
+
21
+ # @staticmethod
22
+ # def empty_hello( # noqa: PLR0912
23
+ # **kwargs,
24
+ # ) -> Tuple["OpenBBFigure", Dict[str, Any]]:
25
+ # """Get Derivatives Price Historical Chart."""
26
+ # pylint: disable=import-outside-toplevel
27
+ # from openbb_charting.charts.price_historical import price_historical
28
+
29
+ # return price_historical(**kwargs)
build/conda/installer/assets/examples/empty_router/pyproject.toml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "empty-router"
3
+ version = "0.0.1"
4
+ description = "An empty OpenBB Router extension"
5
+ authors = ["OpenBB Team <hello@openbb.co>"]
6
+ readme = "README.md"
7
+ packages = [{ include = "empty_router" }]
8
+
9
+ [tool.poetry.dependencies]
10
+ python = "^3.9.21,<3.13"
11
+ openbb-core = "^1.4.6"
12
+
13
+ [build-system]
14
+ requires = ["poetry-core"]
15
+ build-backend = "poetry.core.masonry.api"
16
+
17
+ [tool.poetry.plugins."openbb_core_extension"]
18
+ empty = "empty_router.empty_router:router"
build/conda/installer/assets/examples/install_examples.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Script to install the example extensions in develop mode to the current Python environment."""
2
+
3
+
4
+ def main():
5
+ """Run the setup script."""
6
+ # pylint: disable=import-outside-toplevel
7
+ import glob
8
+ import os
9
+ import subprocess
10
+ from pathlib import Path
11
+
12
+ try:
13
+ import openbb # noqa: F401 # pylint: disable=unused-import
14
+ except ImportError:
15
+ subprocess.check_call("openbb-build", shell=True) # noqa: S602, S607
16
+
17
+ base_dir = Path(__file__).parent
18
+
19
+ directories = [
20
+ os.path.join(base_dir, d)
21
+ for d in os.listdir(base_dir)
22
+ if os.path.isdir(os.path.join(base_dir, d))
23
+ and glob.glob(os.path.join(base_dir, d, "*.toml"))
24
+ ]
25
+
26
+ for directory in directories:
27
+ subprocess.check_call(
28
+ [ # noqa: S603
29
+ os.sys.executable,
30
+ "-m",
31
+ "poetry",
32
+ "install",
33
+ "-C",
34
+ directory,
35
+ "--only-root",
36
+ ]
37
+ )
38
+
39
+ subprocess.check_call("openbb-build", shell=True) # noqa: S602, S607
40
+
41
+ print( # noqa: T201
42
+ "\nExample extensions have been installed and are ready-to-use."
43
+ "\nTo connect the examples to OpenBB Pro and edit the code live, run: openbb-api --reload\n"
44
+ )
45
+
46
+
47
+ if __name__ == "__main__":
48
+ main()
build/conda/installer/assets/examples/python_basics.ipynb ADDED
@@ -0,0 +1,3848 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Getting The Python Basics Right\n",
8
+ "\n",
9
+ "Special thanks to PyQuantNews for donating this content. Subscribe [here](https://www.pyquantnews.com/) for free Python resources that will help you get started with Python for Quant Finance.\n",
10
+ "\n",
11
+ "## Code Comments\n",
12
+ "\n",
13
+ "A comment is a note made by a programmer in the source code of a program. Its purpose is to clarify the source code and make it easier for people to follow along with what is happening. Anything in a comment is generally ignored when the code is actually run, making comments useful for including explanations and reasoning as well as removing specific lines of code that you may be unsure about. Comments in Python are created by using the pound symbol (`# Insert Text Here`). Including a `#` in a line of code will comment out anything that follows it."
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "code",
18
+ "execution_count": 1,
19
+ "metadata": {},
20
+ "outputs": [],
21
+ "source": [
22
+ "# This is a comment\n",
23
+ "# These lines of code will not change any values\n",
24
+ "# Anything following the first # is not run as code"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "markdown",
29
+ "metadata": {},
30
+ "source": [
31
+ "You may hear text enclosed in triple quotes (`\"\"\" Insert Text Here \"\"\"`) referred to as multi-line comments, but this is not entirely accurate. This is a special type of `string` (a data type we will cover), called a `docstring`, used to explain the purpose of a function."
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": 2,
37
+ "metadata": {},
38
+ "outputs": [
39
+ {
40
+ "data": {
41
+ "text/plain": [
42
+ "' This is a special string '"
43
+ ]
44
+ },
45
+ "execution_count": 2,
46
+ "metadata": {},
47
+ "output_type": "execute_result"
48
+ }
49
+ ],
50
+ "source": [
51
+ "\"\"\" This is a special string \"\"\""
52
+ ]
53
+ },
54
+ {
55
+ "cell_type": "code",
56
+ "execution_count": 3,
57
+ "metadata": {},
58
+ "outputs": [
59
+ {
60
+ "data": {
61
+ "text/plain": [
62
+ "\u001b[0;31mInit signature:\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m/\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
63
+ "\u001b[0;31mDocstring:\u001b[0m \n",
64
+ "str(object='') -> str\n",
65
+ "str(bytes_or_buffer[, encoding[, errors]]) -> str\n",
66
+ "\n",
67
+ "Create a new string object from the given object. If encoding or\n",
68
+ "errors is specified, then the object must expose a data buffer\n",
69
+ "that will be decoded using the given encoding and error handler.\n",
70
+ "Otherwise, returns the result of object.__str__() (if defined)\n",
71
+ "or repr(object).\n",
72
+ "encoding defaults to sys.getdefaultencoding().\n",
73
+ "errors defaults to 'strict'.\n",
74
+ "\u001b[0;31mType:\u001b[0m type\n",
75
+ "\u001b[0;31mSubclasses:\u001b[0m StrEnum, DeferredConfigString, FoldedCase, _rstr, _ScriptTarget, _ModuleTarget, LSString, include, Keys, InputMode, ..."
76
+ ]
77
+ },
78
+ "metadata": {},
79
+ "output_type": "display_data"
80
+ }
81
+ ],
82
+ "source": [
83
+ "str??"
84
+ ]
85
+ },
86
+ {
87
+ "cell_type": "markdown",
88
+ "metadata": {},
89
+ "source": [
90
+ "Make sure you read the comments within each code cell (if they are there). They will provide more real-time explanations of what is going on as you look at each line of code."
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "markdown",
95
+ "metadata": {},
96
+ "source": [
97
+ "## Python Objects - Basic Types & Variables\n",
98
+ "\n",
99
+ "Everything in Python is an **object** and every object in Python has a **type**. Some of the basic types include:\n",
100
+ "\n",
101
+ "- **`int`** (integer; a whole number with no decimal place)\n",
102
+ " - `10`\n",
103
+ " - `-3`\n",
104
+ "- **`float`** (float; a number that has a decimal place)\n",
105
+ " - `7.41`\n",
106
+ " - `-0.006`\n",
107
+ "- **`str`** (string; a sequence of characters enclosed in single quotes, double quotes, or triple quotes)\n",
108
+ " - `'this is a string using single quotes'`\n",
109
+ " - `\"this is a string using double quotes\"`\n",
110
+ " - `'''this is a triple quoted string using single quotes'''`\n",
111
+ " - `\"\"\"this is a triple quoted string using double quotes\"\"\"`\n",
112
+ "- **`bool`** (boolean; a binary value that is either true or false)\n",
113
+ " - `True`\n",
114
+ " - `False`\n",
115
+ "- **`NoneType`** (a special type representing the absence of a value)\n",
116
+ " - `None`\n",
117
+ "\n",
118
+ "In Python, a **variable** is a name you specify in your code that maps to a particular **object**, object **instance**, or value.\n",
119
+ "\n",
120
+ "By defining variables, we can refer to things by names that make sense to us. Names for variables can only contain letters, underscores (`_`), or numbers (no spaces, dashes, or other characters). Variable names must start with a letter or underscore.\n",
121
+ "\n",
122
+ "<hr>"
123
+ ]
124
+ },
125
+ {
126
+ "cell_type": "markdown",
127
+ "metadata": {},
128
+ "source": [
129
+ "## Basic Operators\n",
130
+ "\n",
131
+ "In Python, there are different types of **operators** (special symbols) that operate on different values. Some of the basic operators include:\n",
132
+ "\n",
133
+ "- arithmetic operators\n",
134
+ " - **`+`** (addition)\n",
135
+ " - **`-`** (subtraction)\n",
136
+ " - **`*`** (multiplication)\n",
137
+ " - **`/`** (division)\n",
138
+ " - __`**`__ (exponent)\n",
139
+ "- assignment operators\n",
140
+ " - **`=`** (assign a value)\n",
141
+ " - **`+=`** (add and re-assign; increment)\n",
142
+ " - **`-=`** (subtract and re-assign; decrement)\n",
143
+ " - **`*=`** (multiply and re-assign)\n",
144
+ "- comparison operators (return either `True` or `False`)\n",
145
+ " - **`==`** (equal to)\n",
146
+ " - **`!=`** (not equal to)\n",
147
+ " - **`<`** (less than)\n",
148
+ " - **`<=`** (less than or equal to)\n",
149
+ " - **`>`** (greater than)\n",
150
+ " - **`>=`** (greater than or equal to)\n",
151
+ "\n",
152
+ "When multiple operators are used in a single expression, **operator precedence** determines which parts of the expression are evaluated in which order. Operators with higher precedence are evaluated first (like PEMDAS in math). Operators with the same precedence are evaluated from left to right.\n",
153
+ "\n",
154
+ "- `()` parentheses, for grouping\n",
155
+ "- `**` exponent\n",
156
+ "- `*`, `/` multiplication and division\n",
157
+ "- `+`, `-` addition and subtraction\n",
158
+ "- `==`, `!=`, `<`, `<=`, `>`, `>=` comparisons\n",
159
+ "\n",
160
+ "> See https://docs.python.org/3/reference/expressions.html#operator-precedence"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "code",
165
+ "execution_count": 4,
166
+ "metadata": {},
167
+ "outputs": [],
168
+ "source": [
169
+ "# Assigning some numbers to different variables\n",
170
+ "num_1 = 10\n",
171
+ "num_2 = -3\n",
172
+ "num_3 = 7.41\n",
173
+ "num_4 = -0.6\n",
174
+ "num_5 = 7\n",
175
+ "num_6 = 3\n",
176
+ "num_7 = 11.11"
177
+ ]
178
+ },
179
+ {
180
+ "cell_type": "code",
181
+ "execution_count": 5,
182
+ "metadata": {},
183
+ "outputs": [
184
+ {
185
+ "data": {
186
+ "text/plain": [
187
+ "10"
188
+ ]
189
+ },
190
+ "execution_count": 5,
191
+ "metadata": {},
192
+ "output_type": "execute_result"
193
+ }
194
+ ],
195
+ "source": [
196
+ "num_1"
197
+ ]
198
+ },
199
+ {
200
+ "cell_type": "code",
201
+ "execution_count": 6,
202
+ "metadata": {},
203
+ "outputs": [
204
+ {
205
+ "data": {
206
+ "text/plain": [
207
+ "7"
208
+ ]
209
+ },
210
+ "execution_count": 6,
211
+ "metadata": {},
212
+ "output_type": "execute_result"
213
+ }
214
+ ],
215
+ "source": [
216
+ "# Addition\n",
217
+ "num_1 + num_2"
218
+ ]
219
+ },
220
+ {
221
+ "cell_type": "code",
222
+ "execution_count": 7,
223
+ "metadata": {},
224
+ "outputs": [
225
+ {
226
+ "data": {
227
+ "text/plain": [
228
+ "-10.41"
229
+ ]
230
+ },
231
+ "execution_count": 7,
232
+ "metadata": {},
233
+ "output_type": "execute_result"
234
+ }
235
+ ],
236
+ "source": [
237
+ "# Subtraction\n",
238
+ "num_2 - num_3"
239
+ ]
240
+ },
241
+ {
242
+ "cell_type": "code",
243
+ "execution_count": 8,
244
+ "metadata": {},
245
+ "outputs": [
246
+ {
247
+ "data": {
248
+ "text/plain": [
249
+ "-4.446"
250
+ ]
251
+ },
252
+ "execution_count": 8,
253
+ "metadata": {},
254
+ "output_type": "execute_result"
255
+ }
256
+ ],
257
+ "source": [
258
+ "# Multiplication\n",
259
+ "num_3 * num_4"
260
+ ]
261
+ },
262
+ {
263
+ "cell_type": "code",
264
+ "execution_count": 9,
265
+ "metadata": {},
266
+ "outputs": [
267
+ {
268
+ "data": {
269
+ "text/plain": [
270
+ "-0.08571428571428572"
271
+ ]
272
+ },
273
+ "execution_count": 9,
274
+ "metadata": {},
275
+ "output_type": "execute_result"
276
+ }
277
+ ],
278
+ "source": [
279
+ "# Division\n",
280
+ "num_4 / num_5"
281
+ ]
282
+ },
283
+ {
284
+ "cell_type": "code",
285
+ "execution_count": 10,
286
+ "metadata": {},
287
+ "outputs": [
288
+ {
289
+ "data": {
290
+ "text/plain": [
291
+ "343"
292
+ ]
293
+ },
294
+ "execution_count": 10,
295
+ "metadata": {},
296
+ "output_type": "execute_result"
297
+ }
298
+ ],
299
+ "source": [
300
+ "# Exponent\n",
301
+ "num_5**num_6"
302
+ ]
303
+ },
304
+ {
305
+ "cell_type": "code",
306
+ "execution_count": 11,
307
+ "metadata": {},
308
+ "outputs": [
309
+ {
310
+ "data": {
311
+ "text/plain": [
312
+ "15.11"
313
+ ]
314
+ },
315
+ "execution_count": 11,
316
+ "metadata": {},
317
+ "output_type": "execute_result"
318
+ }
319
+ ],
320
+ "source": [
321
+ "# Increment existing variable\n",
322
+ "num_7 += 4 # num_7 = num_7 + 4\n",
323
+ "num_7"
324
+ ]
325
+ },
326
+ {
327
+ "cell_type": "code",
328
+ "execution_count": 12,
329
+ "metadata": {},
330
+ "outputs": [
331
+ {
332
+ "data": {
333
+ "text/plain": [
334
+ "1"
335
+ ]
336
+ },
337
+ "execution_count": 12,
338
+ "metadata": {},
339
+ "output_type": "execute_result"
340
+ }
341
+ ],
342
+ "source": [
343
+ "# Decrement existing variable\n",
344
+ "num_6 -= 2\n",
345
+ "num_6"
346
+ ]
347
+ },
348
+ {
349
+ "cell_type": "code",
350
+ "execution_count": 13,
351
+ "metadata": {},
352
+ "outputs": [
353
+ {
354
+ "data": {
355
+ "text/plain": [
356
+ "37.05"
357
+ ]
358
+ },
359
+ "execution_count": 13,
360
+ "metadata": {},
361
+ "output_type": "execute_result"
362
+ }
363
+ ],
364
+ "source": [
365
+ "# Multiply & re-assign\n",
366
+ "num_3 *= 5\n",
367
+ "num_3"
368
+ ]
369
+ },
370
+ {
371
+ "cell_type": "code",
372
+ "execution_count": 14,
373
+ "metadata": {},
374
+ "outputs": [
375
+ {
376
+ "data": {
377
+ "text/plain": [
378
+ "-101.14999999999999"
379
+ ]
380
+ },
381
+ "execution_count": 14,
382
+ "metadata": {},
383
+ "output_type": "execute_result"
384
+ }
385
+ ],
386
+ "source": [
387
+ "# Assign the value of an expression to a variable\n",
388
+ "num_8 = num_1 + num_2 * num_3\n",
389
+ "num_8"
390
+ ]
391
+ },
392
+ {
393
+ "cell_type": "code",
394
+ "execution_count": 15,
395
+ "metadata": {},
396
+ "outputs": [
397
+ {
398
+ "data": {
399
+ "text/plain": [
400
+ "True"
401
+ ]
402
+ },
403
+ "execution_count": 15,
404
+ "metadata": {},
405
+ "output_type": "execute_result"
406
+ }
407
+ ],
408
+ "source": [
409
+ "# Are these two expressions equal to each other?\n",
410
+ "num_1 + num_2 == num_5"
411
+ ]
412
+ },
413
+ {
414
+ "cell_type": "code",
415
+ "execution_count": 16,
416
+ "metadata": {},
417
+ "outputs": [
418
+ {
419
+ "data": {
420
+ "text/plain": [
421
+ "True"
422
+ ]
423
+ },
424
+ "execution_count": 16,
425
+ "metadata": {},
426
+ "output_type": "execute_result"
427
+ }
428
+ ],
429
+ "source": [
430
+ "# Are these two expressions not equal to each other?\n",
431
+ "num_3 != num_4"
432
+ ]
433
+ },
434
+ {
435
+ "cell_type": "code",
436
+ "execution_count": 17,
437
+ "metadata": {},
438
+ "outputs": [
439
+ {
440
+ "data": {
441
+ "text/plain": [
442
+ "False"
443
+ ]
444
+ },
445
+ "execution_count": 17,
446
+ "metadata": {},
447
+ "output_type": "execute_result"
448
+ }
449
+ ],
450
+ "source": [
451
+ "# Is the first expression less than the second expression?\n",
452
+ "num_5 < num_6"
453
+ ]
454
+ },
455
+ {
456
+ "cell_type": "code",
457
+ "execution_count": 18,
458
+ "metadata": {},
459
+ "outputs": [
460
+ {
461
+ "data": {
462
+ "text/plain": [
463
+ "True"
464
+ ]
465
+ },
466
+ "execution_count": 18,
467
+ "metadata": {},
468
+ "output_type": "execute_result"
469
+ }
470
+ ],
471
+ "source": [
472
+ "# Is this expression True?\n",
473
+ "5 > 3 > 1"
474
+ ]
475
+ },
476
+ {
477
+ "cell_type": "code",
478
+ "execution_count": 19,
479
+ "metadata": {},
480
+ "outputs": [
481
+ {
482
+ "data": {
483
+ "text/plain": [
484
+ "True"
485
+ ]
486
+ },
487
+ "execution_count": 19,
488
+ "metadata": {},
489
+ "output_type": "execute_result"
490
+ }
491
+ ],
492
+ "source": [
493
+ "# Is this expression True?\n",
494
+ "5 > 3 < 4 == 3 + 1"
495
+ ]
496
+ },
497
+ {
498
+ "cell_type": "code",
499
+ "execution_count": 20,
500
+ "metadata": {},
501
+ "outputs": [],
502
+ "source": [
503
+ "# Assign some strings to different variables\n",
504
+ "simple_string_1 = \"an example\"\n",
505
+ "simple_string_2 = \"oranges \""
506
+ ]
507
+ },
508
+ {
509
+ "cell_type": "code",
510
+ "execution_count": 21,
511
+ "metadata": {},
512
+ "outputs": [
513
+ {
514
+ "data": {
515
+ "text/plain": [
516
+ "'an example of using the + operator'"
517
+ ]
518
+ },
519
+ "execution_count": 21,
520
+ "metadata": {},
521
+ "output_type": "execute_result"
522
+ }
523
+ ],
524
+ "source": [
525
+ "# Addition\n",
526
+ "simple_string_1 + \" of using the + operator\""
527
+ ]
528
+ },
529
+ {
530
+ "cell_type": "code",
531
+ "execution_count": 22,
532
+ "metadata": {},
533
+ "outputs": [
534
+ {
535
+ "data": {
536
+ "text/plain": [
537
+ "'an example'"
538
+ ]
539
+ },
540
+ "execution_count": 22,
541
+ "metadata": {},
542
+ "output_type": "execute_result"
543
+ }
544
+ ],
545
+ "source": [
546
+ "# Notice that the string was not modified\n",
547
+ "simple_string_1"
548
+ ]
549
+ },
550
+ {
551
+ "cell_type": "code",
552
+ "execution_count": 23,
553
+ "metadata": {},
554
+ "outputs": [
555
+ {
556
+ "data": {
557
+ "text/plain": [
558
+ "'oranges oranges oranges oranges '"
559
+ ]
560
+ },
561
+ "execution_count": 23,
562
+ "metadata": {},
563
+ "output_type": "execute_result"
564
+ }
565
+ ],
566
+ "source": [
567
+ "# Multiplication\n",
568
+ "simple_string_2 * 4"
569
+ ]
570
+ },
571
+ {
572
+ "cell_type": "code",
573
+ "execution_count": 24,
574
+ "metadata": {},
575
+ "outputs": [
576
+ {
577
+ "data": {
578
+ "text/plain": [
579
+ "'oranges '"
580
+ ]
581
+ },
582
+ "execution_count": 24,
583
+ "metadata": {},
584
+ "output_type": "execute_result"
585
+ }
586
+ ],
587
+ "source": [
588
+ "# This string wasn't modified either\n",
589
+ "simple_string_2"
590
+ ]
591
+ },
592
+ {
593
+ "cell_type": "code",
594
+ "execution_count": 25,
595
+ "metadata": {},
596
+ "outputs": [
597
+ {
598
+ "data": {
599
+ "text/plain": [
600
+ "False"
601
+ ]
602
+ },
603
+ "execution_count": 25,
604
+ "metadata": {},
605
+ "output_type": "execute_result"
606
+ }
607
+ ],
608
+ "source": [
609
+ "# Are these two expressions equal to each other?\n",
610
+ "simple_string_1 == simple_string_2"
611
+ ]
612
+ },
613
+ {
614
+ "cell_type": "code",
615
+ "execution_count": 26,
616
+ "metadata": {},
617
+ "outputs": [
618
+ {
619
+ "data": {
620
+ "text/plain": [
621
+ "True"
622
+ ]
623
+ },
624
+ "execution_count": 26,
625
+ "metadata": {},
626
+ "output_type": "execute_result"
627
+ }
628
+ ],
629
+ "source": [
630
+ "# Are these two expressions equal to each other?\n",
631
+ "simple_string_1 == \"an example\""
632
+ ]
633
+ },
634
+ {
635
+ "cell_type": "code",
636
+ "execution_count": 27,
637
+ "metadata": {},
638
+ "outputs": [
639
+ {
640
+ "data": {
641
+ "text/plain": [
642
+ "'an example that re-assigned the original string'"
643
+ ]
644
+ },
645
+ "execution_count": 27,
646
+ "metadata": {},
647
+ "output_type": "execute_result"
648
+ }
649
+ ],
650
+ "source": [
651
+ "# Add and re-assign\n",
652
+ "simple_string_1 += \" that re-assigned the original string\"\n",
653
+ "simple_string_1"
654
+ ]
655
+ },
656
+ {
657
+ "cell_type": "code",
658
+ "execution_count": 28,
659
+ "metadata": {},
660
+ "outputs": [
661
+ {
662
+ "data": {
663
+ "text/plain": [
664
+ "'oranges oranges oranges '"
665
+ ]
666
+ },
667
+ "execution_count": 28,
668
+ "metadata": {},
669
+ "output_type": "execute_result"
670
+ }
671
+ ],
672
+ "source": [
673
+ "# Multiply and re-assign\n",
674
+ "simple_string_2 *= 3\n",
675
+ "simple_string_2"
676
+ ]
677
+ },
678
+ {
679
+ "cell_type": "code",
680
+ "execution_count": 29,
681
+ "metadata": {},
682
+ "outputs": [],
683
+ "source": [
684
+ "# Note: Subtraction, division, and decrement operators do not apply to strings."
685
+ ]
686
+ },
687
+ {
688
+ "cell_type": "markdown",
689
+ "metadata": {},
690
+ "source": [
691
+ "## Basic Data Structures\n",
692
+ "\n",
693
+ "> Note: **mutable** objects can be modified after creation and **immutable** objects cannot.\n",
694
+ "\n",
695
+ "Containers are objects that can be used to group other objects together. The basic container types include:\n",
696
+ "\n",
697
+ "- **`str`** (string: immutable; indexed by integers; items are stored in the order they were added)\n",
698
+ "- **`list`** (list: mutable; indexed by integers; items are stored in the order they were added)\n",
699
+ " - `[3, 5, 6, 3, 'dog', 'cat', False]`\n",
700
+ "- **`tuple`** (tuple: immutable; indexed by integers; items are stored in the order they were added)\n",
701
+ " - `(3, 5, 6, 3, 'dog', 'cat', False)`\n",
702
+ "- **`set`** (set: mutable; not indexed at all; items are NOT stored in the order they were added; can only contain immutable objects; does NOT contain duplicate objects)\n",
703
+ " - `{3, 5, 6, 3, 'dog', 'cat', False}`\n",
704
+ "- **`dict`** (dictionary: mutable; key-value pairs are indexed by immutable keys; items are NOT stored in the order they were added)\n",
705
+ " - `{'name': 'Jane', 'age': 23, 'fav_foods': ['pizza', 'fruit', 'fish']}`\n",
706
+ "\n",
707
+ "When defining lists, tuples, or sets, use commas (,) to separate the individual items. When defining dicts, use a colon (:) to separate keys from values and commas (,) to separate the key-value pairs.\n",
708
+ "\n",
709
+ "Strings, lists, and tuples are all **sequence types** that can use the `+`, `*`, `+=`, and `*=` operators."
710
+ ]
711
+ },
712
+ {
713
+ "cell_type": "code",
714
+ "execution_count": 30,
715
+ "metadata": {},
716
+ "outputs": [],
717
+ "source": [
718
+ "# Assign some containers to different variables\n",
719
+ "list_1 = [3, 5, 6, 3, \"dog\", \"cat\", False]\n",
720
+ "tuple_1 = (3, 5, 6, 3, \"dog\", \"cat\", False)\n",
721
+ "set_1 = {3, 5, 6, 3, \"dog\", \"cat\", False}\n",
722
+ "set_2 = set((\"jane\", \"jaya\", \"jukes\", \"jason\", \"john\"))\n",
723
+ "dict_1 = {\"name\": \"Jane\", \"age\": 23, \"fav_foods\": [\"pizza\", \"fruit\", \"fish\"]}\n",
724
+ "dict_2 = {\"name\": \"Javier\", \"age\": 45, \"fav_foods\": [\"chicken\", \"veg\", \"candy\"]}"
725
+ ]
726
+ },
727
+ {
728
+ "cell_type": "code",
729
+ "execution_count": 31,
730
+ "metadata": {},
731
+ "outputs": [
732
+ {
733
+ "data": {
734
+ "text/plain": [
735
+ "[3, 5, 6, 3, 'dog', 'cat', False]"
736
+ ]
737
+ },
738
+ "execution_count": 31,
739
+ "metadata": {},
740
+ "output_type": "execute_result"
741
+ }
742
+ ],
743
+ "source": [
744
+ "# Items in the list object are stored in the order they were added\n",
745
+ "list_1"
746
+ ]
747
+ },
748
+ {
749
+ "cell_type": "code",
750
+ "execution_count": 32,
751
+ "metadata": {},
752
+ "outputs": [
753
+ {
754
+ "data": {
755
+ "text/plain": [
756
+ "(3, 5, 6, 3, 'dog', 'cat', False)"
757
+ ]
758
+ },
759
+ "execution_count": 32,
760
+ "metadata": {},
761
+ "output_type": "execute_result"
762
+ }
763
+ ],
764
+ "source": [
765
+ "# Items in the tuple object are stored in the order they were added\n",
766
+ "tuple_1"
767
+ ]
768
+ },
769
+ {
770
+ "cell_type": "code",
771
+ "execution_count": 33,
772
+ "metadata": {},
773
+ "outputs": [
774
+ {
775
+ "data": {
776
+ "text/plain": [
777
+ "{3, 5, 6, False, 'cat', 'dog'}"
778
+ ]
779
+ },
780
+ "execution_count": 33,
781
+ "metadata": {},
782
+ "output_type": "execute_result"
783
+ }
784
+ ],
785
+ "source": [
786
+ "# Items in the set object are not stored in the order they were added\n",
787
+ "# Also, notice that the value 3 only appears once in this set object\n",
788
+ "set_1"
789
+ ]
790
+ },
791
+ {
792
+ "cell_type": "code",
793
+ "execution_count": 34,
794
+ "metadata": {},
795
+ "outputs": [
796
+ {
797
+ "data": {
798
+ "text/plain": [
799
+ "{'name': 'Jane', 'age': 23, 'fav_foods': ['pizza', 'fruit', 'fish']}"
800
+ ]
801
+ },
802
+ "execution_count": 34,
803
+ "metadata": {},
804
+ "output_type": "execute_result"
805
+ }
806
+ ],
807
+ "source": [
808
+ "# Items in the dict object are not stored in the order they were added\n",
809
+ "dict_1"
810
+ ]
811
+ },
812
+ {
813
+ "cell_type": "code",
814
+ "execution_count": 35,
815
+ "metadata": {},
816
+ "outputs": [
817
+ {
818
+ "data": {
819
+ "text/plain": [
820
+ "[3, 5, 6, 3, 'dog', 'cat', False, 5, 'grapes']"
821
+ ]
822
+ },
823
+ "execution_count": 35,
824
+ "metadata": {},
825
+ "output_type": "execute_result"
826
+ }
827
+ ],
828
+ "source": [
829
+ "# Add and re-assign\n",
830
+ "list_1 += [5, \"grapes\"]\n",
831
+ "list_1"
832
+ ]
833
+ },
834
+ {
835
+ "cell_type": "code",
836
+ "execution_count": 36,
837
+ "metadata": {},
838
+ "outputs": [
839
+ {
840
+ "data": {
841
+ "text/plain": [
842
+ "(3, 5, 6, 3, 'dog', 'cat', False, 5, 'grapes')"
843
+ ]
844
+ },
845
+ "execution_count": 36,
846
+ "metadata": {},
847
+ "output_type": "execute_result"
848
+ }
849
+ ],
850
+ "source": [
851
+ "# Add and re-assign\n",
852
+ "tuple_1 += (5, \"grapes\")\n",
853
+ "tuple_1"
854
+ ]
855
+ },
856
+ {
857
+ "cell_type": "code",
858
+ "execution_count": 37,
859
+ "metadata": {},
860
+ "outputs": [
861
+ {
862
+ "data": {
863
+ "text/plain": [
864
+ "[1, 2, 3, 4, 1, 2, 3, 4]"
865
+ ]
866
+ },
867
+ "execution_count": 37,
868
+ "metadata": {},
869
+ "output_type": "execute_result"
870
+ }
871
+ ],
872
+ "source": [
873
+ "# Multiply\n",
874
+ "[1, 2, 3, 4] * 2"
875
+ ]
876
+ },
877
+ {
878
+ "cell_type": "code",
879
+ "execution_count": 38,
880
+ "metadata": {},
881
+ "outputs": [
882
+ {
883
+ "data": {
884
+ "text/plain": [
885
+ "(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4)"
886
+ ]
887
+ },
888
+ "execution_count": 38,
889
+ "metadata": {},
890
+ "output_type": "execute_result"
891
+ }
892
+ ],
893
+ "source": [
894
+ "# Multiply\n",
895
+ "(1, 2, 3, 4) * 3"
896
+ ]
897
+ },
898
+ {
899
+ "cell_type": "markdown",
900
+ "metadata": {},
901
+ "source": [
902
+ "## Accessing Data In Containers\n",
903
+ "\n",
904
+ "For strings, lists, tuples, and dicts, we can use **subscript notation** (square brackets) to access data at an index.\n",
905
+ "\n",
906
+ "- strings, lists, and tuples are indexed by integers, **starting at 0** for first item\n",
907
+ " - these sequence types also support accesing a range of items, known as **slicing**\n",
908
+ " - use **negative indexing** to start at the back of the sequence\n",
909
+ "- dicts are indexed by their keys\n",
910
+ "\n",
911
+ "> Note: sets are not indexed, so we cannot use subscript notation to access data elements."
912
+ ]
913
+ },
914
+ {
915
+ "cell_type": "code",
916
+ "execution_count": 39,
917
+ "metadata": {},
918
+ "outputs": [
919
+ {
920
+ "data": {
921
+ "text/plain": [
922
+ "[3, 5, 6, 3, 'dog', 'cat', False, 5, 'grapes']"
923
+ ]
924
+ },
925
+ "execution_count": 39,
926
+ "metadata": {},
927
+ "output_type": "execute_result"
928
+ }
929
+ ],
930
+ "source": [
931
+ "# Remember what's in list_1\n",
932
+ "list_1"
933
+ ]
934
+ },
935
+ {
936
+ "cell_type": "code",
937
+ "execution_count": 40,
938
+ "metadata": {},
939
+ "outputs": [
940
+ {
941
+ "data": {
942
+ "text/plain": [
943
+ "3"
944
+ ]
945
+ },
946
+ "execution_count": 40,
947
+ "metadata": {},
948
+ "output_type": "execute_result"
949
+ }
950
+ ],
951
+ "source": [
952
+ "# Access the first item in a sequence\n",
953
+ "list_1[0]"
954
+ ]
955
+ },
956
+ {
957
+ "cell_type": "code",
958
+ "execution_count": 41,
959
+ "metadata": {},
960
+ "outputs": [
961
+ {
962
+ "data": {
963
+ "text/plain": [
964
+ "(3, 5, 6, 3, 'dog', 'cat', False, 5, 'grapes')"
965
+ ]
966
+ },
967
+ "execution_count": 41,
968
+ "metadata": {},
969
+ "output_type": "execute_result"
970
+ }
971
+ ],
972
+ "source": [
973
+ "# Remember what's in tuple_1\n",
974
+ "tuple_1"
975
+ ]
976
+ },
977
+ {
978
+ "cell_type": "code",
979
+ "execution_count": 42,
980
+ "metadata": {},
981
+ "outputs": [
982
+ {
983
+ "data": {
984
+ "text/plain": [
985
+ "'grapes'"
986
+ ]
987
+ },
988
+ "execution_count": 42,
989
+ "metadata": {},
990
+ "output_type": "execute_result"
991
+ }
992
+ ],
993
+ "source": [
994
+ "# Access the last item in a sequence\n",
995
+ "tuple_1[-1]"
996
+ ]
997
+ },
998
+ {
999
+ "cell_type": "code",
1000
+ "execution_count": 43,
1001
+ "metadata": {},
1002
+ "outputs": [
1003
+ {
1004
+ "data": {
1005
+ "text/plain": [
1006
+ "'an example that re-assigned the original string'"
1007
+ ]
1008
+ },
1009
+ "execution_count": 43,
1010
+ "metadata": {},
1011
+ "output_type": "execute_result"
1012
+ }
1013
+ ],
1014
+ "source": [
1015
+ "# Access a range of items in a sequence\n",
1016
+ "simple_string_1"
1017
+ ]
1018
+ },
1019
+ {
1020
+ "cell_type": "code",
1021
+ "execution_count": 44,
1022
+ "metadata": {},
1023
+ "outputs": [
1024
+ {
1025
+ "data": {
1026
+ "text/plain": [
1027
+ "'n'"
1028
+ ]
1029
+ },
1030
+ "execution_count": 44,
1031
+ "metadata": {},
1032
+ "output_type": "execute_result"
1033
+ }
1034
+ ],
1035
+ "source": [
1036
+ "simple_string_1[1]"
1037
+ ]
1038
+ },
1039
+ {
1040
+ "cell_type": "code",
1041
+ "execution_count": 45,
1042
+ "metadata": {},
1043
+ "outputs": [
1044
+ {
1045
+ "data": {
1046
+ "text/plain": [
1047
+ "'an ex'"
1048
+ ]
1049
+ },
1050
+ "execution_count": 45,
1051
+ "metadata": {},
1052
+ "output_type": "execute_result"
1053
+ }
1054
+ ],
1055
+ "source": [
1056
+ "simple_string_1[0:5]"
1057
+ ]
1058
+ },
1059
+ {
1060
+ "cell_type": "code",
1061
+ "execution_count": 46,
1062
+ "metadata": {},
1063
+ "outputs": [
1064
+ {
1065
+ "data": {
1066
+ "text/plain": [
1067
+ "(5, 'grapes')"
1068
+ ]
1069
+ },
1070
+ "execution_count": 46,
1071
+ "metadata": {},
1072
+ "output_type": "execute_result"
1073
+ }
1074
+ ],
1075
+ "source": [
1076
+ "# Access a range of items in a sequence\n",
1077
+ "tuple_1[-2:]"
1078
+ ]
1079
+ },
1080
+ {
1081
+ "cell_type": "code",
1082
+ "execution_count": 47,
1083
+ "metadata": {},
1084
+ "outputs": [
1085
+ {
1086
+ "data": {
1087
+ "text/plain": [
1088
+ "['dog', 'cat', False, 5, 'grapes']"
1089
+ ]
1090
+ },
1091
+ "execution_count": 47,
1092
+ "metadata": {},
1093
+ "output_type": "execute_result"
1094
+ }
1095
+ ],
1096
+ "source": [
1097
+ "# Access a range of items in a sequence\n",
1098
+ "list_1[4:]"
1099
+ ]
1100
+ },
1101
+ {
1102
+ "cell_type": "code",
1103
+ "execution_count": 48,
1104
+ "metadata": {},
1105
+ "outputs": [
1106
+ {
1107
+ "data": {
1108
+ "text/plain": [
1109
+ "{'name': 'Jane', 'age': 23, 'fav_foods': ['pizza', 'fruit', 'fish']}"
1110
+ ]
1111
+ },
1112
+ "execution_count": 48,
1113
+ "metadata": {},
1114
+ "output_type": "execute_result"
1115
+ }
1116
+ ],
1117
+ "source": [
1118
+ "# Rembember what's in dict_1\n",
1119
+ "dict_1"
1120
+ ]
1121
+ },
1122
+ {
1123
+ "cell_type": "code",
1124
+ "execution_count": 49,
1125
+ "metadata": {},
1126
+ "outputs": [
1127
+ {
1128
+ "data": {
1129
+ "text/plain": [
1130
+ "'Jane'"
1131
+ ]
1132
+ },
1133
+ "execution_count": 49,
1134
+ "metadata": {},
1135
+ "output_type": "execute_result"
1136
+ }
1137
+ ],
1138
+ "source": [
1139
+ "# Access an item in a dictionary\n",
1140
+ "# {'name': 'Jane', 'age': 23, 'fav_foods': ['pizza', 'fruit', 'fish']}\n",
1141
+ "dict_1[\"name\"]"
1142
+ ]
1143
+ },
1144
+ {
1145
+ "cell_type": "markdown",
1146
+ "metadata": {},
1147
+ "source": [
1148
+ "## Python Built-In Functions & Callables\n",
1149
+ "\n",
1150
+ "A **function** is a Python object that you can \"call\" to **perform an action** or compute and **return another object**. You call a function by placing parentheses to the right of the function name. Some functions allow you to pass **arguments** inside the parentheses (separating multiple arguments with a comma). Internal to the function, these arguments are treated like variables.\n",
1151
+ "\n",
1152
+ "Python has several useful built-in functions to help you work with different objects and/or your environment. Here is a small sample of them:\n",
1153
+ "\n",
1154
+ "- **`type(obj)`** to determine the type of an object\n",
1155
+ "- **`isinstance(val, obj)`** to determine if `val` is an `obj`\n",
1156
+ "- **`len(container)`** to determine how many items are in a container\n",
1157
+ "- **`callable(obj)`** to determine if an object is callable\n",
1158
+ "- **`sorted(container)`** to return a new list from a container, with the items sorted\n",
1159
+ "- **`sum(container)`** to compute the sum of a container of numbers\n",
1160
+ "- **`min(container)`** to determine the smallest item in a container\n",
1161
+ "- **`max(container)`** to determine the largest item in a container\n",
1162
+ "- **`abs(number)`** to determine the absolute value of a number\n",
1163
+ "- **`repr(obj)`** to return a string representation of an object\n",
1164
+ "\n",
1165
+ "> Complete list of built-in functions: https://docs.python.org/3/library/functions.html\n",
1166
+ "\n",
1167
+ "There are also different ways of defining your own functions and callable objects that we will explore later."
1168
+ ]
1169
+ },
1170
+ {
1171
+ "cell_type": "code",
1172
+ "execution_count": 50,
1173
+ "metadata": {},
1174
+ "outputs": [
1175
+ {
1176
+ "data": {
1177
+ "text/plain": [
1178
+ "float"
1179
+ ]
1180
+ },
1181
+ "execution_count": 50,
1182
+ "metadata": {},
1183
+ "output_type": "execute_result"
1184
+ }
1185
+ ],
1186
+ "source": [
1187
+ "# Use the type() function to determine the type of an object\n",
1188
+ "type(1.0)"
1189
+ ]
1190
+ },
1191
+ {
1192
+ "cell_type": "code",
1193
+ "execution_count": 51,
1194
+ "metadata": {},
1195
+ "outputs": [
1196
+ {
1197
+ "data": {
1198
+ "text/plain": [
1199
+ "False"
1200
+ ]
1201
+ },
1202
+ "execution_count": 51,
1203
+ "metadata": {},
1204
+ "output_type": "execute_result"
1205
+ }
1206
+ ],
1207
+ "source": [
1208
+ "price = \"1.11\"\n",
1209
+ "isinstance(price, float)"
1210
+ ]
1211
+ },
1212
+ {
1213
+ "cell_type": "code",
1214
+ "execution_count": 52,
1215
+ "metadata": {},
1216
+ "outputs": [
1217
+ {
1218
+ "data": {
1219
+ "text/plain": [
1220
+ "3"
1221
+ ]
1222
+ },
1223
+ "execution_count": 52,
1224
+ "metadata": {},
1225
+ "output_type": "execute_result"
1226
+ }
1227
+ ],
1228
+ "source": [
1229
+ "# Use the len() function to determine how many items are in a container\n",
1230
+ "len([1, 2, 3])"
1231
+ ]
1232
+ },
1233
+ {
1234
+ "cell_type": "code",
1235
+ "execution_count": 53,
1236
+ "metadata": {},
1237
+ "outputs": [
1238
+ {
1239
+ "data": {
1240
+ "text/plain": [
1241
+ "24"
1242
+ ]
1243
+ },
1244
+ "execution_count": 53,
1245
+ "metadata": {},
1246
+ "output_type": "execute_result"
1247
+ }
1248
+ ],
1249
+ "source": [
1250
+ "# Use the len() function to determine how many items are in a container\n",
1251
+ "len(simple_string_2)"
1252
+ ]
1253
+ },
1254
+ {
1255
+ "cell_type": "code",
1256
+ "execution_count": 54,
1257
+ "metadata": {},
1258
+ "outputs": [
1259
+ {
1260
+ "data": {
1261
+ "text/plain": [
1262
+ "False"
1263
+ ]
1264
+ },
1265
+ "execution_count": 54,
1266
+ "metadata": {},
1267
+ "output_type": "execute_result"
1268
+ }
1269
+ ],
1270
+ "source": [
1271
+ "# Use the callable() function to determine if an object is callable\n",
1272
+ "callable(\"a\")"
1273
+ ]
1274
+ },
1275
+ {
1276
+ "cell_type": "code",
1277
+ "execution_count": 55,
1278
+ "metadata": {},
1279
+ "outputs": [
1280
+ {
1281
+ "data": {
1282
+ "text/plain": [
1283
+ "False"
1284
+ ]
1285
+ },
1286
+ "execution_count": 55,
1287
+ "metadata": {},
1288
+ "output_type": "execute_result"
1289
+ }
1290
+ ],
1291
+ "source": [
1292
+ "# Use the callable() function to determine if an object is callable\n",
1293
+ "callable(dict_1)"
1294
+ ]
1295
+ },
1296
+ {
1297
+ "cell_type": "code",
1298
+ "execution_count": 56,
1299
+ "metadata": {},
1300
+ "outputs": [
1301
+ {
1302
+ "data": {
1303
+ "text/plain": [
1304
+ "[-3, 1, 2, 3.6, 5, 7, 10]"
1305
+ ]
1306
+ },
1307
+ "execution_count": 56,
1308
+ "metadata": {},
1309
+ "output_type": "execute_result"
1310
+ }
1311
+ ],
1312
+ "source": [
1313
+ "# Use the sorted() function to return a new list from a container, with the items sorted\n",
1314
+ "sorted([10, 1, 3.6, 7, 5, 2, -3])"
1315
+ ]
1316
+ },
1317
+ {
1318
+ "cell_type": "code",
1319
+ "execution_count": 57,
1320
+ "metadata": {},
1321
+ "outputs": [
1322
+ {
1323
+ "data": {
1324
+ "text/plain": [
1325
+ "['a', 'j', 'n', 'o', 's']"
1326
+ ]
1327
+ },
1328
+ "execution_count": 57,
1329
+ "metadata": {},
1330
+ "output_type": "execute_result"
1331
+ }
1332
+ ],
1333
+ "source": [
1334
+ "sorted(\"jason\")"
1335
+ ]
1336
+ },
1337
+ {
1338
+ "cell_type": "code",
1339
+ "execution_count": 58,
1340
+ "metadata": {},
1341
+ "outputs": [
1342
+ {
1343
+ "data": {
1344
+ "text/plain": [
1345
+ "['California', 'Chicago', 'ants', 'cats', 'dogs', 'mice', 'zebras']"
1346
+ ]
1347
+ },
1348
+ "execution_count": 58,
1349
+ "metadata": {},
1350
+ "output_type": "execute_result"
1351
+ }
1352
+ ],
1353
+ "source": [
1354
+ "# Use the sorted() function to return a new list from a container, with the items sorted\n",
1355
+ "# - notice that capitalized strings come first\n",
1356
+ "sorted([\"dogs\", \"cats\", \"zebras\", \"Chicago\", \"California\", \"ants\", \"mice\"])"
1357
+ ]
1358
+ },
1359
+ {
1360
+ "cell_type": "code",
1361
+ "execution_count": 59,
1362
+ "metadata": {},
1363
+ "outputs": [
1364
+ {
1365
+ "data": {
1366
+ "text/plain": [
1367
+ "25.6"
1368
+ ]
1369
+ },
1370
+ "execution_count": 59,
1371
+ "metadata": {},
1372
+ "output_type": "execute_result"
1373
+ }
1374
+ ],
1375
+ "source": [
1376
+ "# Use the sum() function to compute the sum of a container of numbers\n",
1377
+ "sum([10, 1, 3.6, 7, 5, 2, -3])"
1378
+ ]
1379
+ },
1380
+ {
1381
+ "cell_type": "code",
1382
+ "execution_count": 60,
1383
+ "metadata": {},
1384
+ "outputs": [
1385
+ {
1386
+ "data": {
1387
+ "text/plain": [
1388
+ "-3"
1389
+ ]
1390
+ },
1391
+ "execution_count": 60,
1392
+ "metadata": {},
1393
+ "output_type": "execute_result"
1394
+ }
1395
+ ],
1396
+ "source": [
1397
+ "# Use the min() function to determine the smallest item in a container\n",
1398
+ "min([10, 1, 3.6, 7, 5, 2, -3])"
1399
+ ]
1400
+ },
1401
+ {
1402
+ "cell_type": "code",
1403
+ "execution_count": 61,
1404
+ "metadata": {},
1405
+ "outputs": [
1406
+ {
1407
+ "data": {
1408
+ "text/plain": [
1409
+ "'a'"
1410
+ ]
1411
+ },
1412
+ "execution_count": 61,
1413
+ "metadata": {},
1414
+ "output_type": "execute_result"
1415
+ }
1416
+ ],
1417
+ "source": [
1418
+ "# Use the min() function to determine the smallest item in a container\n",
1419
+ "min([\"g\", \"z\", \"a\", \"y\"])"
1420
+ ]
1421
+ },
1422
+ {
1423
+ "cell_type": "code",
1424
+ "execution_count": 62,
1425
+ "metadata": {},
1426
+ "outputs": [
1427
+ {
1428
+ "data": {
1429
+ "text/plain": [
1430
+ "10"
1431
+ ]
1432
+ },
1433
+ "execution_count": 62,
1434
+ "metadata": {},
1435
+ "output_type": "execute_result"
1436
+ }
1437
+ ],
1438
+ "source": [
1439
+ "# Use the max() function to determine the largest item in a container\n",
1440
+ "max([10, 1, 3.6, 7, 5, 2, -3])"
1441
+ ]
1442
+ },
1443
+ {
1444
+ "cell_type": "code",
1445
+ "execution_count": 63,
1446
+ "metadata": {},
1447
+ "outputs": [
1448
+ {
1449
+ "data": {
1450
+ "text/plain": [
1451
+ "'s'"
1452
+ ]
1453
+ },
1454
+ "execution_count": 63,
1455
+ "metadata": {},
1456
+ "output_type": "execute_result"
1457
+ }
1458
+ ],
1459
+ "source": [
1460
+ "# Use the max() function to determine the largest item in a container\n",
1461
+ "max(\"gibberish\")"
1462
+ ]
1463
+ },
1464
+ {
1465
+ "cell_type": "code",
1466
+ "execution_count": 64,
1467
+ "metadata": {},
1468
+ "outputs": [
1469
+ {
1470
+ "data": {
1471
+ "text/plain": [
1472
+ "10"
1473
+ ]
1474
+ },
1475
+ "execution_count": 64,
1476
+ "metadata": {},
1477
+ "output_type": "execute_result"
1478
+ }
1479
+ ],
1480
+ "source": [
1481
+ "# Use the abs() function to determine the absolute value of a number\n",
1482
+ "abs(10)"
1483
+ ]
1484
+ },
1485
+ {
1486
+ "cell_type": "code",
1487
+ "execution_count": 65,
1488
+ "metadata": {},
1489
+ "outputs": [
1490
+ {
1491
+ "data": {
1492
+ "text/plain": [
1493
+ "12"
1494
+ ]
1495
+ },
1496
+ "execution_count": 65,
1497
+ "metadata": {},
1498
+ "output_type": "execute_result"
1499
+ }
1500
+ ],
1501
+ "source": [
1502
+ "# Use the abs() function to determine the absolute value of a number\n",
1503
+ "abs(-12)"
1504
+ ]
1505
+ },
1506
+ {
1507
+ "cell_type": "code",
1508
+ "execution_count": 66,
1509
+ "metadata": {},
1510
+ "outputs": [
1511
+ {
1512
+ "data": {
1513
+ "text/plain": [
1514
+ "True"
1515
+ ]
1516
+ },
1517
+ "execution_count": 66,
1518
+ "metadata": {},
1519
+ "output_type": "execute_result"
1520
+ }
1521
+ ],
1522
+ "source": [
1523
+ "# Use the repr() function to return a string representation of an object\n",
1524
+ "isinstance(repr(list_1), str)"
1525
+ ]
1526
+ },
1527
+ {
1528
+ "cell_type": "markdown",
1529
+ "metadata": {},
1530
+ "source": [
1531
+ "## Python Object Attributes (Methods & Properties)\n",
1532
+ "\n",
1533
+ "Different types of objects in Python have different **attributes** that can be referred to by name (similar to a variable). To access an attribute of an object, use a dot (`.`) after the object, then specify the attribute (i.e. `obj.attribute`)\n",
1534
+ "\n",
1535
+ "When an attribute of an object is a callable, that attribute is called a **method**. It is the same as a function, only this function is bound to a particular object.\n",
1536
+ "\n",
1537
+ "When an attribute of an object is not a callable, that attribute is called a **property**. It is just a piece of data about the object, that is itself another object.\n",
1538
+ "\n",
1539
+ "The built-in `dir()` function can be used to return a list of an object's attributes.\n",
1540
+ "\n",
1541
+ "<hr>"
1542
+ ]
1543
+ },
1544
+ {
1545
+ "cell_type": "markdown",
1546
+ "metadata": {},
1547
+ "source": [
1548
+ "## Some Methods On `string` Objects\n",
1549
+ "\n",
1550
+ "- **`.capitalize()`** to return a capitalized version of the string (only first char uppercase)\n",
1551
+ "- **`.upper()`** to return an uppercase version of the string (all chars uppercase)\n",
1552
+ "- **`.lower()`** to return an lowercase version of the string (all chars lowercase)\n",
1553
+ "- **`.count(substring)`** to return the number of occurences of the substring in the string\n",
1554
+ "- **`.startswith(substring)`** to determine if the string starts with the substring\n",
1555
+ "- **`.endswith(substring)`** to determine if the string ends with the substring\n",
1556
+ "- **`.replace(old, new)`** to return a copy of the string with occurences of the \"old\" replaced by \"new\""
1557
+ ]
1558
+ },
1559
+ {
1560
+ "cell_type": "code",
1561
+ "execution_count": 67,
1562
+ "metadata": {},
1563
+ "outputs": [],
1564
+ "source": [
1565
+ "# Assign a string to a variable\n",
1566
+ "a_string = \"tHis is a sTriNg\""
1567
+ ]
1568
+ },
1569
+ {
1570
+ "cell_type": "code",
1571
+ "execution_count": 68,
1572
+ "metadata": {},
1573
+ "outputs": [
1574
+ {
1575
+ "data": {
1576
+ "text/plain": [
1577
+ "'This is a string'"
1578
+ ]
1579
+ },
1580
+ "execution_count": 68,
1581
+ "metadata": {},
1582
+ "output_type": "execute_result"
1583
+ }
1584
+ ],
1585
+ "source": [
1586
+ "# Return a capitalized version of the string\n",
1587
+ "a_string.capitalize()"
1588
+ ]
1589
+ },
1590
+ {
1591
+ "cell_type": "code",
1592
+ "execution_count": 69,
1593
+ "metadata": {},
1594
+ "outputs": [
1595
+ {
1596
+ "data": {
1597
+ "text/plain": [
1598
+ "'THIS IS A STRING'"
1599
+ ]
1600
+ },
1601
+ "execution_count": 69,
1602
+ "metadata": {},
1603
+ "output_type": "execute_result"
1604
+ }
1605
+ ],
1606
+ "source": [
1607
+ "# Return an uppercase version of the string\n",
1608
+ "a_string.upper()"
1609
+ ]
1610
+ },
1611
+ {
1612
+ "cell_type": "code",
1613
+ "execution_count": 70,
1614
+ "metadata": {},
1615
+ "outputs": [
1616
+ {
1617
+ "data": {
1618
+ "text/plain": [
1619
+ "'this is a string'"
1620
+ ]
1621
+ },
1622
+ "execution_count": 70,
1623
+ "metadata": {},
1624
+ "output_type": "execute_result"
1625
+ }
1626
+ ],
1627
+ "source": [
1628
+ "# Return a lowercase version of the string\n",
1629
+ "a_string.lower()"
1630
+ ]
1631
+ },
1632
+ {
1633
+ "cell_type": "code",
1634
+ "execution_count": 71,
1635
+ "metadata": {},
1636
+ "outputs": [
1637
+ {
1638
+ "data": {
1639
+ "text/plain": [
1640
+ "'tHis is a sTriNg'"
1641
+ ]
1642
+ },
1643
+ "execution_count": 71,
1644
+ "metadata": {},
1645
+ "output_type": "execute_result"
1646
+ }
1647
+ ],
1648
+ "source": [
1649
+ "# Notice that the methods called have not actually modified the string\n",
1650
+ "a_string"
1651
+ ]
1652
+ },
1653
+ {
1654
+ "cell_type": "code",
1655
+ "execution_count": 72,
1656
+ "metadata": {},
1657
+ "outputs": [
1658
+ {
1659
+ "data": {
1660
+ "text/plain": [
1661
+ "3"
1662
+ ]
1663
+ },
1664
+ "execution_count": 72,
1665
+ "metadata": {},
1666
+ "output_type": "execute_result"
1667
+ }
1668
+ ],
1669
+ "source": [
1670
+ "# Count number of occurences of a substring in the string\n",
1671
+ "a_string.count(\"i\")"
1672
+ ]
1673
+ },
1674
+ {
1675
+ "cell_type": "code",
1676
+ "execution_count": 73,
1677
+ "metadata": {},
1678
+ "outputs": [
1679
+ {
1680
+ "data": {
1681
+ "text/plain": [
1682
+ "1"
1683
+ ]
1684
+ },
1685
+ "execution_count": 73,
1686
+ "metadata": {},
1687
+ "output_type": "execute_result"
1688
+ }
1689
+ ],
1690
+ "source": [
1691
+ "# Count number of occurences of a substring in the string after a certain position\n",
1692
+ "a_string.count(\"i\", 7)"
1693
+ ]
1694
+ },
1695
+ {
1696
+ "cell_type": "code",
1697
+ "execution_count": 74,
1698
+ "metadata": {},
1699
+ "outputs": [
1700
+ {
1701
+ "data": {
1702
+ "text/plain": [
1703
+ "2"
1704
+ ]
1705
+ },
1706
+ "execution_count": 74,
1707
+ "metadata": {},
1708
+ "output_type": "execute_result"
1709
+ }
1710
+ ],
1711
+ "source": [
1712
+ "# Count number of occurences of a substring in the string\n",
1713
+ "a_string.count(\"is\")"
1714
+ ]
1715
+ },
1716
+ {
1717
+ "cell_type": "code",
1718
+ "execution_count": 75,
1719
+ "metadata": {},
1720
+ "outputs": [
1721
+ {
1722
+ "data": {
1723
+ "text/plain": [
1724
+ "False"
1725
+ ]
1726
+ },
1727
+ "execution_count": 75,
1728
+ "metadata": {},
1729
+ "output_type": "execute_result"
1730
+ }
1731
+ ],
1732
+ "source": [
1733
+ "# Does the string start with 'this'?\n",
1734
+ "a_string.startswith(\"this\")"
1735
+ ]
1736
+ },
1737
+ {
1738
+ "cell_type": "code",
1739
+ "execution_count": 76,
1740
+ "metadata": {},
1741
+ "outputs": [
1742
+ {
1743
+ "data": {
1744
+ "text/plain": [
1745
+ "True"
1746
+ ]
1747
+ },
1748
+ "execution_count": 76,
1749
+ "metadata": {},
1750
+ "output_type": "execute_result"
1751
+ }
1752
+ ],
1753
+ "source": [
1754
+ "# Does the lowercase string start with 'this'?\n",
1755
+ "a_string.lower().startswith(\"this\")"
1756
+ ]
1757
+ },
1758
+ {
1759
+ "cell_type": "code",
1760
+ "execution_count": 77,
1761
+ "metadata": {},
1762
+ "outputs": [
1763
+ {
1764
+ "data": {
1765
+ "text/plain": [
1766
+ "True"
1767
+ ]
1768
+ },
1769
+ "execution_count": 77,
1770
+ "metadata": {},
1771
+ "output_type": "execute_result"
1772
+ }
1773
+ ],
1774
+ "source": [
1775
+ "# Does the string end with 'Ng'?\n",
1776
+ "a_string.endswith(\"Ng\")"
1777
+ ]
1778
+ },
1779
+ {
1780
+ "cell_type": "code",
1781
+ "execution_count": 78,
1782
+ "metadata": {},
1783
+ "outputs": [
1784
+ {
1785
+ "data": {
1786
+ "text/plain": [
1787
+ "'tHXYZ XYZ a sTriNg'"
1788
+ ]
1789
+ },
1790
+ "execution_count": 78,
1791
+ "metadata": {},
1792
+ "output_type": "execute_result"
1793
+ }
1794
+ ],
1795
+ "source": [
1796
+ "# Return a version of the string with a substring replaced with something else\n",
1797
+ "a_string.replace(\"is\", \"XYZ\")"
1798
+ ]
1799
+ },
1800
+ {
1801
+ "cell_type": "code",
1802
+ "execution_count": 79,
1803
+ "metadata": {},
1804
+ "outputs": [
1805
+ {
1806
+ "data": {
1807
+ "text/plain": [
1808
+ "'tH!s !s a sTr!Ng'"
1809
+ ]
1810
+ },
1811
+ "execution_count": 79,
1812
+ "metadata": {},
1813
+ "output_type": "execute_result"
1814
+ }
1815
+ ],
1816
+ "source": [
1817
+ "# Return a version of the string with a substring replaced with something else\n",
1818
+ "a_string.replace(\"i\", \"!\")"
1819
+ ]
1820
+ },
1821
+ {
1822
+ "cell_type": "code",
1823
+ "execution_count": 80,
1824
+ "metadata": {},
1825
+ "outputs": [
1826
+ {
1827
+ "data": {
1828
+ "text/plain": [
1829
+ "'tH!s !s a sTriNg'"
1830
+ ]
1831
+ },
1832
+ "execution_count": 80,
1833
+ "metadata": {},
1834
+ "output_type": "execute_result"
1835
+ }
1836
+ ],
1837
+ "source": [
1838
+ "# Return a version of the string with the first 2 occurences a substring replaced with something else\n",
1839
+ "a_string.replace(\"i\", \"!\", 2)"
1840
+ ]
1841
+ },
1842
+ {
1843
+ "cell_type": "markdown",
1844
+ "metadata": {
1845
+ "collapsed": true,
1846
+ "jupyter": {
1847
+ "outputs_hidden": true
1848
+ }
1849
+ },
1850
+ "source": [
1851
+ "## Some Methods On `list` Objects\n",
1852
+ "\n",
1853
+ "- **`.append(item)`** to add a single item to the list\n",
1854
+ "- **`.extend([item1, item2, ...])`** to add multiple items to the list\n",
1855
+ "- **`.remove(item)`** to remove a single item from the list\n",
1856
+ "- **`.pop()`** to remove and return the item at the end of the list\n",
1857
+ "- **`.pop(index)`** to remove and return an item at an index"
1858
+ ]
1859
+ },
1860
+ {
1861
+ "cell_type": "code",
1862
+ "execution_count": 81,
1863
+ "metadata": {},
1864
+ "outputs": [
1865
+ {
1866
+ "data": {
1867
+ "text/plain": [
1868
+ "[3, 5, 6, 3, 'dog', 'cat', False, 5, 'grapes']"
1869
+ ]
1870
+ },
1871
+ "execution_count": 81,
1872
+ "metadata": {},
1873
+ "output_type": "execute_result"
1874
+ }
1875
+ ],
1876
+ "source": [
1877
+ "# Remember what's in list_1\n",
1878
+ "list_1"
1879
+ ]
1880
+ },
1881
+ {
1882
+ "cell_type": "code",
1883
+ "execution_count": 82,
1884
+ "metadata": {},
1885
+ "outputs": [
1886
+ {
1887
+ "data": {
1888
+ "text/plain": [
1889
+ "[3, 5, 6, 3, 'dog', 'cat', False, 5, 'grapes', 'basketball']"
1890
+ ]
1891
+ },
1892
+ "execution_count": 82,
1893
+ "metadata": {},
1894
+ "output_type": "execute_result"
1895
+ }
1896
+ ],
1897
+ "source": [
1898
+ "# append a string to a list\n",
1899
+ "list_1.append(\"basketball\")\n",
1900
+ "list_1"
1901
+ ]
1902
+ },
1903
+ {
1904
+ "cell_type": "code",
1905
+ "execution_count": 83,
1906
+ "metadata": {},
1907
+ "outputs": [
1908
+ {
1909
+ "data": {
1910
+ "text/plain": [
1911
+ "[3, 5, 6, 3, 'dog', 'cat', False, 5, 'grapes', 'basketball', 'baseball', 1]"
1912
+ ]
1913
+ },
1914
+ "execution_count": 83,
1915
+ "metadata": {},
1916
+ "output_type": "execute_result"
1917
+ }
1918
+ ],
1919
+ "source": [
1920
+ "# Add multiple items to a list\n",
1921
+ "list_1.extend([\"baseball\", 1]) # equiv. list + list\n",
1922
+ "list_1"
1923
+ ]
1924
+ },
1925
+ {
1926
+ "cell_type": "code",
1927
+ "execution_count": 84,
1928
+ "metadata": {},
1929
+ "outputs": [
1930
+ {
1931
+ "data": {
1932
+ "text/plain": [
1933
+ "[3, 5, 6, 3, 'dog', False, 5, 'grapes', 'basketball', 'baseball', 1]"
1934
+ ]
1935
+ },
1936
+ "execution_count": 84,
1937
+ "metadata": {},
1938
+ "output_type": "execute_result"
1939
+ }
1940
+ ],
1941
+ "source": [
1942
+ "# Remove a sinle item from a list\n",
1943
+ "list_1.remove(\"cat\")\n",
1944
+ "list_1"
1945
+ ]
1946
+ },
1947
+ {
1948
+ "cell_type": "code",
1949
+ "execution_count": 85,
1950
+ "metadata": {},
1951
+ "outputs": [
1952
+ {
1953
+ "data": {
1954
+ "text/plain": [
1955
+ "1"
1956
+ ]
1957
+ },
1958
+ "execution_count": 85,
1959
+ "metadata": {},
1960
+ "output_type": "execute_result"
1961
+ }
1962
+ ],
1963
+ "source": [
1964
+ "# Remove the last item and return it\n",
1965
+ "list_1.pop()"
1966
+ ]
1967
+ },
1968
+ {
1969
+ "cell_type": "code",
1970
+ "execution_count": 86,
1971
+ "metadata": {},
1972
+ "outputs": [
1973
+ {
1974
+ "data": {
1975
+ "text/plain": [
1976
+ "[3, 5, 6, 3, 'dog', False, 5, 'grapes', 'basketball', 'baseball']"
1977
+ ]
1978
+ },
1979
+ "execution_count": 86,
1980
+ "metadata": {},
1981
+ "output_type": "execute_result"
1982
+ }
1983
+ ],
1984
+ "source": [
1985
+ "list_1"
1986
+ ]
1987
+ },
1988
+ {
1989
+ "cell_type": "code",
1990
+ "execution_count": 87,
1991
+ "metadata": {},
1992
+ "outputs": [
1993
+ {
1994
+ "data": {
1995
+ "text/plain": [
1996
+ "3"
1997
+ ]
1998
+ },
1999
+ "execution_count": 87,
2000
+ "metadata": {},
2001
+ "output_type": "execute_result"
2002
+ }
2003
+ ],
2004
+ "source": [
2005
+ "# remove an item at index 0 and return it\n",
2006
+ "list_1.pop(0)"
2007
+ ]
2008
+ },
2009
+ {
2010
+ "cell_type": "markdown",
2011
+ "metadata": {},
2012
+ "source": [
2013
+ "## Some Methods On `set` Objects\n",
2014
+ "\n",
2015
+ "- **`.add(item)`** to add a single item to the set\n",
2016
+ "- **`.update([item1, item2, ...])`** to add multiple items to the set\n",
2017
+ "- **`.update(set_2, set3, ...)`** to add items from all provided sets to the set\n",
2018
+ "- **`.remove(item)`** to remove a single item from the set\n",
2019
+ "- **`.difference(set_2)`** to return items in the set that are not in another set\n",
2020
+ "- **`.intersection(set_2)`** to return items in both sets\n",
2021
+ "- **`.union(set_2)`** to return items that are in either set\n",
2022
+ "- **`.symmetric_difference(set_2)`** to return items that are only in one set (not both)\n",
2023
+ "- **`.issuperset(set_2)`** does the set contain everything in the other set?\n",
2024
+ "- **`.issubset(set_2)`** is the set contained in the other set?"
2025
+ ]
2026
+ },
2027
+ {
2028
+ "cell_type": "code",
2029
+ "execution_count": 88,
2030
+ "metadata": {},
2031
+ "outputs": [
2032
+ {
2033
+ "data": {
2034
+ "text/plain": [
2035
+ "{'Jason', 'jason'}"
2036
+ ]
2037
+ },
2038
+ "execution_count": 88,
2039
+ "metadata": {},
2040
+ "output_type": "execute_result"
2041
+ }
2042
+ ],
2043
+ "source": [
2044
+ "set([\"Jason\", \"jason\", \"jason\"])"
2045
+ ]
2046
+ },
2047
+ {
2048
+ "cell_type": "code",
2049
+ "execution_count": 89,
2050
+ "metadata": {},
2051
+ "outputs": [
2052
+ {
2053
+ "data": {
2054
+ "text/plain": [
2055
+ "{3, 5, 6, False, 'cat', 'dog', 'fuzz'}"
2056
+ ]
2057
+ },
2058
+ "execution_count": 89,
2059
+ "metadata": {},
2060
+ "output_type": "execute_result"
2061
+ }
2062
+ ],
2063
+ "source": [
2064
+ "set_1.add(\"fuzz\")\n",
2065
+ "set_1"
2066
+ ]
2067
+ },
2068
+ {
2069
+ "cell_type": "code",
2070
+ "execution_count": 90,
2071
+ "metadata": {},
2072
+ "outputs": [
2073
+ {
2074
+ "data": {
2075
+ "text/plain": [
2076
+ "{3, 5, 6, False, 'cat', 'coke', 'dog', 'fuzz', 'pepsi'}"
2077
+ ]
2078
+ },
2079
+ "execution_count": 90,
2080
+ "metadata": {},
2081
+ "output_type": "execute_result"
2082
+ }
2083
+ ],
2084
+ "source": [
2085
+ "set_1.update([\"coke\", \"pepsi\"])\n",
2086
+ "set_1"
2087
+ ]
2088
+ },
2089
+ {
2090
+ "cell_type": "code",
2091
+ "execution_count": 91,
2092
+ "metadata": {},
2093
+ "outputs": [
2094
+ {
2095
+ "data": {
2096
+ "text/plain": [
2097
+ "{3,\n",
2098
+ " 5,\n",
2099
+ " 6,\n",
2100
+ " False,\n",
2101
+ " 'cat',\n",
2102
+ " 'coke',\n",
2103
+ " 'dog',\n",
2104
+ " 'fuzz',\n",
2105
+ " 'jane',\n",
2106
+ " 'jason',\n",
2107
+ " 'jaya',\n",
2108
+ " 'john',\n",
2109
+ " 'jukes',\n",
2110
+ " 'pepsi'}"
2111
+ ]
2112
+ },
2113
+ "execution_count": 91,
2114
+ "metadata": {},
2115
+ "output_type": "execute_result"
2116
+ }
2117
+ ],
2118
+ "source": [
2119
+ "set_1.update(set_2)\n",
2120
+ "set_1"
2121
+ ]
2122
+ },
2123
+ {
2124
+ "cell_type": "code",
2125
+ "execution_count": 92,
2126
+ "metadata": {},
2127
+ "outputs": [
2128
+ {
2129
+ "data": {
2130
+ "text/plain": [
2131
+ "{3,\n",
2132
+ " 5,\n",
2133
+ " 6,\n",
2134
+ " False,\n",
2135
+ " 'coke',\n",
2136
+ " 'dog',\n",
2137
+ " 'fuzz',\n",
2138
+ " 'jane',\n",
2139
+ " 'jason',\n",
2140
+ " 'jaya',\n",
2141
+ " 'john',\n",
2142
+ " 'jukes',\n",
2143
+ " 'pepsi'}"
2144
+ ]
2145
+ },
2146
+ "execution_count": 92,
2147
+ "metadata": {},
2148
+ "output_type": "execute_result"
2149
+ }
2150
+ ],
2151
+ "source": [
2152
+ "set_1.remove(\"cat\")\n",
2153
+ "set_1"
2154
+ ]
2155
+ },
2156
+ {
2157
+ "cell_type": "code",
2158
+ "execution_count": 93,
2159
+ "metadata": {},
2160
+ "outputs": [
2161
+ {
2162
+ "data": {
2163
+ "text/plain": [
2164
+ "{3, 5, 6, False, 'coke', 'dog', 'fuzz', 'pepsi'}"
2165
+ ]
2166
+ },
2167
+ "execution_count": 93,
2168
+ "metadata": {},
2169
+ "output_type": "execute_result"
2170
+ }
2171
+ ],
2172
+ "source": [
2173
+ "set_1.difference(set_2)"
2174
+ ]
2175
+ },
2176
+ {
2177
+ "cell_type": "code",
2178
+ "execution_count": 94,
2179
+ "metadata": {},
2180
+ "outputs": [
2181
+ {
2182
+ "data": {
2183
+ "text/plain": [
2184
+ "{'jane', 'jason', 'jaya', 'john', 'jukes'}"
2185
+ ]
2186
+ },
2187
+ "execution_count": 94,
2188
+ "metadata": {},
2189
+ "output_type": "execute_result"
2190
+ }
2191
+ ],
2192
+ "source": [
2193
+ "set_1.intersection(set_2)"
2194
+ ]
2195
+ },
2196
+ {
2197
+ "cell_type": "code",
2198
+ "execution_count": 95,
2199
+ "metadata": {},
2200
+ "outputs": [
2201
+ {
2202
+ "data": {
2203
+ "text/plain": [
2204
+ "{3,\n",
2205
+ " 5,\n",
2206
+ " 6,\n",
2207
+ " False,\n",
2208
+ " 'coke',\n",
2209
+ " 'dog',\n",
2210
+ " 'fuzz',\n",
2211
+ " 'jane',\n",
2212
+ " 'jason',\n",
2213
+ " 'jaya',\n",
2214
+ " 'john',\n",
2215
+ " 'jukes',\n",
2216
+ " 'pepsi'}"
2217
+ ]
2218
+ },
2219
+ "execution_count": 95,
2220
+ "metadata": {},
2221
+ "output_type": "execute_result"
2222
+ }
2223
+ ],
2224
+ "source": [
2225
+ "set_1.union(set_2)"
2226
+ ]
2227
+ },
2228
+ {
2229
+ "cell_type": "code",
2230
+ "execution_count": 96,
2231
+ "metadata": {},
2232
+ "outputs": [
2233
+ {
2234
+ "data": {
2235
+ "text/plain": [
2236
+ "True"
2237
+ ]
2238
+ },
2239
+ "execution_count": 96,
2240
+ "metadata": {},
2241
+ "output_type": "execute_result"
2242
+ }
2243
+ ],
2244
+ "source": [
2245
+ "set_1.issuperset(set_2)"
2246
+ ]
2247
+ },
2248
+ {
2249
+ "cell_type": "code",
2250
+ "execution_count": 97,
2251
+ "metadata": {},
2252
+ "outputs": [
2253
+ {
2254
+ "data": {
2255
+ "text/plain": [
2256
+ "False"
2257
+ ]
2258
+ },
2259
+ "execution_count": 97,
2260
+ "metadata": {},
2261
+ "output_type": "execute_result"
2262
+ }
2263
+ ],
2264
+ "source": [
2265
+ "set_1.issubset(set_2)"
2266
+ ]
2267
+ },
2268
+ {
2269
+ "cell_type": "markdown",
2270
+ "metadata": {},
2271
+ "source": [
2272
+ "## Some Methods On `dict` Objects\n",
2273
+ "\n",
2274
+ "- **`.update([(key1, val1), (key2, val2), ...])`** to add multiple key-value pairs to the dict\n",
2275
+ "- **`.update(dict_2)`** to add all keys and values from another dict to the dict\n",
2276
+ "- **`.pop(key)`** to remove key and return its value from the dict (error if key not found)\n",
2277
+ "- **`.pop(key, default_val)`** to remove key and return its value from the dict (or return default_val if key not found)\n",
2278
+ "- **`.get(key)`** to return the value at a specified key in the dict (or None if key not found)\n",
2279
+ "- **`.get(key, default_val)`** to return the value at a specified key in the dict (or default_val if key not found)\n",
2280
+ "- **`.keys()`** to return a list of keys in the dict\n",
2281
+ "- **`.values()`** to return a list of values in the dict\n",
2282
+ "- **`.items()`** to return a list of key-value pairs (tuples) in the dict"
2283
+ ]
2284
+ },
2285
+ {
2286
+ "cell_type": "code",
2287
+ "execution_count": 98,
2288
+ "metadata": {},
2289
+ "outputs": [
2290
+ {
2291
+ "data": {
2292
+ "text/plain": [
2293
+ "{'name': 'Jane', 'age': 23, 'fav_foods': ['pizza', 'fruit', 'fish']}"
2294
+ ]
2295
+ },
2296
+ "execution_count": 98,
2297
+ "metadata": {},
2298
+ "output_type": "execute_result"
2299
+ }
2300
+ ],
2301
+ "source": [
2302
+ "# Remember what's in dict_1\n",
2303
+ "dict_1"
2304
+ ]
2305
+ },
2306
+ {
2307
+ "cell_type": "code",
2308
+ "execution_count": 99,
2309
+ "metadata": {},
2310
+ "outputs": [
2311
+ {
2312
+ "data": {
2313
+ "text/plain": [
2314
+ "{'name': 'Jane',\n",
2315
+ " 'age': 23,\n",
2316
+ " 'fav_foods': ['pizza', 'fruit', 'fish'],\n",
2317
+ " 'rain': True,\n",
2318
+ " 'cars': 'a lot'}"
2319
+ ]
2320
+ },
2321
+ "execution_count": 99,
2322
+ "metadata": {},
2323
+ "output_type": "execute_result"
2324
+ }
2325
+ ],
2326
+ "source": [
2327
+ "# Update dict_1 with an iterable\n",
2328
+ "dict_1.update([(\"rain\", True), (\"cars\", \"a lot\")])\n",
2329
+ "dict_1"
2330
+ ]
2331
+ },
2332
+ {
2333
+ "cell_type": "code",
2334
+ "execution_count": 100,
2335
+ "metadata": {},
2336
+ "outputs": [
2337
+ {
2338
+ "data": {
2339
+ "text/plain": [
2340
+ "{'name': 'Javier',\n",
2341
+ " 'age': 45,\n",
2342
+ " 'fav_foods': ['chicken', 'veg', 'candy'],\n",
2343
+ " 'rain': True,\n",
2344
+ " 'cars': 'a lot'}"
2345
+ ]
2346
+ },
2347
+ "execution_count": 100,
2348
+ "metadata": {},
2349
+ "output_type": "execute_result"
2350
+ }
2351
+ ],
2352
+ "source": [
2353
+ "# Update dict_1 with another dict\n",
2354
+ "dict_1.update(dict_2)\n",
2355
+ "dict_1"
2356
+ ]
2357
+ },
2358
+ {
2359
+ "cell_type": "code",
2360
+ "execution_count": 101,
2361
+ "metadata": {},
2362
+ "outputs": [
2363
+ {
2364
+ "data": {
2365
+ "text/plain": [
2366
+ "45"
2367
+ ]
2368
+ },
2369
+ "execution_count": 101,
2370
+ "metadata": {},
2371
+ "output_type": "execute_result"
2372
+ }
2373
+ ],
2374
+ "source": [
2375
+ "# Remove the key and value at age\n",
2376
+ "dict_1.pop(\"age\")"
2377
+ ]
2378
+ },
2379
+ {
2380
+ "cell_type": "code",
2381
+ "execution_count": 102,
2382
+ "metadata": {},
2383
+ "outputs": [
2384
+ {
2385
+ "data": {
2386
+ "text/plain": [
2387
+ "{'name': 'Javier',\n",
2388
+ " 'fav_foods': ['chicken', 'veg', 'candy'],\n",
2389
+ " 'rain': True,\n",
2390
+ " 'cars': 'a lot'}"
2391
+ ]
2392
+ },
2393
+ "execution_count": 102,
2394
+ "metadata": {},
2395
+ "output_type": "execute_result"
2396
+ }
2397
+ ],
2398
+ "source": [
2399
+ "# Key and value are removed\n",
2400
+ "dict_1"
2401
+ ]
2402
+ },
2403
+ {
2404
+ "cell_type": "code",
2405
+ "execution_count": 103,
2406
+ "metadata": {},
2407
+ "outputs": [
2408
+ {
2409
+ "data": {
2410
+ "text/plain": [
2411
+ "50"
2412
+ ]
2413
+ },
2414
+ "execution_count": 103,
2415
+ "metadata": {},
2416
+ "output_type": "execute_result"
2417
+ }
2418
+ ],
2419
+ "source": [
2420
+ "# Use a default value\n",
2421
+ "dict_1.pop(\"age\", 50)"
2422
+ ]
2423
+ },
2424
+ {
2425
+ "cell_type": "code",
2426
+ "execution_count": 104,
2427
+ "metadata": {},
2428
+ "outputs": [
2429
+ {
2430
+ "data": {
2431
+ "text/plain": [
2432
+ "'No car found'"
2433
+ ]
2434
+ },
2435
+ "execution_count": 104,
2436
+ "metadata": {},
2437
+ "output_type": "execute_result"
2438
+ }
2439
+ ],
2440
+ "source": [
2441
+ "# Use get to set a default\n",
2442
+ "dict_1.get(\"car\", \"No car found\")"
2443
+ ]
2444
+ },
2445
+ {
2446
+ "cell_type": "code",
2447
+ "execution_count": 105,
2448
+ "metadata": {},
2449
+ "outputs": [
2450
+ {
2451
+ "data": {
2452
+ "text/plain": [
2453
+ "dict_keys(['name', 'fav_foods', 'rain', 'cars'])"
2454
+ ]
2455
+ },
2456
+ "execution_count": 105,
2457
+ "metadata": {},
2458
+ "output_type": "execute_result"
2459
+ }
2460
+ ],
2461
+ "source": [
2462
+ "# Get the keys of a dict as an iterable\n",
2463
+ "dict_1.keys()"
2464
+ ]
2465
+ },
2466
+ {
2467
+ "cell_type": "code",
2468
+ "execution_count": 106,
2469
+ "metadata": {},
2470
+ "outputs": [
2471
+ {
2472
+ "data": {
2473
+ "text/plain": [
2474
+ "dict_values(['Javier', ['chicken', 'veg', 'candy'], True, 'a lot'])"
2475
+ ]
2476
+ },
2477
+ "execution_count": 106,
2478
+ "metadata": {},
2479
+ "output_type": "execute_result"
2480
+ }
2481
+ ],
2482
+ "source": [
2483
+ "# Get the values of a dict as an iterable\n",
2484
+ "dict_1.values()"
2485
+ ]
2486
+ },
2487
+ {
2488
+ "cell_type": "code",
2489
+ "execution_count": 107,
2490
+ "metadata": {},
2491
+ "outputs": [
2492
+ {
2493
+ "data": {
2494
+ "text/plain": [
2495
+ "dict_items([('name', 'Javier'), ('fav_foods', ['chicken', 'veg', 'candy']), ('rain', True), ('cars', 'a lot')])"
2496
+ ]
2497
+ },
2498
+ "execution_count": 107,
2499
+ "metadata": {},
2500
+ "output_type": "execute_result"
2501
+ }
2502
+ ],
2503
+ "source": [
2504
+ "# Get the key-value pairs of a dict as an iterable\n",
2505
+ "dict_1.items()"
2506
+ ]
2507
+ },
2508
+ {
2509
+ "cell_type": "markdown",
2510
+ "metadata": {},
2511
+ "source": [
2512
+ "## Positional Arguments & Keyword Arguments To Callables\n",
2513
+ "\n",
2514
+ "You can call a function/method in a number of different ways:\n",
2515
+ "\n",
2516
+ "- `func()`: Call `func` with no arguments\n",
2517
+ "- `func(arg)`: Call `func` with one positional argument\n",
2518
+ "- `func(arg1, arg2)`: Call `func` with two positional arguments\n",
2519
+ "- `func(arg1, arg2, ..., argn)`: Call `func` with many positional arguments\n",
2520
+ "- `func(kwarg=value)`: Call `func` with one keyword argument \n",
2521
+ "- `func(kwarg1=value1, kwarg2=value2)`: Call `func` with two keyword arguments\n",
2522
+ "- `func(kwarg1=value1, kwarg2=value2, ..., kwargn=valuen)`: Call `func` with many keyword arguments\n",
2523
+ "- `func(arg1, arg2, kwarg1=value1, kwarg2=value2)`: Call `func` with positonal arguments and keyword arguments\n",
2524
+ "- `obj.method()`: Same for `func`.. and every other `func` example\n",
2525
+ "\n",
2526
+ "When using **positional arguments**, you must provide them in the order that the function defined them (the function's **signature**).\n",
2527
+ "\n",
2528
+ "When using **keyword arguments**, you can provide the arguments you want, in any order you want, as long as you specify each argument's name.\n",
2529
+ "\n",
2530
+ "When using positional and keyword arguments, positional arguments must come first."
2531
+ ]
2532
+ },
2533
+ {
2534
+ "cell_type": "code",
2535
+ "execution_count": 108,
2536
+ "metadata": {},
2537
+ "outputs": [],
2538
+ "source": [
2539
+ "def func_1():\n",
2540
+ " return 1 + 1"
2541
+ ]
2542
+ },
2543
+ {
2544
+ "cell_type": "code",
2545
+ "execution_count": 109,
2546
+ "metadata": {},
2547
+ "outputs": [
2548
+ {
2549
+ "data": {
2550
+ "text/plain": [
2551
+ "2"
2552
+ ]
2553
+ },
2554
+ "execution_count": 109,
2555
+ "metadata": {},
2556
+ "output_type": "execute_result"
2557
+ }
2558
+ ],
2559
+ "source": [
2560
+ "func_1()"
2561
+ ]
2562
+ },
2563
+ {
2564
+ "cell_type": "code",
2565
+ "execution_count": 110,
2566
+ "metadata": {},
2567
+ "outputs": [
2568
+ {
2569
+ "data": {
2570
+ "text/plain": [
2571
+ "25"
2572
+ ]
2573
+ },
2574
+ "execution_count": 110,
2575
+ "metadata": {},
2576
+ "output_type": "execute_result"
2577
+ }
2578
+ ],
2579
+ "source": [
2580
+ "def func_2(x):\n",
2581
+ " return x**2 # equiv. x^2\n",
2582
+ "\n",
2583
+ "\n",
2584
+ "func_2(5)"
2585
+ ]
2586
+ },
2587
+ {
2588
+ "cell_type": "code",
2589
+ "execution_count": 111,
2590
+ "metadata": {},
2591
+ "outputs": [
2592
+ {
2593
+ "data": {
2594
+ "text/plain": [
2595
+ "4.0"
2596
+ ]
2597
+ },
2598
+ "execution_count": 111,
2599
+ "metadata": {},
2600
+ "output_type": "execute_result"
2601
+ }
2602
+ ],
2603
+ "source": [
2604
+ "def func_3(x, y):\n",
2605
+ " return x / y\n",
2606
+ "\n",
2607
+ "\n",
2608
+ "func_3(8, 2)"
2609
+ ]
2610
+ },
2611
+ {
2612
+ "cell_type": "code",
2613
+ "execution_count": 112,
2614
+ "metadata": {},
2615
+ "outputs": [
2616
+ {
2617
+ "name": "stdout",
2618
+ "output_type": "stream",
2619
+ "text": [
2620
+ "{'one': 1, 'two': 2, 'jason': 'banana'}\n"
2621
+ ]
2622
+ }
2623
+ ],
2624
+ "source": [
2625
+ "def func_4(**kwargs):\n",
2626
+ " print(kwargs)\n",
2627
+ "\n",
2628
+ "\n",
2629
+ "func_4(one=1, two=2, jason=\"banana\")"
2630
+ ]
2631
+ },
2632
+ {
2633
+ "cell_type": "code",
2634
+ "execution_count": 113,
2635
+ "metadata": {},
2636
+ "outputs": [],
2637
+ "source": [
2638
+ "def func_5(a, b, c, **kwargs):\n",
2639
+ " pass\n",
2640
+ "\n",
2641
+ "\n",
2642
+ "func_5(2, 3, c=5)"
2643
+ ]
2644
+ },
2645
+ {
2646
+ "cell_type": "markdown",
2647
+ "metadata": {},
2648
+ "source": [
2649
+ "## Python \"for loops\"\n",
2650
+ "\n",
2651
+ "It is easy to **iterate** over a collection of items using a **for loop**. The strings, lists, tuples, sets, and dictionaries we defined are all **iterable** containers.\n",
2652
+ "\n",
2653
+ "The for loop will go through the specified container, one item at a time, and provide a temporary variable for the current item. You can use this temporary variable like a normal variable."
2654
+ ]
2655
+ },
2656
+ {
2657
+ "cell_type": "code",
2658
+ "execution_count": 114,
2659
+ "metadata": {
2660
+ "scrolled": true
2661
+ },
2662
+ "outputs": [
2663
+ {
2664
+ "name": "stdout",
2665
+ "output_type": "stream",
2666
+ "text": [
2667
+ "5\n",
2668
+ "6\n",
2669
+ "3\n",
2670
+ "dog\n",
2671
+ "False\n",
2672
+ "5\n",
2673
+ "grapes\n",
2674
+ "basketball\n",
2675
+ "baseball\n"
2676
+ ]
2677
+ }
2678
+ ],
2679
+ "source": [
2680
+ "list_1\n",
2681
+ "\n",
2682
+ "for item in list_1:\n",
2683
+ " print(item)"
2684
+ ]
2685
+ },
2686
+ {
2687
+ "cell_type": "code",
2688
+ "execution_count": 115,
2689
+ "metadata": {},
2690
+ "outputs": [
2691
+ {
2692
+ "name": "stdout",
2693
+ "output_type": "stream",
2694
+ "text": [
2695
+ "3\n",
2696
+ "5\n",
2697
+ "6\n",
2698
+ "3\n",
2699
+ "dog\n",
2700
+ "cat\n",
2701
+ "False\n",
2702
+ "5\n",
2703
+ "grapes\n"
2704
+ ]
2705
+ }
2706
+ ],
2707
+ "source": [
2708
+ "for item in tuple_1:\n",
2709
+ " print(item)"
2710
+ ]
2711
+ },
2712
+ {
2713
+ "cell_type": "code",
2714
+ "execution_count": 116,
2715
+ "metadata": {},
2716
+ "outputs": [
2717
+ {
2718
+ "name": "stdout",
2719
+ "output_type": "stream",
2720
+ "text": [
2721
+ "False\n",
2722
+ "3\n",
2723
+ "5\n",
2724
+ "6\n",
2725
+ "john\n",
2726
+ "jane\n",
2727
+ "coke\n",
2728
+ "jukes\n",
2729
+ "jaya\n",
2730
+ "jason\n",
2731
+ "fuzz\n",
2732
+ "pepsi\n",
2733
+ "dog\n"
2734
+ ]
2735
+ }
2736
+ ],
2737
+ "source": [
2738
+ "for item in set_1:\n",
2739
+ " print(item)"
2740
+ ]
2741
+ },
2742
+ {
2743
+ "cell_type": "code",
2744
+ "execution_count": 117,
2745
+ "metadata": {},
2746
+ "outputs": [
2747
+ {
2748
+ "name": "stdout",
2749
+ "output_type": "stream",
2750
+ "text": [
2751
+ "Key:name -> Value:Javier\n",
2752
+ "Key:fav_foods -> Value:['chicken', 'veg', 'candy']\n",
2753
+ "Key:rain -> Value:True\n",
2754
+ "Key:cars -> Value:a lot\n"
2755
+ ]
2756
+ }
2757
+ ],
2758
+ "source": [
2759
+ "for key, value in dict_1.items():\n",
2760
+ " print(f\"Key:{key} -> Value:{value}\")"
2761
+ ]
2762
+ },
2763
+ {
2764
+ "cell_type": "markdown",
2765
+ "metadata": {},
2766
+ "source": [
2767
+ "## Python \"if statements\" & \"while loops\"\n",
2768
+ "\n",
2769
+ "Conditional expressions can be used with these two **conditional statements**.\n",
2770
+ "\n",
2771
+ "The **if statement** allows you to test a condition and perform some actions if the condition evaluates to `True`. You can also provide `elif` and/or `else` clauses to an if statement to take alternative actions if the condition evaluates to `False`.\n",
2772
+ "\n",
2773
+ "The **while loop** will keep looping until its conditional expression evaluates to `False`.\n",
2774
+ "\n",
2775
+ "> Note: It is possible to \"loop forever\" when using a while loop with a conditional expression that never evaluates to `False`.\n",
2776
+ ">\n",
2777
+ "> Note: Since the **for loop** will iterate over a container of items until there are no more, there is no need to specify a \"stop looping\" condition."
2778
+ ]
2779
+ },
2780
+ {
2781
+ "cell_type": "code",
2782
+ "execution_count": 118,
2783
+ "metadata": {},
2784
+ "outputs": [
2785
+ {
2786
+ "name": "stdout",
2787
+ "output_type": "stream",
2788
+ "text": [
2789
+ "Correct\n"
2790
+ ]
2791
+ }
2792
+ ],
2793
+ "source": [
2794
+ "if 1 < 2:\n",
2795
+ " print(\"Correct\")"
2796
+ ]
2797
+ },
2798
+ {
2799
+ "cell_type": "code",
2800
+ "execution_count": 119,
2801
+ "metadata": {},
2802
+ "outputs": [
2803
+ {
2804
+ "data": {
2805
+ "text/plain": [
2806
+ "True"
2807
+ ]
2808
+ },
2809
+ "execution_count": 119,
2810
+ "metadata": {},
2811
+ "output_type": "execute_result"
2812
+ }
2813
+ ],
2814
+ "source": [
2815
+ "1 < 2"
2816
+ ]
2817
+ },
2818
+ {
2819
+ "cell_type": "code",
2820
+ "execution_count": 120,
2821
+ "metadata": {},
2822
+ "outputs": [
2823
+ {
2824
+ "name": "stdout",
2825
+ "output_type": "stream",
2826
+ "text": [
2827
+ "Correct\n"
2828
+ ]
2829
+ }
2830
+ ],
2831
+ "source": [
2832
+ "if (1 < 2) and isinstance(\"jason\", str) and 1 and 12 < 20:\n",
2833
+ " print(\"Correct\")"
2834
+ ]
2835
+ },
2836
+ {
2837
+ "cell_type": "code",
2838
+ "execution_count": 121,
2839
+ "metadata": {},
2840
+ "outputs": [
2841
+ {
2842
+ "name": "stdout",
2843
+ "output_type": "stream",
2844
+ "text": [
2845
+ "Default\n"
2846
+ ]
2847
+ }
2848
+ ],
2849
+ "source": [
2850
+ "if 1 > 2:\n",
2851
+ " print(\"Incorrect\")\n",
2852
+ "elif 1 > 3:\n",
2853
+ " print(\"Still incorrect\")\n",
2854
+ "else:\n",
2855
+ " print(\"Default\")"
2856
+ ]
2857
+ },
2858
+ {
2859
+ "cell_type": "markdown",
2860
+ "metadata": {},
2861
+ "source": [
2862
+ "## List Comprehensions"
2863
+ ]
2864
+ },
2865
+ {
2866
+ "cell_type": "code",
2867
+ "execution_count": 122,
2868
+ "metadata": {},
2869
+ "outputs": [
2870
+ {
2871
+ "data": {
2872
+ "text/plain": [
2873
+ "[1, 2, 3, 4, 5]"
2874
+ ]
2875
+ },
2876
+ "execution_count": 122,
2877
+ "metadata": {},
2878
+ "output_type": "execute_result"
2879
+ }
2880
+ ],
2881
+ "source": [
2882
+ "# Create a simple list\n",
2883
+ "l = [1, 2, 3, 4, 5]\n",
2884
+ "l"
2885
+ ]
2886
+ },
2887
+ {
2888
+ "cell_type": "code",
2889
+ "execution_count": 123,
2890
+ "metadata": {},
2891
+ "outputs": [
2892
+ {
2893
+ "data": {
2894
+ "text/plain": [
2895
+ "[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]"
2896
+ ]
2897
+ },
2898
+ "execution_count": 123,
2899
+ "metadata": {},
2900
+ "output_type": "execute_result"
2901
+ }
2902
+ ],
2903
+ "source": [
2904
+ "# This does not multiply each value by 2\n",
2905
+ "l * 2"
2906
+ ]
2907
+ },
2908
+ {
2909
+ "cell_type": "code",
2910
+ "execution_count": 124,
2911
+ "metadata": {},
2912
+ "outputs": [],
2913
+ "source": [
2914
+ "# The long way to do it...\n",
2915
+ "new_list = []\n",
2916
+ "for item in l:\n",
2917
+ " v = item * 2\n",
2918
+ " new_list.append(v)"
2919
+ ]
2920
+ },
2921
+ {
2922
+ "cell_type": "code",
2923
+ "execution_count": 125,
2924
+ "metadata": {},
2925
+ "outputs": [
2926
+ {
2927
+ "data": {
2928
+ "text/plain": [
2929
+ "[2, 4, 6, 8, 10]"
2930
+ ]
2931
+ },
2932
+ "execution_count": 125,
2933
+ "metadata": {},
2934
+ "output_type": "execute_result"
2935
+ }
2936
+ ],
2937
+ "source": [
2938
+ "new_list"
2939
+ ]
2940
+ },
2941
+ {
2942
+ "cell_type": "code",
2943
+ "execution_count": 126,
2944
+ "metadata": {},
2945
+ "outputs": [
2946
+ {
2947
+ "data": {
2948
+ "text/plain": [
2949
+ "[2, 4, 6, 8, 10]"
2950
+ ]
2951
+ },
2952
+ "execution_count": 126,
2953
+ "metadata": {},
2954
+ "output_type": "execute_result"
2955
+ }
2956
+ ],
2957
+ "source": [
2958
+ "# Same result using a list comprehension\n",
2959
+ "[item * 2 for item in l]"
2960
+ ]
2961
+ },
2962
+ {
2963
+ "cell_type": "code",
2964
+ "execution_count": 127,
2965
+ "metadata": {},
2966
+ "outputs": [
2967
+ {
2968
+ "data": {
2969
+ "text/plain": [
2970
+ "[0.5, 1.0, 1.5, 2.0, 2.5]"
2971
+ ]
2972
+ },
2973
+ "execution_count": 127,
2974
+ "metadata": {},
2975
+ "output_type": "execute_result"
2976
+ }
2977
+ ],
2978
+ "source": [
2979
+ "# Another example\n",
2980
+ "x = []\n",
2981
+ "for i in [1, 2, 3, 4, 5]:\n",
2982
+ " x.append(i / 2)\n",
2983
+ "x"
2984
+ ]
2985
+ },
2986
+ {
2987
+ "cell_type": "code",
2988
+ "execution_count": 128,
2989
+ "metadata": {},
2990
+ "outputs": [
2991
+ {
2992
+ "data": {
2993
+ "text/plain": [
2994
+ "[0.5, 1.0, 1.5, 2.0, 2.5]"
2995
+ ]
2996
+ },
2997
+ "execution_count": 128,
2998
+ "metadata": {},
2999
+ "output_type": "execute_result"
3000
+ }
3001
+ ],
3002
+ "source": [
3003
+ "[i / 2 for i in [1, 2, 3, 4, 5]]"
3004
+ ]
3005
+ },
3006
+ {
3007
+ "cell_type": "code",
3008
+ "execution_count": 129,
3009
+ "metadata": {},
3010
+ "outputs": [
3011
+ {
3012
+ "data": {
3013
+ "text/plain": [
3014
+ "[int, int, int, str, bool, int, str, str, str]"
3015
+ ]
3016
+ },
3017
+ "execution_count": 129,
3018
+ "metadata": {},
3019
+ "output_type": "execute_result"
3020
+ }
3021
+ ],
3022
+ "source": [
3023
+ "[type(i) for i in list_1]"
3024
+ ]
3025
+ },
3026
+ {
3027
+ "cell_type": "markdown",
3028
+ "metadata": {},
3029
+ "source": [
3030
+ "## Importing Modules"
3031
+ ]
3032
+ },
3033
+ {
3034
+ "cell_type": "code",
3035
+ "execution_count": 130,
3036
+ "metadata": {},
3037
+ "outputs": [],
3038
+ "source": [
3039
+ "import math\n",
3040
+ "import numpy"
3041
+ ]
3042
+ },
3043
+ {
3044
+ "cell_type": "code",
3045
+ "execution_count": 131,
3046
+ "metadata": {},
3047
+ "outputs": [
3048
+ {
3049
+ "data": {
3050
+ "text/plain": [
3051
+ "3.0"
3052
+ ]
3053
+ },
3054
+ "execution_count": 131,
3055
+ "metadata": {},
3056
+ "output_type": "execute_result"
3057
+ }
3058
+ ],
3059
+ "source": [
3060
+ "math.sqrt(9)"
3061
+ ]
3062
+ },
3063
+ {
3064
+ "cell_type": "code",
3065
+ "execution_count": 132,
3066
+ "metadata": {},
3067
+ "outputs": [
3068
+ {
3069
+ "data": {
3070
+ "text/plain": [
3071
+ "3.0"
3072
+ ]
3073
+ },
3074
+ "execution_count": 132,
3075
+ "metadata": {},
3076
+ "output_type": "execute_result"
3077
+ }
3078
+ ],
3079
+ "source": [
3080
+ "numpy.sqrt(9)"
3081
+ ]
3082
+ },
3083
+ {
3084
+ "cell_type": "code",
3085
+ "execution_count": 133,
3086
+ "metadata": {},
3087
+ "outputs": [],
3088
+ "source": [
3089
+ "import math as m"
3090
+ ]
3091
+ },
3092
+ {
3093
+ "cell_type": "code",
3094
+ "execution_count": 134,
3095
+ "metadata": {},
3096
+ "outputs": [
3097
+ {
3098
+ "data": {
3099
+ "text/plain": [
3100
+ "3.0"
3101
+ ]
3102
+ },
3103
+ "execution_count": 134,
3104
+ "metadata": {},
3105
+ "output_type": "execute_result"
3106
+ }
3107
+ ],
3108
+ "source": [
3109
+ "m.sqrt(9)"
3110
+ ]
3111
+ },
3112
+ {
3113
+ "cell_type": "code",
3114
+ "execution_count": 135,
3115
+ "metadata": {},
3116
+ "outputs": [],
3117
+ "source": [
3118
+ "from math import sqrt\n",
3119
+ "from numpy import sqrt"
3120
+ ]
3121
+ },
3122
+ {
3123
+ "cell_type": "code",
3124
+ "execution_count": 136,
3125
+ "metadata": {},
3126
+ "outputs": [
3127
+ {
3128
+ "data": {
3129
+ "text/plain": [
3130
+ "3.0"
3131
+ ]
3132
+ },
3133
+ "execution_count": 136,
3134
+ "metadata": {},
3135
+ "output_type": "execute_result"
3136
+ }
3137
+ ],
3138
+ "source": [
3139
+ "sqrt(9)"
3140
+ ]
3141
+ },
3142
+ {
3143
+ "cell_type": "markdown",
3144
+ "metadata": {},
3145
+ "source": [
3146
+ "## Exceptions"
3147
+ ]
3148
+ },
3149
+ {
3150
+ "cell_type": "code",
3151
+ "execution_count": 137,
3152
+ "metadata": {},
3153
+ "outputs": [
3154
+ {
3155
+ "ename": "KeyError",
3156
+ "evalue": "'food'",
3157
+ "output_type": "error",
3158
+ "traceback": [
3159
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3160
+ "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
3161
+ "Cell \u001b[0;32mIn[137], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m dict3 \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mjason\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcar\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnope\u001b[39m\u001b[38;5;124m\"\u001b[39m}\n\u001b[0;32m----> 2\u001b[0m \u001b[43mdict3\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mfood\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\n",
3162
+ "\u001b[0;31mKeyError\u001b[0m: 'food'"
3163
+ ]
3164
+ }
3165
+ ],
3166
+ "source": [
3167
+ "dict3 = {\"name\": \"jason\", \"car\": \"nope\"}\n",
3168
+ "dict3[\"food\"]"
3169
+ ]
3170
+ },
3171
+ {
3172
+ "cell_type": "code",
3173
+ "execution_count": 138,
3174
+ "metadata": {},
3175
+ "outputs": [
3176
+ {
3177
+ "ename": "ZeroDivisionError",
3178
+ "evalue": "division by zero",
3179
+ "output_type": "error",
3180
+ "traceback": [
3181
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3182
+ "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
3183
+ "Cell \u001b[0;32mIn[138], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;241;43m2\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\n",
3184
+ "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero"
3185
+ ]
3186
+ }
3187
+ ],
3188
+ "source": [
3189
+ "2 / 0"
3190
+ ]
3191
+ },
3192
+ {
3193
+ "cell_type": "code",
3194
+ "execution_count": 139,
3195
+ "metadata": {},
3196
+ "outputs": [
3197
+ {
3198
+ "ename": "TypeError",
3199
+ "evalue": "set expected at most 1 argument, got 3",
3200
+ "output_type": "error",
3201
+ "traceback": [
3202
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3203
+ "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
3204
+ "Cell \u001b[0;32mIn[139], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;43mset\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m)\u001b[49m\n",
3205
+ "\u001b[0;31mTypeError\u001b[0m: set expected at most 1 argument, got 3"
3206
+ ]
3207
+ }
3208
+ ],
3209
+ "source": [
3210
+ "set(1, 2, 3)"
3211
+ ]
3212
+ },
3213
+ {
3214
+ "cell_type": "code",
3215
+ "execution_count": 140,
3216
+ "metadata": {},
3217
+ "outputs": [
3218
+ {
3219
+ "ename": "NameError",
3220
+ "evalue": "name 'jason' is not defined",
3221
+ "output_type": "error",
3222
+ "traceback": [
3223
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3224
+ "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
3225
+ "Cell \u001b[0;32mIn[140], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mjason\u001b[49m\n",
3226
+ "\u001b[0;31mNameError\u001b[0m: name 'jason' is not defined"
3227
+ ]
3228
+ }
3229
+ ],
3230
+ "source": [
3231
+ "jason"
3232
+ ]
3233
+ },
3234
+ {
3235
+ "cell_type": "code",
3236
+ "execution_count": 141,
3237
+ "metadata": {},
3238
+ "outputs": [
3239
+ {
3240
+ "ename": "SyntaxError",
3241
+ "evalue": "invalid syntax (1125386000.py, line 1)",
3242
+ "output_type": "error",
3243
+ "traceback": [
3244
+ "\u001b[0;36m Cell \u001b[0;32mIn[141], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m 1 + 2:\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
3245
+ ]
3246
+ }
3247
+ ],
3248
+ "source": [
3249
+ "1 + 2:"
3250
+ ]
3251
+ },
3252
+ {
3253
+ "cell_type": "code",
3254
+ "execution_count": 150,
3255
+ "metadata": {},
3256
+ "outputs": [
3257
+ {
3258
+ "ename": "Exception",
3259
+ "evalue": "My own exception",
3260
+ "output_type": "error",
3261
+ "traceback": [
3262
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3263
+ "\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
3264
+ "Cell \u001b[0;32mIn[150], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMy own exception\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
3265
+ "\u001b[0;31mException\u001b[0m: My own exception"
3266
+ ]
3267
+ }
3268
+ ],
3269
+ "source": [
3270
+ "raise Exception(\"My own exception\")"
3271
+ ]
3272
+ },
3273
+ {
3274
+ "cell_type": "code",
3275
+ "execution_count": 151,
3276
+ "metadata": {},
3277
+ "outputs": [
3278
+ {
3279
+ "ename": "AssertionError",
3280
+ "evalue": "Pass a number >=0",
3281
+ "output_type": "error",
3282
+ "traceback": [
3283
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3284
+ "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
3285
+ "Cell \u001b[0;32mIn[151], line 6\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m x \u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPass a number >=0\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m math\u001b[38;5;241m.\u001b[39msqrt(x)\n\u001b[0;32m----> 6\u001b[0m \u001b[43mfcn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n",
3286
+ "Cell \u001b[0;32mIn[151], line 2\u001b[0m, in \u001b[0;36mfcn\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mfcn\u001b[39m(x):\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m x \u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPass a number >=0\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m math\u001b[38;5;241m.\u001b[39msqrt(x)\n",
3287
+ "\u001b[0;31mAssertionError\u001b[0m: Pass a number >=0"
3288
+ ]
3289
+ }
3290
+ ],
3291
+ "source": [
3292
+ "def fcn(x):\n",
3293
+ " assert x >= 0, \"Pass a number >=0\"\n",
3294
+ " return math.sqrt(x)\n",
3295
+ "\n",
3296
+ "\n",
3297
+ "fcn(-1)"
3298
+ ]
3299
+ },
3300
+ {
3301
+ "cell_type": "code",
3302
+ "execution_count": 152,
3303
+ "metadata": {},
3304
+ "outputs": [
3305
+ {
3306
+ "ename": "ModuleNotFoundError",
3307
+ "evalue": "No module named 'my_module'",
3308
+ "output_type": "error",
3309
+ "traceback": [
3310
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3311
+ "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
3312
+ "Cell \u001b[0;32mIn[152], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmy_module\u001b[39;00m\n",
3313
+ "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'my_module'"
3314
+ ]
3315
+ }
3316
+ ],
3317
+ "source": [
3318
+ "import my_module"
3319
+ ]
3320
+ },
3321
+ {
3322
+ "cell_type": "code",
3323
+ "execution_count": 153,
3324
+ "metadata": {},
3325
+ "outputs": [
3326
+ {
3327
+ "ename": "NameError",
3328
+ "evalue": "name 'calculate' is not defined",
3329
+ "output_type": "error",
3330
+ "traceback": [
3331
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3332
+ "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
3333
+ "Cell \u001b[0;32mIn[153], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mcalculate\u001b[49m(\u001b[38;5;241m5\u001b[39m, \u001b[38;5;241m5\u001b[39m)\n",
3334
+ "\u001b[0;31mNameError\u001b[0m: name 'calculate' is not defined"
3335
+ ]
3336
+ }
3337
+ ],
3338
+ "source": [
3339
+ "calculate(5, 5)"
3340
+ ]
3341
+ },
3342
+ {
3343
+ "cell_type": "code",
3344
+ "execution_count": 154,
3345
+ "metadata": {},
3346
+ "outputs": [
3347
+ {
3348
+ "ename": "ValueError",
3349
+ "evalue": "math domain error",
3350
+ "output_type": "error",
3351
+ "traceback": [
3352
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3353
+ "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
3354
+ "Cell \u001b[0;32mIn[154], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmath\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msqrt\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n",
3355
+ "\u001b[0;31mValueError\u001b[0m: math domain error"
3356
+ ]
3357
+ }
3358
+ ],
3359
+ "source": [
3360
+ "math.sqrt(-1)"
3361
+ ]
3362
+ },
3363
+ {
3364
+ "cell_type": "code",
3365
+ "execution_count": 155,
3366
+ "metadata": {},
3367
+ "outputs": [
3368
+ {
3369
+ "ename": "AttributeError",
3370
+ "evalue": "module 'math' has no attribute 'my_func'",
3371
+ "output_type": "error",
3372
+ "traceback": [
3373
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3374
+ "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
3375
+ "Cell \u001b[0;32mIn[155], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmath\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m \u001b[43mmath\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmy_func\u001b[49m(\u001b[38;5;241m2\u001b[39m)\n",
3376
+ "\u001b[0;31mAttributeError\u001b[0m: module 'math' has no attribute 'my_func'"
3377
+ ]
3378
+ }
3379
+ ],
3380
+ "source": [
3381
+ "import math\n",
3382
+ "\n",
3383
+ "math.my_func(2)"
3384
+ ]
3385
+ },
3386
+ {
3387
+ "cell_type": "code",
3388
+ "execution_count": 156,
3389
+ "metadata": {},
3390
+ "outputs": [
3391
+ {
3392
+ "ename": "AttributeError",
3393
+ "evalue": "'str' object has no attribute 'my_func'",
3394
+ "output_type": "error",
3395
+ "traceback": [
3396
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3397
+ "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
3398
+ "Cell \u001b[0;32mIn[156], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mjason\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmy_func\u001b[49m()\n",
3399
+ "\u001b[0;31mAttributeError\u001b[0m: 'str' object has no attribute 'my_func'"
3400
+ ]
3401
+ }
3402
+ ],
3403
+ "source": [
3404
+ "\"jason\".my_func()"
3405
+ ]
3406
+ },
3407
+ {
3408
+ "cell_type": "markdown",
3409
+ "metadata": {},
3410
+ "source": [
3411
+ "## Classes: Creating Your Own Objects"
3412
+ ]
3413
+ },
3414
+ {
3415
+ "cell_type": "code",
3416
+ "execution_count": 157,
3417
+ "metadata": {},
3418
+ "outputs": [],
3419
+ "source": [
3420
+ "class JasonStrimpel:\n",
3421
+ " pass\n",
3422
+ "\n",
3423
+ "\n",
3424
+ "class ThisIsMyClass:\n",
3425
+ " pass"
3426
+ ]
3427
+ },
3428
+ {
3429
+ "cell_type": "code",
3430
+ "execution_count": null,
3431
+ "metadata": {},
3432
+ "outputs": [],
3433
+ "source": []
3434
+ },
3435
+ {
3436
+ "cell_type": "code",
3437
+ "execution_count": 158,
3438
+ "metadata": {},
3439
+ "outputs": [],
3440
+ "source": [
3441
+ "# Define a new class called `Thing` that is derived from the base Python object\n",
3442
+ "class Car(object):\n",
3443
+ " color = \"red\""
3444
+ ]
3445
+ },
3446
+ {
3447
+ "cell_type": "code",
3448
+ "execution_count": 159,
3449
+ "metadata": {},
3450
+ "outputs": [
3451
+ {
3452
+ "data": {
3453
+ "text/plain": [
3454
+ "__main__.Car"
3455
+ ]
3456
+ },
3457
+ "execution_count": 159,
3458
+ "metadata": {},
3459
+ "output_type": "execute_result"
3460
+ }
3461
+ ],
3462
+ "source": [
3463
+ "# Create \"instances\" of our new classes\n",
3464
+ "a = Car()\n",
3465
+ "b = Car()\n",
3466
+ "c = Car()\n",
3467
+ "\n",
3468
+ "type(c)"
3469
+ ]
3470
+ },
3471
+ {
3472
+ "cell_type": "code",
3473
+ "execution_count": 160,
3474
+ "metadata": {},
3475
+ "outputs": [
3476
+ {
3477
+ "data": {
3478
+ "text/plain": [
3479
+ "'red'"
3480
+ ]
3481
+ },
3482
+ "execution_count": 160,
3483
+ "metadata": {},
3484
+ "output_type": "execute_result"
3485
+ }
3486
+ ],
3487
+ "source": [
3488
+ "c.color"
3489
+ ]
3490
+ },
3491
+ {
3492
+ "cell_type": "code",
3493
+ "execution_count": 161,
3494
+ "metadata": {},
3495
+ "outputs": [],
3496
+ "source": [
3497
+ "# Interact with a DictThing instance just as you would a normal dictionary\n",
3498
+ "# Define a new class called `DictThing` that is derived from the `dict` type\n",
3499
+ "class DictThing(dict):\n",
3500
+ " my_property = 'I am a \"DictThing\"'"
3501
+ ]
3502
+ },
3503
+ {
3504
+ "cell_type": "code",
3505
+ "execution_count": 162,
3506
+ "metadata": {},
3507
+ "outputs": [],
3508
+ "source": [
3509
+ "d = DictThing()"
3510
+ ]
3511
+ },
3512
+ {
3513
+ "cell_type": "code",
3514
+ "execution_count": 163,
3515
+ "metadata": {},
3516
+ "outputs": [
3517
+ {
3518
+ "data": {
3519
+ "text/plain": [
3520
+ "{'name': 'Javier',\n",
3521
+ " 'fav_foods': ['chicken', 'veg', 'candy'],\n",
3522
+ " 'rain': True,\n",
3523
+ " 'cars': 'a lot'}"
3524
+ ]
3525
+ },
3526
+ "execution_count": 163,
3527
+ "metadata": {},
3528
+ "output_type": "execute_result"
3529
+ }
3530
+ ],
3531
+ "source": [
3532
+ "dict_1"
3533
+ ]
3534
+ },
3535
+ {
3536
+ "cell_type": "code",
3537
+ "execution_count": 164,
3538
+ "metadata": {},
3539
+ "outputs": [
3540
+ {
3541
+ "ename": "AttributeError",
3542
+ "evalue": "'dict' object has no attribute 'my_property'",
3543
+ "output_type": "error",
3544
+ "traceback": [
3545
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
3546
+ "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
3547
+ "Cell \u001b[0;32mIn[164], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mdict_1\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmy_property\u001b[49m\n",
3548
+ "\u001b[0;31mAttributeError\u001b[0m: 'dict' object has no attribute 'my_property'"
3549
+ ]
3550
+ }
3551
+ ],
3552
+ "source": [
3553
+ "dict_1.my_property"
3554
+ ]
3555
+ },
3556
+ {
3557
+ "cell_type": "code",
3558
+ "execution_count": 165,
3559
+ "metadata": {},
3560
+ "outputs": [
3561
+ {
3562
+ "name": "stdout",
3563
+ "output_type": "stream",
3564
+ "text": [
3565
+ "{'age': 13, 'fav_foods': ['pizza', 'sushi', 'pad thai', 'waffles'], 'fav_color': 'green'}\n"
3566
+ ]
3567
+ }
3568
+ ],
3569
+ "source": [
3570
+ "d.update(\n",
3571
+ " {\n",
3572
+ " \"age\": 13,\n",
3573
+ " \"fav_foods\": [\"pizza\", \"sushi\", \"pad thai\", \"waffles\"],\n",
3574
+ " \"fav_color\": \"green\",\n",
3575
+ " }\n",
3576
+ ")\n",
3577
+ "print(d)"
3578
+ ]
3579
+ },
3580
+ {
3581
+ "cell_type": "code",
3582
+ "execution_count": 166,
3583
+ "metadata": {},
3584
+ "outputs": [
3585
+ {
3586
+ "name": "stdout",
3587
+ "output_type": "stream",
3588
+ "text": [
3589
+ "I am a \"DictThing\"\n"
3590
+ ]
3591
+ }
3592
+ ],
3593
+ "source": [
3594
+ "print(d.my_property)"
3595
+ ]
3596
+ },
3597
+ {
3598
+ "cell_type": "markdown",
3599
+ "metadata": {},
3600
+ "source": [
3601
+ "## Creating An Initializer Method For Classes"
3602
+ ]
3603
+ },
3604
+ {
3605
+ "cell_type": "code",
3606
+ "execution_count": 167,
3607
+ "metadata": {},
3608
+ "outputs": [],
3609
+ "source": [
3610
+ "class Car:\n",
3611
+ "\n",
3612
+ " color = \"red\"\n",
3613
+ "\n",
3614
+ " def __init__(self):\n",
3615
+ " print(f\"The car is going fast.\")"
3616
+ ]
3617
+ },
3618
+ {
3619
+ "cell_type": "code",
3620
+ "execution_count": 168,
3621
+ "metadata": {},
3622
+ "outputs": [
3623
+ {
3624
+ "name": "stdout",
3625
+ "output_type": "stream",
3626
+ "text": [
3627
+ "The car is going fast.\n"
3628
+ ]
3629
+ }
3630
+ ],
3631
+ "source": [
3632
+ "a = Car()"
3633
+ ]
3634
+ },
3635
+ {
3636
+ "cell_type": "markdown",
3637
+ "metadata": {},
3638
+ "source": [
3639
+ "## Defining Attributes & Methods"
3640
+ ]
3641
+ },
3642
+ {
3643
+ "cell_type": "code",
3644
+ "execution_count": 169,
3645
+ "metadata": {},
3646
+ "outputs": [],
3647
+ "source": [
3648
+ "class Car:\n",
3649
+ "\n",
3650
+ " color = \"red\"\n",
3651
+ "\n",
3652
+ " def __init__(self):\n",
3653
+ " print(f\"The car is going fast.\")\n",
3654
+ "\n",
3655
+ " def drive(self, how_fast):\n",
3656
+ " return f\"The {self.color} car drives {how_fast} mph.\""
3657
+ ]
3658
+ },
3659
+ {
3660
+ "cell_type": "code",
3661
+ "execution_count": 170,
3662
+ "metadata": {},
3663
+ "outputs": [
3664
+ {
3665
+ "name": "stdout",
3666
+ "output_type": "stream",
3667
+ "text": [
3668
+ "The car is going fast.\n",
3669
+ "The car is going fast.\n"
3670
+ ]
3671
+ }
3672
+ ],
3673
+ "source": [
3674
+ "car_a = Car()\n",
3675
+ "car_b = Car()"
3676
+ ]
3677
+ },
3678
+ {
3679
+ "cell_type": "code",
3680
+ "execution_count": 171,
3681
+ "metadata": {},
3682
+ "outputs": [
3683
+ {
3684
+ "data": {
3685
+ "text/plain": [
3686
+ "'red'"
3687
+ ]
3688
+ },
3689
+ "execution_count": 171,
3690
+ "metadata": {},
3691
+ "output_type": "execute_result"
3692
+ }
3693
+ ],
3694
+ "source": [
3695
+ "car_a.color"
3696
+ ]
3697
+ },
3698
+ {
3699
+ "cell_type": "code",
3700
+ "execution_count": 172,
3701
+ "metadata": {},
3702
+ "outputs": [
3703
+ {
3704
+ "data": {
3705
+ "text/plain": [
3706
+ "'red'"
3707
+ ]
3708
+ },
3709
+ "execution_count": 172,
3710
+ "metadata": {},
3711
+ "output_type": "execute_result"
3712
+ }
3713
+ ],
3714
+ "source": [
3715
+ "car_b.color"
3716
+ ]
3717
+ },
3718
+ {
3719
+ "cell_type": "code",
3720
+ "execution_count": 173,
3721
+ "metadata": {},
3722
+ "outputs": [
3723
+ {
3724
+ "data": {
3725
+ "text/plain": [
3726
+ "'The red car drives 55 mph.'"
3727
+ ]
3728
+ },
3729
+ "execution_count": 173,
3730
+ "metadata": {},
3731
+ "output_type": "execute_result"
3732
+ }
3733
+ ],
3734
+ "source": [
3735
+ "car_b.drive(55)"
3736
+ ]
3737
+ },
3738
+ {
3739
+ "cell_type": "markdown",
3740
+ "metadata": {},
3741
+ "source": [
3742
+ "# `self` - Setting Attributes & Methods"
3743
+ ]
3744
+ },
3745
+ {
3746
+ "cell_type": "code",
3747
+ "execution_count": 174,
3748
+ "metadata": {},
3749
+ "outputs": [],
3750
+ "source": [
3751
+ "class Car:\n",
3752
+ "\n",
3753
+ " def __init__(self, color, make):\n",
3754
+ " self.color = color\n",
3755
+ " self.color_cap = color.upper()\n",
3756
+ " self.make = make\n",
3757
+ "\n",
3758
+ " def mph_to_kph(self, mph):\n",
3759
+ " return mph * 1.60934\n",
3760
+ "\n",
3761
+ " def drive(self, how_fast):\n",
3762
+ " return f\"The {self.color} {self.make} drives {how_fast} mph.\"\n",
3763
+ "\n",
3764
+ " def drive_in_kph(self, how_fast):\n",
3765
+ " kph = self.mph_to_kph(how_fast)\n",
3766
+ " return f\"The {self.color} {self.make} drives {kph} kph.\""
3767
+ ]
3768
+ },
3769
+ {
3770
+ "cell_type": "code",
3771
+ "execution_count": 175,
3772
+ "metadata": {},
3773
+ "outputs": [],
3774
+ "source": [
3775
+ "car_a = Car(\"Black\", \"Tahoe\")"
3776
+ ]
3777
+ },
3778
+ {
3779
+ "cell_type": "code",
3780
+ "execution_count": 176,
3781
+ "metadata": {},
3782
+ "outputs": [
3783
+ {
3784
+ "data": {
3785
+ "text/plain": [
3786
+ "'The Black Tahoe drives 88.5137 kph.'"
3787
+ ]
3788
+ },
3789
+ "execution_count": 176,
3790
+ "metadata": {},
3791
+ "output_type": "execute_result"
3792
+ }
3793
+ ],
3794
+ "source": [
3795
+ "car_a.drive_in_kph(55)"
3796
+ ]
3797
+ },
3798
+ {
3799
+ "cell_type": "code",
3800
+ "execution_count": 177,
3801
+ "metadata": {},
3802
+ "outputs": [
3803
+ {
3804
+ "data": {
3805
+ "text/plain": [
3806
+ "'The Black Audi drives 160.934 kph.'"
3807
+ ]
3808
+ },
3809
+ "execution_count": 177,
3810
+ "metadata": {},
3811
+ "output_type": "execute_result"
3812
+ }
3813
+ ],
3814
+ "source": [
3815
+ "car_b = Car(\"Black\", \"Audi\")\n",
3816
+ "car_b.drive_in_kph(100)"
3817
+ ]
3818
+ },
3819
+ {
3820
+ "cell_type": "code",
3821
+ "execution_count": null,
3822
+ "metadata": {},
3823
+ "outputs": [],
3824
+ "source": []
3825
+ }
3826
+ ],
3827
+ "metadata": {
3828
+ "kernelspec": {
3829
+ "display_name": "Python 3 (ipykernel)",
3830
+ "language": "python",
3831
+ "name": "python3"
3832
+ },
3833
+ "language_info": {
3834
+ "codemirror_mode": {
3835
+ "name": "ipython",
3836
+ "version": 3
3837
+ },
3838
+ "file_extension": ".py",
3839
+ "mimetype": "text/x-python",
3840
+ "name": "python",
3841
+ "nbconvert_exporter": "python",
3842
+ "pygments_lexer": "ipython3",
3843
+ "version": "3.12.5"
3844
+ }
3845
+ },
3846
+ "nbformat": 4,
3847
+ "nbformat_minor": 4
3848
+ }
build/conda/installer/assets/header_win.png ADDED
build/conda/installer/assets/installer.nsi ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ;--------------------------------
2
+ ; Includes
3
+
4
+ !include "MUI2.nsh"
5
+ !include "logiclib.nsh"
6
+
7
+
8
+ #if enable_debugging is True
9
+ # Special logging build needed for ENABLE_LOGGING
10
+ # See https://nsis.sourceforge.io/Special_Builds
11
+ !define ENABLE_LOGGING=True
12
+ #endif
13
+
14
+ # Comes from https://nsis.sourceforge.io/Logging:Enable_Logs_Quickly
15
+ !define LogSet "!insertmacro LogSetMacro"
16
+ !macro LogSetMacro SETTING
17
+ !ifdef ENABLE_LOGGING
18
+ LogSet ${SETTING}
19
+ !endif
20
+ !macroend
21
+
22
+ !define LogText "!insertmacro LogTextMacro"
23
+ !macro LogTextMacro INPUT_TEXT
24
+ !ifdef ENABLE_LOGGING
25
+ LogText ${INPUT_TEXT}
26
+ !endif
27
+ !macroend
28
+
29
+ ;--------------------------------
30
+ ; Custom defines
31
+ !define NAME "OpenBB Platform"
32
+ !define COMPANY "OpenBB"
33
+ !define VERSION "1.0.0"
34
+ !define SLUG "${NAME} v${VERSION}"
35
+
36
+ ;--------------------------------
37
+ ; General
38
+ Name "${NAME}"
39
+ InstallDir "${PROFILE}\OpenBB"
40
+ RequestExecutionLevel user
41
+
42
+ ;--------------------------------
43
+ ; UI
44
+
45
+ !define MUI_ICON "assets\openbb_icon.ico"
46
+ !define MUI_UNICON "assets\openbb_icon.ico"
47
+ !define MUI_HEADERIMAGE
48
+ !define MUI_WELCOMEFINISHPAGE_BITMAP "assets\installer_vertical2.bmp"
49
+ !define MUI_HEADERIMAGE_BITMAP "assets\installer_horizontal.bmp"
50
+ !define MUI_ABORTWARNING
51
+ !define MUI_WELCOMEPAGE_TITLE "${SLUG} Setup"
52
+ !define UninstId "OpenBBPlatform" ; You might want to use a GUID here
53
+
54
+ ;--------------------------------
55
+ ; Pages
56
+
57
+ ; Installer pages
58
+ !insertmacro MUI_PAGE_WELCOME
59
+ !insertmacro MUI_PAGE_LICENSE "assets\installer_license.txt"
60
+ ; !insertmacro MUI_PAGE_COMPONENTS
61
+ !insertmacro MUI_PAGE_DIRECTORY
62
+ !insertmacro MUI_PAGE_INSTFILES
63
+ !insertmacro MUI_PAGE_FINISH
64
+
65
+ ; Uninstaller pages
66
+ !insertmacro MUI_UNPAGE_CONFIRM
67
+ !insertmacro MUI_UNPAGE_INSTFILES
68
+
69
+ ; Set UI language
70
+ !insertmacro MUI_LANGUAGE "English"
71
+
72
+
73
+ ; Var /GLOBAL installerPath
74
+
75
+
76
+
77
+
78
+
79
+ ; StrContains
80
+ ; This function does a case sensitive searches for an occurrence of a substring in a string.
81
+ ; It returns the substring if it is found.
82
+ ; Otherwise it returns null("").
83
+ ; Written by kenglish_hi
84
+ ; Adapted from StrReplace written by dandaman32
85
+
86
+
87
+ Var STR_HAYSTACK
88
+ Var STR_NEEDLE
89
+ Var STR_CONTAINS_VAR_1
90
+ Var STR_CONTAINS_VAR_2
91
+ Var STR_CONTAINS_VAR_3
92
+ Var STR_CONTAINS_VAR_4
93
+ Var STR_RETURN_VAR
94
+
95
+ Function StrContains
96
+ Exch $STR_NEEDLE
97
+ Exch 1
98
+ Exch $STR_HAYSTACK
99
+ ; Uncomment to debug
100
+ ;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
101
+ StrCpy $STR_RETURN_VAR ""
102
+ StrCpy $STR_CONTAINS_VAR_1 -1
103
+ StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
104
+ StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
105
+ loop:
106
+ IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
107
+ StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
108
+ StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
109
+ StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
110
+ Goto loop
111
+ found:
112
+ StrCpy $STR_RETURN_VAR $STR_NEEDLE
113
+ Goto done
114
+ done:
115
+ Pop $STR_NEEDLE ;Prevent "invalid opcode" errors and keep the
116
+ Exch $STR_RETURN_VAR
117
+ FunctionEnd
118
+
119
+ !macro _StrContainsConstructor OUT NEEDLE HAYSTACK
120
+ Push `${HAYSTACK}`
121
+ Push `${NEEDLE}`
122
+ Call StrContains
123
+ Pop `${OUT}`
124
+ !macroend
125
+
126
+ !define StrContains '!insertmacro "_StrContainsConstructor"'
127
+
128
+
129
+ ;-------------------------------
130
+ ; Uninstall Previous Version if exists
131
+
132
+ !macro UninstallExisting exitcode uninstcommand
133
+ Push `${uninstcommand}`
134
+ Call UninstallExisting
135
+ Pop ${exitcode}
136
+ !macroend
137
+ Function UninstallExisting
138
+ Exch $1 ; uninstcommand
139
+ Push $2 ; Uninstaller
140
+ Push $3 ; Len
141
+ StrCpy $3 ""
142
+ StrCpy $2 $1 1
143
+ StrCmp $2 '"' qloop sloop
144
+ sloop:
145
+ StrCpy $2 $1 1 $3
146
+ IntOp $3 $3 + 1
147
+ StrCmp $2 "" +2
148
+ StrCmp $2 ' ' 0 sloop
149
+ IntOp $3 $3 - 1
150
+ Goto run
151
+ qloop:
152
+ StrCmp $3 "" 0 +2
153
+ StrCpy $1 $1 "" 1 ; Remove initial quote
154
+ IntOp $3 $3 + 1
155
+ StrCpy $2 $1 1 $3
156
+ StrCmp $2 "" +2
157
+ StrCmp $2 '"' 0 qloop
158
+ run:
159
+ StrCpy $2 $1 $3 ; Path to uninstaller
160
+ StrCpy $1 161 ; ERROR_BAD_PATHNAME
161
+ GetFullPathName $3 "$2\.." ; $InstDir
162
+ IfFileExists "$2" 0 +4
163
+ ExecWait '"$2" /S _?=$3' $1 ; This assumes the existing uninstaller is a NSIS uninstaller, other uninstallers don't support /S nor _?=
164
+ IntCmp $1 0 "" +2 +2 ; Don't delete the installer if it was aborted
165
+ Delete "$2" ; Delete the uninstaller
166
+ RMDir "$3" ; Try to delete $InstDir
167
+ RMDir "$3\.." ; (Optional) Try to delete the parent of $InstDir
168
+ Pop $3
169
+ Pop $2
170
+ Exch $1 ; exitcode
171
+ FunctionEnd
172
+
173
+
174
+ Function .onInit
175
+ ReadRegStr $0 HKCU "Software\Software\Microsoft\Windows\CurrentVersion\Uninstall\${UninstId}" "UninstallString"
176
+ ${If} $0 != ""
177
+ ${AndIf} ${Cmd} `MessageBox MB_YESNO|MB_ICONQUESTION "It is highly recommended to uninstall the previous version of OpenBB Terminal - Please click Yes to proceed (Note - You will not lose your custom settings) - Or you can uninstall manually. " /SD IDYES IDYES`
178
+ !insertmacro UninstallExisting $0 $0
179
+ ${If} $0 <> 0
180
+ MessageBox MB_YESNO|MB_ICONSTOP "Failed to uninstall, continue anyway?" /SD IDYES IDYES +2
181
+ Abort
182
+ ${EndIf}
183
+ ${EndIf}
184
+ FunctionEnd
185
+
186
+ ;--------------------------------
187
+ ; Section - Install App
188
+
189
+ Section "-hidden app"
190
+ SectionIn RO
191
+ ${StrContains} $0 "\OpenBB" "$INSTDIR"
192
+ ; Making sure here if user manually removes \openbb from their path that it still installs there
193
+ ; so we dont have issues with uninstaller later.
194
+ StrCmp $0 "" notfound
195
+ ; MessageBox MB_OK 'Found string $0 $INSTDIR'
196
+ SetOutPath "$INSTDIR"
197
+ Goto done
198
+ notfound:
199
+ ; MessageBox MB_OK "$INSTDIR is 'bla'"
200
+ SetOutPath "$INSTDIR\OpenBB"
201
+ StrCpy $InstDir "$INSTDIR\OpenBB"
202
+ ; MessageBox MB_OK 'Did not find string "$INSTDIR\OpenBB" "$installerPath"'
203
+ done:
204
+
205
+ ; File /r "app\*.*"
206
+ WriteRegStr HKCU "Software\${NAME}" "" $INSTDIR
207
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
208
+ WriteRegStr HKCU "Software\Software\Microsoft\Windows\CurrentVersion\Uninstall\${UninstId}" "OpenBBPlatform" "OpenBB"
209
+ WriteRegStr HKCU "Software\Software\Microsoft\Windows\CurrentVersion\Uninstall\${UninstId}" "UninstallString" '"$InstDir\Uninstall.exe"'
210
+ WriteRegStr HKCU "Software\Software\Microsoft\Windows\CurrentVersion\Uninstall\${UninstId}" "QuietUninstallString" '"$InstDir\Uninstall.exe" /S'
211
+ SectionEnd
212
+
213
+
214
+ ;--------------------------------
215
+ ; Remove empty parent directories
216
+
217
+ Function un.RMDirUP
218
+ !define RMDirUP '!insertmacro RMDirUPCall'
219
+
220
+ !macro RMDirUPCall _PATH
221
+ push '${_PATH}'
222
+ Call un.RMDirUP
223
+ !macroend
224
+
225
+ ; $0 - current folder
226
+ ClearErrors
227
+
228
+ Exch $0
229
+ ;DetailPrint "ASDF - $0\.."
230
+ RMDir "$0\.."
231
+
232
+ IfErrors Skip
233
+ ${RMDirUP} "$0\.."
234
+ Skip:
235
+
236
+ Pop $0
237
+
238
+ FunctionEnd
239
+
240
+ ;--------------------------------
241
+ ; Section - Uninstaller
242
+
243
+ Section "Uninstall"
244
+
245
+ ;Delete Shortcut
246
+ Delete "$DESKTOP\${NAME}.lnk"
247
+
248
+ ;Delete Directory
249
+ Delete '$SMPROGRAMS\${Company}\${NAME}'
250
+
251
+ ;Delete Reg Key
252
+ DeleteRegKey HKCU "Software\Software\Microsoft\Windows\CurrentVersion\Uninstall\${UninstId}"
253
+
254
+ ;Delete Uninstall
255
+ Delete "$INSTDIR\Uninstall.exe"
256
+
257
+
258
+ ;Delete Folder
259
+ RMDir /r "$INSTDIR"
260
+ ${RMDirUP} "$INSTDIR"
261
+
262
+ DeleteRegKey /ifempty HKCU "Software\${NAME}"
263
+
264
+ SectionEnd
build/conda/installer/assets/installer_conclusion.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Thank you for installing OpenBB Platform!
2
+
3
+ To get started, open the installed OpenBB folder, in the home folder of your user, and review the README.md file. Or, open one of the launchers using the provided shortcuts.
4
+
5
+ The OpenBB Platform Documentation is found here:
6
+ https://docs.openbb.co
7
+
8
+ Bugs/Issues/Requests can be posted here:
9
+ https://github.com/OpenBB-finance/OpenBB/issues
10
+
11
+ Security vulnerabilities can be reported here:
12
+ https://github.com/OpenBB-finance/OpenBB/security/advisories
build/conda/installer/assets/installer_license.txt ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 1. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) <year> <name of author>
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published
637
+ by the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
build/conda/installer/assets/installer_readme.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ OpenBB Platform provides a convenient way to access raw financial data from multiple data providers.
2
+
3
+ Important Notes:
4
+
5
+ In order to install you need access to the Internet.
6
+
7
+ The installation will take approximately 1-2 GB of storage and is for the current user only, system-wide installations are not allowed.
8
+
9
+ If a folder named "OpenBB" already exists at the user home directory, please remove it before installing.
10
+
11
+ The installed packages can be reconfigured, post-installation, for custom configurations.
12
+
13
+ If the OpenBB folder is moved, post-installation, the shortcuts will not be updated to reflect the change.
14
+
15
+
16
+
17
+ This application is intended strictly for research and educational purposes.
18
+
19
+ By proceeding with the installation, you agree not to use this application for any purpose that is unlawful or prohibited by international and national laws, regulations, or governmental and industry requirements.
build/conda/installer/assets/installer_welcome.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ Welcome to the OpenBB Platform Installer.
2
+
3
+
4
+ This application will install the latest version of the OpenBB Platform on your computer in a self-contained, Python 3.12, Conda environment. It contains everything required to get started immediately, both as a user and a developer.
5
+
6
+ Several launch scripts are included; OpenBB CLI, OpenBB API, Jupyter Notebook, IPython, Update, and shortcuts to key folders.
7
+
8
+ Find them at the base of the installation folder, along with the README.md file for getting started.
build/conda/installer/assets/openbb.icns ADDED
Binary file (16.7 kB). View file
 
build/conda/installer/assets/openbb_icon.ico ADDED
build/conda/installer/assets/openbb_osx.png ADDED
build/conda/installer/assets/openbb_platform_installer/README.md ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenBB Platform Installer Package
2
+
3
+ This package is for installing the OpenBB Platform packages into any Python environment. Versions between 3.9 and 3.12, inclusively, are supported.
4
+
5
+ The `obb` virtual environment that came with the installation is pre-loaded, and this configuration can be duplicated by creating a new environment and running, `poetry install`, from this location.
6
+
7
+ ## Installation
8
+
9
+ Assuming the current working directory is the location of this document, the code block below will create a new environment, activate it, update the dependencies, and then install the OpenBB Platform.
10
+
11
+ Open the Terminal command line with the Bash/CMD shortcut.
12
+
13
+ ```sh
14
+ conda create -n my_env python=3.10 -y
15
+ conda activate my_env
16
+ pip install poetry
17
+ poetry lock
18
+ poetry install
19
+ openbb-build
20
+ ```
21
+
22
+ ## Updating Packages
23
+
24
+ Update the environment dependencies with:
25
+
26
+ ```sh
27
+ poetry lock
28
+ poetry install
29
+ ```
30
+
31
+ ## Installation Groups
32
+
33
+ The package can be installed in different configurations, using Poetry groups as `--with`, `--without`, or `--only` keyword arguments.
34
+
35
+ - main
36
+ - openbb-all
37
+ - cli
38
+ - notebook
39
+
40
+ To install, in a fresh environment, only the `openbb-core` package and the base dependencies:
41
+
42
+ ```sh
43
+ poetry install --only main --sync
44
+ ```
45
+
46
+ The `--sync` flag with sync the environment to the `poetry.lock` file for the flagged group(s). All items are installed when no arguments are supplied. Use this as a way to restore corrupted environments.
47
+
48
+ Do not use the `--sync` flag if you wish to keep installed packages that are not defined in the `pyproject.toml` and `poetry.lock` files.
build/conda/installer/assets/openbb_platform_installer/obb-env.yml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ name: obb
2
+ channels:
3
+ - conda-forge
4
+ dependencies:
5
+ - python=3.12
build/conda/installer/assets/openbb_platform_installer/openbb_platform_installer/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ """Placeholder for the OpenBB Platform Installer package."""
2
+
3
+ __version__ = "1.0.2"
build/conda/installer/assets/openbb_platform_installer/openbb_platform_installer/update.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Entry point for the OpenBB Updater script."""
2
+
3
+ # pylint: disable=import-outside-toplevel,unused-import
4
+ # flake8: noqa
5
+
6
+ def main():
7
+ """Update the OpenBB Platform and rebuild the Python interface."""
8
+
9
+ import os
10
+ import sys
11
+ import subprocess
12
+ from pathlib import Path
13
+
14
+ args = os.sys.argv[1:].copy() if os.sys.argv[1:] else []
15
+
16
+ cwd = Path(os.path.dirname(os.path.realpath(__file__))).parent.resolve()
17
+
18
+ command = (
19
+ f"{sys.executable} -m pip install -U pip && "
20
+ f"{sys.executable} -m poetry lock && "
21
+ f"{sys.executable} -m poetry install {' '.join(args)} && "
22
+ "openbb-build"
23
+ )
24
+
25
+ subprocess.run(command, shell=True, cwd=cwd)
26
+
27
+ input("\nUpdate complete. Press Enter to exit...")
28
+
29
+ if __name__ == "__main__":
30
+ main()
build/conda/installer/assets/openbb_platform_installer/pyproject.toml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # If you will be using this as a template for your own package, please change the values accordingly.
2
+ [tool.poetry]
3
+ name = "openbb_platform_installer" # Change this to your package name
4
+ version = "1.0.3" # Change this to your package version
5
+ description = "A meta package for installing the OpenBB Platform: Investment research for everyone, anywhere." # Change this to your description
6
+ authors = ["OpenBB <hello@openbb.co>"] # Change this to your name and email
7
+ license = "AGPL-3.0-only" # This license must be compatible with the OpenBB license
8
+ readme = "README.md" # Change this to your README file
9
+ homepage = "https://openbb.co" # Change this to your website
10
+ repository = "https://github.com/openbb-finance/openbb" # Change this to your repository
11
+ documentation = "https://docs.openbb.co" # Change this to your documentation
12
+ packages = [{ include = "openbb_platform_installer" }] # Update accordingly - these are build scripts and entry points.
13
+
14
+ [tool.poetry.scripts]
15
+ openbb-update = "openbb_platform_installer.update:main"
16
+
17
+ [tool.poetry.dependencies]
18
+ python = ">=3.9.21,<3.13"
19
+ openbb-platform-api = "^1.1.8"
20
+
21
+ [tool.poetry.group.openbb-all]
22
+
23
+ [tool.poetry.group.openbb-all.dependencies]
24
+ openbb = { version = "^4.4.4", extras = ["all"] }
25
+
26
+ [tool.poetry.group.cli]
27
+
28
+ [tool.poetry.group.cli.dependencies]
29
+ openbb-cli = "^1"
30
+
31
+ [tool.poetry.group.notebook]
32
+
33
+ [tool.poetry.group.notebook.dependencies]
34
+ notebook = "^7"
35
+ nbclassic = "^1"
36
+ jedi-language-server = "^0.41"
37
+
38
+ [build-system]
39
+ requires = ["poetry-core>=1.0.0"]
40
+ build-backend = "poetry.core.masonry.api"
build/conda/installer/assets/openbb_win.png ADDED
build/conda/installer/construct.yaml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "OpenBB"
2
+ version: "Platform"
3
+ company: OpenBB, Inc.
4
+ license_file: ./assets/installer_license.txt
5
+
6
+ installer_type: all
7
+
8
+ register_python: false # [win]
9
+ register_python_default: false # [win]
10
+ register_envs: false
11
+ initialize_by_default: false
12
+ initialize_conda: false
13
+ write_condarc: true
14
+
15
+ default_location_pkg: OpenBB # [osx]
16
+ default_prefix_domain_user: "%USERPROFILE%\\OpenBB\\conda" # [win]
17
+ default_prefix: "${HOME}/OpenBB" # [linux]
18
+ default_prefix: "%USERPROFILE%\\OpenBB\\conda" # [win]
19
+ pkg_name: conda
20
+
21
+ specs:
22
+ - conda
23
+ - bash # [unix]
24
+ - python=3.12
25
+
26
+ extra_envs:
27
+ obb:
28
+ environment_file: ./assets/openbb_platform_installer/obb-env.yml
29
+
30
+ channels:
31
+ - conda-forge
32
+
33
+ condarc:
34
+ {channels: [conda-forge],
35
+ allow_softlinks: false,
36
+ auto_activate_base: false,
37
+ always_copy: true,
38
+ register_envs: false,
39
+ pip_interop_enabled: true}
40
+
41
+ pkg_domains:
42
+ enable_anywhere: false
43
+ enable_currentUserHome: true
44
+
45
+ post_install: post_install.sh # [unix]
46
+ post_install: post_install.bat # [win]
47
+
48
+ extra_files:
49
+ # Bundle launcher assets
50
+ - ./README.md: ../README.md
51
+ - ./assets/openbb_platform_installer/obb-env.yml: ../extensions/openbb_platform_installer/obb-env.yml
52
+ - ./assets/openbb_platform_installer/pyproject.toml: ../extensions/openbb_platform_installer/pyproject.toml
53
+ - ./assets/openbb_platform_installer/README.md: ../extensions/openbb_platform_installer/README.md
54
+ - ./assets/openbb_platform_installer/openbb_platform_installer/__init__.py: ../extensions/openbb_platform_installer/openbb_platform_installer/__init__.py
55
+ - ./assets/openbb_platform_installer/openbb_platform_installer/update.py: ../extensions/openbb_platform_installer/openbb_platform_installer/update.py
56
+ - ./assets/openbb_icon.ico: assets/openbb_icon.ico # [win]
57
+ - ./assets/openbb.icns: ../openbb_icon.icns # [osx]
58
+ - ./assets/create_shortcut.vbs: assets/create_shortcut.vbs # [win]
59
+ - ./assets/installer_license.txt: assets/installer_license.txt # [win]
60
+ - ./assets/installer_vertical2.bmp: assets/installer_vertical2.bmp # [win]
61
+ - ./assets/installer_horizontal.bmp: assets/installer_horizontal.bmp # [win]
62
+ - ./assets/examples/README.md: ../extensions/examples/README.md
63
+ - ./assets/examples/install_examples.py: ../extensions/examples/install_examples.py
64
+ - ./assets/examples/empty_provider/pyproject.toml: ../extensions/examples/empty_provider/pyproject.toml
65
+ - ./assets/examples/empty_provider/README.md: ../extensions/examples/empty_provider/README.md
66
+ - ./assets/examples/empty_provider/empty_provider/__init__.py: ../extensions/examples/empty_provider/empty_provider/__init__.py
67
+ - ./assets/examples/empty_provider/empty_provider/models/__init__.py: ../extensions/examples/empty_provider/empty_provider/models/__init__.py
68
+ - ./assets/examples/empty_provider/empty_provider/models/empty_model.py: ../extensions/examples/empty_provider/empty_provider/models/empty_model.py
69
+ - ./assets/examples/empty_provider/empty_provider/utils/__init__.py: ../extensions/examples/empty_provider/empty_provider/utils/__init__.py
70
+ - ./assets/examples/empty_router/pyproject.toml: ../extensions/examples/empty_router/pyproject.toml
71
+ - ./assets/examples/empty_router/README.md: ../extensions/examples/empty_router/README.md
72
+ - ./assets/examples/empty_router/empty_router/__init__.py: ../extensions/examples/empty_router/empty_router/__init__.py
73
+ - ./assets/examples/empty_router/empty_router/empty_router.py: ../extensions/examples/empty_router/empty_router/empty_router.py
74
+ - ./assets/examples/empty_router/empty_router/empty_views.py: ../extensions/examples/empty_router/empty_router/empty_views.py
75
+ - ./assets/examples/empty_obbject/pyproject.toml: ../extensions/examples/empty_obbject/pyproject.toml
76
+ - ./assets/examples/empty_obbject/README.md: ../extensions/examples/empty_obbject/README.md
77
+ - ./assets/examples/empty_obbject/empty_obbject/__init__.py: ../extensions/examples/empty_obbject/empty_obbject/__init__.py
78
+ - ./assets/examples/python_basics.ipynb: ../notebooks/python_basics.ipynb
79
+ - ../../../examples/platform_standardization.ipynb: ../notebooks/how_platform_works.ipynb
80
+
81
+ icon_image: ../openbb_icon.icns # [osx]
82
+ icon_image: ./assets/openbb_icon.ico # [win]
83
+ welcome_image: ./assets/openbb_osx.png # [unix]
84
+ welcome_image: ./assets/Installer_vertical2.bmp # [win]
85
+ header_image: ./assets/Installer_horizontal2.png # [win]
86
+ welcome_image_text: "OpenBB Platform"
87
+ readme_file: ./assets/installer_readme.txt # [unix]
88
+ conclusion_file: ./assets/installer_conclusion.txt # [unix]
89
+ welcome_file: ./assets/installer_welcome.txt # [unix]
90
+ welcome_file: ./assets/custom_welcome.nsi # [win]
91
+ conclusion_file: ./assets/custom_conclusion.nsi # [win]
92
+
93
+ # Add extra files to the installer - this is another way - was playing with this
94
+ temp_extra_files:
95
+ - ./assets/Installer_vertical2.bmp: Installer_vertical2.bmp # [win]
build/conda/installer/post_install.bat ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ echo Installing environment, this may take a few minutes... Watch for changes in post_install_log.txt file at the root of the installation directory.
3
+
4
+ cd "%PREFIX%\..\extensions\openbb_platform_installer"
5
+
6
+ PATH %PREFIX%;%PREFIX%\Scripts;%PREFIX%\Library\bin;%PATH%
7
+ SET LOG_FILE="%PREFIX%\..\post_install_log.txt"
8
+
9
+ call "%PREFIX%\Scripts\activate.bat"
10
+
11
+ call conda activate "%PREFIX%\envs\obb" >> "%LOG_FILE%" 2>&1
12
+
13
+ python -m pip install -U pip >> "%LOG_FILE%" 2>&1
14
+
15
+ pip install -U setuptools >> "%LOG_FILE%" 2>&1
16
+
17
+ pip install poetry >> "%LOG_FILE%" 2>&1
18
+
19
+ poetry config virtualenvs.path "%PREFIX%\envs" --local >> "%LOG_FILE%" 2>&1
20
+
21
+ poetry config virtualenvs.create false --local >> "%LOG_FILE%" 2>&1
22
+
23
+ poetry lock >> "%LOG_FILE%" 2>&1
24
+
25
+ poetry install >> "%LOG_FILE%" 2>&1
26
+
27
+ IF ERRORLEVEL 1 (
28
+ echo %date% %time% "Error during post-installation: poetry install failed." >> %LOG_FILE%
29
+ exit /b 1
30
+ ) ELSE (
31
+ echo %date% %time% "Python environment successfully installed... Building the OpenBB Python interface..." >> %LOG_FILE%
32
+ )
33
+
34
+ echo Python environment successfully installed... Building the OpenBB Python interface...
35
+
36
+ call openbb-build >> "%LOG_FILE%" 2>&1
37
+ IF ERRORLEVEL 1 (
38
+ call :log_with_timestamp "Error during post-installation: building OpenBB's Python interface failed."
39
+ exit /b 1
40
+ ) ELSE (
41
+ call :log_with_timestamp "OpenBB's Python interface built successfully."
42
+ )
43
+
44
+ cscript "%PREFIX%\assets\create_shortcut.vbs" >> "%LOG_FILE%" 2>&1
45
+ IF ERRORLEVEL 1 (
46
+ echo %date% %time% "Error during post-installation: creating shortcuts failed." >> %LOG_FILE%
47
+ exit /b 1
48
+ ) ELSE (
49
+ echo %date% %time% "Shortcuts created successfully." >> %LOG_FILE%
50
+ )
51
+
52
+ echo Post-installation steps completed successfully.
53
+
54
+ exit /b 0
55
+
56
+ goto :eof
57
+
58
+ REM Function to add timestamp
59
+ :log_with_timestamp
60
+ echo %date%_%time% %1 >> %LOG_FILE%
61
+ goto :eof