Skip to content

Instantly share code, notes, and snippets.

View saleh-old's full-sized avatar

Saleh O saleh-old

View GitHub Profile

Installation:

brew install ffmpeg 
brew cask install xquartz
brew install gifsicle

usage for file with the name in.mov and output of out.gif:

ffmpeg -i in.mov -s 1400x900 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=1 > out.gif
import jesse.indicators as ta
entry = ta.ema(self.candles, 50)
stop = ta.ema(self.candles, 100)
# docs for self.get_candles:
# https://docs.jesse-ai.com/docs/strategies/api.html#get-candles
all_daily_candles = self.get_candles(self.exchange, self.symbol, '1D')
# notice that "-1" would have have given me the current candle,
# hence "-2" gives me the one before that which is yesterday's
previous_day_candle = all_daily_candles[-2]
previous_day_candle_low = previous_day_candle[4]
# My trading route is "4h".
routes = [
('Bitfinex', 'BTCUSD', '4h', 'TrendFollowingStrategy'),
]
# I need to add an extra route to "extra_candles" below:
extra_candles = [
('Bitfinex', 'BTCUSD', '1D'),
]
# "4" is the index of low of the candle in Jesse's strategy API.
# for more, read https://docs.jesse-ai.com/docs/strategies/api.html#current-candle
last_20_lows = self.candles[-20:, 4]
previous_low = np.min(last_20_lows)
# get the ATR indicator value for current candle
atr = ta.atr(self.candles)
# enter at current price with a market order
entry = self.price
stop = entry - (atr * 3)
entry_price = 100
stop_price = 90
risk_percentage = 0.03
capital_size = 10000
risk_per_qty = 100 - 90 # 10
position_size = ((risk_percentage * capital_size) / risk_per_qty) * entry_price
position_qty = position_size / entry_price # 30
entry_price = 100
stop_price = 80
risk_percentage = 0.03
capital_size = 10000
risk_per_qty = 100 - 80 # 20
position_size = ((risk_percentage * capital_size) / risk_per_qty) * entry_price
position_qty = position_size / entry_price # 15
@saleh-old
saleh-old / python-ubuntu18.sh
Created June 17, 2020 15:51
Environment setup for Python on a Ubuntu 18.04 machine
echo "updaing ubuntu..."
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get install git -y
# python 3.8
echo "installing Python 3.8 ..."
sudo apt-get -y install gcc binutils
sudo apt-get update
def filters(self):
return [
self.reward_to_risk_filter,
]