Tag Archives: Python

unknown crypto currency error: Send order to Binance exchange with Python CCXT package 

Sending order to Binance exchange with Python CCXT package

To enable API, you login to follow these instructions  but understand working with unknown code from Binance crypto currency exchange. Realize that this is not an easy process like Coinbase. This is confirmation is not as slick as other brokers/exchanges I have worked with.

https://support.coinigy.com/hc/en-us/articles/360001144614-How-do-I-find-my-API-key-on-Binance-com-

https://support.binance.com/hc/en-us/articles/115000840592-Binance-API-Beta

Also for CCXT Python package, use this source code example

https://github.com/ccxt/ccxt/issues/2552

When I run this sample with test enabled, I get this return code:

{‘info’: {}, ‘id’: None, ‘timestamp’: None, ‘datetime’: None, ‘lastTradeTimestamp’: None, ‘symbol’: None, ‘type’: None, ‘side’: None, ‘price’: None, ‘amount’: None, ‘cost’: None, ‘filled’: 0.0, ‘remaining’: None, ‘status’: None, ‘fee’: None}

Confirmed Binance login

Do understand this account is unfunded so it does confirm to work when you enter the correct API and secret keys. If the secret or API keys were incorrect, you will get this exceptions:

File “/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ccxt/binance.py”, line 834, in handle_errors
raise ExchangeError(self.id + ‘: unknown error code: ‘ + body + ‘ ‘ + error)
ccxt.base.errors.ExchangeError: binance: unknown error code: {“code”:-1022,”msg”:”Signature for this request is not valid.”} -1022

In the Trenches with Crypto Currencies video replay

Here is an ongoing dialogue with my most helpful dialogue PRIVATE Telegram group:

for anyone with Binance API experience. I am using this example with binance for CCXT https://github.com/ccxt/ccxt/issues/2552

Some coding examples

It seems to login ok with the proper API keys. I test a fake one which resulted as an error as expected. When I try set up these coding parameters with:

symbol = ‘XZC/BNB’

#symbol = ‘BCH/BNB’

type = ‘limit’ # or ‘market’

side = ‘buy’ # or ‘buy’

amount = 1.0

price = 1.302 #0.060154 # or None

# extra params and overrides if needed

params = {

‘test’: True, # test if it’s valid, but don’t actually place it

}

order = exchange.create_order(symbol, ‘limit’, side, amount, price, params)

It results in which is nothing:

{‘info’: {}, ‘id’: None, ‘timestamp’: None, ‘datetime’: None, ‘lastTradeTimestamp’: None, ‘symbol’: None, ‘type’: None, ‘side’: None, ‘price’: None, ‘amount’: None, ‘cost’: None, ‘filled’: 0.0, ‘remaining’: None, ‘status’: None, ‘fee’: None}

My test account has a Bitcoin balance of 0.00176200. Do I need to choose another pair with a lower value? Do I need to only use a crypto currency pair with BTC not BNB?

Thanks

also, i tried this code:

symbol = ‘XLM/BTC’

#symbol = ‘XZC/BNB’

#symbol = ‘BCH/BNB’

type = ‘limit’ # or ‘market’

side = ‘buy’ # or ‘buy’

amount = 1.0

#price = 1.302 #0.060154 # or None

price =0.00003550

but now get response of: ccxt.base.errors.InvalidOrder: binance {“code”:-1013,”msg”:”Filter failure: MIN_NOTIONAL”}

any pointers?

—–

MIN_NOTIONAL hints at your account not having enough capital/margin for the transaction. Have you verified this?

I’d suggest you try a transaction with an amount of 0.01 or something like that ← tried this but it did not correct the problem

For the currency question based on the pair:

Yes, in this case you need BNB in order to convert it to XZC. So you would first have to convert your BTC to BNB using the BNB/BTC pair.

…Yes, it sounds like you’re hitting a minimum order size restriction. Don’t forget that order sizes are denominated in the base currency of the pair (XLM in this case). One XLM is only worth 27c, so try increasing the order size to 10, or 50 or something like that.

