Giter Site home page Giter Site logo

Comments (3)

ArsenAbazian avatar ArsenAbazian commented on June 23, 2024

Hi, I added BuyLong and SellLong (previously Buy and Sell) and BuyShort and SellShort. The last two methods I implemented only for Binance.

Here is the code:

       public override TradingResult BuyLong(AccountInfo account, Ticker ticker, double rate, double amount) {
            return MakeTrade(account, ticker, rate, amount, "BUY", "LONG");
       }

       public override TradingResult BuyShort(AccountInfo account, Ticker ticker, double rate, double amount) {
            return MakeTrade(account, ticker, rate, amount, "BUY", "SHORT");
       }

       public override TradingResult SellShort(AccountInfo account, Ticker ticker, double rate, double amount) {
            return MakeTrade(account, ticker, rate, amount, "SELL", "SHORT");
       }

       public override TradingResult SellLong(AccountInfo account, Ticker ticker, double rate, double amount) {
            return MakeTrade(account, ticker, rate, amount, "SELL", "LONG");
       }

       protected TradingResult MakeTrade(AccountInfo account, Ticker ticker, double rate, double amount, string side, string positionSide) {
            string queryString = string.Format("symbol={0}&side={1}&positionSide={2}&quantity={3:0.########}&price={4:0.########}&timestamp={5}&type=LIMIT&timeInForce=GTC&recvWindow=5000", 
                ticker.Name, side, positionSide, amount, rate, GetNonce());
            string signature = account.GetSign(queryString);

            string address = string.Format("https://api.binance.com/api/v3/order?{0}&signature={1}",
                queryString, signature);
            MyWebClient client = GetWebClient();

            client.Headers.Clear();
            client.Headers.Add("X-MBX-APIKEY", account.ApiKey);

            try {
                return OnTradeResult(account, ticker, client.UploadValues(address, new HttpRequestParamsCollection()));
            }
            catch(Exception e) {
                LogManager.Default.Log(e.ToString());
                return null;
            }
        }

I implement them according this documentation: https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

from cryptotradingframework.

xyong6024 avatar xyong6024 commented on June 23, 2024

Thank you. I have a look. There is a lack of futures module on the whole. For example, the front desk has only the spot part, but there is no futures market part, including the account is also the spot account

from cryptotradingframework.

ArsenAbazian avatar ArsenAbazian commented on June 23, 2024

I see... Well, currently I am busy with another project (which is, honesty, more preferrable, because one pays me for that). I'll implement this functionality when I have time. Currently you can do it by your own, it is not so difficult. Please take a look at binancemodule.cs and try to implement similar functionality using this documentation.

from cryptotradingframework.

Related Issues (10)

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.