every new file till today

This commit is contained in:
2025-05-27 13:23:26 +02:00
parent 3e6beb7b3b
commit b74d05c6ce
7 changed files with 5644 additions and 784 deletions
+542
View File
@@ -0,0 +1,542 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 28,
"id": "02ce9da2",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import keyring as kr\n",
"import MetaTrader5 as mt\n",
"import requests\n",
"import re\n",
"from time import sleep\n",
"from time import strftime\n",
"import datetime as dt\n",
"import sqlite3 as db\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ffcf5c1a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# login to your Trading Account - sign up in the description\n",
"mt.initialize()\n",
" \n",
"login = 10800246\n",
"server = 'VantageInternational-Demo'\n",
"password = kr.get_password(server, str(login))\n",
"\n",
"\n",
"mt.login(login, password, server)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d94de78e",
"metadata": {},
"outputs": [],
"source": [
"symbols = ['BTCUSD', 'ETHUSD', \n",
" 'XRPUSD', 'XAUUSD', 'EURUSD', 'EURNZD']"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "f225d16e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SymbolInfo(custom=False, chart_mode=0, select=True, visible=True, session_deals=0, session_buy_orders=0, session_sell_orders=0, volume=0, volumehigh=0, volumelow=0, time=1747583136, digits=2, spread=1603, spread_float=True, ticks_bookdepth=0, trade_calc_mode=5, trade_mode=4, start_time=0, expiration_time=0, trade_stops_level=0, trade_freeze_level=0, trade_exemode=2, swap_mode=5, swap_rollover3days=5, margin_hedged_use_leg=False, expiration_mode=15, filling_mode=2, order_mode=63, order_gtc_mode=0, option_mode=0, option_right=0, bid=103854.84, bidhigh=104085.24, bidlow=102892.04, ask=103870.87, askhigh=104101.27, asklow=102908.07, last=0.0, lasthigh=0.0, lastlow=0.0, volume_real=0.0, volumehigh_real=0.0, volumelow_real=0.0, option_strike=0.0, point=0.01, trade_tick_value=0.01, trade_tick_value_profit=0.01, trade_tick_value_loss=0.01, trade_tick_size=0.01, trade_contract_size=1.0, trade_accrued_interest=0.0, trade_face_value=0.0, trade_liquidity_rate=0.0, volume_min=0.01, volume_max=100.0, volume_step=0.01, volume_limit=0.0, swap_long=-19.0, swap_short=10.0, margin_initial=0.0, margin_maintenance=0.0, session_volume=0.0, session_turnover=0.0, session_interest=0.0, session_buy_orders_volume=0.0, session_sell_orders_volume=0.0, session_open=103363.54, session_close=103363.54, session_aw=0.0, session_price_settlement=0.0, session_price_limit_min=0.0, session_price_limit_max=0.0, margin_hedged=0.0, price_change=0.4753, price_volatility=0.0, price_theoretical=0.0, price_greeks_delta=0.0, price_greeks_theta=0.0, price_greeks_gamma=0.0, price_greeks_vega=0.0, price_greeks_rho=0.0, price_greeks_omega=0.0, price_sensitivity=0.0, basis='', category='', currency_base='BTC', currency_profit='USD', currency_margin='BTC', bank='', description='Bitcoin', exchange='', formula='', isin='', name='BTCUSD', page='', path='Crypto Currency\\\\Crypto Major\\\\BTCUSD')"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mt.symbol_info('BTCUSD')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "329ff8fe",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"datetime.datetime(2025, 5, 18, 21, 59, 2, 465512)"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"current_date_and_time = dt.datetime.now()\n",
"format = '%Y-%m-%d %H:%M:%S'\n",
"current_date_and_time.strftime(format)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5f56252c",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 150,
"id": "3ce21edb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'XAUUSD': 0.97, 'EURUSD': 0.87, 'EURNZD': 0.47, 'ETHUSD': -0.0, 'BTCUSD': -1.65, 'XRPUSD': -3.22}\n"
]
},
{
"data": {
"text/plain": [
"{'BTCUSD': -1.65,\n",
" 'ETHUSD': -0.0,\n",
" 'XRPUSD': -3.22,\n",
" 'XAUUSD': 0.97,\n",
" 'EURUSD': 0.87,\n",
" 'EURNZD': 0.47}"
]
},
"execution_count": 150,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pricemovement = {}\n",
"for s in symbols:\n",
" items = mt.symbol_info(s)\n",
" pricemovement[s] = round(items.price_change,2)\n",
" #print(s, round(items.price_change,2))\n",
"\n",
"sorted_pricemovement = sorted(pricemovement.items(), key=lambda x:x[1], reverse=True)\n",
"converted_dict = dict(sorted_pricemovement)\n",
"\n",
"print(converted_dict)\n",
"\n",
"pricemovement"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b30f529c",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 68,
"id": "f174bc75",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n"
]
}
],
"source": [
"con = db.connect(\"trading.db\")\n",
"print(con.total_changes)\n"
]
},
{
"cell_type": "code",
"execution_count": 69,
"id": "f2ff9f72",
"metadata": {},
"outputs": [],
"source": [
"cursor = con.cursor()"
]
},
{
"cell_type": "code",
"execution_count": 70,
"id": "0b4facf6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<sqlite3.Cursor at 0x268bf0321c0>"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cursor.execute(\"Create Table If Not Exists pricemovment (date TEXT,symbol TEXT, movement INTEGER)\")"
]
},
{
"cell_type": "code",
"execution_count": 151,
"id": "107514d6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"BTCUSD -1.65\n",
"ETHUSD -0.0\n",
"XRPUSD -3.22\n",
"XAUUSD 0.97\n",
"EURUSD 0.87\n",
"EURNZD 0.47\n"
]
}
],
"source": [
"for key, value in pricemovement.items():\n",
" print(key, value)\n",
" current_date_and_time = dt.datetime.now()\n",
" format = '%Y-%m-%d %H:%M:%S'\n",
" current_date_and_time.strftime(format)\n",
" cursor.execute(\"Insert into pricemovment values(?, ?, ?)\", (current_date_and_time, key, value))\n",
" con.commit()"
]
},
{
"cell_type": "code",
"execution_count": 152,
"id": "b99a7d5f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"BTCUSD\n",
"[('2025-05-18 22:02:41.439814', 'BTCUSD', 0.13), ('2025-05-18 22:06:10.375867', 'BTCUSD', 0.2), ('2025-05-18 22:42:44.244148', 'BTCUSD', 0.65), ('2025-05-18 22:57:00.481991', 'BTCUSD', 0.65)]\n",
"ETHUSD\n",
"[('2025-05-18 22:02:41.441815', 'ETHUSD', -5.19), ('2025-05-18 22:06:10.379865', 'ETHUSD', -4.86), ('2025-05-18 22:42:44.249142', 'ETHUSD', -3.92), ('2025-05-18 22:57:00.485990', 'ETHUSD', -4.05)]\n",
"XRPUSD\n",
"[('2025-05-18 22:02:41.441815', 'XRPUSD', -0.63), ('2025-05-18 22:06:10.382865', 'XRPUSD', -0.37), ('2025-05-18 22:42:44.252143', 'XRPUSD', 0.45), ('2025-05-18 22:57:00.487996', 'XRPUSD', 0.45)]\n",
"XAUUSD\n",
"[('2025-05-18 22:02:41.441815', 'XAUUSD', -1.21), ('2025-05-18 22:06:10.384868', 'XAUUSD', -1.21), ('2025-05-18 22:42:44.255142', 'XAUUSD', -1.21), ('2025-05-18 22:57:00.491343', 'XAUUSD', -1.21)]\n",
"EURUSD\n",
"[('2025-05-18 22:02:41.441815', 'EURUSD', -0.2), ('2025-05-18 22:06:10.387868', 'EURUSD', -0.2), ('2025-05-18 22:42:44.258146', 'EURUSD', -0.2), ('2025-05-18 22:57:00.493342', 'EURUSD', -0.2)]\n",
"EURNZD\n",
"[('2025-05-18 22:02:41.441815', 'EURNZD', -0.29), ('2025-05-18 22:06:10.426110', 'EURNZD', -0.29), ('2025-05-18 22:42:44.262143', 'EURNZD', -0.29), ('2025-05-18 22:57:00.496339', 'EURNZD', -0.29)]\n"
]
}
],
"source": [
"for s in symbols:\n",
" print(s)\n",
" cursor.execute(f\"Select * from pricemovment where date like '2025-05-18%' and symbol = '{s}'\")\n",
" inhalt = cursor.fetchall()\n",
" print(inhalt)"
]
},
{
"cell_type": "code",
"execution_count": 155,
"id": "9b8fc8e9",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>symbol</th>\n",
" <th>percentage</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2025-05-19 14:42:14.686479</td>\n",
" <td>BTCUSD</td>\n",
" <td>-1.72</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2025-05-19 14:42:14.735008</td>\n",
" <td>ETHUSD</td>\n",
" <td>-0.04</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2025-05-19 14:42:14.738010</td>\n",
" <td>XRPUSD</td>\n",
" <td>-3.05</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2025-05-19 14:42:14.741009</td>\n",
" <td>XAUUSD</td>\n",
" <td>1.30</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2025-05-19 14:42:14.743007</td>\n",
" <td>EURUSD</td>\n",
" <td>0.92</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>2025-05-19 14:42:14.746007</td>\n",
" <td>EURNZD</td>\n",
" <td>0.43</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>2025-05-19 14:57:55.112334</td>\n",
" <td>BTCUSD</td>\n",
" <td>-1.65</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>2025-05-19 14:57:55.116333</td>\n",
" <td>ETHUSD</td>\n",
" <td>0.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>2025-05-19 14:57:55.124334</td>\n",
" <td>XRPUSD</td>\n",
" <td>-3.22</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>2025-05-19 14:57:55.128902</td>\n",
" <td>XAUUSD</td>\n",
" <td>0.97</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>2025-05-19 14:57:55.186314</td>\n",
" <td>EURUSD</td>\n",
" <td>0.87</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>2025-05-19 14:57:55.202850</td>\n",
" <td>EURNZD</td>\n",
" <td>0.47</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" date symbol percentage\n",
"0 2025-05-19 14:42:14.686479 BTCUSD -1.72\n",
"1 2025-05-19 14:42:14.735008 ETHUSD -0.04\n",
"2 2025-05-19 14:42:14.738010 XRPUSD -3.05\n",
"3 2025-05-19 14:42:14.741009 XAUUSD 1.30\n",
"4 2025-05-19 14:42:14.743007 EURUSD 0.92\n",
"5 2025-05-19 14:42:14.746007 EURNZD 0.43\n",
"6 2025-05-19 14:57:55.112334 BTCUSD -1.65\n",
"7 2025-05-19 14:57:55.116333 ETHUSD 0.00\n",
"8 2025-05-19 14:57:55.124334 XRPUSD -3.22\n",
"9 2025-05-19 14:57:55.128902 XAUUSD 0.97\n",
"10 2025-05-19 14:57:55.186314 EURUSD 0.87\n",
"11 2025-05-19 14:57:55.202850 EURNZD 0.47"
]
},
"execution_count": 155,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cursor.execute(\"Select * from pricemovment where date like '2025-05-19%'\")\n",
"inhalt = cursor.fetchall()\n",
"inhalt = pd.DataFrame(inhalt, columns=['date', 'symbol', 'percentage'])\n",
"\n",
"for s in symbols:\n",
" x = inhalt.loc[inhalt['symbol'] == s].percentage.diff()\n",
" pd.concat([inhalt, x])\n",
" \n",
"inhalt\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 187,
"id": "6f27e0ac",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[1.3, 0.97]"
]
},
"execution_count": 187,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list = inhalt.loc[inhalt['symbol'] == 'XAUUSD'].percentage.to_list()\n",
"list\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "31180731",
"metadata": {},
"outputs": [],
"source": [
"cursor.execute(\"Insert into pricemovement values(?, ?, ?)\", ())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e5425f12",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 59,
"id": "1422339e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<sqlite3.Cursor at 0x268bee8ab40>"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cursor.execute('Drop Table pricemovment')"
]
},
{
"cell_type": "code",
"execution_count": 74,
"id": "3d94a299",
"metadata": {},
"outputs": [],
"source": [
"con.commit()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bf1487ac",
"metadata": {},
"outputs": [],
"source": [
"cursor.execute('INSERT INTO pricemovement VALUES(1, datetime('now'))'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ce546c4d",
"metadata": {},
"outputs": [],
"source": [
"con.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "354653fc",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
[ZoneTransfer]
ZoneId=3
+1963
View File
File diff suppressed because it is too large Load Diff
+25 -12
View File
@@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -33,18 +33,31 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"login = 10730196\n",
"password = '#mDJu9O3'\n",
"# Live Acccount\n",
"login = 10676507\n",
"password = '5l5^hbEL'\n",
"server = 'VantageInternational-Live 4'"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# Demo Acccount\n",
"login = 10800246\n",
"password = '%dN!Zu96'\n",
"server = 'VantageInternational-Demo'"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -69,14 +82,14 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#mDJu9O3\n"
"5l5^hbEL\n"
]
}
],
@@ -93,15 +106,15 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Username : 10730196\n",
"Password : #mDJu9O3\n"
"Username : 10676507\n",
"Password : 5l5^hbEL\n"
]
}
],
@@ -130,7 +143,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -139,7 +152,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"outputs": [
{
+747 -772
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff