Tag Archives: order

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!

Redis NOSQL command driven submit order to Dukascopy JForex for Python algo forex trading

Complete Redis NOSQL command driven submitting order to Dukascopy JForex for automated Python algo forex trading

I show how you can interface a language like to Python with Redis NOSQL to drive your orders into Dukascopy Jforex with their API

You need to follow these steps in the 2 previous videos I have here

Complete Redis NOSQL command driven submitting order to Dukascopy JForex for automated algo forex trading

Here is Python sample code:

import redis
import time

r = redis.StrictRedis(host=’localhost’, port=6379, db=0)
r.flushall()
print(“PUSH Open”)
r.lpush(“order”,”open,Sep420,EURUSD,BUY,0.001,0,20,1.15,1.30″)
print(“pause”)
time.sleep(3)
print(“PUSH close”)
r.lpush(“order”,”close,Sep420″)

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!

Complete Redis NOSQL command driven submitting order to Dukascopy JForex for automated algo forex trading

Complete Redis NOSQL command driven submitting order to Dukascopy JForex for automated Java algo forex trading

Primitive message queue with Redis NOSQL but does work as explained using Java for the Dukascopy JForex API

Please watch this video first

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!

Redis NOSQL command driven to submit simple order and close with Dukascopy Java API

Redis NOSQL command driven to submit simple order and close with Dukascopy Java API

Confusing but the start of primitive messagage queue with Redis and Dukascopy Java SDK to maintain orders and positions. There is a still a lot to do as described in this video

 

 

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!

Dukascopy Jforex vs Java Standalone API SDK with simple order example

Dukascopy Jforex vs Java Standalone API SDK with simple order example

This is after the challenges of bugs found in the JForex platform

https://www.dukascopy.com/wiki/en/development/get-started-api/use-jforex-sdk/use-in-netbeans

Buy Dukascopy API training video product here

Videos

 

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!

Detailed overview of Dukascopy API order and positions with stop loss and take profit

Complete overview of Dukascopy API order and positions with stop loss and take profit

I wondered what exit strategies people use in their trading. I posted this on various Facebook entities I administer. I posted this:

Who uses either stop loss and/or take profit only on their exits only? What other techniques have you used in an automated trading setting?

I got these comments:

I use trailing stops on nearly all trades… I break up my sells and trail stops a little different for each block… I don’t automate trading – I wish I could learn it, but its too much for me to learn by myself…

always have a limit order for exit, it’s the only way you can predict your losses therefore have a strategy, if you don’t cap your losses how can you have a profitable strategy?

 

I am interested to know what you use. I had many dialogues over this but things may have changed since then.

 

I also posted this video lately regarding the API. If you missed the memo, I have found Visual JForex can generate really ugly Java code as part of your strategy. In fact, I would consider it even useless or beginners if they want to advance their own programming skills.

 

Right now, I am focused on the stop losses right now for exit strategies. As a result, I made a video on this as usual. Also, note that I do plan to use regression for entry as hinted in another previously sent video as well. In short, just take a look at my most recent videos found in my Dukascopy playlist on my Youtube.com/quantlabs channel.

I got deep on these different scenarios which means I will use various techniques for my exit strategy needs https://quantlabs.net/blog/2017/09/complte-overview-of-dukascopy-api-order-and-positions-with-stop-loss-and-take-profit/
Remember I got my affordable video course series on these topics if you want to learn what I am applying here with Dukascopy.
Dukascopy Tools and API development for Algo forex trading
Dukascopy Tools and API development for Algo forex trading
$47.00
View
Dukascopy Visual JForex for NON programming to do algo forex trading
Dukascopy Visual JForex for NON programming to do algo forex trading
$47.00
View
JOIN OUR FREE DAILY ANALYTICS
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!

Complete overview of Dukascopy API order and positions with stop loss and take profit

Complete overview of Dukascopy API order and positions with stop loss and take profit

I got deep on these different scenarios which means I will use various techniques for my exit strategy needs

https://www.dukascopy.com/wiki/en/development/strategy-api/orders-and-positions/stop-loss

https://www.dukascopy.com/client/javadoc/com/dukascopy/api/IOrder.html

Dukascopy Tools and API development for Algo forex trading

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!

Reminder TONITE: Fractal Order Flow Trading Online Meetup Event

Reminder TONITE: Fractal Order Flow#Trading Online Meetup Event

Fractal Order Flow#Trading Online Meetup Event Jul 3

Fractal Order Flow Trading

– A Brief Introduction

-Basic Fractal Theory

-Fractal Pairs and SAFs

-Fractal Energy Indicators

-Market Profile Basics

-The Basics of Order Flow Mechanics

-Putting it all together

Presenter is Sholom Benzev

Monday Jul 3 at 7PM EDT

You are invited to a Zoom meeting.

When: Jul 3, 2017 7:00 AM Eastern Time (US and Canada)

Register in advance for this meeting:
https://zoom.us/meeting/register/052ac4eeef5b9d8434538d7d4481ef37

After registering, you will receive a confirmation email containing information about joining the meeting.

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 submit order to Dukascopy JForex via sockets for forex algo trading

Demo to submit order to Dukascopy JForex via sockets for forex algo trading

Wow that was easy once again thanks to Dukascopy API demos

Dukascopy JForex submitting order Java source code notes

Join my FREE newsletter to learn more about on how this broker can help in your automated algo forex trading

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!

Dukascopy JForex submitting order Java source code notes

Dukascopy JForex submitting order Java source code notes

Here is what I can decipher where I start here

https://www.quantisan.com/tag/JForex/index2.html

https://www.dukascopy.com/wiki/en/development/get-started-api/use-in-jforex/strategy-tutorial

https://www.dukascopy.com/fxcomm/fx-article-contest/?Creating-Your-First-Strategy-Part=&action=read&id=847&language=en <– best source example for JForex use

Java source code here

https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=82&t=47482

MyFirstStrategy.java line has buy/sell instructions

This seems to have popular examples http://www.programcreek.com/java-api-examples/index.php?api=com.dukascopy.api.IOrder

https://github.com/giowck/jforex-trading-strategies <– most popular from ProgramCreek.com

Github Python and Java (Dukascopy JForex) using Jython

https://github.com/brotchie/pyforex

Jython tutorial to merge Python and Java

As for MongoDB or any NOSQL (like Redis) this is all i could find

https://github.com/caub/jForexWebOrderBook/blob/master/src/main/java/ws/Strategy.java

Another way to for clients to communicate with JForex is through sockets

https://www.dukascopy.com/wiki/en/development/strategy-api/practices/socket-connection

https://www.dukascopy.com/wiki/en/development/strategy-api/practices/socket-channel

Join my FREE newsletter to learn more about how JForex can be helpful for your automated trading

 

 

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!