Hasan and Hazrat Ibn Sirin say that the profit will be according to the agreed condition, and the loss will be deducted from the principal amount.