Tag Archives: package

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!

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

http://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

http://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!

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

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

Here is a FREE fast tutorial

This is a quick and dirty script to show you how to download crypto currency market data from Binance and Bittrex! This works with no fund nor registration on the exchange!

 

Download Cryptocurrency Data with CCXT

Algo trading with forex and crypto currency using Python

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!

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

How to install open source ccxt Python package for your crypto currency or Bitcoin custom bot
Here are the links used in this 5 minute video
https://github.com/ccxt/ccxt/tree/master/python/ccxt
https://www.youtube.com/user/quantlabs/search?query=ccxt
YouTube Preview Image
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 of FXCM Python package for forex trading

Demo of FXCM Python package for forex trading

Note that FXCM does not take US customers

Try connecting by installing:

https://www.fxcm.com/uk/algorithmic-trading/forex-python/

GitHub report for fxcmpy package https://github.com/fxcm/fxcmpy

usage instructions

http://fxcmpy.tpq.io/01_connecting.html

http://fxcmpy.tpq.io/03_streaming_market_data.html

http://fxcmpy.tpq.io/05_market_orders.html

http://fxcmpy.tpq.io/06_entry_orders.html

Do note that this info will be made available for my latest Python 3 algo trading course

Free video course on Automated Trading with Forex and Bitcoin crypto currency bot

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!

dot net framework array to r program code through the R CSharp package

Note: I really no longer support dot net framework array to r anymore. This means that I don’t support .NET nor Microsoft nor Windows anymore due to  back door security concerns I have with their product. I would strongly Python and other open source technologies over Microsoft product Also, this R posting is here as a courtesy due to R is still popular. Also remember this link recommended from my Academy section is from 2012 so it might no longer work.

Very Nice! My C# program calls R Code through the R.NET package. 

How to get R connect to NOSQL scalable database Redis with doRedis R package for parallelization

Whoa! I finally got this working with R.NET. I can get my C# appliction call directly R code which is very nice. There is a nasty bug on the search path of R so note at the beginning of the code as well. Get more info about R.Net package from http://rdotnet.codeplex.com/. Here is the C# code but don’t foret to add the.NET.DLL DLL reference in your Visual Studio:

Enjoy this C Sharp code

using System;
using System.Linq;
using RDotNet;

class Program
{
    static void Main(string[] args)
    {
        //code solution from http://stackoverflow.com/questions/7960738/importing-mgcv-fails-because-rlapack-dll-cannot-be-found
        string rhome = System.Environment.GetEnvironmentVariable(“R_HOME”);
        if (string.IsNullOrEmpty(rhome))
            rhome = @”C:Program FilesRR-2.15.0″;

        System.Environment.SetEnvironmentVariable(“R_HOME”, rhome);
        System.Environment.SetEnvironmentVariable(“PATH”, System.Environment.GetEnvironmentVariable(“PATH”) + “;” + rhome + @”bini386″);

        // Set the folder in which R.dll locates.
        //REngine.SetDllDirectory(@”C:Program FilesRR-2.12.0bini386″);
        REngine.SetDllDirectory(@”C:Program FilesRR-2.15.0bini386″);
        using (REngine engine = REngine.CreateInstance(“RDotNet”, new[] { “-q” }))  // quiet mode
        {
            foreach (string path in engine.EagerEvaluate(“.libPaths()”).AsCharacter())
            {
               Console.WriteLine(path);
            }
            //engine.EagerEvaluate(“.libPaths(“C:/Program Files/R/R-2.15.0/library”);

            // .NET Framework array to R vector.
            NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 });
            engine.SetSymbol(“group1”, group1);
            // Direct parsing from R script.
            NumericVector group2 = engine.EagerEvaluate(“group2 <- c(29.89, 29.93, 29.72, 29.98, 30.02, 29.98)”).AsNumeric();

            // Test difference of mean and get the P-value.
            GenericVector testResult = engine.EagerEvaluate(“t.test(group1, group2)”).AsList();
            double p = testResult[“p.value”].AsNumeric().First();

            Console.WriteLine(“Group1: [{0}]”, string.Join(“, “, group1));
            Console.WriteLine(“Group2: [{0}]”, string.Join(“, “, group2));
            Console.WriteLine(“P-value = {0:0.000}”, p);
        }
    }
}

 

Here is an C# example:

using System;
using System.Linq;
using RDotNet;

class Program
{
    static void Main(string[] args)
    {
        //code solution from http://stackoverflow.com/questions/7960738/importing-mgcv-fails-because-rlapack-dll-cannot-be-found
        string rhome = System.Environment.GetEnvironmentVariable(“R_HOME”);
        if (string.IsNullOrEmpty(rhome))
            rhome = @”C:Program FilesRR-2.15.0″;

        System.Environment.SetEnvironmentVariable(“R_HOME”, rhome);
        System.Environment.SetEnvironmentVariable(“PATH”, System.Environment.GetEnvironmentVariable(“PATH”) + “;” + rhome + @”bini386″);

        // Set the folder in which R.dll locates.
        //REngine.SetDllDirectory(@”C:Program FilesRR-2.12.0bini386″);
        REngine.SetDllDirectory(@”C:Program FilesRR-2.15.0bini386″);
        using (REngine engine = REngine.CreateInstance(“RDotNet”, new[] { “-q” }))  // quiet mode
        {
            foreach (string path in engine.EagerEvaluate(“.libPaths()”).AsCharacter())
            {
               Console.WriteLine(path);
            }
            engine.EagerEvaluate(“.libPaths(“C:/Program Files/R/R-2.15.0/library”);

            // .NET Framework array to R vector.
            //NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 });
            //engine.SetSymbol(“group1”, group1);
            //// Direct parsing from R script.
            //NumericVector group2 = engine.EagerEvaluate(“group2 <- c(29.89, 29.93, 29.72, 29.98, 30.02, 29.98)”).AsNumeric();

            //// Test difference of mean and get the P-value.
            //GenericVector testResult = engine.EagerEvaluate(“t.test(group1, group2)”).AsList();
            //double p = testResult[“p.value”].AsNumeric().First();

            //Console.WriteLine(“Group1: [{0}]”, string.Join(“, “, group1));
            //Console.WriteLine(“Group2: [{0}]”, string.Join(“, “, group2));
            //Console.WriteLine(“P-value = {0:0.000}”, p);

            //example to call complete R script from http://rdotnet.codeplex.com/discussions/262426
            //REngine R = REngine.GetInstanceFromID(“RDotNet”);
            //R.EagerEvaluate(“source(“MyRscript.r”)”);
            engine.EagerEvaluate(“source(“test.r”)”);
            Console.ReadLine();
        }
    }
}

Here is R script test.r which resides in the same Release directory as the C# program.

G<-c(1,2,3)
G
cat(‘hello from r’, G)

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!

How to get R connect to NOSQL scalable database Redis with Rstats package for parallelization

Who knew Rstats was popular still ?

Note that this is an article open available found on my Academy section of the site here:

How to get R connect to NOSQL scalable database Redis with doRedis R package for parallelization

How to get R connect to NOSQL scalable database Redis with doRedis R package for parallelization

Do note the links below that helped me accomplish this:
Discussion on various NOSQL databases including Redis:

http://stackoverflow.com/questions/4720508/redis-couchdb-or-cassandra

https://github.com/causes/redis-centos/blob/master/README.markdown

As said in my video, follow the downloaded packages INSTALL readme guide. You need to make to build from the source of Redis. It ain’t that bad.
For doRedis R package video demo and instructions on how to use it in within R:

http://bigcomputing.com/doredis.html

 

 

CCXT Python package wrapper best to stay on top of Bitcoin crypto currency exchanges

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!