It looks the like the minimum order size on Binance is 0.002 BTC, so try an order size greater than 55 or 60.

Source code updates compared to a few weeks

I also got this CCXT exception:

ccxt.base.errors.ExchangeNotAvailable: binance POST https://www.binance.com/api/v1/order 400 Bad Request {“code”:-1104,”msg”:”Not all sent parameters were read; read ‘8’ parameter(s) but was sent ‘9’.”}

But here is the latest source code sample:

import ccxt

exchange = ccxt.binance({

‘apiKey’: , ## these appear to work with valid keys

‘secret’: ,

‘enableRateLimit’: True,

})

symbol = ‘XLM/BTC’

#symbol = ‘XZC/BNB’

#symbol = ‘BCH/BNB’

typ = ‘limit’ # or ‘market’

side = ‘buy’ # or ‘buy’

amount = 55 #1.0 tried 0.1 but not balid

#price = 1.302 #0.060154 # or None

price =0.00003550

# extra params and overrides if needed

#removed because of this exception

#ccxt.base.errors.ExchangeNotAvailable: binance POST https://www.binance.com/api/v1/order 400 Bad Request {“code”:-1104,”msg”:”Not all sent parameters were read; read ‘8’ parameter(s) but was sent ‘9’.”}

# File “testBinanceOrder.py”, line 26, in <module>

# order = exchange.create_order(symbol, ‘limit’, side, amount, price, params)

# NameError: name ‘params’ is not defined

params = {

‘test’: True # test if it’s valid, but don’t actually place it

}

order = exchange.create_order(symbol, typ, side, amount, price, params)

print(order)

note the new exception of Not all sent parameters were read; read ‘8’ parameter(s) but was sent ‘9’.”

i am sending a total of 9 of but what am I supposed to eliminate? i tired the extra params but that did not help

I finally got something working with this https://github.com/ccxt/ccxt/issues/298

Can you post verbose output for it?

Try a minimal example:

import ccxt
binance = ccxt.binance({
    "apiKey": "YOUR_KEY",
    "secret": "YOUR_SECRET",
    "verbose": True,
})
print(binance.create_market_sell_order('BTC/USDT', 0.00711675))


This also seems to work fine as well:

#print(binance.create_market_sell_order(‘BTC/USDT’, 0.0001))
print(binance.create_market_buy_order(‘BTC/USDT’, 0.00001))

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Anyone ever use Quant Rocket? Support Python and Interactive Brokers 

 

I find these solutions and platforms can be useless compared to coding your own. If you roll your own, you will be able to define and control your own trading techniques. You will understand them better so don’t be lazy. This does support Python though.

I am still hearing about those use this QuantRocket or something similar?

https://www.quantrocket.com

 

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Overview of backtrader with Python 3 for a complete algo trading system

There are numerous part of this video but I try to explain how to install backtrader which I got running on Python.This can also be used in conjunction to build a out a complete algo trading system.  This project clearly is growing quickly to replace Quantopian and maybe Quantstart. It is 100% in Python with some great example Quick Start guides to get you up and running. I am sure the community is up to par by now.

Oanda? Really so here is why ?

Also, I explain how I may go back to Oanda( ugh and yuck) as a quick and easy gateway for forex or CFD trading. This  project will ease the intro to a forex algo trading system with 100% Python without the complex extra process of including Java with the JForex platform from Dukascopy. Also, it seems American residents really only have Oanda as the only remaining choice to use Python. It sucks I know but this includes the huge market interest for using the 100% Python option for an algo trading system. Just remember Dukascopy does not allow USA customers so I can only use Oanda for now. My opinions of Oanda has not changed. I just wish there was a better option to implement.

Also, the Python backtrader project support Oanda and my eventual migration to Interactive Brokers for eventual options/futures. Always remember this asset class is used by institutions and is recession proof as well.

Spoiler alert

To save you time, I also tried to install a GUI project built for backtrader called Omega UI.

https://github.com/OmegaTrading/OmegaUI

