mirror of
https://git.wownero.com/lza_menace/totrader.git
synced 2024-08-15 00:33:13 +00:00
adding work thus far
This commit is contained in:
parent
c8a1900b93
commit
bc56861ca1
8 changed files with 735 additions and 1 deletions
22
README.md
22
README.md
|
@ -1,3 +1,23 @@
|
|||
# to-trade-bot
|
||||
|
||||
Makin money, ya bitch, can ya dig it?
|
||||
Makin money, ya bitch, can ya dig it?
|
||||
|
||||
From this youtube vid: https://www.youtube.com/watch?v=es9jyTTxKB4
|
||||
|
||||
1. get current price
|
||||
2. look at book and place 1 buy order directly below price and 1 sell order above price
|
||||
3. Once the buy and sell is filled, do it again
|
||||
|
||||
|
||||
### 1. Manipulations and beliefs
|
||||
|
||||
Market is not driven by price, but by belief. The market is determined by what traders believe.
|
||||
|
||||
The market is manipulated; it is a manipulative process. (Beliefs of the traders is being manipulated).
|
||||
|
||||
|
||||
3 phases of the manipulation process:
|
||||
|
||||
* Accumulation - when accumulation of buy or sell orders is taking place.
|
||||
* Manipulation - where market makers use well established practices to manipulate traders beliefs about future price.
|
||||
* Profit Release - where market makers are able to distribute the orders they accumulated in the first phase.
|
||||
|
|
64
db.py
Normal file
64
db.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
from os import getenv
|
||||
from dotenv import load_dotenv
|
||||
from peewee import *
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
load_dotenv('.env')
|
||||
|
||||
db = PostgresqlDatabase(
|
||||
'trader',
|
||||
user=getenv('DB_USER'),
|
||||
password=getenv('DB_PASS'),
|
||||
host=getenv('DB_HOST', '127.0.0.1'),
|
||||
port=getenv('DB_PORT', 5432)
|
||||
)
|
||||
|
||||
def get_time():
|
||||
now = datetime.now()
|
||||
now = now + timedelta(hours=7)
|
||||
return now
|
||||
|
||||
class Ticker(Model):
|
||||
id = AutoField()
|
||||
trade_pair = CharField()
|
||||
initial_price = DoubleField()
|
||||
current_price = DoubleField()
|
||||
high_price = DoubleField()
|
||||
low_price = DoubleField()
|
||||
volume = DoubleField()
|
||||
bid = DoubleField()
|
||||
ask = DoubleField()
|
||||
spread_btc = DoubleField()
|
||||
spread_sats = IntegerField()
|
||||
spread_perc = DoubleField()
|
||||
date = DateTimeField(default=get_time)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
|
||||
class Balance(Model):
|
||||
total = DoubleField()
|
||||
available = DoubleField()
|
||||
currency = CharField()
|
||||
date = DateTimeField(default=get_time)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
|
||||
# class Trade(Model):
|
||||
# id = AutoField()
|
||||
# title = CharField()
|
||||
# text = CharField()
|
||||
# submitter = CharField()
|
||||
# image_name = CharField()
|
||||
# readonly = BooleanField(default=False)
|
||||
# hidden = BooleanField(default=False)
|
||||
# account_index = DoubleField()
|
||||
# address_index = DoubleField()
|
||||
# timestamp = DateTimeField(default=datetime.now)
|
||||
#
|
||||
# class Meta:
|
||||
# database = db
|
||||
|
||||
db.create_tables([Ticker, Balance])
|
33
docker-compose.yaml
Normal file
33
docker-compose.yaml
Normal file
|
@ -0,0 +1,33 @@
|
|||
version: '3'
|
||||
volumes:
|
||||
grafana:
|
||||
postgres:
|
||||
services:
|
||||
grafana:
|
||||
image: grafana/grafana:6.5.0
|
||||
container_name: trader_grafana
|
||||
ports:
|
||||
- 127.0.0.1:3000:3000
|
||||
environment:
|
||||
HOSTNAME: grafana
|
||||
GF_SECURITY_ADMIN_USER: admin
|
||||
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}
|
||||
GF_SERVER_ROOT_URL: ${GRAFANA_URL}
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
GF_USERS_ALLOW_ORG_CREATE: "false"
|
||||
GF_LOG_LEVEL: "debug"
|
||||
volumes:
|
||||
- grafana:/var/lib/grafana
|
||||
postgres:
|
||||
image: postgres:9.6.15-alpine
|
||||
container_name: trader_postgres
|
||||
ports:
|
||||
- 5432:5432
|
||||
environment:
|
||||
POSTGRES_PASSWORD: ${DB_PASS}
|
||||
POSTGRES_USER: ${DB_USER}
|
||||
POSTGRES_DB: ${DB_NAME}
|
||||
volumes:
|
||||
- postgres:/var/lib/postgresql/data
|
506
grafana/daemon_metrics.json
Normal file
506
grafana/daemon_metrics.json
Normal file
|
@ -0,0 +1,506 @@
|
|||
{
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": "-- Grafana --",
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"id": 1,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": null,
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 9,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 4,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "connected",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg(monerod_connections_incoming)",
|
||||
"legendFormat": "Incoming",
|
||||
"refId": "A"
|
||||
},
|
||||
{
|
||||
"expr": "avg(monerod_connections_outgoing)",
|
||||
"legendFormat": "Outgoing",
|
||||
"refId": "B"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Connections",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"decimals": null,
|
||||
"format": "none",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": "0",
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": null,
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 9,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 2,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": false,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "connected",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [
|
||||
{
|
||||
"alias": "/.*/",
|
||||
"color": "#C4162A"
|
||||
}
|
||||
],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": true,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg(monerod_block_difficulty)",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Difficulty",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "none",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": null,
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 9
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 8,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": false,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "connected",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [
|
||||
{
|
||||
"alias": "/.*/",
|
||||
"color": "#FA6400"
|
||||
}
|
||||
],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg(monerod_block_reward)",
|
||||
"legendFormat": "Block Reward (WOW)",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Block Reward (WOW)",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"decimals": null,
|
||||
"format": "none",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": false
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": null,
|
||||
"fill": 1,
|
||||
"fillGradient": 0,
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 9
|
||||
},
|
||||
"hiddenSeries": false,
|
||||
"id": 6,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": false,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"nullPointMode": "connected",
|
||||
"options": {
|
||||
"dataLinks": []
|
||||
},
|
||||
"percentage": false,
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [
|
||||
{
|
||||
"alias": "/.*/",
|
||||
"color": "#8F3BB8"
|
||||
}
|
||||
],
|
||||
"spaceLength": 10,
|
||||
"stack": false,
|
||||
"steppedLine": true,
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg(monerod_tx_mempool)",
|
||||
"legendFormat": "Pool Transactions",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeRegions": [],
|
||||
"timeShift": null,
|
||||
"title": "Mempool Transactions",
|
||||
"tooltip": {
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
],
|
||||
"yaxis": {
|
||||
"align": false,
|
||||
"alignLevel": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"cacheTimeout": null,
|
||||
"colorBackground": false,
|
||||
"colorPostfix": false,
|
||||
"colorPrefix": false,
|
||||
"colorValue": false,
|
||||
"colors": [
|
||||
"#299c46",
|
||||
"rgba(237, 129, 40, 0.89)",
|
||||
"#d44a3a"
|
||||
],
|
||||
"datasource": null,
|
||||
"format": "none",
|
||||
"gauge": {
|
||||
"maxValue": 100,
|
||||
"minValue": 0,
|
||||
"show": false,
|
||||
"thresholdLabels": false,
|
||||
"thresholdMarkers": true
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 5,
|
||||
"w": 8,
|
||||
"x": 8,
|
||||
"y": 17
|
||||
},
|
||||
"id": 10,
|
||||
"interval": null,
|
||||
"links": [],
|
||||
"mappingType": 1,
|
||||
"mappingTypes": [
|
||||
{
|
||||
"name": "value to text",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"name": "range to text",
|
||||
"value": 2
|
||||
}
|
||||
],
|
||||
"maxDataPoints": 100,
|
||||
"nullPointMode": "connected",
|
||||
"nullText": null,
|
||||
"options": {},
|
||||
"postfix": "",
|
||||
"postfixFontSize": "50%",
|
||||
"prefix": "",
|
||||
"prefixFontSize": "50%",
|
||||
"rangeMaps": [
|
||||
{
|
||||
"from": "null",
|
||||
"text": "N/A",
|
||||
"to": "null"
|
||||
}
|
||||
],
|
||||
"sparkline": {
|
||||
"fillColor": "rgba(31, 118, 189, 0.18)",
|
||||
"full": false,
|
||||
"lineColor": "rgb(31, 120, 193)",
|
||||
"show": false,
|
||||
"ymax": null,
|
||||
"ymin": null
|
||||
},
|
||||
"tableColumn": "",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "avg(monerod_tx_chain)",
|
||||
"instant": true,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": "",
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Total Transactions",
|
||||
"type": "singlestat",
|
||||
"valueFontSize": "100%",
|
||||
"valueMaps": [
|
||||
{
|
||||
"op": "=",
|
||||
"text": "N/A",
|
||||
"value": "null"
|
||||
}
|
||||
],
|
||||
"valueName": "current"
|
||||
}
|
||||
],
|
||||
"refresh": "30s",
|
||||
"schemaVersion": 21,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": [
|
||||
"5s",
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
]
|
||||
},
|
||||
"timezone": "",
|
||||
"title": "Daemon Stats",
|
||||
"uid": "0ktA4KDGk",
|
||||
"version": 2
|
||||
}
|
13
grafana/dashboards.yaml
Normal file
13
grafana/dashboards.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: 'default'
|
||||
orgId: 1
|
||||
folder: ''
|
||||
type: file
|
||||
disableDeletion: true
|
||||
editable: true
|
||||
updateIntervalSeconds: 60
|
||||
allowUiUpdates: true
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
9
grafana/prometheus.yaml
Normal file
9
grafana/prometheus.yaml
Normal file
|
@ -0,0 +1,9 @@
|
|||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: PostgreSQL
|
||||
type: postgresql
|
||||
url: http://prometheus:9090
|
||||
access: proxy
|
||||
isDefault: true
|
||||
timeInterval: 10s
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
requests
|
||||
peewee
|
||||
psycopg2-binary
|
86
trade.py
Executable file
86
trade.py
Executable file
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from os import getenv
|
||||
from dotenv import load_dotenv
|
||||
from requests import get as requests_get
|
||||
from requests import post as requests_post
|
||||
from requests.auth import HTTPBasicAuth
|
||||
from decimal import Decimal
|
||||
from pprint import pprint
|
||||
from time import sleep
|
||||
from db import Ticker, Balance
|
||||
|
||||
|
||||
class TradeOgre(object):
|
||||
def __init__(self):
|
||||
load_dotenv('.env')
|
||||
self.base = 'https://tradeogre.com/api/v1'
|
||||
self.auth = HTTPBasicAuth(
|
||||
getenv('TO_USER'),
|
||||
getenv('TO_PASS')
|
||||
)
|
||||
|
||||
def req(self, route, method='get', data={}):
|
||||
url = self.base + route
|
||||
if method == 'get':
|
||||
r = requests_get(url, auth=self.auth)
|
||||
else:
|
||||
r = requests_post(url, auth=self.auth, data=data)
|
||||
return r.json()
|
||||
|
||||
def get_trade_pair(self, pair):
|
||||
route = f'/ticker/{pair}'
|
||||
return self.req(route)
|
||||
|
||||
def get_balance(self, currency):
|
||||
route = '/account/balance'
|
||||
return self.req(route, 'post', {'currency': currency})
|
||||
|
||||
def get_balances(self):
|
||||
route = '/account/balances'
|
||||
return self.req(route)
|
||||
|
||||
|
||||
def run():
|
||||
# define vars
|
||||
to = TradeOgre()
|
||||
base = 'BTC'
|
||||
currency = 'WOW'
|
||||
trade_pair = f'{base}-{currency}'
|
||||
|
||||
# ticker market data
|
||||
tp_res = to.get_trade_pair(trade_pair)
|
||||
print(tp_res)
|
||||
spreat_btc = Decimal(tp_res['ask']) - Decimal(tp_res['bid'])
|
||||
spread_sats = float(spreat_btc / Decimal(.00000001))
|
||||
spread_perc = (spreat_btc / Decimal(tp_res['ask'])) * 100
|
||||
t = Ticker(
|
||||
trade_pair=trade_pair,
|
||||
initial_price=tp_res['initialprice'],
|
||||
current_price=tp_res['price'],
|
||||
high_price=tp_res['high'],
|
||||
low_price=tp_res['low'],
|
||||
volume=tp_res['volume'],
|
||||
bid=tp_res['bid'],
|
||||
ask=tp_res['ask'],
|
||||
spread_btc=spreat_btc,
|
||||
spread_sats=spread_sats,
|
||||
spread_perc=spread_perc
|
||||
)
|
||||
t.save()
|
||||
|
||||
for c in base, currency:
|
||||
gb_res = to.get_balance(c)
|
||||
print(gb_res)
|
||||
b = Balance(
|
||||
currency=c,
|
||||
total=gb_res['balance'],
|
||||
available=gb_res['available']
|
||||
)
|
||||
b.save()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
while True:
|
||||
run()
|
||||
sleep(30)
|
Loading…
Reference in a new issue