Problem Description Your challenge is to write a trading algorithm that, given historical data, attempts to determine the best trades that could have been made to maximise profits. By looking at the...

1 answer below »

mailed the assignment on joy


Problem Description Your challenge is to write a trading algorithm that, given historical data, attempts to determine the best trades that could have been made to maximise profits. By looking at the data provided, your algorithm will aim to select the best times to enter the market and the best times to exit the market, in order to maximise the overall return. There are however some conditions that make this problem more complex. The following requirements must be observed: 1. A trade must be open for a minimum of 30 mins and closed before reaching 60mins. 2. You may only have 1 trade active at a time (eg, if you close at time 1:36 you can then open at 1:37). 3. You can only buy into the market, that is you can only make a profit from buying low and selling high. The algorithm is only investing 1 ‘unit’ in each trade. If your algorithm enters the market at 1.1 and exits at 1.2 then the algorithm has made 0.1 units of profit. Summing the return over all trades gives the algorithm’s total return. Conditions 1 and 2 cause a situation where entering the market will commit you for a minimum time and other trades that overlap cannot be executed. This means each trade may come with tradeoffs. Your task is to generate an application with your trading algorithm at the core. You will be provided data for a single ‘stock’ and must make trading decisions to maximise profit. All open trades must be closed before the end of the data. Your program will: 1. Read in the data 2. Determine when to open a position 3. Determine when to close the position 4. Present trades and profit made. Your trading algorithm is NOT required to produce the optimal result however you should be aware of any limitations your approach does have. There are many ways to solve this problem. You are required to implement at least one profitable algorithm. If you like, you may implement multiple strategies and compare the results. Data The data is a CSV file with 2 columns, time and price. Time is the minute for the data point, for example, time=94 is 01hr 34mins. An example of what the CSV file looks like is (full data in external file provided): Time,Price 0,1.2546 1,1.2567 2,1.2577 3,1.2579 4,1.2593 5,1.2668 6,1.2695 7,1.2689 8,1.2679 9,1.2679 10,1.2678 The following sample output was generated on a data set with 240 data points (Note: your output does NOT need to match this exact formatting): Trades are: Open at 0 (1.2546), close 58 (1.2796) for profit 0.025 Open at 64 (1.2635), close 94 (1.2845) for profit 0.021 Open at 101 (1.275), close 138 (1.2929) for profit 0.0179 Open at 139 (1.2846), close 169 (1.3016) for profit 0.017 Open at 178 (1.2943), close 228 (1.3728) for profit 0.0785 Total profit 0.1594
Answered Same DayAug 19, 2021

Answer To: Problem Description Your challenge is to write a trading algorithm that, given historical data,...

Sandeep Kumar answered on Aug 21 2021
135 Votes
Trading bot JS/bot.jsconst SteamUser = require ("steam-user");
const SteamCommunity = require("steamcommunity");
const TradeOfferManager = require ("steam-tradeoffer-manager");
const TeamFortress2 = require ("tf2");
const prices = require ("./prices.json");
const config = require("./config.json");
const client = new SteamUser();
const tf2 = new TeamFortress2(client);
const community = new SteamCommunity();
const manager = ne
w TradeOfferManager({
steam: client,
community: community,
language: "en"
})
const logOnOptions = {
accountName: config.username,
password: config.password
};
client.logOn(logOnOptions);
client.on("loggedOn", () => {
console.log("succesfully logged on.");
client.setPersona(SteamUser.EPersonaState.Online);
client.gamesPlayed(440);
});
client.on('friendRelationship', (steamid, relationship) => {
if (relationship === 2) {
client.addFriend(steamid);
client.chatMessage(steamid, 'Hello there! Thanks for adding me!');
}
});
client.on("friendMessage", function(steamID, message) {
if (message == "hi", "hello") {
client.chatMessage(steamID, "Hello, this is a trading bot welcome")
}
});
client.on("webSession", (sessionid, cookies) => {
manager.setCookies(cookies);
community.setCookies(cookies);
});
function processOffer(offer) {
if (offer.isGlitched() || offer.state === 11) {
console.log("Offer was glitched, declining.");
declineOffer(offer)
} else if (offer.partner.getSteamID64() === config.ownerID) {
acceptOffer(offer);
} else {
var ourItems = offer.itemsToGive;
var theirItems = offer.itemsToReceive;
var ourValue = 0;
var theirValue = 0;
for (var i in ourItems) {
var item = ourItems[i].market_name;
if(prices[item]) {
ourValue += prices[item].sell;
} else {
console.log("Invalid Value.");
ourValue += 99999;
}
}
for(var i in theirItems) {
var item= theirItems[i].market_name;
if(prices[item]) {
theirValue += Prices[item].buy;
} else {
console.log("their value was different")
}
}
}
console.log("Our value: " +ourValue);
console.log("Their value:", +theirValue);

if (ourValue <= theirValue) {
acceptOffer(offer);
} else {
declineOffer(offer);
}
}
manager.on("newOffer", (offer) => {
processOffer(offer);
});
/* crafting */
var scrapAmt = 25;
var pollCraft = 30;
tf2.on("connectToGC", function() {
console.log("Connected to tf2 game server.")
});
tf2.on("backpackLoaded", function () {
console.log("Loaded our backpack.");
});
function craftS(amtNeedScrap) {
if (tf2.backpack == undefined) {
console.log("unable to load backpack, can't craft");
return
}else {
console.log("attempting to craft...");
var amtOfScrap = 0;
for (var i = 0; i if(tf2.backpack[i].defIndex === 5000) {
amtOfScrap++;
}
}
for (var i = 0; i if(tf2.backpack[i].defIndex === 5002) {
amtOfScrap +=9;
var beep = new Array;
beep.push(parseInt(tf2.backpack[i].id));
tf2.craft(beep);
} else if
(tf2.backpack[i].defIndex === 5001) {
amtOfScrap +=3;
var beep = new Array;
beep.push(parsenInt(tf2.backpack[i].id));
tf2.craft(beep);
}
if (amtOfScrap >= amtNeedScrap) {
break;
}
}
}
}
tf2.on("craftingComplete", function(e){
console.log("Finished Crafting.");
});
client.on("friendMessage#" +config.ownedID, function(steamID, message) {
if (message == "craft") {
craftS(scrapAmt);
console.log("Recieved order to craft from admin.")
} else {
console.log("craft error.")
}
});
setInterval(function() {
craftS(scrapAmt);
}, 1000 * 60 * pollCraft)
Trading bot JS/config.json{
"username":"ad3rito121",
"password":"aderito12"
}
Trading bot...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here