Most of the video focuses on this attempt but this project clearly needs a tutorial or document to get it running. This portion was a chunk of time wasted so don’t bother.

Note: I plan to only use backtrader for the broker connection only as explained above. I don’t plan to change the strategies I have been working over the last number of months

I will be adding the productive learning to my course as explained below

New course!! Building Python algo trading system with Bitcoin an crypto currency focus

Links

https://www.backtrader.com/docu/quickstart/quickstart.html?highlight=optimize

https://github.com/OmegaTrading/OmegaUI

https://www.backtrader.com/features

https://github.com/backtrader/backtrader

https://stackoverflow.com/questions/3387695/add-to-python-path-mac-os-x

https://superuser.com/questions/273966/how-can-i-uninstall-using-homebrew

https://marketing.plot.ly/products/cloud/

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Most reliable candlestick patterns with TA-Lib Python demo

Most reliable candlestick patterns with TA-Lib Python demo

As continuation with the 2 patterns I mentioned earlier which include Marubozu line and others listed below.

Here are the links from my video

https://mrjbq7.github.io/ta-lib/func_groups/pattern_recognition.html

http://thepatternsite.com/BlackMarubozu.html

http://thepatternsite.com/RickshawMan.html

Market reversal with Marubozu Line and Adam and Eve

Reliable candlestick patterns for TA-Lib pattern recognition acts as a bullish reversal

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Is this Python code of linear regression really machine learning

Is this Python code of linear regression really machine learning? Seriously, why do less knowledgable people just rely on the result of some popular machine learning framework like TensorFlow. Don’t you think it is wise to understand the underlying math? I have used this stuff with MATLAB well before the terms big data and machine learning  became popular. I am no expert here but I would like to have some experts add their opinion on it.

Looking for input

Comment away in my video where I am wrong. I like to learn what you think. All I ask is be respectful about it

Robert Pardo book for forward walking

https://onlinelibrary.wiley.com/doi/book/10.1002/9781119196969

https://en.wikipedia.org/wiki/Linear_function

TensorFlow and Nutonian machine learning for algo trading tips

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Lessons learned about CCXT Python package for 3 largest crypto exchanges Bitmex binance OKex

Lessons learned about CCXT Python package for 3 largest crypto exchanges Bitmex Binance OKex

Please be advised

Using CCXT with a recent script I sourced to download generically from various exchanges is powerful. I have thought come across some severe limitations in the process.

  1. Binance appears to be the most reliable since you have the widest selection of timeframes you can use. Also, you can download up to 1000 rows into a comma separated value file as well.
  2. Both Bitmex and OKEx offer some form downloading limit of 500 which really messes up my analytical Python script. When downloading, you can only seem to have a limit of 400 to just under 500. This seems to work only work for lower time frames like 1 or 5 minutes. As the timeframe selection is very limited compared to Binance.

I am unsure of other crypto currency exchanges what limitations offer but I will stick with Binance for now as the only exchange of interest. It seems that the others offer much lower daily volume which means slower fills due to lower liquidity.  Also the other exchanges have weird download exceptions which also means the charting will not work as well.

 

Further note about Bitfinix

I just execute 5 request no different than Binance, Bitfinex starts thinking it is being attacked where it responds:

ccxt.base.errors.DDoSProtection: bitfinex {“error”:”ERR_RATE_LIMIT”}

Pretty pathetic architecture if you ask me.

In summary, it just seems that Binance works out of box for both downloading and charting.

 

Update: Which Bitcoin crypto currency bot project? Gekko vs ccxt vs Tribeca vs Blackbird

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Corrected video Demo to download 525 crypto currency pairs via CCXT Python package from OKEx

This all comes from this video posted here

Double your trading opportunity just from 1 correction !

I have corrected this big as hinted in this Youtube content listed below. . Please find I am now able to double my opportunity of trades just from this simple correction. This goes in hand with my evolving Automated Head and Shoulder indicator. 

As compared to a recent post, I am now able to analyze over 525 symbols vs 200+ as in the previous.

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Demo to download hundreds of crypto currency pairs via CCXT Python package from Binance Bitmex

 

 

