added notebooks
This commit is contained in:
78
notebooks/RiskManager.ipynb
Normal file
78
notebooks/RiskManager.ipynb
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "ad08f522",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import datetime\n",
|
||||
"import numpy as np\n",
|
||||
"import random"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "b9b18667",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class riskManager:\n",
|
||||
" \n",
|
||||
" def __init__(self,commision=0.04):\n",
|
||||
" self.commision = commision\n",
|
||||
" pass\n",
|
||||
" def getDecision(self,signalDecision,probabilityDecision, price, deals=None) -> dict:\n",
|
||||
" ans = {}\n",
|
||||
" if probabilityDecision['trande'] == 'up':\n",
|
||||
" ans['decision'] = 'buy'\n",
|
||||
" ans['amount'] = 1\n",
|
||||
" elif probabilityDecision['trande'] == 'none':\n",
|
||||
" ans['decision'] = 'none'\n",
|
||||
" elif probabilityDecision['trande'] == 'down': \n",
|
||||
" for i in deals.shape[0]:\n",
|
||||
" ans['decision'] = 'None'\n",
|
||||
" ans['deals'] = []\n",
|
||||
" row = deals.iloc[i]\n",
|
||||
" if row.startPrice < price*pow(1+self.commission,2):\n",
|
||||
" ans['decision'] = 'sell'\n",
|
||||
" ans['deals'].append(row.name)\n",
|
||||
" return ans\n",
|
||||
" \n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "8f5dd64e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.8"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user