With Python
Dr. Yves J. Hilpisch | The Python Quants & The AI Machine
Python for Quant Finance Meetup, London, 16. November 2022
(short link to this Gist: http://bit.ly/pqf_risk)
With Python
Dr. Yves J. Hilpisch | The Python Quants & The AI Machine
Python for Quant Finance Meetup, London, 16. November 2022
(short link to this Gist: http://bit.ly/pqf_risk)
| # Name: c_usda_quick_stats.py | |
| # Author: Randy Runtsch | |
| # Date: March 29, 2022 | |
| # Project: Query USDA QuickStats API | |
| # Author: Randall P. Runtsch | |
| # | |
| # Description: Query the USDA QuickStats api_GET API with a specified set of | |
| # parameters. Write the retrieved data, in CSV format, to a file. | |
| # | |
| # See Quick Stats (NASS) API user guide: https://quickstats.nass.usda.gov/api |
Lecture 1: Introduction to Research — [📝Lecture Notebooks] [
Lecture 2: Introduction to Python — [📝Lecture Notebooks] [
Lecture 3: Introduction to NumPy — [📝Lecture Notebooks] [
Lecture 4: Introduction to pandas — [📝Lecture Notebooks] [
Lecture 5: Plotting Data — [📝Lecture Notebooks] [[
| from typing import List | |
| def http_error(status: int) -> str: | |
| match status: | |
| case 400: | |
| return "Bad request" | |
| case 404: | |
| return "Not found" | |
| case 418: |
| ## docker-compose para correr wordpress con una base de datos en mysql | |
| ## by PeladoNerd https://youtu.be/eoFxMaeB9H4 | |
| version: '3.1' | |
| services: | |
| wordpress: | |
| image: wordpress:php7.1-apache | |
| ports: |
| # -*- coding: utf-8 -*- | |
| """ | |
| Created on Fri Jun 02 17:02:32 2017 | |
| @author: Vangelis@logical-invest.com | |
| This script will pull the symbols from your specified Amibroker database and download historical EOD dividend adjusted data from Tiingo.com and will store them | |
| in a folder (Destop/Data/TiingoEOD) as csv files, one for each stock (APPLE.csv SPY.csv, etc) | |
| It will then attempt to open Amibroker and import the csv files. | |
| You need: | |
| 1. To add your own Token number you will get when you register at Tiingo.com (line 51) | |
| 2. Specify the Amibroker database you want updated (line 99) |
| def treatoutliers(self, df=None, columns=None, factor=1.5, method='IQR', treament='cap'): | |
| """ | |
| Removes the rows from self.df whose value does not lies in the specified standard deviation | |
| :param columns: | |
| :param in_stddev: | |
| :return: | |
| """ | |
| # if not columns: | |
| # columns = self.mandatory_cols_ + self.optional_cols_ + [self.target_col] | |
| if not columns: |
| window = 253 | |
| # detrend tome series by MA | |
| ratesM = data['Adj Close'].rolling(window).mean().dropna() | |
| ratesD = data['Adj Close'].reindex(ratesM.index).sub(ratesM) | |
| fig, axs = plt.subplots(2, figsize=(16, 8), sharex=True) | |
| data['Adj Close'].plot(ax=axs[0], title="Trend") | |
| ratesM.plot(ax=axs[0]) | |
| ratesD.plot(ax=axs[1], c="g", title="Residuals"); |
| seasonal["2019-11":"2019-12"].plot(label='Seasonality', color="blue", figsize=(20,8)); |
| seasonal["2019"].plot(label='Seasonality', color="blue", figsize=(20,8)); |