The advantages

This has a huge benefit if you are into building scanners for crypto currency. Also, remember I did not fund any of these exchanges but always remember to be on guard with your data with exchanges you may not trust. This will help in my automated head and shoulders demo I will have tomorrow night. Get details below.

Video here:

https://www.youtube.com/watch?v=Mf76ZVKsX8I&t=545s

Demo to download hundreds of crypto currency pairs via CCXT Python package from Binance Bitmex OKEx exchanges

Get the original script here

Questions and Answers on automated head and shoulders with CCXT Python crypto currency

Here are the links and questions/comments including my popular automated head and shoulders

Links

https://quantlabs.net/blog/2018/05/questions-and-answers-on-automated-head-and-shoulders-with-ccxt-python-crypto-currency/

 

Sample questions

Questions and Answers

I would like to do algo trading in india for nse exchange using zerodha kite connect api, is it possible to do using jstock, as i see only analysis is done but to buy or sell

in an automated way for nse exchanges is it possible or can you recommend some opensource software for this algo trading, i am a good programmer can do coding in

any language.

Thanks,

Shailes

More here

https://quantlabs.net/blog/2018/05/questions-and-answers-on-automated-head-and-shoulders-with-ccxt-python-crypto-currency/

https://www.youtube.com/watch?v=MDBOqkz3ZQs

Automated head and shoulders webinar on tomorrow night

 

Details here

Hi there,

You are invited to a Zoom webinar.
When: May 23, 2018 7:00 AM Eastern Time (US and Canada)
Topic: Automated head and shoulders webinar demo

Please click the link below to join the webinar:
https://zoom.us/j/255491924

Or iPhone one-tap :
US: +16465588656,,255491924# or +16699006833,,255491924#
Or Telephone:
Dial(for higher quality, dial a number based on your current location):
US: +1 646 558 8656 or +1 669 900 6833
Webinar ID: 255 491 924
International numbers available: https://zoom.us/u/fnY7djwr

Automated head and shoulders indicator webinar for May 23 at 7 PM EDT

Demo of automated head and shoulders with XRB BTC hourly crypto currency data from Binance

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Demo to download hundreds of crypto currency pairs via CCXT Python package from Binance Bitmex OKEx exchanges

Demo to download hundreds of crypto currency pairs via CCXT Python package from Binance Bitmex OKEx exchanges

 

The advantages

This has a huge benefit if you are into building scanners. Also, remember I did not fund any of these exchanges but always remember to be on guard with your data with exchanges you may not trust.

https://coinmarketcap.com

Original Python downloading script from

Easy Python script to download crypto currency market data with CCXT package

 

 

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Questions and Answers on automated head and shoulders with CCXT Python crypto currency 

 

Here are the links and questions/comments including my popular automated head and shoulders

Links

https://www.interactivebrokers.co.in/en/index.php?f=2222&exch=nse

https://github.com/ccxt/ccxt/tree/master/python

New course!! Building Python algo trading system with Bitcoin an crypto currency focus

 

Shopping Cart

Questions and Answers

I would like to do algo trading in india for nse exchange using zerodha kite connect api, is it possible to do using jstock, as i see only analysis is done but to buy or sell

in an automated way for nse exchanges is it possible or can you recommend some opensource software for this algo trading, i am a good programmer can do coding in

any language.

Thanks,

Shailes

Hi,

A friend refer me to your site.
I’m on the way researching some way could we adapt in binary options trading with consistant result. Just ask if something of your works could help me with that?

I’m reading from you now.

Thanks  Anh Vu

I want to mention – that i for sure like your “style” of email communication. I’m not rich with eloquent english, and in simple words – not formal (straight, strict), cosy (comfy), unusual in a good way for me. As the result – i am not just reading all content of your emails, i also answer or even go to the survey page ))

And i hope that your are real, not some advanced AI/ML tech, which were made at Quantlabs )))

I cant see the results, at least the new one – latest is in youtube format , dated 12 apr )

