Giter Site home page Giter Site logo

trading-bot's Introduction

Cryptocurrency Trading Bot

This bot is a work-in-progress and development can be followed on the Cryptocurrency Trading YouTube channel: https://youtube.com/cryptocurrencytrading

Part 1 and Part 2 are included in this project for future viewers of those videos, but Part 3 is where active development is happening.

Currently, only backtesting using the Poloniex API is supported, but plans for other exchanges and live trading are planned.

Backtesting can be run using the following command on Part 3: python backtest.py

trading-bot's People

Contributors

awratten avatar bwentzloff avatar kenfrost1987 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trading-bot's Issues

Unused history list of candles when running live

So, lines 53 and 64 of bot.py,
candlesticks = []
and
candlesticks.append(developingCandlestick)

Right now they doesn't serve a purpose. The code is good, has a lot of possibilities of where one would want to expand it.

I could see this being useful in a later version, possibly adding in a method (function?) in order to see what the previous candle sticks are, and then making a buy/sell with that information in mind. Much like the moving average is for the backtesting.

No trading despite what is being shown

I have some bitcoin moved to the Margin Trading section of Polo. I ran the program for 8 hours. It shows profits and losses, but there is no action on any of the coins I selected (BTC_LTC).

What would be the right way to log the activity to verify it is indeed working, and from the raw code as provided, how can I get the trades to actually start showing up?

SyntaxError: 'return' outside function

root@j314793:/trading-bot/part 3# python backtest.py
Traceback (most recent call last):
File "backtest.py", line 4, in
from botstrategy import BotStrategy
File "/root/trading-bot/part 3/botstrategy.py", line 2, in
from botindicators import BotIndicators
File "/root/trading-bot/part 3/botindicators.py", line 23
return a
SyntaxError: 'return' outside function
root@j314793:/trading-bot/part 3#

code does not work on Mac

Hi, i have tried to run the first bot but got the error bellow. When running the code on my friends linux it worked. How can this be resolved? I have tried in Python 2 and 3.

Traceback (most recent call last):
File "trading-bot.py", line 102, in
main(sys.argv[1:])
File "trading-bot.py", line 60, in main
currentValues = conn.api_query("returnTicker")
File "/Users/default/Documents/trading-bot-master/poloniex.py", line 31, in api_query
ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/public?command=' + command))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 429, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 447, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1241, in https_open
context=self._context)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1198, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)>

Backtest fail, Help

i am trying to run a backtest whit a startTime = 21/01/2018 14:00:00 (1516543200)
endTime = 21/01/2018 23:45:00 (1516578300)
on "BTC_XMR" pair on poloniex
but the price that is returned was not correct, they seems to be from another date (I Told this because the prices are too diferent).
I am using this parameters : -s 1516543200 -e 1516578300

These are the output (Partial, I remove the Entry Price: entrance to short the output):
Price: 0.01778382 Moving Average: 0.01778382
Price: 0.01779416 Moving Average: 0.017788989999999998
Price: 0.01778603 Moving Average: 0.017788003333333333
Trade opened
Price: 0.01783528 Moving Average: 0.0177998225
Trade closed
Price: 0.01778879 Moving Average: 0.017797616
Trade opened
Price: 0.01782878 Moving Average: 0.01780281
Trade closed
Price: 0.01790495 Moving Average: 0.01781740142857143
Price: 0.01790028 Moving Average: 0.01782776125
Price: 0.01799615 Moving Average: 0.01784647111111111
Price: 0.01819673 Moving Average: 0.017892349999999998
Price: 0.01826543 Moving Average: 0.017944713333333334
Price: 0.01831097 Moving Average: 0.01800304
Price: 0.0181363 Moving Average: 0.01803648666666667
Price: 0.01818053 Moving Average: 0.018080013333333332
Price: 0.01818899 Moving Average: 0.018120036666666665
Price: 0.01820367 Moving Average: 0.018153227777777777
Price: 0.01819987 Moving Average: 0.018186515555555553
Price: 0.01819146 Moving Average: 0.018208216666666666
Trade opened
Price: 0.01810712 Moving Average: 0.01819826
Price: 0.01802347 Moving Average: 0.018171375555555553
Trade closed
Price: 0.01802243 Moving Average: 0.018139315555555556
Trade opened
Price: 0.01806026 Moving Average: 0.01813086666666667
Price: 0.01809434 Moving Average: 0.018121289999999998
Price: 0.01793798 Moving Average: 0.018093399999999996
Price: 0.01789414 Moving Average: 0.018059007777777775
Trade closed
Price: 0.01796811 Moving Average: 0.018033256666666667
Trade opened
Price: 0.01796895 Moving Average: 0.018008533333333337
Price: 0.01796897 Moving Average: 0.017993183333333336
Price: 0.01782219 Moving Average: 0.01797081888888889
Trade closed
Price: 0.01793247 Moving Average: 0.017960823333333334
Trade opened
Price: 0.01791024 Moving Average: 0.017944154444444443
Price: 0.0179953 Moving Average: 0.017933149999999995
Trade closed
Price: 0.01809091 Moving Average: 0.01795014222222222
Price: 0.01805406 Moving Average: 0.017967911111111113
Price: 0.01811778 Moving Average: 0.01798454111111111
Price: 0.01818379 Moving Average: 0.018008412222222225
Price: 0.01820467 Moving Average: 0.018034601111111114
Price: 0.01818194 Moving Average: 0.018074573333333333
Price: 0.0180701 Moving Average: 0.018089865555555557
Trade opened
Price: 0.018107 Moving Average: 0.01811172777777778
Price: 0.01804641 Moving Average: 0.01811740666666667
Price: 0.01834212 Moving Average: 0.018145318888888887
Trade closed

