Code Monkey home page Code Monkey logo

Comments (6)

RacingStatistics avatar RacingStatistics commented on May 27, 2024 1

huh... now it works...
I got a 'order would trigger immediately' earlier when I tried...

Anyway, this now works like a charm 👍

$api->buy('NULSBTC', 20, 0.00018500, "STOP_LOSS_LIMIT", [ "stopPrice" => 0.00019000 ]);

Creates a stop-limit buy order for 20 NULS when the price goes above 19000 sats and from that moment on tries to buy it for 18500 sats.

Thanks for your reply and overall very handy library jaggedsoft!!

from php-binance-api.

0dark0 avatar 0dark0 commented on May 27, 2024

None!

They are SELL orders. If you want to buy, use BUY LIMIT or BUY MARKET order.

Here is what I would do

$price = current market price;

if $price >= '8510';

then do a BUY LIMIT/MARKET order;

from php-binance-api.

jaggedsoft avatar jaggedsoft commented on May 27, 2024

Thanks 0dark0 for helping 👍

Yes, all you need is to place a 'limit' buy order for 8510.
A stop_loss_limit will sell something you own if the price drops below a certain point
A take_profit_limit will sell something you own if the price goes above a certain point

from php-binance-api.

RacingStatistics avatar RacingStatistics commented on May 27, 2024

Sorry to open this one up, but the answer has not really been given.
Although 'placing a limit buy when price >= x' sounds nice, it's not the automatic method like 'STOP_LOSS_LIMIT' is.

If I have a script which monitors every 5 minutes and places stop-limit markers for both BUY and SELL, you need a functionality such as 'STOP_LOSS_LIMIT' but for BUY.

If you look at the binance interface, these 'stop-limits' for buy can be placed there. Just haven't found a way to do those through the API / this lib.

Hope you can help!

from php-binance-api.

jaggedsoft avatar jaggedsoft commented on May 27, 2024

@RacingStatistics Hi there, most things that you can do from the binance interface are supported by this library.

$flags = ['stopPrice' => 7444.77, 'newOrderRespType' => 'FULL'];
$amount = 0.002;
$order = $api->order('SELL', 'BTCUSDT', $amount, 0, 'STOP_LOSS_LIMIT', $flags);

Just reverse the logic for buying.
Binance does not allow both a BUY and a SELL stoploss at the same time though.

from php-binance-api.

gnzlst avatar gnzlst commented on May 27, 2024

Hi @jaggedsoft

I am sorry to open this again, but I cannot understand how you create a STOP_LOSS_LIMIT sell order with a price of 0.

$flags = ['stopPrice' => 7444.77, 'newOrderRespType' => 'FULL'];
$amount = 0.002;
$order = $api->order('SELL', 'BTCUSDT', $amount, 0, 'STOP_LOSS_LIMIT', $flags);

I tried, but it just throws and "Invalid price" exception.

from php-binance-api.

Related Issues (20)

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.