Compare commits
10 Commits
d5df9d1014
...
working
| Author | SHA1 | Date | |
|---|---|---|---|
| 796e5afe0c | |||
| b54f4a29b7 | |||
| b6798e84f5 | |||
| aa38f9745a | |||
| b6a37681ba | |||
| aca85ce4d8 | |||
| 6264db6502 | |||
| f598ac6a3d | |||
| 45353b8a01 | |||
| 8df645aac5 |
@@ -1,12 +1,7 @@
|
||||
stocks.parquet
|
||||
stocks_preview.csv
|
||||
appdata.db
|
||||
__pycache__
|
||||
obj
|
||||
bin
|
||||
*.db
|
||||
*.keras
|
||||
*.pkl
|
||||
*.csv
|
||||
|
||||
!/WebServer/AIPython/python/bin
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 522 KiB |
@@ -7,11 +7,24 @@ Overview of the directories
|
||||
└── WebServer # The ASP.NET Core 9 Webserver
|
||||
├── AIPython # All the AI files written in python [Copied to the docker container via the C# compiler]
|
||||
├── Components # HTML pages written in .razor pages
|
||||
├── Controllers # Python Interop Controllers and Database Controlelrs
|
||||
├── Controllers # Python Interop Controllers and Database Controller
|
||||
├── Properties # ASP.Net Properties files
|
||||
└── wwwroot # Statically hosted Web Files
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
You need to have docker and docker-compose installed
|
||||
|
||||
## Hardware Requrement
|
||||
|
||||
You need a computer with docker-compose installed.
|
||||
GPU is not needed as it runs via the CPU runtime.
|
||||
|
||||
Minimum Specs:
|
||||
4 core CPU.
|
||||
16GB ram.
|
||||
|
||||
## Installation
|
||||
How to host a local copy
|
||||
|
||||
@@ -27,4 +40,13 @@ docker compose up -d
|
||||
```
|
||||
|
||||
## Usage
|
||||
Navigate to [Localhost:5000](http://localhost:5000).
|
||||
|
||||
Navigate to [localhost:5000](http://127.0.0.1:5000).
|
||||
|
||||
Register an account with a username and password
|
||||
Add as many stock symbols as you would like to the watched stocks
|
||||
Sit back and let the AI day trade for you
|
||||
This will auto trade once per day based on the AI predicted stock movement 5 days in advance
|
||||
-------------------
|
||||
If you would like to simulate your watched stocks on the last 30 days of stock history you can run the 'Run 1Mo Evaluation'
|
||||
This will simulate, such as the real algorithm, the stock trade's per day on your watched stocks so you can get a feel for your watched stocks
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 MiB |
@@ -0,0 +1 @@
|
||||
0.198600759951581
|
||||
@@ -17,8 +17,6 @@ def Predict():
|
||||
# get the number of days ago to run the simulation for
|
||||
DaysBack = int(sys.argv[2])
|
||||
|
||||
print(f"Days back: {DaysBack}")
|
||||
|
||||
# calculate the time offsets
|
||||
end_date = datetime.now() - timedelta(days=DaysBack)
|
||||
start_date = end_date - timedelta(days=70)
|
||||
@@ -27,9 +25,6 @@ def Predict():
|
||||
start_str = start_date.strftime('%Y-%m-%d')
|
||||
end_str = end_date.strftime('%Y-%m-%d')
|
||||
|
||||
print(f"Start Date: {start_str}")
|
||||
print(f"End Date: {end_str}")
|
||||
|
||||
# Define paths (consistent with your previous script)
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
DATA_DIR = os.path.join(SCRIPT_DIR, "data")
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
import pandas as pd
|
||||
from sklearn.metrics import f1_score, precision_score, recall_score, accuracy_score
|
||||
import features
|
||||
import joblib
|
||||
import os
|
||||
|
||||
# Suppress TensorFlow INFO and WARNING logs
|
||||
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
|
||||
|
||||
# Suppress specialized XLA and autotuning logs
|
||||
os.environ['TF_XLA_FLAGS'] = '--tf_xla_enable_xla_devices=false'
|
||||
os.environ['TF_CPP_MAX_VLOG_LEVEL'] = '0'
|
||||
|
||||
# CPU only
|
||||
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
|
||||
|
||||
from sklearn.model_selection import train_test_split
|
||||
from keras import Sequential, layers, optimizers
|
||||
from keras.callbacks import ReduceLROnPlateau
|
||||
@@ -19,6 +30,9 @@ def TrainAI():
|
||||
# Use external featuers to make sure loaded is the same
|
||||
dataset = features.MakeFeatures(dataset)
|
||||
|
||||
# Make sure empty columns dont exist
|
||||
dataset = dataset.dropna()
|
||||
|
||||
# Create the X, Y vareables
|
||||
X, Y, X_Scaler, Y_Scaler = features.Prepare(dataset)
|
||||
|
||||
@@ -30,7 +44,7 @@ def TrainAI():
|
||||
print(dataset.dtypes)
|
||||
|
||||
# Split out the test and train
|
||||
train_features, test_features, train_labels, test_labels = train_test_split(X, Y, test_size=0.2)
|
||||
train_features, test_features, train_labels, test_labels = train_test_split(X, Y, test_size=0.2, shuffle=False) # Keep the training and test data in order as its sequential
|
||||
|
||||
# Create the DNN
|
||||
dnn_model = Sequential([
|
||||
@@ -45,9 +59,6 @@ def TrainAI():
|
||||
layers.Dense(1, activation='linear') # DNN layer
|
||||
])
|
||||
|
||||
# Allow negative numbers
|
||||
dnn_model.add(layers.LeakyReLU(alpha=0.01))
|
||||
|
||||
# Configure the model
|
||||
dnn_model.compile(
|
||||
optimizer=optimizers.Adam(learning_rate=0.0001, clipvalue=1.0),
|
||||
@@ -59,7 +70,7 @@ def TrainAI():
|
||||
dnn_model.summary()
|
||||
|
||||
# Learning rate reducer
|
||||
reduce_lr = ReduceLROnPlateau(monitor='val_loss', factor=0.5, patience=5, min_lr=0.0000001)
|
||||
reduce_lr = ReduceLROnPlateau(monitor='loss', factor=0.5, patience=5, min_lr=0.0000001)
|
||||
|
||||
# Train the model
|
||||
Training_Data = dnn_model.fit(
|
||||
@@ -68,8 +79,7 @@ def TrainAI():
|
||||
batch_size=64,
|
||||
epochs=50, # Tuned to the point before overfitting
|
||||
verbose=1, # Show progress
|
||||
validation_split = 0.2, # Calculate validation results on 20% of the training data.
|
||||
shuffle=True,
|
||||
shuffle=False, # Time series data
|
||||
callbacks=[reduce_lr] # Reduce the learning_rate every run
|
||||
)
|
||||
|
||||
@@ -78,6 +88,27 @@ def TrainAI():
|
||||
test_features, test_labels, verbose=0
|
||||
)
|
||||
|
||||
# Perform test on test data split earlier
|
||||
predictions = dnn_model.predict(test_features)
|
||||
|
||||
# Convert to Binary Direction (The "Signal")
|
||||
y_true_binary = (test_labels > 0).astype(int)
|
||||
y_pred_binary = (predictions > 0).astype(int)
|
||||
|
||||
# Calculate the metrics
|
||||
acc = accuracy_score(y_true_binary, y_pred_binary)
|
||||
prec = precision_score(y_true_binary, y_pred_binary)
|
||||
rec = recall_score(y_true_binary, y_pred_binary)
|
||||
f1 = f1_score(y_true_binary, y_pred_binary)
|
||||
|
||||
# Output the meterics; this gets spit out when training from the python file directly. The C# interop does not output these
|
||||
print(f"Test Loss: {test_results[0]:.4f}")
|
||||
print(f"Test MAE: {test_results[1]:.2%}")
|
||||
print(f"Test Accuracy: {acc:.2%}")
|
||||
print(f"Test Precision: {prec:.2%}")
|
||||
print(f"Test Recall: {rec:.2%}")
|
||||
print(f"F1 Score: {f1:.2%}")
|
||||
|
||||
# Save the model
|
||||
dnn_model.save(os.path.join(DATA_DIR, "model.keras"))
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from datetime import datetime, timedelta
|
||||
import sys
|
||||
import yfinance as yf
|
||||
|
||||
@@ -6,8 +7,21 @@ def getCurrentPrice():
|
||||
# Get the Symbol from ARGV
|
||||
symbol = sys.argv[1]
|
||||
|
||||
# get the number of days ago to run the simulation for
|
||||
DaysBack = int(sys.argv[2])
|
||||
|
||||
ticker = yf.Ticker(symbol)
|
||||
data = ticker.history(period="1d", interval="1m")
|
||||
|
||||
# Calculate the target date
|
||||
target_date = datetime.now() - timedelta(days=DaysBack)
|
||||
start_str = target_date.strftime('%Y-%m-%d')
|
||||
|
||||
# End date must be the day AFTER the target to get that day's data
|
||||
end_date = target_date + timedelta(days=1)
|
||||
end_str = end_date.strftime('%Y-%m-%d')
|
||||
|
||||
# Fetch data for that specific 24-hour window
|
||||
data = ticker.history(start=start_str, end=end_str)
|
||||
current_price = data['Close'].iloc[-1]
|
||||
|
||||
# Return to C# via stdout
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,201 @@
|
||||
Date,Close,High,Low,Open,Volume,Ticker
|
||||
1962-01-02,0.5549417734146118,0.5674593755384081,0.5507693916653374,0.5507693916653374,254509,MMM
|
||||
1962-01-03,0.559114396572113,0.559114396572113,0.5455538586598488,0.5549418618657949,505190,MMM
|
||||
1962-01-04,0.559114396572113,0.5685025520700743,0.559114396572113,0.559114396572113,254509,MMM
|
||||
1962-01-05,0.5445109605789185,0.5570283786547682,0.542424597322887,0.5570283786547682,376979,MMM
|
||||
1962-01-08,0.5413813591003418,0.5455538940775435,0.5382519102761827,0.5445108079245009,399942,MMM
|
||||
1962-01-09,0.5413813591003418,0.5455538940775435,0.5392951487212504,0.5413813591003418,376979,MMM
|
||||
1962-01-10,0.5351223945617676,0.5403380516287226,0.5340793088359654,0.5403380516287226,304262,MMM
|
||||
1962-01-11,0.5330365300178528,0.538252153504966,0.5205190717218046,0.5351228555587451,269818,MMM
|
||||
1962-01-12,0.5226050615310669,0.5403381306302644,0.5226050615310669,0.533036148752137,692723,MMM
|
||||
1962-01-15,0.5278207659721375,0.5288640046108162,0.522605296165997,0.522605296165997,252595,MMM
|
||||
1962-01-16,0.5372088551521301,0.5372088551521301,0.5257344880028373,0.5278206985024275,239200,MMM
|
||||
1962-01-17,0.5330365300178528,0.538252153504966,0.5299072320716318,0.5372090668805668,135866,MMM
|
||||
1962-01-18,0.5372088551521301,0.538251941365421,0.5309501094343341,0.5330363199339243,306176,MMM
|
||||
1962-01-19,0.5309498310089111,0.5361654877783718,0.526777297978745,0.5361654877783718,170310,MMM
|
||||
1962-01-22,0.5340795516967773,0.5361657621700302,0.5278206918389706,0.53095010273137,246854,MMM
|
||||
1962-01-23,0.5319932103157043,0.5392951561445691,0.5319932103157043,0.5340795349425326,164570,MMM
|
||||
1962-01-24,0.536165714263916,0.536165714263916,0.5299069691843488,0.5319931794712,139693,MMM
|
||||
1962-01-25,0.5330365300178528,0.538252153504966,0.530950318696031,0.5361659802561677,415251,MMM
|
||||
1962-01-26,0.5351223945617676,0.5361655183605605,0.5309498612936054,0.5330360708182005,118643,MMM
|
||||
1962-01-29,0.5267777442932129,0.5372090285970914,0.5267777442932129,0.5351228174239406,216237,MMM
|
||||
1962-01-30,0.5309498310089111,0.5340792783727715,0.526777297978745,0.526777297978745,170310,MMM
|
||||
1962-01-31,0.5507694482803345,0.5591143649286696,0.5340794626916576,0.5340794626916576,327226,MMM
|
||||
1962-02-01,0.5674593448638916,0.5705886024519443,0.5486829998026658,0.5507693618930127,319571,MMM
|
||||
1962-02-02,0.5737183094024658,0.5758044820696092,0.5695457737031148,0.5695457737031148,239200,MMM
|
||||
1962-02-05,0.5831063985824585,0.5831063985824585,0.5716318791669666,0.5737182419538933,233459,MMM
|
||||
1962-02-06,0.5841494202613831,0.5841494202613831,0.5778907133220973,0.5831063341656723,210496,MMM
|
||||
1962-02-07,0.5831063985824585,0.586235695288294,0.5799769495845895,0.5841494847934009,221978,MMM
|
||||
1962-02-08,0.5820633769035339,0.5841497023946279,0.581020290304032,0.5831066157951261,116730,MMM
|
||||
1962-02-09,0.5810205340385437,0.5862361595890886,0.5716323319014859,0.5820636210756142,153088,MMM
|
||||
1962-02-12,0.5758044719696045,0.5799770075957664,0.573718299339054,0.5799770075957664,110989,MMM
|
||||
1962-02-13,0.5674593448638916,0.5799767559460595,0.5674593448638916,0.575804222130344,183706,MMM
|
||||
1962-02-14,0.5507694482803345,0.5674594338690114,0.5476399998364543,0.5674594338690114,179878,MMM
|
||||
1962-02-15,0.5528554916381836,0.5612005586359451,0.5497260819957749,0.5507693200712253,187533,MMM
|
||||
1962-02-16,0.5528554916381836,0.5612005586359451,0.5507693200712253,0.5528554916381836,218150,MMM
|
||||
1962-02-19,0.5451132655143738,0.5503446806435088,0.5451132655143738,0.5503446806435088,197101,MMM
|
||||
1962-02-20,0.5670852661132812,0.5670852661132812,0.54720600118734,0.54720600118734,174138,MMM
|
||||
1962-02-21,0.5649929046630859,0.5681317929582201,0.5608077329990109,0.5670853950243437,126298,MMM
|
||||
1962-02-23,0.5597610473632812,0.5649924986367659,0.5587148029345257,0.5649924986367659,124384,MMM
|
||||
1962-02-26,0.5576686859130859,0.5639463448612618,0.5524372716326951,0.559761175248656,170310,MMM
|
||||
1962-02-27,0.553483247756958,0.560807186007724,0.553483247756958,0.5576684153389702,124384,MMM
|
||||
1962-02-28,0.5587150454521179,0.5587150454521179,0.5482522147401887,0.5534836300961533,116730,MMM
|
||||
1962-03-01,0.5566224455833435,0.5639465040194891,0.5524374275428052,0.5587150882626765,139693,MMM
|
||||
1962-03-02,0.553483247756958,0.560807186007724,0.5482518360147862,0.5566220184257119,267904,MMM
|
||||
1962-03-05,0.5482519268989563,0.5555758281755367,0.5482519268989563,0.5534833395083437,202842,MMM
|
||||
1962-03-06,0.5482519268989563,0.5482519268989563,0.5440667586231654,0.5482519268989563,216237,MMM
|
||||
1962-03-07,0.5524373650550842,0.5524373650550842,0.5461597050452965,0.5482521947347264,130125,MMM
|
||||
1962-03-08,0.555575966835022,0.5597611361553386,0.5524372330508738,0.5524372330508738,310003,MMM
|
||||
1962-03-09,0.5566224455833435,0.5597613332257351,0.5545299174689224,0.5555761624319809,177965,MMM
|
||||
1962-03-12,0.5649929046630859,0.5649929046630859,0.5587152044494412,0.5587152044494412,176051,MMM
|
||||
1962-03-13,0.5817335844039917,0.5827798681039148,0.5670855744167432,0.5670855744167432,325312,MMM
|
||||
1962-03-14,0.5838258862495422,0.5859185292110747,0.5827796411453942,0.5827796411453942,340621,MMM
|
||||
1962-03-15,0.5859183669090271,0.5869646117233606,0.5848721220946936,0.5848721220946936,137779,MMM
|
||||
1962-03-16,0.5838258862495422,0.5869647743152228,0.5838258862495422,0.5859185292110747,135866,MMM
|
||||
1962-03-19,0.5827798247337341,0.5859187137882331,0.5817335411116749,0.5838260701674723,162656,MMM
|
||||
1962-03-20,0.5817335844039917,0.5848725118804091,0.5817335844039917,0.5827798681039148,225805,MMM
|
||||
1962-03-21,0.5848719477653503,0.5859181922678358,0.5806867788139725,0.581733023316458,135866,MMM
|
||||
1962-03-22,0.5817335844039917,0.5859187573920084,0.5785946951158981,0.5848725118804091,195187,MMM
|
||||
1962-03-23,0.5827798247337341,0.5838260701674723,0.5775483684351166,0.5817335411116749,114816,MMM
|
||||
1962-03-26,0.5817335844039917,0.5848725118804091,0.5796410933807932,0.5827798681039148,130125,MMM
|
||||
1962-03-27,0.5785943269729614,0.5817332142638713,0.5754555542469507,0.5817332142638713,135866,MMM
|
||||
1962-03-28,0.5817335844039917,0.5817335844039917,0.5765021659043758,0.5785946951158981,88026,MMM
|
||||
1962-03-29,0.5848719477653503,0.5859181922678358,0.5827793060072307,0.5827793060072307,166483,MMM
|
||||
1962-03-30,0.5848719477653503,0.5848719477653503,0.5806867788139725,0.5848719477653503,166483,MMM
|
||||
1962-04-02,0.5838258862495422,0.5848722841069267,0.580687112748789,0.5848722841069267,116730,MMM
|
||||
1962-04-03,0.5712702870368958,0.5817331156044795,0.5639463452278805,0.5817331156044795,176051,MMM
|
||||
1962-04-04,0.5649929046630859,0.5712705666884187,0.5649929046630859,0.5712705666884187,168397,MMM
|
||||
1962-04-05,0.5733627676963806,0.5744092032904746,0.5566222804298955,0.5649926195338696,223891,MMM
|
||||
1962-04-06,0.5754554271697998,0.5806868411855696,0.5691777685391674,0.5733627469986182,114816,MMM
|
||||
1962-04-09,0.5712702870368958,0.5806868709360142,0.5712702870368958,0.5754554566522224,168397,MMM
|
||||
1962-04-10,0.5806869268417358,0.5817331716109284,0.5691778524976492,0.5712703420360342,160742,MMM
|
||||
1962-04-11,0.5744094848632812,0.5859185635668441,0.5744094848632812,0.5806871467978104,116730,MMM
|
||||
1962-04-12,0.5806869268417358,0.5848720968599904,0.5744092672850962,0.5744092672850962,221978,MMM
|
||||
1962-04-13,0.5785943269729614,0.5796407245720638,0.574409309401047,0.5796407245720638,145434,MMM
|
||||
1962-04-16,0.5754554271697998,0.5817330858004323,0.5733627469986182,0.5785941992026792,103334,MMM
|
||||
1962-04-17,0.577548086643219,0.5806870123545236,0.5733629160086503,0.5754555967966909,110989,MMM
|
||||
1962-04-18,0.5691778063774109,0.5785942376669155,0.5691778063774109,0.577547954794206,149261,MMM
|
||||
1962-04-19,0.5754554271697998,0.5754554271697998,0.57022401315403,0.57022401315403,101421,MMM
|
||||
1962-04-23,0.5754554271697998,0.5806868411855696,0.5733627469986182,0.5754554271697998,141606,MMM
|
||||
1962-04-24,0.5744094848632812,0.5785945037135742,0.5723168035907338,0.5754557300287766,97594,MMM
|
||||
1962-04-25,0.5712702870368958,0.5765017013206877,0.5670851174215691,0.5744092119837573,199014,MMM
|
||||
1962-04-26,0.5618535876274109,0.568131398042198,0.5576685716256461,0.568131398042198,166483,MMM
|
||||
1962-04-27,0.5608074069023132,0.567085065277331,0.5566222376718185,0.5618536514745748,191360,MMM
|
||||
1962-04-30,0.5315114259719849,0.5639461853354529,0.5315114259719849,0.5608072994668349,621920,MMM
|
||||
1962-05-01,0.5451132655143738,0.5482521909684536,0.527326492263614,0.5315116625552214,359757,MMM
|
||||
1962-05-02,0.5608074069023132,0.562900048799995,0.5555759549112672,0.5555759549112672,273645,MMM
|
||||
1962-05-03,0.5691778063774109,0.5765017101097902,0.5576686947776057,0.5608074670191469,199014,MMM
|
||||
1962-05-04,0.5649929046630859,0.5649929046630859,0.5545300327853662,0.5649929046630859,110989,MMM
|
||||
1962-05-07,0.5587150454521179,0.5681316312811553,0.5587150454521179,0.5649927438792754,141606,MMM
|
||||
1962-05-08,0.5566224455833435,0.5566224455833435,0.5482522567490512,0.5566224455833435,103334,MMM
|
||||
1962-05-09,0.5492985844612122,0.5587151724303411,0.5461598490992016,0.5566225294357618,145434,MMM
|
||||
1962-05-10,0.5398814678192139,0.5513905729478308,0.5367426973424994,0.5492980465672637,243027,MMM
|
||||
1962-05-11,0.5262802243232727,0.5451132415848224,0.5262802243232727,0.5398818266853377,214323,MMM
|
||||
1962-05-14,0.527326226234436,0.527326226234436,0.503261805157199,0.5262799819247249,476486,MMM
|
||||
1962-05-15,0.5419743657112122,0.5513907955069477,0.5336040276807713,0.5336040276807713,304262,MMM
|
||||
1962-05-16,0.5367425084114075,0.541973956180331,0.5304648551028689,0.541973956180331,189446,MMM
|
||||
1962-05-17,0.5304650068283081,0.535696417905279,0.5252335957513372,0.535696417905279,164570,MMM
|
||||
1962-05-18,0.5241875648498535,0.5262800537548723,0.514770982894416,0.5262800537548723,183706,MMM
|
||||
1962-05-21,0.5325577855110168,0.5336040682973905,0.5210487130491974,0.5241876377848996,118643,MMM
|
||||
1962-05-22,0.516864001750946,0.5304657664040224,0.5158177562256991,0.5304657664040224,153088,MMM
|
||||
1962-05-23,0.4854753017425537,0.5147713512108435,0.4854753017425537,0.5147713512108435,531981,MMM
|
||||
1962-05-24,0.4854753017425537,0.502215988726291,0.4854753017425537,0.4854753017425537,507104,MMM
|
||||
1962-05-25,0.48128989338874817,0.49175275700671056,0.46245673123875947,0.4854749089957752,478400,MMM
|
||||
1962-05-28,0.4216521680355072,0.4729199824186637,0.42060592273892966,0.4729199824186637,685069,MMM
|
||||
1962-05-29,0.48338285088539124,0.4854753414587612,0.4519943084470535,0.4519943084470535,1416064,MMM
|
||||
1962-05-31,0.4603639543056488,0.48442836135115536,0.46036395430564875,0.4833821176514992,757786,MMM
|
||||
1962-06-01,0.444670170545578,0.47187352916410125,0.444670170545578,0.46036445409071763,694637,MMM
|
||||
1962-06-04,0.4226981997489929,0.44990155661077746,0.4185130297358061,0.444670141829665,621920,MMM
|
||||
1962-06-05,0.44257763028144836,0.45617923165924784,0.4101428602517509,0.4226981787253665,801798,MMM
|
||||
1962-06-06,0.43943876028060913,0.4478091009399801,0.4300221747741914,0.4425776857632479,346362,MMM
|
||||
1962-06-07,0.43839237093925476,0.4467625178983233,0.4373461264370506,0.43943861544145885,239200,MMM
|
||||
1962-06-08,0.43943876028060913,0.4478091009399801,0.43943876028060913,0.43943876028060913,181792,MMM
|
||||
1962-06-11,0.4279298782348633,0.44257792502518994,0.4279298782348633,0.4394389978456165,260250,MMM
|
||||
1962-06-12,0.4153743088245392,0.4279296283274243,0.4143278730813902,0.4279296283274243,371238,MMM
|
||||
1962-06-13,0.4070037007331848,0.42688310265066615,0.40595745661992044,0.41537403552202895,558771,MMM
|
||||
1962-06-14,0.3965409994125366,0.42060561661542495,0.3934022658072246,0.40700386483474815,575994,MMM
|
||||
1962-06-15,0.40491148829460144,0.40909665893428593,0.35678246510370865,0.3965411470152324,2893363,MMM
|
||||
1962-06-18,0.38503190875053406,0.40386507322405557,0.37143031039042185,0.40386507322405557,1197914,MMM
|
||||
1962-06-19,0.38503190875053406,0.38921707762703134,0.37980049539027055,0.38503190875053406,340621,MMM
|
||||
1962-06-20,0.36724501848220825,0.39026319136770277,0.35992108041973747,0.38503177976002817,621920,MMM
|
||||
1962-06-21,0.36096763610839844,0.3745692402125385,0.3609676361083984,0.36724529660351674,495622,MMM
|
||||
1962-06-22,0.3536435067653656,0.3756154501082348,0.3536435067653656,0.3609676024445524,524326,MMM
|
||||
1962-06-25,0.3682914078235626,0.37038393510338996,0.3442269813168052,0.3536434113584614,849638,MMM
|
||||
1962-06-26,0.36096763610839844,0.3714304672474332,0.3578287103900828,0.36829154152911764,392288,MMM
|
||||
1962-06-27,0.3693377673625946,0.3714304480471326,0.35887493676441334,0.3609676174489514,273645,MMM
|
||||
1962-06-28,0.3954949378967285,0.39863386389605193,0.3808469348024356,0.3808469348024356,782662,MMM
|
||||
1962-06-29,0.39235565066337585,0.40386490810353126,0.3871243921950628,0.3954945737727554,468832,MMM
|
||||
1962-07-02,0.40281859040260315,0.40491123167867,0.3913094834552969,0.39235572771677374,195187,MMM
|
||||
1962-07-03,0.4164203107357025,0.41746655492710577,0.4017723192319203,0.40281856342332356,357843,MMM
|
||||
1962-07-05,0.41746655106544495,0.4174665510654449,0.4080499715471634,0.41642030688371967,267904,MMM
|
||||
1962-07-06,0.40072643756866455,0.40805038336190474,0.39863394709341987,0.40805038336190474,264077,MMM
|
||||
1962-07-09,0.4153743088245392,0.4153743088245392,0.39758738343037997,0.4007262705885483,256422,MMM
|
||||
1962-07-10,0.4132811427116394,0.4352530596857095,0.4111886555668057,0.41537382079773894,717600,MMM
|
||||
1962-07-11,0.4185130000114441,0.4206056803401495,0.39967998451362435,0.4132815856018863,359757,MMM
|
||||
1962-07-12,0.4195592999458313,0.4289759234994519,0.4164205654517213,0.4185130551144613,296608,MMM
|
||||
1962-07-13,0.4185130000114441,0.4185130000114441,0.41014285152103397,0.4185130000114441,158829,MMM
|
||||
1962-07-16,0.4289758503437042,0.4321147370557182,0.4153742497841637,0.41851298374300716,204755,MMM
|
||||
1962-07-17,0.4132811427116394,0.43211429078020586,0.4101424119943889,0.42897540730994266,246854,MMM
|
||||
1962-07-18,0.40595778822898865,0.41223544897788444,0.40177261741588455,0.41223544897788444,271731,MMM
|
||||
1962-07-19,0.40491148829460144,0.4226982630246723,0.40281884569230536,0.40595777140744693,304262,MMM
|
||||
1962-07-20,0.4101428985595703,0.41328163300039833,0.4049114453617327,0.4049114453617327,176051,MMM
|
||||
1962-07-23,0.4038652777671814,0.4122354670062276,0.4017726349866554,0.4101429769789247,252595,MMM
|
||||
1962-07-24,0.3986338675022125,0.4059578118331546,0.39758746972025805,0.40386528358739,147347,MMM
|
||||
1962-07-25,0.4038652777671814,0.4038652777671814,0.3892172747514745,0.3986338617573953,193274,MMM
|
||||
1962-07-26,0.40595778822898865,0.4101429590420927,0.40386526010489276,0.40386526010489276,158829,MMM
|
||||
1962-07-27,0.4143277406692505,0.4164204205452731,0.40595759398944786,0.40595759398944786,189446,MMM
|
||||
1962-07-30,0.4226981997489929,0.42479072747314106,0.41223537018676804,0.4143278597226194,265990,MMM
|
||||
1962-07-31,0.42583709955215454,0.43106851402071045,0.4226981744944319,0.4226981744944319,386547,MMM
|
||||
1962-08-01,0.4164203107357025,0.4226979668255009,0.4143276314115171,0.4226979668255009,177965,MMM
|
||||
1962-08-02,0.42479053139686584,0.4258369284349793,0.41432766847582847,0.4164203479872177,156915,MMM
|
||||
1962-08-03,0.4164203107357025,0.42583689034108957,0.4164203107357025,0.4247904933965832,189446,MMM
|
||||
1962-08-06,0.4132811427116394,0.41955879508740623,0.4101424119943889,0.4164200643701558,118643,MMM
|
||||
1962-08-07,0.4080498516559601,0.4132812619688962,0.4080498516559601,0.4132812619688962,118643,MMM
|
||||
1962-08-08,0.4164203107357025,0.418512799118509,0.40281856342332356,0.4080499753217187,133952,MMM
|
||||
1962-08-09,0.4143277406692505,0.41851290947986647,0.4101427628000638,0.4164204205452731,181792,MMM
|
||||
1962-08-10,0.4132811427116394,0.4164200643701558,0.40595724676345574,0.4143273862840562,147347,MMM
|
||||
1962-08-13,0.41118887066841125,0.4122351147881405,0.4049111768203966,0.4122351147881405,166483,MMM
|
||||
1962-08-14,0.41746655106544495,0.4206054745519978,0.4080499715471634,0.41118889503371625,323398,MMM
|
||||
1962-08-15,0.42479053139686584,0.430021943763245,0.41537410370222105,0.41746659227221433,327226,MMM
|
||||
1962-08-16,0.42583709955215454,0.428975871856699,0.4185130047312927,0.4247907020935598,235373,MMM
|
||||
1962-08-17,0.44257763028144836,0.4467626091450039,0.42583710381450773,0.42583710381450773,784576,MMM
|
||||
1962-08-20,0.45304054021835327,0.4593182005761022,0.445716444016389,0.445716444016389,434387,MMM
|
||||
1962-08-21,0.4515698254108429,0.4568206386713144,0.4494695767664581,0.4547203900269296,216237,MMM
|
||||
1962-08-22,0.4662725627422333,0.4694229383002179,0.45262032204536506,0.45262032204536506,466918,MMM
|
||||
1962-08-23,0.4515698254108429,0.4662721791999669,0.45051970108865047,0.4662721791999669,340621,MMM
|
||||
1962-08-24,0.4536705017089844,0.4557709054754684,0.4494699624855598,0.45157021293230465,156915,MMM
|
||||
1962-08-27,0.45787104964256287,0.45892117453427395,0.45472063663750684,0.45472063663750684,122470,MMM
|
||||
1962-08-28,0.445269376039505,0.45892142882558906,0.4442192505659126,0.4578713033519967,177965,MMM
|
||||
1962-08-29,0.442118763923645,0.4442192063112962,0.43686794542906776,0.4442192063112962,239200,MMM
|
||||
1962-08-30,0.444219172000885,0.44736954786448363,0.4410686044876006,0.44211872977546685,101421,MMM
|
||||
1962-08-31,0.4536705017089844,0.45472078025209595,0.44211870262260483,0.44421914471902363,214323,MMM
|
||||
1962-09-04,0.44947025179862976,0.459971740771516,0.44631968245089365,0.453670793725841,193274,MMM
|
||||
1962-09-05,0.44316884875297546,0.4463194162213983,0.4368679054658126,0.4463194162213983,177965,MMM
|
||||
1962-09-06,0.4379180669784546,0.43896838398796945,0.42846670876047205,0.43896838398796945,380806,MMM
|
||||
1962-09-07,0.4316170811653137,0.4368678991030881,0.43056695590769484,0.4368678991030881,141606,MMM
|
||||
1962-09-10,0.4326671063899994,0.4326671063899994,0.42321560130649544,0.43161682842763743,141606,MMM
|
||||
1962-09-11,0.4284667372703552,0.4347677198281529,0.4263663330912047,0.4326674306388293,181792,MMM
|
||||
1962-09-12,0.42951706051826477,0.43056722476156095,0.42531636521512,0.4284669346049285,130125,MMM
|
||||
1962-09-13,0.43476757407188416,0.4358176991495193,0.4253160267439438,0.42951671870413166,135866,MMM
|
||||
1962-09-14,0.44947025179862976,0.4526206294965686,0.4368681660574826,0.4368681660574826,160742,MMM
|
||||
1962-09-17,0.44947025179862976,0.4515705035972557,0.4452695565515807,0.44947025179862976,189446,MMM
|
||||
1962-09-18,0.44631946086883545,0.4526204047863114,0.44316889308524643,0.44947002865242447,166483,MMM
|
||||
1962-09-19,0.44631946086883545,0.44841971162476,0.44316889308524643,0.44631946086883545,118643,MMM
|
||||
1962-09-20,0.442118763923645,0.44947002480587345,0.442118763923645,0.4463194570492469,187533,MMM
|
||||
1962-09-21,0.4284667372703552,0.4410686640560082,0.4263663330912047,0.4410686640560082,244941,MMM
|
||||
1962-09-24,0.41166412830352783,0.42426601592834623,0.4116641283035278,0.42426601592834623,342534,MMM
|
||||
1962-09-25,0.415864497423172,0.41691481409912684,0.4022124504518491,0.41166399731790454,208582,MMM
|
||||
1962-09-26,0.4064132869243622,0.4190152133567231,0.40536316152411156,0.41586464550626506,183706,MMM
|
||||
1962-09-27,0.4053632318973541,0.4148145921200641,0.40326282741244646,0.4064133574799122,260250,MMM
|
||||
1962-09-28,0.4074634611606598,0.41061399076241034,0.4032627678016398,0.4053631719760631,170310,MMM
|
||||
1962-10-01,0.3959116041660309,0.4106139330306167,0.39591160416603094,0.40746340387182656,225805,MMM
|
||||
1962-10-02,0.40116244554519653,0.40431285989740007,0.39906204154393055,0.39906204154393055,271731,MMM
|
||||
1962-10-03,0.40011242032051086,0.4064133655913568,0.3990621413971991,0.40116254592402795,126298,MMM
|
||||
1962-10-04,0.403262734413147,0.403262734413147,0.39696175239122566,0.40011232006206443,135866,MMM
|
||||
1962-10-05,0.4095633029937744,0.4095633029937744,0.40326236507270313,0.40326236507270313,105248,MMM
|
||||
1962-10-08,0.41166412830352783,0.41481450438488293,0.4106139646131363,0.4106139646131363,91853,MMM
|
||||
1962-10-09,0.4137643575668335,0.41481448287282624,0.4106139433189174,0.41166410695484795,84198,MMM
|
||||
1962-10-10,0.4127139747142792,0.42111516356930306,0.41271397471427923,0.413764099364961,231546,MMM
|
||||
1962-10-11,0.4095633029937744,0.41271386777906993,0.4085131786151825,0.41271386777906993,103334,MMM
|
||||
1962-10-12,0.4064132869243622,0.4095637014550552,0.40536316152411156,0.4095637014550552,101421,MMM
|
||||
1962-10-15,0.4148140251636505,0.41691446510768254,0.4053626778587824,0.4064128020060596,112902,MMM
|
||||
|
Binary file not shown.
@@ -40,19 +40,37 @@
|
||||
</div>
|
||||
|
||||
<!-- Tool Frame -->
|
||||
<div>
|
||||
<div class="gridFrame">
|
||||
<div>
|
||||
<div><h2>Actions</h2></div>
|
||||
<div>
|
||||
<input placeholder="Stock Symbol [NVDA]" @bind="addStockSymbol" />
|
||||
<button @onclick="addStock">Add To Tracked Stocks</button>
|
||||
<div>
|
||||
<input placeholder="Stock Symbol [NVDA]" @bind="addStockSymbol" />
|
||||
<button @onclick="addStock">Add To Watched Stocks</button>
|
||||
</div>
|
||||
<br />
|
||||
<div>
|
||||
<button @onclick="RunTest">Run 1Mo Evaluation</button>
|
||||
<br />
|
||||
<span>@TestResults</span>
|
||||
</div>
|
||||
<span>@resultError</span>
|
||||
</div>
|
||||
<br />
|
||||
</div>
|
||||
<!-- Tracked Stocks -->
|
||||
<div style="margin-top: 20px;" class="gridFrame">
|
||||
<div>
|
||||
<button @onclick="RunTest">Run 1Mo Test</button>
|
||||
<span>@TestResults</span>
|
||||
<h2>Watched Stocks</h2>
|
||||
</div>
|
||||
<div style="column-count: 2;">
|
||||
@foreach (Stock cur in Session.TrackedStocks){
|
||||
<div class="signalBlock">
|
||||
<p style="text-align: center; font-weight: bold;">@cur.Symbol</p>
|
||||
<p>AI Predicted Score: @cur.Score</p>
|
||||
<button @onclick="() => {removeStock(cur);}">Remove</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<span>@resultError</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -60,30 +78,19 @@
|
||||
<!-- AI Frame -->
|
||||
@if (Session != null){
|
||||
<div>
|
||||
<!-- Tracked Stocks -->
|
||||
<div class="gridFrame">
|
||||
<div>
|
||||
<h2>Current Signal</h2>
|
||||
</div>
|
||||
@foreach (Stock cur in Session.TrackedStocks){
|
||||
<div class="signalBlock">
|
||||
<p style="text-align: center; font-weight: bold;">@cur.Symbol</p>
|
||||
<p>AI Predicted Score: @cur.Score</p>
|
||||
<button @onclick="() => {removeStock(cur);}">Remove</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<!-- Trade History -->
|
||||
<div class="gridFrame">
|
||||
<div>
|
||||
<h2>Trade History</h2>
|
||||
<h2>@HistoryTitle</h2>
|
||||
</div>
|
||||
@foreach (PurchasedStock cur in Session.TradeHistory){
|
||||
<div class="signalBlock">
|
||||
<p style="text-align: center; font-weight: bold;">@cur.Symbol</p>
|
||||
<p>Purchased Quantity: @cur.Quantity</p>
|
||||
<p>Purchased Price: @cur.PurchasePrice</p>
|
||||
<p>Sell Price: @cur.PurchasePrice</p>
|
||||
<p>Sell Price: @cur.PurchasePrice</p><br />
|
||||
<p>Buy Date: @cur.BuyDate.ToString("MM/dd/yy")</p><br />
|
||||
<p>Sell Date: @cur.BuyDate.ToString("MM/dd/yy")</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -100,7 +107,7 @@
|
||||
|
||||
loginSession? Session = null;
|
||||
string resultError = "";
|
||||
|
||||
string HistoryTitle = "Auto Trade History";
|
||||
|
||||
|
||||
|
||||
@@ -205,9 +212,18 @@
|
||||
|
||||
string TestResults = "";
|
||||
async Task RunTest(){
|
||||
|
||||
// Make sure a session exists
|
||||
if (Session == null){
|
||||
return;
|
||||
}
|
||||
|
||||
// Simulate 1 month
|
||||
D683_Project_Test tests = new D683_Project_Test(aiModule);
|
||||
float score = await tests.Simulate();
|
||||
TestResults = score.ToString();
|
||||
(float, List<PurchasedStock>) score = await tests.Simulate(Session.TrackedStocks);
|
||||
TestResults = $"The amount of money the AI did better than the SPY: ${score} or { score.Item1 / 10 }% better";
|
||||
Session.TradeHistory = score.Item2;
|
||||
HistoryTitle = "Simulated History";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -62,25 +62,36 @@
|
||||
|
||||
.signalBlock {
|
||||
display: flex;
|
||||
width: min-content;
|
||||
margin-top: 5px;;
|
||||
}
|
||||
|
||||
.signalBlock > :nth-child(1) {
|
||||
border: solid #040 1px;
|
||||
border-radius: 15px;
|
||||
padding: 0px 20px;
|
||||
padding: 5px 20px;
|
||||
background-color: greenyellow;
|
||||
align-self: center;
|
||||
margin: 0;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.signalBlock > :nth-child(2) {
|
||||
padding: 0 30px;
|
||||
font-size: 30px;
|
||||
align-content: center;
|
||||
margin: 0;
|
||||
text-wrap: nowrap;
|
||||
}
|
||||
|
||||
.signalBlock > :nth-child(3) {
|
||||
color: white;
|
||||
padding: 0 30px;
|
||||
width: 40px;
|
||||
padding: 10px 30px;
|
||||
border: solid #000 1px;
|
||||
border-radius: 15px;
|
||||
background-color: #F44;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.signalBlock > :nth-child(3):hover {
|
||||
background-color: #f00;
|
||||
}
|
||||
@@ -22,6 +22,13 @@ namespace Controllers.Automation {
|
||||
// Start this process on a background thread so its non-blocking
|
||||
Task thread = new Task(() => {
|
||||
|
||||
// Check if the day is a weekend
|
||||
DateTime chosenDate = DateTime.Now.AddDays(-DaysBefore);
|
||||
if (chosenDate.DayOfWeek == DayOfWeek.Saturday || chosenDate.DayOfWeek == DayOfWeek.Sunday) {
|
||||
// If its a weekend skip
|
||||
return;
|
||||
}
|
||||
|
||||
// Load the userlist
|
||||
List<string> VerifiedUserList = new List<string>(){ "TESTMODE" };
|
||||
if (!testmode) {
|
||||
@@ -121,6 +128,9 @@ namespace Controllers.Automation {
|
||||
|
||||
// Get sell price
|
||||
float sellPrice = cur.Quantity * _aiModule.GetCurrentPrice( cur.Symbol );
|
||||
if (sellPrice == 0) {
|
||||
return -1f;
|
||||
}
|
||||
|
||||
// Try create payment session
|
||||
(bool, string) createResult = _paymentProcessor.CreatePayment(username);
|
||||
@@ -157,6 +167,9 @@ namespace Controllers.Automation {
|
||||
|
||||
// Get Stock Price
|
||||
float stockPrice = _aiModule.GetCurrentPrice( stockSymbol );
|
||||
if (stockPrice == 0) {
|
||||
return -1f;
|
||||
}
|
||||
|
||||
// Get max stocks user can purchase [ int cast truncates the decimal ]
|
||||
int MaxQty = (int)( Money / stockPrice );
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Controllers.PythonInterop;
|
||||
using Entities;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
|
||||
namespace Controllers.ProjectTest {
|
||||
|
||||
@@ -9,20 +8,6 @@ namespace Controllers.ProjectTest {
|
||||
// TESTING Starting Money
|
||||
float Money = 1000;
|
||||
|
||||
// TESTING WATCH STOCK LIST
|
||||
List<Stock> TrackedStocks = new List<Stock>() {
|
||||
new Stock(){ Symbol="NVDA" },
|
||||
new Stock(){ Symbol="INTL" },
|
||||
new Stock(){ Symbol="AAPL" },
|
||||
new Stock(){ Symbol="SHOP" },
|
||||
new Stock(){ Symbol="PANW" },
|
||||
new Stock(){ Symbol="BBBY" },
|
||||
new Stock(){ Symbol="REAL" },
|
||||
new Stock(){ Symbol="W" },
|
||||
new Stock(){ Symbol="ROKU" },
|
||||
new Stock(){ Symbol="FUN" }
|
||||
};
|
||||
|
||||
// TESTING STOCK HISTORY
|
||||
List<PurchasedStock> StockHistory = new List<PurchasedStock>();
|
||||
|
||||
@@ -31,31 +16,34 @@ namespace Controllers.ProjectTest {
|
||||
_aiModule = aiModule;
|
||||
}
|
||||
|
||||
public async Task<float> Simulate() {
|
||||
public async Task<(float, List<PurchasedStock>)> Simulate(List<Stock> TrackedStocks) {
|
||||
float StartingMoney = Money;
|
||||
// Run once for each day 30 days straight
|
||||
for (int i=30; i>=0; i--) {
|
||||
|
||||
// Check if the day is a weekend
|
||||
DateTime chosenDate = DateTime.Now.AddDays(-i);
|
||||
if (chosenDate.DayOfWeek == DayOfWeek.Saturday || chosenDate.DayOfWeek == DayOfWeek.Sunday) {
|
||||
// If its a weekend skip
|
||||
continue;
|
||||
}
|
||||
|
||||
// Go through each watched stock and find the highest prediction
|
||||
List<Task> threadpool = new List<Task>();
|
||||
foreach(Stock cur in TrackedStocks) {
|
||||
|
||||
// Predict the trend on a new thread
|
||||
Task thread = new Task(async () => {
|
||||
Task thread = new Task(() => {
|
||||
(string, float)Result = _aiModule.PredictAI(cur.Symbol, i);
|
||||
|
||||
// If error log it
|
||||
if (!string.IsNullOrEmpty(Result.Item1)){
|
||||
Console.WriteLine(Result.Item1);
|
||||
}
|
||||
|
||||
// Write the score to the users tracked stocks
|
||||
cur.Score = Result.Item2;
|
||||
});
|
||||
thread.Start();
|
||||
threadpool.Add(thread);
|
||||
}
|
||||
|
||||
// Wait for all processes to finish
|
||||
await Task.WhenAll( threadpool );
|
||||
|
||||
@@ -68,24 +56,28 @@ namespace Controllers.ProjectTest {
|
||||
}
|
||||
|
||||
// Sell all stocks
|
||||
float totalSale = 0;
|
||||
foreach(PurchasedStock cur in StockHistory) {
|
||||
if (cur.Sold == false) {
|
||||
// Get sell price
|
||||
float sellPrice = cur.Quantity * _aiModule.GetCurrentPrice( cur.Symbol );
|
||||
float sellPrice = cur.Quantity * _aiModule.GetCurrentPrice( cur.Symbol, i );
|
||||
if (sellPrice == 0) {
|
||||
// Account for holidays
|
||||
goto next;
|
||||
}
|
||||
// Add up the total sale
|
||||
totalSale += sellPrice;
|
||||
Money = Money + sellPrice;
|
||||
// Mark as sold
|
||||
cur.Sold = true;
|
||||
// Set Sell Date
|
||||
cur.SellDate = DateTime.Now.AddDays(-i);
|
||||
}
|
||||
}
|
||||
Money += totalSale;
|
||||
|
||||
// Dont buy anything on the last run
|
||||
if (i != 0) {
|
||||
|
||||
// Buy predicted stock
|
||||
float stockPrice = _aiModule.GetCurrentPrice( HighestRanking.Symbol );
|
||||
float stockPrice = _aiModule.GetCurrentPrice( HighestRanking.Symbol, i );
|
||||
|
||||
// Get max stocks user can purchase [ int cast truncates the decimal ]
|
||||
int MaxQty = (int)( Money / stockPrice );
|
||||
@@ -95,13 +87,26 @@ namespace Controllers.ProjectTest {
|
||||
Symbol = HighestRanking.Symbol.ToUpper(),
|
||||
PurchasePrice = stockPrice,
|
||||
Quantity = MaxQty,
|
||||
BuyDate = DateTime.Now.AddDays(-i)
|
||||
} );
|
||||
Money = Money - ( stockPrice * MaxQty );
|
||||
}
|
||||
|
||||
next:;
|
||||
}
|
||||
|
||||
// Return a score [Bigger than 0 is money earned] or [Less than 0 is money lost]
|
||||
return Money - StartingMoney;
|
||||
// Get price of SPY starting and end
|
||||
float SPYbegin = _aiModule.GetCurrentPrice( "SPY", 30 );
|
||||
float SPYend = _aiModule.GetCurrentPrice( "SPY" );
|
||||
|
||||
// Get max quantity for the amount of money given
|
||||
int SPYQty = (int)( StartingMoney / SPYbegin );
|
||||
|
||||
// Calculate how much money you would end with if just stayed in the normal S&P500
|
||||
float earned = StartingMoney / SPYbegin * SPYend;
|
||||
|
||||
// Return the difference between the AI and the SPY -> if value returned is 10. The AI did better than the SPY by $10
|
||||
return (Money - earned, StockHistory);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace Controllers.PythonInterop {
|
||||
}
|
||||
}
|
||||
|
||||
public float GetCurrentPrice(string StockSymbol) {
|
||||
(bool, string) Success = PyProcess.RunPythonProcess(_PyPath, _ExecPath + "/currentprice.py", returns: true, PyArgs: StockSymbol);
|
||||
public float GetCurrentPrice(string StockSymbol, int DataEndDaysAgo = 0) {
|
||||
(bool, string) Success = PyProcess.RunPythonProcess(_PyPath, _ExecPath + "/currentprice.py", returns: true, PyArgs: $"{StockSymbol} {DataEndDaysAgo}");
|
||||
if (!Success.Item1) {
|
||||
return 0;
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Entities {
|
||||
|
||||
class loginSession {
|
||||
public class loginSession {
|
||||
public string UserName { get; set; } = "";
|
||||
public float Money { get; set; } = 0;
|
||||
public List<Stock> TrackedStocks { get; set; } = new List<Stock>();
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
namespace Entities {
|
||||
|
||||
class PurchasedStock {
|
||||
public class PurchasedStock {
|
||||
public string Symbol { get; set; } = "";
|
||||
public float Quantity { get; set; } = 0;
|
||||
public float PurchasePrice { get; set; } = 0;
|
||||
public float SellPrice { get; set; } = 0;
|
||||
public bool Sold = false;
|
||||
public bool Sold { get; set; } = false;
|
||||
public DateTime BuyDate { get; set; } = new DateTime();
|
||||
public DateTime SellDate { get; set; } = new DateTime();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Entities {
|
||||
|
||||
class Stock {
|
||||
public class Stock {
|
||||
public string Symbol { get; set; } = "";
|
||||
public float Score { get; set; } = 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
0 0 1 * * root /app/WebServer Retrain-AI >> /var/log/cron.log 2>&1
|
||||
0 9-16 * * 1-5 root /app/WebServer Perform-AI >> /var/log/cron.log 2>&1
|
||||
0 9 * * 1-5 root /app/WebServer Perform-AI >> /var/log/cron.log 2>&1
|
||||
|
||||
Reference in New Issue
Block a user