Skip to content

Instantly share code, notes, and snippets.

View ugik's full-sized avatar

GK ugik

View GitHub Profile
@ugik
ugik / Screener strategy
Created February 26, 2020 21:21
Backtrader screener strategy
# Create a Stratey
class TestStrategy(bt.Strategy):
params = (
('maperiod', 20),
)
def log(self, txt, optimization=False, dt=None):
if optimization:
return
def telegram_EMA(sma, back=50, show=False):
file = 'EMAs.jpg'
ax = sma[-back:].plot(y="BTCUSDT_C", kind="line", color="k", \
linewidth=3, use_index=True, x_compat=True, \
rot=25, linestyle='-', figsize=(6, 5))
sma[-back:].plot(y="EMA20", kind="line", ax=ax, color="y", \
x_compat=True, rot=25, linestyle=':', figsize=(6, 5))
sma[-back:].plot(y="EMA50", kind="line", ax=ax, color="r", \
# setup EMA indicator values
def setup_ema():
ticksAgo = datetime.datetime.now() - timedelta(hours= 24)
candlesticks = client.get_historical_klines(EXCHANGE, Client.KLINE_INTERVAL_3MINUTE, str(ticksAgo))
for candle in candlesticks:
del candle[-6:]
ema = pd.DataFrame(candlesticks, columns=['date', EXCHANGE+'_O', EXCHANGE+'_H', \
file = "stats.jpg"
# create your own numerical lists here...
days = [30, 21, 14, 5, 2]
data = [10, 19, 6, 34, 12]
labels = days
plt.xticks(range(len(data)), labels)
plt.xlabel('Days')
plt.ylabel('% Position Gain')
client = Client(config.BINANCE_API_KEY, config.BINANCE_API_SECRET, tld='us')
def getPositionInfo(startDate=None, exchange='BTCUSDT'):
if not startDate:
return
candlesticks = client.get_historical_klines(exchange, Client.KLINE_INTERVAL_1HOUR, str(startDate))
# trim each candle
for candle in candlesticks:
del candle[-6:]
dateFrom = '2022-08-05 12:00:00'
positionData = getPositionInfo(startDate=timezoneGMT(parser.parse(dateFrom)), exchange='BTCUSDT')
file = coin +'.jpg'
ax = plt.gca()
dateFrom = str(timezoneGMT(parser.parse(dateFrom)))
positionData.plot(kind='line',x='date',y=coin[:3],ax=ax, marker='.', \
title= coin[:3] +" since "+dateFrom)
plt.savefig(file, bbox_inches='tight')
@ugik
ugik / main.dart
Created March 11, 2020 15:16
Flutter Voting App main.dart
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
def main():
start_time = time()
csvfile = open('arbitrage', 'w', newline='', encoding='UTF8')
result_writer = csv.writer(csvfile, delimiter=',')
n = 0
while n < ITERATIONS:
n += 1
prices = get_prices()
from collections import defaultdict
from operator import itemgetter
from time import time
import config, csv
from binance.client import Client
FEE = 0.00075 # Binance VIP0 level spot-trade transaction fee for "Taker" (limit order)
ITERATIONS = 5000 # iterations to run
PRIMARY = ['ETH', 'USDT', 'BTC', 'BNB', 'ADA', 'SOL', 'LINK', 'LTC', 'UNI', 'XTZ']
FEE = 0.00075 # Binance VIP0 level spot-trade transaction fee for "Taker" (limit order)
ITERATIONS = 5000 # iterations to run
PRIMARY = ['ETH', 'USDT', 'BTC', 'BNB', 'ADA', 'SOL', 'LINK', 'LTC', 'UNI', 'XTZ']