On 21/01/2018 14:00:00 the price war arround the 0.02983 (0,0297 to 0,0300)
What I am doing wrong?

multiple pair

hello , can this bot auto tracking all btc pair and auto order for uptrend pair ? Thanks!

Ran program, wiped personal data

Ran program after "filling in all the blanks" then immediately all my personal files and downloaded software disappeared from my computer. I can get them all back off the cloud, so no worries, but any idea what I may have done wrong?

What is a numpy?

So when I go to run bot.py, live.py or backtest.py they fail at import numpy in botindicators.py.. I'm assuming that I need to have a numpy.py, But Part 3 doesn't have a numpy.py. I can get Part 3 to run when I comment out "import numpy" #import numpy.

This is what I get when "import numpy" is not commented out.
c:\Trading-Bot>python bot.py Traceback (most recent call last): File "bot.py", line 6, in <module> from botstrategy import BotStrategy File "c:\Trading-Bot\botstrategy.py", line 2, in <module> from botindicators import BotIndicators File "c:\Trading-Bot\botindicators.py", line 1, in <module> import numpy ImportError: No module named numpy

Here is what I get when I comment out "import numpy" - Side note I changed to USDT_BTC
c:\Trading-Bot>python bot.py Open: 11311.7737104 Close: None High: 11311.7737104 Low: 11311.7737104 Current: 11311.7737104 Open: 11311.7737104 Close: None High: 11324.6035649 Low: 11311.7737104 Current: 11324.6035649

Is there supposed to be a numpy.py? Also when can we expect to seen another Video/code release? I know there are other trading bots on GitHub, but I like how you are doing the guides on YouTube for your code. I'd like to stick with it.

Botchart type error

In line 22 of botchart.py I'm getting a type error saying string indices must be integers. Is this an indication that it's failing to get the data from poloniex, or could something else be causing this error?

Part3 error

Using the part 3 backtest.py this error occur any guess how to resolve this ?

File "C:\Users\rogerio.LAPTOP_ROGER\PycharmProjects\Part3_bot\botstrategy.py", line 32, in evaluatePositions
if (self.currentPrice < self.indicators.movingAverage(self.prices,15)):
TypeError: '<' not supported between instances of 'float' and 'NoneType'

Abandoned?

No more videos on this project or no updates. Abandoned?

Backtest with External Data

Hi there - Brilliant work btw - Is it possible to use the backtest ability on a separate dataset; eg, a csv of price data stored locally (pulled from separate source)?
Thanks in Advance - S

Issues with MACD and MEA functions

This one's a head scratcher for me. I'm trying to implement a MACD-based strategy in botstrategy.py, but as soon as it tries to calculate the MACD indicator I get an error in the EMA function at line 22:

a[:period] = a[period]

The error says the index is out of bounds. I don't see how that's either possible or why the breakdown would happen there, since it's the least controversial, and the maximum period is either 12 or 26. I've tried adding a tick counter so that it only fires after 26 candlesticks, but that didn't solve the problem. Any ideas as to what this error could be coming from?

Also, this is a dumb question, but I'm assuming the MACD function returns a list. Is it actually going to return a string?

HTTP 422 error

Hi,

I used your code as a basis to a trading bot I created. Everything works fine except for Buy and Sell orders. When I run the following code I get an "HTTP 422 error ":

conn = poloniex(key, secret)
conn.api_query('returnBalances') # works fine
conn.api_query('returnTicker') # works fine
conn.buy ('BTC_XMR', 0.00001,0.01) # fails and generates HTTP 422 error

Is there anything wrong with my syntax?

Thanks for your help

Indention error

