private void createTestBuyOrder_Click(object sender, EventArgs e) { ; //ApiClient apiclient = new ApiClient(Configuration.Default); Configuration.Default.AddDefaultHeader("Access-Control-Allow-Origin", "*"); Configuration.Default.AddDefaultHeader("Authorization", "Bearer " + accessToken); var apiInstance = new PrivateApi(Configuration.Default); var instrumentName = "BTC-PERPETUAL"; // string | Instrument name var amount = 500.0M; // decimal? | It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH var type = "limit"; // string | The order type, default: `\"limit\"` (optional) var label = "Test Buy Order by Bot"; // string | user defined label for the order (maximum 32 characters) (optional) var price = 45000.0M; // decimal? | <p>The order price in base currency (Only for limit and stop_limit orders)</p> <p>When adding order with advanced=usd, the field price should be the option price value in USD.</p> <p>When adding order with advanced=implv, the field price should be a value of implied volatility in percentages. For example, price=100, means implied volatility of 100%</p> (optional) // var timeInForce = timeInForce_example; // string | <p>Specifies how long the order remains in effect. Default `\"good_til_cancelled\"`</p> <ul> <li>`\"good_til_cancelled\"` - unfilled order remains in order book until cancelled</li> <li>`\"fill_or_kill\"` - execute a transaction immediately and completely or not at all</li> <li>`\"immediate_or_cancel\"` - execute a transaction immediately, and any portion of the order that cannot be immediately filled is cancelled</li> </ul> (optional) (default to good_til_cancelled) // var maxShow = 8.14; // decimal? | Maximum amount within an order to be shown to other customers, `0` for invisible order (optional) (default to 1M) // var postOnly = true; // bool? | <p>If true, the order is considered post-only. If the new price would cause the order to be filled immediately (as taker), the price will be changed to be just below the bid.</p> <p>Only valid in combination with time_in_force=`\"good_til_cancelled\"`</p> (optional) (default to true) // var reduceOnly = true; // bool? | If `true`, the order is considered reduce-only which is intended to only reduce a current position (optional) (default to false) var stopPrice = 45000.0M; // decimal? | Stop price, required for stop limit orders (Only for stop orders) (optional) // var trigger = trigger_example; // string | Defines trigger type, required for `\"stop_limit\"` order type (optional) // var advanced = advanced_example; // string | Advanced option order type. (Only for options) (optional) try { // Places a buy order for an instrument. //privateApiInstance.Configuration.AccessToken = Configuration.Default.AccessToken; MessageBox.Show("access token: " + privateApiInstance.Configuration.AccessToken); // MessageBox.Show(privateApiInstance.GetBasePath()); foreach (string key in Configuration.Default.DefaultHeader.Keys) { if (privateApiInstance.DefaultHeader().TryGetValue(key, out string value)) { MessageBox.Show("key: " + key + " value: " + value); } } // Configuration.Default.AddDefaultHeader("authorization", "bearer " + accessToken); ; // apiInstance.AddDefaultHeader("Access-Control-Allow-Origin","*"); // privateApiInstance.AddDefaultHeader("scope", "trade:read_write"); //ApiClient.Default.con = Configuration; // MessageBox.Show(ApiClient.Default.Configuration.AccessToken); Object result = apiInstance.PrivateBuyGetWithHttpInfo(instrumentName, amount, type, label, price, string.Empty, null, null, null, stopPrice, string.Empty, string.Empty); MessageBox.Show(result.ToString()); Clipboard.SetText(result.ToString()); } catch (ApiException ex) { MessageBox.Show("Exception when calling PrivateApi.PrivateBuyGet: " + ex.Message); MessageBox.Show("Status Code: " + ex.ErrorCode); MessageBox.Show(ex.StackTrace); } }