This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [Mamba: Linear-Time Sequence Modeling with Selective State Spaces](https://arxiv.org/abs/2312.00752) | |
import torch | |
import torch.nn as nn | |
import torch.optim as optim | |
from torch.utils.data import DataLoader, Dataset | |
from torch.nn import functional as F | |
from einops import rearrange, repeat | |
from tqdm import tqdm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def visFBP(df, forecast): | |
""" | |
Given two dataframes: before training df and a forecast df, returns | |
a visual chart of the predicted values and actual values. | |
""" | |
# Visual DF | |
vis_df = df[['ds','Open']].append(forecast).rename( | |
columns={'yhat': 'Prediction', | |
'yhat_upper': "Predicted High", | |
'yhat_lower': "Predicted Low"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fbpTrainPredict(df, forecast_period): | |
""" | |
Uses FB Prophet and fits to a appropriately formatted DF. Makes a prediction N days into | |
the future based on given forecast period. Returns predicted values as a DF. | |
""" | |
# Setting up prophet | |
m = Prophet( | |
daily_seasonality=True, | |
yearly_seasonality=True, | |
weekly_seasonality=True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
sudo apt install build-essential wget -y | |
wget https://artiya4u.keybase.pub/TA-lib/ta-lib-0.4.0-src.tar.gz | |
tar -xvf ta-lib-0.4.0-src.tar.gz | |
cd ta-lib/ | |
./configure --prefix=/usr | |
make | |
sudo make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
""" | |
To use, import in to your file, and the main thing you want is run the *safe_launch_ibc* function | |
pass in your path to your start script (code assumes LOG directory is in the same directory), pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from btgym import BTgymEnv | |
import IPython.display as Display | |
import PIL.Image as Image | |
from gym import spaces | |
import gym | |
import numpy as np | |
import random |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#the following code takes a list such as | |
#[1,1,2,6,8,5,5,7,8,8,1,1,4,5,5,0,0,0,1,1,4,4,5,1,3,3,4,5,4,1,1] | |
#with states labeled as successive integers starting with 0 | |
#and returns a transition matrix, M, | |
#where M[i][j] is the probability of transitioning from i to j | |
def transition_matrix(transitions): | |
n = 1+ max(transitions) #number of states | |
M = [[0]*n for _ in range(n)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This example was built using standard create-react-app out of the box with no modifications or ejections | |
to the underlying scripts. | |
In this example, i'm using Google as a social provider configured within the Cognito User Pool. | |
Each step also represents a file, so you can see how I've chosen to organize stuff...you can do it however | |
you'd like so long as you follow the basic flow (which may or may not be the official way....but its what I found that works. | |
The docs are pretty horrible) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gist example of IB wrapper ... | |
# | |
# Download API from http://interactivebrokers.github.io/# | |
# | |
# Install python API code /IBJts/source/pythonclient $ python3 setup.py install | |
# | |
# Note: The test cases, and the documentation refer to a python package called IBApi, | |
# but the actual package is called ibapi. Go figure. | |
# | |
# Get the latest version of the gateway: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gym | |
import numpy as np | |
import random | |
from keras.models import Sequential | |
from keras.layers import Dense, Dropout | |
from keras.optimizers import Adam | |
from collections import deque | |
class DQN: |
NewerOlder