Skip to content

Instantly share code, notes, and snippets.

@jmoz
jmoz / Dockerfile
Created Oct 10, 2020
Dockerfile for Django, python-slim (requirements had Twisted which caused gcc and other errors)
View Dockerfile
FROM python:3.8-slim
ENV PYTHONUNBUFFERED=1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN apt-get update \
&& apt-get install -y --no-install-recommends gcc build-essential \
&& pip3 install -r requirements.txt \
@jmoz
jmoz / Asyncio_aiohttp_FTX_prices.py
Created Jul 1, 2020
asyncio aiohttp FTX prices
View Asyncio_aiohttp_FTX_prices.py
import asyncio
import aiohttp
symbols = [
'BTC-PERP',
'ETH-PERP',
'EOS-PERP',
'BCH-PERP',
'LTC-PERP',
@jmoz
jmoz / ftx_websockets.js
Created Jun 2, 2020
FTX Websockets Javascript
View ftx_websockets.js
const symbols = [
"BTC-PERP",
"BTC/USD",
"ETH-PERP",
"ETH/USD",
];
const ws_init = function () {
ws = new WebSocket("wss://ftx.com/ws/");
@jmoz
jmoz / ftx_api_balance.py
Created May 12, 2020
FTX API get balance
View ftx_api_balance.py
import FtxClient
c = FtxClient(
api_key='YOURKEY',
api_secret='YOURSECRET',
)
balance = c.get_balances()
print(balance)
btc_total = next((b['total'] for b in balance if b['coin'] == 'BTC'))
@jmoz
jmoz / ccxt_ftx_balance.py
Created May 12, 2020
Python CCXT FTX API get balance
View ccxt_ftx_balance.py
import ccxt
c = ccxt.ftx({
'apiKey': 'YOURKEY',
'secret': 'YOURSECRET',
'enableRateLimit': True,
#'headers': {'FTX-SUBACCOUNT': 'YOURSUBACCOUNTNAME'}, # uncomment line if using subaccount
})
balance = c.fetch_balance()
@jmoz
jmoz / rsi.py
Created Sep 27, 2019
RSI calculation to match Tradingview
View rsi.py
import pandas as pd
def rsi(ohlc: pd.DataFrame, period: int = 14) -> pd.Series:
"""See source https://github.com/peerchemist/finta
and fix https://www.tradingview.com/wiki/Talk:Relative_Strength_Index_(RSI)
Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements.
RSI oscillates between zero and 100. Traditionally, and according to Wilder, RSI is considered overbought when above 70 and oversold when below 30.
Signals can also be generated by looking for divergences, failure swings and centerline crossovers.
@jmoz
jmoz / twitter_favouriter.py
Created Aug 1, 2013
Twitter API favouriter
View twitter_favouriter.py
from twitter import Twitter, OAuth, TwitterHTTPError
OAUTH_TOKEN = 'foo'
OAUTH_SECRET = 'bar'
CONSUMER_KEY = 'baz'
CONSUMER_SECRET = 'bat'
t = Twitter(auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET, CONSUMER_KEY, CONSUMER_SECRET))
@jmoz
jmoz / phpunit_chaining.php
Last active Jan 19, 2016
Phpunit mocking and chaining.
View phpunit_chaining.php
<?php
namespace Foo\Unit;
class Foo
{
public function foo($foo = true)
{
return $foo;
}
View README.md

OEmbed Liquid Tag for Jekyll

This is a simple liquid tag that helps to easily embed images, videos or slides from OEmbed enabled providers. It uses Magnus Holm's great oembed gem which connects to the OEmbed endpoint of the link's provider and retrieves the HTML code to embed the content properly (i.e. an in-place YouTube player, Image tag for Flickr, in-place slideshare viewer etc.). By default it supports the following OEmbed providers (but can fallback to Embed.ly or OoEmbed for other providers):

  • Youtube
  • Flickr
  • Viddler
  • Qik
  • Revision3
  • Hulu
  • Vimeo
@jmoz
jmoz / python_import_this
Created Apr 7, 2013
Python import this
View python_import_this
$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.