Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wwbustb committed Apr 11, 2019
1 parent 5701b68 commit 387e59b
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions doc/code_Instruction/Trade API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,13 @@ A JavaScript example:

.. code-block:: JavaScript
// Note: GetPosition function obtains position information of all positions.
function main(){
exchange.SetContractType("this_week");
exchange.SetMarginLevel(10);
exchange.SetDirection("buy");
exchange.Buy(10000, 2);
position = exchange.GetPosition();
Log("Amount:", position[0].Amount, "FrozenAmount:", position[0].FrozenAmount, "Price:",
position[0].Price, "Profit:", position[0].Profit, "Type:", position[0].Type,
"ContractType:", position[0].ContractType);
exchange.SetDirection("closebuy");
exchange.Sell(10000, 2);
exchange.SetContractType("this_week") //for OKEX future
var position = exchange.GetPosition()
if(position.length>0){
Log("Amount:", position[0].Amount, "FrozenAmount:", position[0].FrozenAmount, "Price:",
position[0].Price, "Profit:", position[0].Profit, "Type:", position[0].Type, "ContractType:", position[0].ContractType)
}
}
2.4.9 SetMarginLevel
Expand Down Expand Up @@ -453,9 +448,8 @@ A JavaScript example:
exchange.SetMarginLevel(5); // Set the leverage to 5 times
exchange.SetDirection("buy"); // Set the order type to buy long
exchange.Buy(1000, 2); //buy long at the price 1000, quantity of 2
exchange.SetMarginLevel(5);
exchange.SetDirection("closebuy");
exchange.Sell(1000, 2);
exchange.Sell(1000, 2); //close long position
}

0 comments on commit 387e59b

Please sign in to comment.