Yuri

Video


How to install open source ccxt Python package for your crypto currency or Bitcoin custom bot

How do you create a strategy?

 

Automated Head and Shoulder

Au
Demo of automated head and shoulders with XRB BTC hourly crypto currency data from Binance
Wayne Filkins

I have a pattern kind of like head and shoulders but not commonly known which I use to trade by hand. I have tried to automate it using Gekko and tradingview, and Gekko kept bugging out, and it works on tradingview but I use a chrome plugin called autoview to automate it and that bugs out as bad as gekko. It just randomly doesn’t trade sometimes or just messes up a lot. Could you possibly do a video on how to automate our own pattern using ccxt?


How to create a Microsoft Word document from Python 3


brian ciocca

This only contains audio. Video is a still frame

 

Bryan , let me tell a few words about my aims at the moment.

Specializing in IT security with 5+ years in web development experience, having a strong computer background i’ve been recently asked by my boss to dig into trading strategies implementations and backtesting ( the man who worked on that – left our company).

I can refuse him with no consequences on salary , etc… and we all do what we want to do, so i have and interest for trading and markets, got little basic self education in this area, improved finance and economy english words knowledge. I was fine with switching to trading strategy analysis… cause its also includes programming.

We have a little fund, and we rely on trend following in common. So the legacy i got from the man who worked and was kinda experienced in the field are Wealth-Lab and few strategies.

CSI UA is for futures historical data, and as i know yahoo is for stocks. Daily trading – meaning that we rely on the data for the day, not intraday…

Our trader guy is follow this strategies and manually make all trades. Portfolio – is futures and CFD’s .

So i started to go deeper only few weeks ago, looked at wealth lab scripts which is in C# which i consider good language, and my fav is Python )

And these scripts appears to be a mess… it’s really f-ud up for me as a programmer)

So me research into this area showed that first of all – the Wealth Lab “for loop” approach while testing strategy is have far more cons than pros. Event-driven model is far more real, and convenient.

Starting from this post

http://www.followingthetrend.com/2014/05/why-i-prefer-rightedge-for-strategy-modeling/

made by Andreas Clenow, later he became my “mentor” in this area, i like his approach, found his articles or posts in a lots of places, he is likes or loves coding, RightEdge uses C#, but he also improves himself at Python and lots of programming stuff.

I also discovered https://www.quantconnect.com/ , quantopian – more as a knowledge base platforms, than actual trading or backtesting.

Took a look at software analogues of WealthLab  (which for me was a bit of fail) , i stopped at RightEdge which is relatively cheap, and has a real full blown C# support (i think they us GUI parts from Visual Studio), the other choice i may ask for could be OpenQuant 2014, but it’s 10 times more expensive ) about 4K $ per year… I think for starting and for moving from shitty WealthLab – RightEdge is right )

Then the common strategy principles are pretty simple – few price channel indicators, and ATR. So as i understood thats called volatility breakout, or pricechannel breakout strategies.

It was added with some additional logic by the guy before, and cause of his shitty code i hardly grasp it yet…

That`s called systematic trading ? for sure not algotrading….

Getting deeper into topic i met few researches, one was huge  –  that statistically tech analysis tools (trend following ) even with proper backtesting, etc in our times… have no evidence as profitable (and yes i know thats a strategy for at least 3 years to wait ).

Compared to this recent strategies which are based on tech analysis plus AI/ML (based on some fundamental data and tech data as i recall) were statistically significant.

summary of all long text:

now i have just basic understanding of implementing trading strategy and backtesting it, appeared there are much much more specifics are need to be done (like proper risk management), and i moving that way slowly, but deeply )

In the nearest future i think we should implement automatic algotrading (at least on some part of equity and instruments), and then for sure i see positive side to use AI/ML and fundamental data in complex approach…

Now i have a lot of beginners questions… as for python, statistics, probability theory, patterns – i would like to join your lecture/lesson – depends on a local time. I will check!

Well, much obliged for reading this far )))

anyway will be in touch, its morning already here )))

Yuri

——

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!