DIY Quantitative Stock Market Investing
Dr. Yves J. Hilpisch | The Python Quants & The AI Machine
Online, PyData Botswana, 15. September 2022
(short link to this Gist: http://bit.ly/pdb_diy)
DIY Quantitative Stock Market Investing
Dr. Yves J. Hilpisch | The Python Quants & The AI Machine
Online, PyData Botswana, 15. September 2022
(short link to this Gist: http://bit.ly/pdb_diy)
| #!/usr/bin/env bash | |
| # | |
| # Reads AirTag data from the FindMy.app cache and converts it to a daily GPX file | |
| # | |
| # Rsyncs the data to a web accessible folder that can be displayed with e.g. | |
| # https://gist.github.com/henrik242/84ad80dd2170385fe819df1d40224cc4 | |
| # | |
| # This should typically be run as a cron job | |
| # |
| import SwiftUI | |
| import HealthKit | |
| struct ContentView: View { | |
| @State var labelText = "Get Data" | |
| @State var flag = false | |
| let healthStore = HKHealthStore() | |
| let allTypes = Set([ | |
| HKSeriesType.heartbeat(), |
| def get_dollar_bars(time_bars, dollar_threshold): #function credit to Max Bodoia | |
| # initialize an empty list of dollar bars | |
| dollar_bars = [] | |
| # initialize the running dollar volume at zero | |
| running_volume = 0 | |
| # initialize the running high and low with placeholder values | |
| running_high, running_low = 0, math.inf |
| import socketio | |
| sio = socketio.Client() | |
| @sio.event | |
| def connect(): | |
| sio.emit('subscribe', 'lightning_executions_FX_BTC_JPY') | |
| @sio.event | |
| def lightning_executions_FX_BTC_JPY(data): |
| import hashlib | |
| import hmac | |
| import json | |
| import time | |
| import urllib.parse | |
| from threading import Thread | |
| from collections import deque | |
| from requests import Request, Session | |
| from requests.exceptions import HTTPError |
| # this code is based on get_historical_data() from python-binance module | |
| # https://github.com/sammchardy/python-binance | |
| # it also requires pybybit.py available from this page | |
| # https://note.mu/mtkn1/n/n9ef3460e4085 | |
| # (where pandas & websocket-client are needed) | |
| import time | |
| import dateparser | |
| import pytz | |
| import json |
| import numpy as np | |
| def object_einsum(string, *arrays): | |
| """Simplified object einsum, not as much error checking | |
| does not support "..." or list input and will see "...", etc. as three times | |
| an axes identifier, tries normal einsum first! | |
| NOTE: This is untested, and not fast, but object type is | |
| never really fast anyway... |
| # MIT License | |
| # | |
| # Copyright (c) 2018 Stefano Nardo https://gist.github.com/stefanonardo | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: |