Skip to content

Instantly share code, notes, and snippets.

@ekam230
ekam230 / translitera
Last active August 25, 2021 18:57
Транслитерация названий страниц на PHP в ЧПУ
Транслитерация названий страниц на PHP в ЧПУ
Следующая функция PHP помогает произвести транслитерацию заголовка страницы в ЧПУ с русского и казахского языков на английский язык:
<?php
function translitURL($str)
{
$tr = array(
"А"=>"a","Б"=>"b","В"=>"v","Г"=>"g",
"Д"=>"d","Е"=>"e","Ё"=>"yo","Ж"=>"zh","З"=>"z","И"=>"i",
@ekam230
ekam230 / supervisord.service
Created March 26, 2018 17:01 — forked from mozillazg/supervisord.service
install and configure supervisord on centos 7.
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown
//проверяю открытые позиции
$openpos=$bitmex2->getOpenPositions();
if ($openpos != Array()) {
message("You have open position. I try close it. Wait...");
//если бай то закрываюсь селом
if ($openpos[0]["liquidationPrice"] < 1000){
message("You have Buy Open Position");
$orderNow = array();
while ($orderNow != TRUE)
{point_zero1:
if ($getOrder["ordStatus"] == "New"){
$i=0;
$opos=False;
while (($bitmex2->cancelAllOpenOrders() !=TRUE) or $opos==True){
message("Try Cancel Order");
$bitmex2->cancelAllOpenOrders();
usleep(505);
$log->warning("Try Cancel Order $name");
$i++;
if ($i==3){
@ekam230
ekam230 / editOrder.php
Created April 23, 2018 18:37
EditOrder
if ($getOrder["ordStatus"] == "New"){
message("Try Edit Order");
//беру цену
$editOrder = array();
while ($editOrder != TRUE) {
$priceNow = array();
while ($priceNow != TRUE){
$priceNow=$bitmex2->getTicker("XBTUSD");
usleep(1000);}
message("Get price OK. Price=".$priceNow);
@ekam230
ekam230 / index.php
Created April 23, 2018 18:59
protection against losses
////защита от потерь
if ((($price-$buyPrice>$limitloss) && ($position=='short'))||(($buyPrice-$price>$limitloss) && ($position=='long'))){
var_dump($buyPrice);
var_dump($price);
var_dump($limitloss);
var_dump($position);
$log->emergency("$name Loss over 100 contracts");
$log->warning("$name Закрываю позиции");
//проверяю открытые позиции
$openpos=$bitmex2->getOpenPositions();
"""
Order copier
"""
# API key основного аккаунта
API_KEY = '69eQkHl0R0vgPod21c3XjQsT'
API_SECRET = 'EFAHxtJiOVYHSWa_HPtLAW50GpV31G_2GVSdm1gBZKH85Ltv'
# Список API ключей куда нужно транслировать ордера
API_KYES = ['hLlWHxkqxs42g-WeEt1_wC20']
# THIS VERSION IS FOR PYTHON 3 #
#https://pythonprogramming.net/advanced-matplotlib-graphing-charting-tutorial/
#
import urllib.request, urllib.error, urllib.parse
import time
import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
@ekam230
ekam230 / ccxt_test.py
Created May 8, 2018 10:27
switch on testnet ccxt bitmex
if 'test' in bitmex.urls:
bitmex.urls['api'] = bitmex.urls['test'] # ←----- switch the base URL to testnet
print (bitmex.fetch_balance())
pip install https://github.com/matplotlib/mpl_finance/archive/master.zip
use with actual env pip!!!