I keep getting this error, even after changing the indention of all return lines to the same amount (3 indents each)
"Traceback (most recent call last):
File "C:\Users\josry\Desktop\trading bot\trading-bot-master\part 3\backtest.py", line 4, in
from botstrategy import BotStrategy
File "C:\Users\josry\Desktop\trading bot\trading-bot-master\part 3\botstrategy.py", line 2, in
from botindicators import BotIndicators
File "C:\Users\josry\Desktop\trading bot\trading-bot-master\part 3\botindicators.py", line 23
return a
^
IndentationError: unexpected indent

"

new to coding and unfortunately couldnt make it work urllib2 problem

Hi,

I copy / pasted this code but having this error.

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/berkinimamoglu/PycharmProjects/poloniex.py
Traceback (most recent call last):
File "/Users/berkinimamoglu/PycharmProjects/poloniex.py", line 4, in
import urllib2
ModuleNotFoundError: No module named 'urllib2'

Process finished with exit code 1

Can you please help me?

Backtest date

Hello, I don't understand something about the backtest dates using the BotCandleStick object.
For the backtest the startTime for your BotCandleStick should be the past date from the result of chart data request no ? but in the BotCandleStick the startTime is still time.time() weather its for backtest or live. Also if we want to plot with backtest past dates we then need another object that hold the past dates.

open trade

how do I make actual trade? on bot.py

AttributeError: 'dict' object has no attribute 'priceAverage'

im sorry but im new to this but what am i missing?

Traceback (most recent call last):
File "backtest.py", line 15, in
main(sys.argv[1:])
File "backtest.py", line 12, in main
strategy.tick(candlestick)
File "/home/pi/trading-bot/part_3/botstrategy.py", line 17, in tick
print candlestick.priceAverage
AttributeError: 'dict' object has no attribute 'priceAverage'

botIndicators.py has an unresolved reference np

this code has an unresolved reference np.

def RSI(self, prices, period=14):
deltas = np.diff(prices)
seed = deltas[:period + 1]
up = seed[seed >= 0].sum() / period
down = -seed[seed < 0].sum() / period
rs = up / down
rsi = np.zeros_like(prices)
rsi[:period] = 100. - 100. / (1. + rs)

Any guess how to resolve this?

not recognizing the poloniex.py

C:\Users\Walmart>bot.py
Traceback (most recent call last):
File "C:\Users\Walmart\bot.py", line 5, in
from botchart import BotChart
File "C:\Users\Walmart\botchart.py", line 1, in
from poloniex import poloniex
ImportError: No module named poloniex

what am I missing here, all scripts are in the same directory including poloniex.py

Running multiple currency pairs on the same exchange account

If Im understanding the code correctly, we can only run one bot per exchange account because we cant designate a budget or portion of the balance to use. In order to run multiple bots, say one for XMR and one for ETH, simultaneously we would need additional exchange accounts, correct?

The profits are the same. Always

Hello guys. When I run the bot in live mode without uncomment the lines that put the orders I observed that despite of the correct pricing values are correctly been retraived from poloniex the values of profits are are Always the same. Anymore else confirms this ?

Run sample program met 403 error.

I try to run the program on this page, but met following error:

Traceback (most recent call last):
File "p.py", line 102, in
main(sys.argv[1:])
File "p.py", line 60, in main
currentValues = conn.api_query("returnTicker")
File "/root/poloniex.py", line 36, in api_query
ret = urllib2.urlopen(urllib2.Request('https://poloniex.com/public?command=' + command))
File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib64/python2.7/urllib2.py", line 437, in open
response = meth(req, response)
File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.7/urllib2.py", line 475, in error
return self._call_chain(*args)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib64/python2.7/urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden

How can I solve this problem?

How to retrive the timestamp from poloniex ?

anyone knows how to retrieve the timestamp from poloniex of a determined day?
these numbers dosent make any sense to me : 14910480000 as startime and 1491091200 as endtime.

I want to retrieve the timestamp for any past day.
Any guess?
Thank you

Is it possible to run self.showPositions at the end?

I'd like to change how this reports instead of running showPositions every tick, run at the end of the ticks.
I tried to move this def over to main in backtest, but of course without all of its dependencies, it won't run. Seems like all of this HAS to run under botstrategy where all of the vars are at.
Im basically trying to get one final report on the trades at the end of the run.

Starting point and ending point

When I look at the code, it doesn't show me "clearly" how much I am trading per attempt. Am I trading 0.01 BTC or ??? And how would I change this? I do have an idea but would like to confirm my suspicion.

While I have the trading bot going, it would be nice to know my starting point (what I have to trade with), and at the end of the day, what were my profits.

Is there a way of knowing this? For example

Available to trade: 1.02 BTC
trade (profit: 0.001)
trade (profit: 0.00010)
...
end of day available to trade: (1.2 BTC)

Any suggestions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.