This file contains 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
image: docker/compose:latest | |
services: | |
- docker:dind | |
stages: | |
- build | |
- test | |
- deploy |
This file contains 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 python:3.11-slim | |
ENV PYTHONUNBUFFERED=1 | |
RUN mkdir /code | |
WORKDIR /code | |
COPY requirements.txt . | |
RUN apt-get update && apt-get -y install git libxml2-dev libxslt-dev gcc zlib1g-dev | |
RUN pip3 install --upgrade pip setuptools wheel |
This file contains 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
async def fetch_all_candles(self, symbol, timeframe='1d', limit=5000, end_time=None): | |
"""If `end_time` is passed it is inclusive in results. | |
This will page through all results and remove the duplicate record, finally make an extra call which will be | |
empty and break the generator. Had to make the extra call as `limit` was not always max 5000 sometimes it | |
returned 5001 or even 4995, so it was impossible to just break if the len() was < 5000. | |
Ccxt paging with `since` is broken, so we must use params end_time and hack the start_time to 0 else | |
library code will override and break pagination. | |
""" |
This file contains 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 asyncio | |
async def producer(queue): | |
i = 1 | |
while True: | |
await queue.put(f'item {i}') | |
i += 1 | |
await asyncio.sleep(5) |
This file contains 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 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 \ |
This file contains 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 asyncio | |
import aiohttp | |
symbols = [ | |
'BTC-PERP', | |
'ETH-PERP', | |
'EOS-PERP', | |
'BCH-PERP', | |
'LTC-PERP', |
This file contains 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
const symbols = [ | |
"BTC-PERP", | |
"BTC/USD", | |
"ETH-PERP", | |
"ETH/USD", | |
]; | |
const ws_init = function () { | |
ws = new WebSocket("wss://ftx.com/ws/"); |
This file contains 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 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')) |
This file contains 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 ccxt | |
c = ccxt.ftx({ | |
'apiKey': 'YOURKEY', | |
'secret': 'YOURSECRET', | |
'enableRateLimit': True, | |
#'headers': {'FTX-SUBACCOUNT': 'YOURSUBACCOUNTNAME'}, # uncomment line if using subaccount | |
}) | |
balance = c.fetch_balance() |
This file contains 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 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. |
NewerOlder